Commit 6c418708 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Only check for ASN1SCC existence in the PATH if source ASN.1 files have changed.

parent dd06103f
...@@ -420,48 +420,47 @@ def ParseAsnFileList(listOfFilenames: List[str]) -> None: # pylint: disable=inv ...@@ -420,48 +420,47 @@ def ParseAsnFileList(listOfFilenames: List[str]) -> None: # pylint: disable=inv
os.fdopen(dummy).close() os.fdopen(dummy).close()
xmlAST2 = xmlAST + "2" xmlAST2 = xmlAST + "2"
asn1SccPath = spawn.find_executable('asn1.exe') if someFilesHaveChanged:
if asn1SccPath is None: asn1SccPath = spawn.find_executable('asn1.exe')
utility.panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n") if asn1SccPath is None:
else: utility.panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n")
if someFilesHaveChanged: asn1SccDir = os.path.dirname(os.path.abspath(asn1SccPath))
asn1SccDir = os.path.dirname(os.path.abspath(asn1SccPath)) spawnResult = os.system("mono \"" + asn1SccPath + "\" -customStg \"" + asn1SccDir + "/xml.stg:" + xmlAST + "\" -typePrefix asn1Scc -fp AUTO -customStgAstVersion 4 \"" + "\" \"".join(listOfFilenames) + "\"")
spawnResult = os.system("mono \"" + asn1SccPath + "\" -customStg \"" + asn1SccDir + "/xml.stg:" + xmlAST + "\" -typePrefix asn1Scc -fp AUTO -customStgAstVersion 4 \"" + "\" \"".join(listOfFilenames) + "\"") if spawnResult != 0:
if spawnResult != 0: errCode = spawnResult / 256
errCode = spawnResult / 256 if errCode == 1:
if errCode == 1: utility.panic("ASN1SCC reported syntax errors. Aborting...")
utility.panic("ASN1SCC reported syntax errors. Aborting...") elif errCode == 2:
elif errCode == 2: utility.panic("ASN1SCC reported semantic errors (or mono failed). Aborting...")
utility.panic("ASN1SCC reported semantic errors (or mono failed). Aborting...") elif errCode == 3:
elif errCode == 3: utility.panic("ASN1SCC reported internal error. Contact ESA with this input. Aborting...")
utility.panic("ASN1SCC reported internal error. Contact ESA with this input. Aborting...") elif errCode == 4:
elif errCode == 4: utility.panic("ASN1SCC reported usage error. Aborting...")
utility.panic("ASN1SCC reported usage error. Aborting...") else:
else: utility.panic("ASN1SCC generic error. Contact ESA with this input. Aborting...")
utility.panic("ASN1SCC generic error. Contact ESA with this input. Aborting...") ParseASN1SCC_AST(xmlAST)
ParseASN1SCC_AST(xmlAST) if projectCache is None:
if projectCache is None: os.unlink(xmlAST)
os.unlink(xmlAST) g_names.update(g_names)
g_names.update(g_names) g_leafTypeDict.update(g_leafTypeDict)
g_leafTypeDict.update(g_leafTypeDict) g_checkedSoFarForKeywords.update(g_checkedSoFarForKeywords)
g_checkedSoFarForKeywords.update(g_checkedSoFarForKeywords) g_typesOfFile.update(g_typesOfFile)
g_typesOfFile.update(g_typesOfFile)
# We also need to mark the artificial types -
# We also need to mark the artificial types - # So spawn the custom type output at level 1 (unfiltered)
# So spawn the custom type output at level 1 (unfiltered) # and mark any types not inside it as artificial.
# and mark any types not inside it as artificial. if someFilesHaveChanged:
if someFilesHaveChanged: os.system("mono \"" + asn1SccPath + "\" -customStg \"" + asn1SccDir + "/xml.stg:" + xmlAST2 + "\" -fp AUTO -typePrefix asn1Scc -customStgAstVersion 1 \"" + "\" \"".join(listOfFilenames) + "\"")
os.system("mono \"" + asn1SccPath + "\" -customStg \"" + asn1SccDir + "/xml.stg:" + xmlAST2 + "\" -fp AUTO -typePrefix asn1Scc -customStgAstVersion 1 \"" + "\" \"".join(listOfFilenames) + "\"") realTypes = {}
realTypes = {} for line in os.popen("grep 'ExportedType\>' \"" + xmlAST2 + "\"").readlines(): # flake8: noqa pylint: disable=anomalous-backslash-in-string
for line in os.popen("grep 'ExportedType\>' \"" + xmlAST2 + "\"").readlines(): # flake8: noqa pylint: disable=anomalous-backslash-in-string line = re.sub(r'^.*Name="', '', line.strip())
line = re.sub(r'^.*Name="', '', line.strip()) line = re.sub(r'" />$', '', line)
line = re.sub(r'" />$', '', line) realTypes[line] = 1
realTypes[line] = 1 if projectCache is None:
if projectCache is None: os.unlink(xmlAST2)
os.unlink(xmlAST2) for nodeTypename in list(g_names.keys()):
for nodeTypename in list(g_names.keys()): if nodeTypename not in realTypes:
if nodeTypename not in realTypes: g_names[nodeTypename]._isArtificial = True
g_names[nodeTypename]._isArtificial = True
def Dump() -> None: def Dump() -> None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment