Commit 877b26e1 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Merge remote-tracking branch 'origin/master' into MORA

parents 38b6ecec 88a80ee7
...@@ -149,8 +149,11 @@ of each SUBPROGRAM param.''' ...@@ -149,8 +149,11 @@ of each SUBPROGRAM param.'''
projectCache = os.getenv("PROJECT_CACHE") projectCache = os.getenv("PROJECT_CACHE")
if projectCache is not None: if projectCache is not None:
if not os.path.isdir(projectCache): if not os.path.isdir(projectCache):
panic("The configured cache folder:\n\n\t" + projectCache + try:
"\n\n...is not there!\n") os.mkdir(projectCache)
except:
panic("The configured cache folder:\n\n\t" + projectCache +
"\n\n...is not there!\n")
cachedModelExists = False cachedModelExists = False
aadlASTcache = None aadlASTcache = None
if projectCache is not None: if projectCache is not None:
......
...@@ -30,9 +30,6 @@ from .commonPy.asnAST import ( ...@@ -30,9 +30,6 @@ from .commonPy.asnAST import (
from .commonPy.utility import inform, panic, mysystem from .commonPy.utility import inform, panic, mysystem
g_keepFiles = False
g_privateHeapSize = -1
g_platformCompilers = ['gcc']
# Ada package names per type # Ada package names per type
g_AdaPackageNameOfType = {} g_AdaPackageNameOfType = {}
...@@ -142,16 +139,16 @@ def calculateForNativeAndASN1SCC(absASN1SCCpath, autosrc, names, inputFiles): ...@@ -142,16 +139,16 @@ def calculateForNativeAndASN1SCC(absASN1SCCpath, autosrc, names, inputFiles):
namesDict[cleanNameAsAsn1cWants(asnTypename)] = asnTypename namesDict[cleanNameAsAsn1cWants(asnTypename)] = asnTypename
# Get a list of all available compilers # Get a list of all available compilers
global g_platformCompilers platformCompilers = ['gcc']
try: try:
pipe = Popen("find-supported-compilers", stdout=PIPE).stdout pipe = Popen("find-supported-compilers", stdout=PIPE).stdout
g_platformCompilers = pipe.read().splitlines() platformCompilers = pipe.read().splitlines()
except OSError as err: except OSError as err:
print('Not running in a TASTE Environment: {}\nUsing GCC only for computing sizeofs'.format(str(err))) print('Not running in a TASTE Environment: {}\nUsing GCC only for computing sizeofs'.format(str(err)))
g_platformCompilers = ['gcc'.encode()] platformCompilers = ['gcc'.encode()]
# Get the maximum size of each asn1type from all platform compilers # Get the maximum size of each asn1type from all platform compilers
messageSizes = {} messageSizes = {}
for cc in g_platformCompilers: for cc in platformCompilers:
# Compile the generated C-file with each compiler # Compile the generated C-file with each compiler
pwd = os.getcwd() pwd = os.getcwd()
os.chdir(autosrc) os.chdir(autosrc)
...@@ -171,7 +168,7 @@ def calculateForNativeAndASN1SCC(absASN1SCCpath, autosrc, names, inputFiles): ...@@ -171,7 +168,7 @@ def calculateForNativeAndASN1SCC(absASN1SCCpath, autosrc, names, inputFiles):
nm = "gnm" nm = "gnm"
else: else:
nm = "nm" nm = "nm"
for line in os.popen( nm + " --print-size " + autosrc + os.sep + base + ".stats.o").readlines(): for line in os.popen(nm + " --print-size " + autosrc + os.sep + base + ".stats.o").readlines():
try: try:
(dummy, size, dummy2, msg) = line.split() (dummy, size, dummy2, msg) = line.split()
except ValueError: except ValueError:
...@@ -229,8 +226,14 @@ def main(): ...@@ -229,8 +226,14 @@ def main():
print("asn2aadlPlus v" + str(version)) # pragma: no cover print("asn2aadlPlus v" + str(version)) # pragma: no cover
sys.exit(1) # pragma: no cover sys.exit(1) # pragma: no cover
global g_keepFiles keepFiles = False
global g_privateHeapSize
projectCache = os.getenv("PROJECT_CACHE")
if projectCache is not None and not os.path.isdir(projectCache):
try:
os.mkdir(projectCache)
except:
panic("The configured cache folder:\n\n\t" + projectCache + "\n\n...is not there!\n")
# Backwards compatibility - the '-acn' option is no longer necessary # Backwards compatibility - the '-acn' option is no longer necessary
# (we auto-detect ACN files via their extension) # (we auto-detect ACN files via their extension)
...@@ -242,15 +245,14 @@ def main(): ...@@ -242,15 +245,14 @@ def main():
sys.argv[ofs] = '--aadlv2' sys.argv[ofs] = '--aadlv2'
try: try:
optlist, args = getopt.gnu_getopt(sys.argv[1:], "hvkadt:", ['help', 'version', 'keep', 'aadlv2', 'debug', 'platform=', 'test=']) optlist, args = getopt.gnu_getopt(sys.argv[1:], "hvkad", ['help', 'version', 'keep', 'aadlv2', 'debug', 'platform='])
except: except getopt.GetoptError:
usage() usage()
bAADLv2 = False bAADLv2 = False
g_keepFiles = False keepFiles = False
g_privateHeapSize = -1
for opt, arg in optlist: for opt, unused_arg in optlist:
if opt in ("-h", "--help"): if opt in ("-h", "--help"):
usage() usage()
elif opt in ("-v", "--version"): elif opt in ("-v", "--version"):
...@@ -262,9 +264,7 @@ def main(): ...@@ -262,9 +264,7 @@ def main():
# Updated, June 2011: AADLv1 no longer supported. # Updated, June 2011: AADLv1 no longer supported.
bAADLv2 = True bAADLv2 = True
elif opt in ("-k", "--keep"): elif opt in ("-k", "--keep"):
g_keepFiles = True keepFiles = True
elif opt in ("-t", "--test"):
g_privateHeapSize = int(arg)
if len(args) < 2: if len(args) < 2:
usage() usage()
...@@ -309,7 +309,7 @@ def main(): ...@@ -309,7 +309,7 @@ def main():
if oldMD5s: if oldMD5s:
def ok(f): def ok(f):
return os.path.exists(f) and md5(f) == oldMD5s[f] return os.path.exists(f) and md5(f) == oldMD5s[f]
# ...and all the current input ASN.1 files exist in the 'burned' list # ...and all the current input ASN.1 files exist in the 'burned' list
# that was built inside the previous version of the output AADL file, # that was built inside the previous version of the output AADL file,
# AND # AND
# all the current input ASN.1 files exist and their MD5 checksum # all the current input ASN.1 files exist and their MD5 checksum
...@@ -365,35 +365,26 @@ def main(): ...@@ -365,35 +365,26 @@ def main():
o.write(' with Taste;\n') o.write(' with Taste;\n')
o.write(' with Base_Types;\n') o.write(' with Base_Types;\n')
o.write(' with Deployment;\n') o.write(' with Deployment;\n')
# o.write('-- No more private heap required (we use the space certified compiler)\n')
# o.write('-- Memory_Required: 0\n\n')
try:
pathToDirectives = os.popen("taste-config --directives").readlines()[0].strip()
except:
panic("taste-config is not in the PATH. Aborting...")
typesUnusableAsInterfaceParameters = [] typesUnusableAsInterfaceParameters = []
if bAADLv2: if bAADLv2:
directiveTypes = [ directiveTypes = [
"Simulink_Tunable_Parameter", "Timer", "Taste_directive"] "Simulink_Tunable_Parameter", "Timer", "Taste_directive"]
for typeName in directiveTypes: for typeName in directiveTypes:
#sourceText = '\n Source_Text => ("' + pathToDirectives + '");'
sourceText = "" sourceText = ""
adaPackageName = "TASTE_Directives" adaPackageName = "TASTE_Directives"
moduleName = "TASTE-Directives" moduleName = "TASTE-Directives"
o.write(''' o.write('DATA {typeName}\n'
DATA {typeName} 'PROPERTIES\n'
PROPERTIES ' TASTE::Ada_Package_Name => "{adaPackageName}";\n'
TASTE::Ada_Package_Name => "{adaPackageName}"; ' Type_Source_Name => "{typeNameASN}";\n'
Type_Source_Name => "{typeNameASN}"; ' Deployment::ASN1_Module_Name => "{moduleName}";{sourceText}\n'
Deployment::ASN1_Module_Name => "{moduleName}";{sourceText} ' TASTE::Forbid_in_PI => true;\n'
TASTE::Forbid_in_PI => true; 'END {typeName};\n'.format(
END {typeName}; typeName=typeName,
'''.format(pathToDirectives=pathToDirectives, typeNameASN=typeName.replace('_', '-'),
typeName=typeName, sourceText=sourceText,
typeNameASN=typeName.replace('_', '-'), adaPackageName=adaPackageName,
sourceText=sourceText, moduleName=moduleName))
adaPackageName=adaPackageName,
moduleName=moduleName))
typesUnusableAsInterfaceParameters = [] typesUnusableAsInterfaceParameters = []
for line in os.popen("badTypes '" + "' '".join(asnFiles) + "'").readlines(): for line in os.popen("badTypes '" + "' '".join(asnFiles) + "'").readlines():
...@@ -417,10 +408,10 @@ end Stream_Element_Buffer; ...@@ -417,10 +408,10 @@ end Stream_Element_Buffer;
o.write(' -- name of the ASN.1 source file:\n') o.write(' -- name of the ASN.1 source file:\n')
# o.write(' Source_Text => ("%s");\n' % os.path.basename(asnParser.g_names[asnTypename]._asnFilename)) # o.write(' Source_Text => ("%s");\n' % os.path.basename(asnParser.g_names[asnTypename]._asnFilename))
o.write(' Source_Text => ("%s");\n' % asnParser.g_names[asnTypename]._asnFilename) o.write(' Source_Text => ("%s");\n' % asnParser.g_names[asnTypename]._asnFilename)
prefix = bAADLv2 and "TASTE::" or "" prefix = "TASTE::" if bAADLv2 else ""
possibleACN = ASNtoACN(asnParser.g_names[asnTypename]._asnFilename) possibleACN = ASNtoACN(asnParser.g_names[asnTypename]._asnFilename)
if bAADLv2 and os.path.exists(possibleACN): if bAADLv2 and os.path.exists(possibleACN):
prefix2 = bAADLv2 and "TASTE::" or "assert_properties::" prefix2 = "TASTE::" if bAADLv2 else "assert_properties::"
base = os.path.splitext(os.path.basename(possibleACN))[0] base = os.path.splitext(os.path.basename(possibleACN))[0]
fname = base.replace("-", "_") fname = base.replace("-", "_")
o.write(' %sEncodingDefinitionFile => classifier(DataView::ACN_%s);\n' % (prefix2, fname)) o.write(' %sEncodingDefinitionFile => classifier(DataView::ACN_%s);\n' % (prefix2, fname))
...@@ -438,7 +429,7 @@ end Stream_Element_Buffer; ...@@ -438,7 +429,7 @@ end Stream_Element_Buffer;
o.write(' Type_Source_Name => "%s";\n' % asnTypename) o.write(' Type_Source_Name => "%s";\n' % asnTypename)
o.write(' TASTE::Position_In_File => [ line => %s ; column => 1 ; ];\n' % node._lineno) o.write(' TASTE::Position_In_File => [ line => %s ; column => 1 ; ];\n' % node._lineno)
o.write(' -- what kind of type is this?\n') o.write(' -- what kind of type is this?\n')
prefix = bAADLv2 and "TASTE" or "assert_properties" prefix = "TASTE" if bAADLv2 else "assert_properties"
o.write(' %s::ASN1_Basic_Type =>' % prefix) o.write(' %s::ASN1_Basic_Type =>' % prefix)
if isinstance(node, AsnBool): if isinstance(node, AsnBool):
o.write('aBOOLEAN;\n') o.write('aBOOLEAN;\n')
...@@ -530,12 +521,13 @@ end Stream_Element_Buffer; ...@@ -530,12 +521,13 @@ end Stream_Element_Buffer;
o.close() o.close()
# Remove generated code # Remove generated code
if not g_keepFiles: if not keepFiles:
shutil.rmtree(autosrc) shutil.rmtree(autosrc)
else: else:
print("Generated message buffers in '%s'" % autosrc) print("Generated message buffers in '%s'" % autosrc)
# os.chdir(pwd) # os.chdir(pwd)
if __name__ == "__main__": if __name__ == "__main__":
main() main()
......
...@@ -389,8 +389,11 @@ def ParseAsnFileList(listOfFilenames: List[str]) -> None: # pylint: disable=inv ...@@ -389,8 +389,11 @@ def ParseAsnFileList(listOfFilenames: List[str]) -> None: # pylint: disable=inv
# Add basic ASN.1 caching to avoid calling the ASN.1 compiler over and over # Add basic ASN.1 caching to avoid calling the ASN.1 compiler over and over
projectCache = os.getenv("PROJECT_CACHE") projectCache = os.getenv("PROJECT_CACHE")
if projectCache is not None and not os.path.isdir(projectCache): if projectCache is not None and not os.path.isdir(projectCache):
utility.panic( try:
"The configured cache folder:\n\n\t" + projectCache + "\n\n...is not there!\n") os.mkdir(projectCache)
except:
utility.panic(
"The configured cache folder:\n\n\t" + projectCache + "\n\n...is not there!\n")
xmlAST = xmlAST2 = None xmlAST = xmlAST2 = None
someFilesHaveChanged = False someFilesHaveChanged = False
if projectCache is not None: if projectCache is not None:
......
...@@ -11,7 +11,7 @@ from setuptools import setup, find_packages ...@@ -11,7 +11,7 @@ from setuptools import setup, find_packages
setup( setup(
name='dmt', name='dmt',
version="2.1.33", version="2.1.35",
packages=find_packages(), packages=find_packages(),
author='Thanassis Tsiodras', author='Thanassis Tsiodras',
author_email='Thanassis.Tsiodras@esa.int', author_email='Thanassis.Tsiodras@esa.int',
......
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