Commit 796510c2 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Remove dependency on ASN1SCC env variable

parent b0dadb4c
......@@ -81,6 +81,7 @@ but with an extra call to OnFinal at the end.
import os
import sys
import copy
import distutils.spawn as spawn
import commonPy.configMT
......@@ -209,13 +210,15 @@ def SpecialCodes(unused_SystemsAndImplementations, unused_uniqueDataFiles, asnFi
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')
if len(asnFiles) != 0:
if None == os.getenv("ASN1SCC"):
if None == os.getenv("DMT"): # pragma: no cover
panic("DMT environment variable is not set, you must set it.") # pragma: no cover
os.putenv("ASN1SCC", os.getenv("DMT") + os.sep + "asn1scc/asn1.exe") # pragma: no cover
os.system("mono \"$ASN1SCC\" -wordSize 8 -typePrefix asn1Scc -Ada -equal -uPER -o \"" + outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
if not asn1SccPath:
panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n")
#os.system("mono \"{asn$ASN1SCC\" -wordSize 8 -typePrefix asn1Scc -Ada -equal -uPER -o \"" + outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
os.system('mono "{}" -wordSize 8 -typePrefix asn1Scc -Ada -equal -uPER -o "{}" "{}"'
.format(asn1SccPath,
outputDir,
'" "'.join(asnFiles)))
def main():
......
......@@ -278,9 +278,9 @@ def main():
autosrc = tempfile.mkdtemp(".asn1c")
inform("Created temporary directory (%s) for auto-generated files...", autosrc)
absPathOfAADLfile = os.path.abspath(aadlFile)
asn1SccPath = os.getenv('ASN1SCC')
asn1SccPath = spawn.find_executable('asn1.exe')
if asn1SccPath is None:
panic("ASN1SCC environment variable is not set, you must set it.\n")
panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n")
absASN1SCCpath = os.path.abspath(asn1SccPath)
# A, those good old days... I could calculate the buffer size for BER (SIZ), and then compare
......
......@@ -24,6 +24,7 @@ code generator A.'''
import os
import sys
import distutils.spawn as spawn
from commonPy.utility import panic
......@@ -38,13 +39,13 @@ def Version():
def OnStartup(unused_modelingLanguage, asnFiles, outputDir):
#print "Use ASN1SCC to generate the structures for '%s'" % asnFile
if None == os.getenv("ASN1SCC"):
if None == os.getenv("DMT"): # pragma: no cover
panic("DMT environment variable is not set, you must set it.") # pragma: no cover
os.putenv("ASN1SCC", os.getenv("DMT") + os.sep + "asn1scc/asn1.exe") # pragma: no cover
asn1SccPath = spawn.find_executable('asn1.exe')
if not asn1SccPath:
panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n")
os.system(
("mono " if sys.argv[0].endswith('.py') and sys.platform.startswith('linux') else "") +
"\"$ASN1SCC\" -wordSize 8 -typePrefix asn1Scc -Ada -uPER -o \"" + outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
"\"{}\" -wordSize 8 -typePrefix asn1Scc -Ada -uPER -o \"".format(asn1SccPath) +
outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
os.system("rm -f \"" + outputDir + "\"/*.adb")
......
......@@ -24,6 +24,7 @@ code generator A.'''
import os
import sys
import distutils.spawn as spawn
from commonPy.utility import panic
......@@ -37,13 +38,13 @@ def Version():
def OnStartup(unused_modelingLanguage, asnFiles, outputDir):
#print "Use ASN1SCC to generate the structures for '%s'" % asnFile
if None == os.getenv("ASN1SCC"):
if None == os.getenv("DMT"): # pragma: no cover
panic("DMT environment variable is not set, you must set it.") # pragma: no cover
os.putenv("ASN1SCC", os.getenv("DMT") + os.sep + "asn1scc/asn1.exe") # pragma: no cover
asn1SccPath = spawn.find_executable('asn1.exe')
if not asn1SccPath:
panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n")
os.system(
("mono " if sys.argv[0].endswith('.py') and sys.platform.startswith('linux') else "") +
"\"$ASN1SCC\" -wordSize 8 -typePrefix asn1Scc -c -uPER -o \"" + outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
"\"{}\" -wordSize 8 -typePrefix asn1Scc -c -uPER -o \"".format(asn1SccPath) +
outputDir + "\" \"" + "\" \"".join(asnFiles) + "\"")
cmd = 'rm -f '
for i in ['real.c', 'asn1crt.c', 'acn.c', 'ber.c', 'xer.c']:
cmd += ' "' + outputDir + '"/' + i
......
......@@ -50,6 +50,7 @@ import sys
import copy
import tempfile
import re
import distutils.spawn as spawn
import configMT
import utility
......@@ -1075,9 +1076,9 @@ def CheckForInvalidKeywords(node):
def ParseAsnFileList(listOfFilenames):
asn1SccPath = os.getenv('ASN1SCC')
asn1SccPath = spawn.find_executable('asn1.exe')
if asn1SccPath is None:
utility.panic("ASN1SCC environment variable is not set, you must set it.\n")
utility.panic("ASN1SCC seems not installed on your system (asn1.exe not found in PATH).\n")
sys.stderr.write("WARNING: ASN1SCC environment var unset, using naive ASN.1 parser...\n")
global g_filename
g_filename = listOfFilenames[0]
......
Supports Markdown
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