support the Ninja build system

This commit is contained in:
Michael Becker 2025-07-29 21:04:35 -04:00
parent 0ee85e44c3
commit a4ad5fc02b
3 changed files with 86 additions and 27 deletions

28
build.ninja Normal file

File diff suppressed because one or more lines are too long

View File

@ -109,9 +109,11 @@ class Yaml2Mcl:
manager.library_reference_guids = libraryRefGuids manager.library_reference_guids = libraryRefGuids
filenames2 = [ ]
for filename in filenames: for filename in filenames:
if not os.path.isdir(filename): if not os.path.isdir(filename):
print ("not a directory: '" + filename + "'") filenames2.append(filename)
continue continue
yaml_files = sorted(glob(filename + "/**/*.yaml", recursive=True)) yaml_files = sorted(glob(filename + "/**/*.yaml", recursive=True))
@ -141,41 +143,68 @@ class Yaml2Mcl:
print("export entities to file: '" + exportEntitiesFileName + "'") print("export entities to file: '" + exportEntitiesFileName + "'")
manager.save_entities_to_file(exportEntitiesFileName, outputFileName) 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: #except NameError as ex:
print (ex) # print (ex)
rgx = "&(.*);" # rgx = "&(.*);"
# go through and get all entity references across all files # # go through and get all entity references across all files
import re # import re
stuff = [] # stuff = []
for yaml_file in yaml_files: # for yaml_file in yaml_files:
f = open(yaml_file, "r") # f = open(yaml_file, "r")
text = f.read() # text = f.read()
matches = re.findall(rgx, text) # matches = re.findall(rgx, text)
for match in matches: # for match in matches:
stuff.append(match) # stuff.append(match)
f.close() # f.close()
missingEntities = [] # missingEntities = []
for stuf in stuff: # for stuf in stuff:
if not stuf in manager.entityReferences: # if not stuf in manager.entityReferences:
if not stuf in missingEntities: # if not stuf in missingEntities:
missingEntities.append(stuf) # missingEntities.append(stuf)
if len(missingEntities) > 0: # if len(missingEntities) > 0:
print("\nNOTE: there were undefined referenced entities:\n") # print("\nNOTE: there were undefined referenced entities:\n")
for missingEntity in missingEntities: # for missingEntity in missingEntities:
print("\t" + missingEntity) # print("\t" + missingEntity)
print("\n") # print("\n")
return False # return False
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
export PYTHONPATH=".:../editor-python/editor-python/src:../framework-python/lib/mbs" SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
python3 compilers/yaml2mcl/Program.py ${1+"$@"}
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+"$@"}