Commit 0b1d95b5 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

Moving to using .NET Core version of ASN1SCC (no more Mono).

parent 07c36209
Pipeline #4477 failed with stage
in 22 seconds
......@@ -11,7 +11,7 @@ stages:
build:
stage: build
script:
- ./configure ; pip3 install --upgrade . ; pip3 uninstall --yes typing ; cd / ; wget -q -O - https://github.com/ttsiodras/asn1scc/releases/download/4.2.4.0f/asn1scc-bin-4.2.4.0f.tar.bz2 | tar jxpvf - ; cd - ; LANG=C LC_ALL=C PATH=$PATH:/asn1scc:/root/.local/bin/ make
- ./configure ; pip3 install --upgrade . ; pip3 uninstall --yes typing ; cd / ; wget -q -O - https://github.com/ttsiodras/asn1scc/releases/download/4.2.4.7f/asn1scc-bin-4.2.4.7f.tar.bz2 | tar jxpvf - ; cd - ; LANG=C LC_ALL=C PATH=$PATH:/asn1scc:/root/.local/bin/ make
# artifacts:
# paths:
# - 'test/logs/*.err.txt'
......
......@@ -43,13 +43,12 @@ def Version() -> None:
def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: # pylint: disable=invalid-sequence-index
# print "Use ASN1SCC to generate the structures for '%s'" % asnFile
asn1SccPath = spawn.find_executable('asn1.exe')
asn1SccPath = spawn.find_executable('asn1scc')
if not asn1SccPath:
panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover
panic("ASN1SCC seems to be missing from your system (asn1scc not found in PATH).\n") # pragma: no cover
# allow externally-defined flags when calling the asn1 compiler (e.g. to set word size based on target)
extraFlags = os.getenv("ASN1SCC_FLAGS") or ""
os.system(
("mono " if sys.platform.startswith('linux') else "") +
"\"{}\" -typePrefix asn1Scc -equal -Ada {} -o \"".format(asn1SccPath, extraFlags) +
outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
# os.system("rm -f \"" + outputDir + "\"/*.adb")
......
......@@ -42,11 +42,10 @@ def Version() -> None:
def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: # pylint: disable=invalid-sequence-index
# print "Use ASN1SCC to generate the structures for '%s'" % asnFile
asn1SccPath = spawn.find_executable('asn1.exe')
asn1SccPath = spawn.find_executable('asn1scc')
if not asn1SccPath:
panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover
panic("ASN1SCC seems to be missing from your system (asn1scc not found in PATH).\n") # pragma: no cover
os.system(
("mono " if sys.platform.startswith('linux') else "") +
"\"{}\" -typePrefix asn1Scc -c -uPER -o \"".format(asn1SccPath) +
outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
# cmd = 'rm -f '
......
......@@ -127,12 +127,10 @@ def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, badTyp
# where "-equal" is passed - the _Equal functions will be generated
# and used during comparisons of incoming TMs (For MSCs)
# mono_exe = "mono " if sys.platform.startswith('linux') else ""
mono_exe = "mono"
makefile_text = '''\
export MAKEFLAGS="-j $(grep -c ^processor /proc/cpuinfo)"
ASN1SCC:=$(shell which asn1.exe)
ASN1SCC:=$(shell which asn1scc)
ASN2DATAMODEL:=asn2dataModel
GRAMMAR := %(origGrammarBase)s
BASEGRAMMAR := %(base)s
......@@ -147,11 +145,11 @@ $(BDIR)/$(GRAMMAR)_getset.c: $(GRAMMAR).asn
# Create the ACN file if it is missing
$(BDIR)/$(GRAMMAR).acn:
%(tab)smono $(ASN1SCC) -ACND -o $(BDIR) $(GRAMMAR).asn
%(tab)s$(ASN1SCC) -ACND -o $(BDIR) $(GRAMMAR).asn
# The hell of multiple outputs (see https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html )
$(BDIR)/asn1crt.c: $(GRAMMAR).asn $(GRAMMAR).acn
%(tab)s%(mono)s $(ASN1SCC) -ACN -c -uPER -equal -o $(BDIR) $< $(GRAMMAR).acn
%(tab)s$(ASN1SCC) -ACN -c -uPER -equal -o $(BDIR) $< $(GRAMMAR).acn
# The hell of multiple outputs (see https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html )
$(BDIR)/$(GRAMMAR).c $(BDIR)/asn1crt_encoding.c $(BDIR)/asn1crt_encoding_uper.c $(BDIR)/asn1crt_encoding_acn.c $(BDIR)/$(GRAMMAR).h $(BDIR)/asn1crt.h: $(BDIR)/asn1crt.c
......@@ -181,7 +179,7 @@ clean:
%(tab)srm -f $(BDIR)/DV.py $(BDIR)/*.pyc $(BDIR)/$(BASEGRAMMAR)_getset.? $(BDIR)/$(BASEGRAMMAR)_getset.so
%(tab)srm -f $(BDIR)/$(GRAMMAR)_asn.py
'''
makefile.write(makefile_text % {'tab': '\t', 'base': base, 'origGrammarBase': origGrammarBase, 'mono': mono_exe})
makefile.write(makefile_text % {'tab': '\t', 'base': base, 'origGrammarBase': origGrammarBase})
makefile.close()
CreateDeclarationsForAllTypes(asnParser.g_names, asnParser.g_leafTypeDict, badTypes)
g_outputGetSetH.write('\n/* Helper functions for NATIVE encodings */\n\n')
......
......@@ -67,11 +67,10 @@ def CleanNameAsSimulinkWants(name: str) -> str:
def OnStartup(unused_modelingLanguage: str, asnFiles: List[str], outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: # pylint: disable=invalid-sequence-index
# print "Use ASN1SCC to generate the structures for '%s'" % asnFile
asn1SccPath = spawn.find_executable('asn1.exe')
asn1SccPath = spawn.find_executable('asn1scc')
if not asn1SccPath:
panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover
panic("ASN1SCC seems to be missing from your system (asn1scc not found in PATH).\n") # pragma: no cover
os.system(
("mono " if sys.platform.startswith('linux') else "") +
"\"{}\" -typePrefix asn1Scc -c -uPER -o \"".format(asn1SccPath) +
outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
os.system("rm -f \"" + outputDir + "\"/*.adb")
......
......@@ -28,12 +28,11 @@ def Version() -> None:
def OnStartup(unused_modelingLanguage: str, asnFile: Union[str, List[str]], outputDir: str, unused_badTypes: SetOfBadTypenames) -> None: # pylint: disable=invalid-sequence-index
# print "Use ASN1SCC to generate the structures for '%s'" % asnFile
asn1SccPath = spawn.find_executable('asn1.exe')
asn1SccPath = spawn.find_executable('asn1scc')
if not asn1SccPath:
panic("ASN1SCC seems to be missing from your system (asn1.exe not found in PATH).\n") # pragma: no cover
panic("ASN1SCC seems to be missing from your system (asn1scc not found in PATH).\n") # pragma: no cover
asn1SccFolder = os.path.dirname(asn1SccPath)
cmd = ("mono " if sys.platform.startswith('linux') else "")
cmd += "\"{}\" -customStg \"{}\"/vdm.stg:\"{}\"/out.vdm \"".format(
cmd = "\"{}\" -customStg \"{}\"/vdm.stg:\"{}\"/out.vdm \"".format(
asn1SccPath, asn1SccFolder, outputDir)
if isinstance(asnFile, str):
cmd += asnFile + "\""
......
......@@ -235,13 +235,13 @@ def SpecialCodes(asnFile: Optional[str]) -> None:
the scope of individual parameters (e.g. it needs access to all ASN.1
types). This used to cover Dumpable C/Ada Types and OG headers.'''
outputDir = commonPy.configMT.outputDir
asn1SccPath = spawn.find_executable('asn1.exe')
asn1SccPath = spawn.find_executable('asn1scc')
# allow externally-defined flags when calling the asn1 compiler (e.g. to set word size based on target)
extraFlags = os.getenv("ASN1SCC_FLAGS") or ""
if asnFile is not None:
if not asn1SccPath:
panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n") # pragma: no cover
os.system('mono "{}" -typePrefix asn1Scc {} -Ada -equal -o "{}" "{}"'
panic("ASN1SCC seems not installed on your system (asn1scc not found in PATH).\n") # pragma: no cover
os.system('"{}" -typePrefix asn1Scc {} -Ada -equal -o "{}" "{}"'
.format(asn1SccPath, extraFlags, outputDir, '" "'.join([asnFile])))
......
......@@ -88,7 +88,7 @@ def calculateForNativeAndASN1SCC(absASN1SCCpath, autosrc, names, inputFiles):
if platform.system() == "Windows" or platform.system() == "Darwin":
mysystem("%s -c -uPER -o \"%s\" %s %s" % (absASN1SCCpath, autosrc, acn, '"' + '" "'.join(inputFiles) + '"'))
else:
cmd = "mono %s -c -uPER -fp AUTO -typePrefix asn1Scc -o \"%s\" %s %s" % (absASN1SCCpath, autosrc, acn, '"' + '" "'.join(inputFiles) + '"')
cmd = "%s -c -uPER -fp AUTO -typePrefix asn1Scc -o \"%s\" %s %s" % (absASN1SCCpath, autosrc, acn, '"' + '" "'.join(inputFiles) + '"')
res = mysystem(cmd)
if res != 0:
panic("This command failed: %s\n" % cmd)
......@@ -342,9 +342,9 @@ def main():
autosrc = tempfile.mkdtemp(".asn1c")
inform("Created temporary directory (%s) for auto-generated files...", autosrc)
absPathOfAADLfile = os.path.abspath(aadlFile)
asn1SccPath = spawn.find_executable('asn1.exe')
asn1SccPath = spawn.find_executable('asn1scc')
if asn1SccPath is None:
panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n")
panic("ASN1SCC seems not installed on your system (asn1scc not found in PATH).\n")
absASN1SCCpath = os.path.abspath(asn1SccPath)
# Update the AdaUses dictionary - can now be safely done in all cases,
......
......@@ -436,17 +436,17 @@ def ParseAsnFileList(listOfFilenames: List[str]) -> None: # pylint: disable=inv
# enforce mutual exclusion via locking.
if someFilesHaveChanged:
with lock_filename('/tmp/onlyOneASN1SCC' + newHash, verbose=False):
asn1SccPath = spawn.find_executable('asn1.exe')
asn1SccPath = spawn.find_executable('asn1scc')
if asn1SccPath is None:
utility.panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n")
utility.panic("ASN1SCC seems not installed on your system (asn1scc not found in PATH).\n")
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("\"" + asn1SccPath + "\" -customStg \"" + asn1SccDir + "/xml.stg:" + xmlAST + "\" -typePrefix asn1Scc -fp AUTO -customStgAstVersion 4 \"" + "\" \"".join(listOfFilenames) + "\"")
if spawnResult != 0:
errCode = spawnResult / 256
if errCode == 1:
utility.panic("ASN1SCC reported syntax errors. Aborting...")
elif errCode == 2:
utility.panic("ASN1SCC reported semantic errors (or mono failed). Aborting...")
utility.panic("ASN1SCC reported semantic errors (or .NET Core failed). Aborting...")
elif errCode == 3:
utility.panic("ASN1SCC reported internal error. Contact ESA with this input. Aborting...")
elif errCode == 4:
......
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