support the Ninja build system
This commit is contained in:
parent
0ee85e44c3
commit
a4ad5fc02b
28
build.ninja
Normal file
28
build.ninja
Normal file
File diff suppressed because one or more lines are too long
@ -109,9 +109,11 @@ class Yaml2Mcl:
|
||||
|
||||
manager.library_reference_guids = libraryRefGuids
|
||||
|
||||
filenames2 = [ ]
|
||||
|
||||
for filename in filenames:
|
||||
if not os.path.isdir(filename):
|
||||
print ("not a directory: '" + filename + "'")
|
||||
filenames2.append(filename)
|
||||
continue
|
||||
|
||||
yaml_files = sorted(glob(filename + "/**/*.yaml", recursive=True))
|
||||
@ -141,41 +143,68 @@ class Yaml2Mcl:
|
||||
|
||||
print("export entities to file: '" + exportEntitiesFileName + "'")
|
||||
manager.save_entities_to_file(exportEntitiesFileName, outputFileName)
|
||||
|
||||
if len(filenames2) > 0:
|
||||
yaml_files = filenames2
|
||||
|
||||
# first, load the entity defs
|
||||
for yaml_file in yaml_files:
|
||||
yl.load_entity_definitions_from_file(yaml_file)
|
||||
|
||||
#try:
|
||||
# then, load instance definitions (also loads sugar elements into memory for later use)
|
||||
for yaml_file in yaml_files:
|
||||
yl.load_instances_from_file(yaml_file)
|
||||
|
||||
# finally, apply syntactic sugar
|
||||
yl.apply_sugar()
|
||||
|
||||
manager.filename = outputFileName
|
||||
manager.parser = yl
|
||||
manager.commit()
|
||||
|
||||
if not exportEntitiesFileName is None:
|
||||
if exportEntitiesFileName == "":
|
||||
exportEntitiesFileName = "entities.cs"
|
||||
|
||||
return True
|
||||
print("export entities to file: '" + exportEntitiesFileName + "'")
|
||||
manager.save_entities_to_file(exportEntitiesFileName, outputFileName)
|
||||
|
||||
|
||||
return True
|
||||
|
||||
#except NameError as ex:
|
||||
|
||||
print (ex)
|
||||
# print (ex)
|
||||
|
||||
rgx = "&(.*);"
|
||||
# rgx = "&(.*);"
|
||||
|
||||
# go through and get all entity references across all files
|
||||
import re
|
||||
# # go through and get all entity references across all files
|
||||
# import re
|
||||
|
||||
stuff = []
|
||||
# stuff = []
|
||||
|
||||
for yaml_file in yaml_files:
|
||||
f = open(yaml_file, "r")
|
||||
text = f.read()
|
||||
matches = re.findall(rgx, text)
|
||||
for match in matches:
|
||||
stuff.append(match)
|
||||
f.close()
|
||||
# for yaml_file in yaml_files:
|
||||
# f = open(yaml_file, "r")
|
||||
# text = f.read()
|
||||
# matches = re.findall(rgx, text)
|
||||
# for match in matches:
|
||||
# stuff.append(match)
|
||||
# f.close()
|
||||
|
||||
missingEntities = []
|
||||
for stuf in stuff:
|
||||
if not stuf in manager.entityReferences:
|
||||
if not stuf in missingEntities:
|
||||
missingEntities.append(stuf)
|
||||
# missingEntities = []
|
||||
# for stuf in stuff:
|
||||
# if not stuf in manager.entityReferences:
|
||||
# if not stuf in missingEntities:
|
||||
# missingEntities.append(stuf)
|
||||
|
||||
if len(missingEntities) > 0:
|
||||
print("\nNOTE: there were undefined referenced entities:\n")
|
||||
for missingEntity in missingEntities:
|
||||
print("\t" + missingEntity)
|
||||
print("\n")
|
||||
# if len(missingEntities) > 0:
|
||||
# print("\nNOTE: there were undefined referenced entities:\n")
|
||||
# for missingEntity in missingEntities:
|
||||
# print("\t" + missingEntity)
|
||||
# print("\n")
|
||||
|
||||
return False
|
||||
# return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PYTHONPATH=".:../editor-python/editor-python/src:../framework-python/lib/mbs"
|
||||
python3 compilers/yaml2mcl/Program.py ${1+"$@"}
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
export PYTHONPATH="$SCRIPT_DIR:$SCRIPT_DIR/../editor-python/editor-python/src:$SCRIPT_DIR/../framework-python/lib/mbs"
|
||||
python3 $SCRIPT_DIR/compilers/yaml2mcl/Program.py ${1+"$@"}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user