Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TASTE
dmt
Commits
9cdde616
Commit
9cdde616
authored
Jul 31, 2019
by
Thanassis Tsiodras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flake8 and pylint pass.
parent
6a563eba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
44 deletions
+33
-44
dmt/asn2aadlPlus.py
dmt/asn2aadlPlus.py
+33
-44
No files found.
dmt/asn2aadlPlus.py
View file @
9cdde616
...
@@ -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: {}
\n
Using GCC only for computing sizeofs'
.
format
(
str
(
err
)))
print
(
'Not running in a TASTE Environment: {}
\n
Using 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,11 @@ def main():
...
@@ -229,8 +226,11 @@ 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
):
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 +242,14 @@ def main():
...
@@ -242,15 +242,14 @@ def main():
sys
.
argv
[
ofs
]
=
'--aadlv2'
sys
.
argv
[
ofs
]
=
'--aadlv2'
try
:
try
:
optlist
,
args
=
getopt
.
gnu_getopt
(
sys
.
argv
[
1
:],
"hvkad
t:"
,
[
'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 +261,7 @@ def main():
...
@@ -262,9 +261,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 +306,7 @@ def main():
...
@@ -309,7 +306,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 +362,26 @@ def main():
...
@@ -365,35 +362,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 +405,10 @@ end Stream_Element_Buffer;
...
@@ -417,10 +405,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 +426,7 @@ end Stream_Element_Buffer;
...
@@ -438,7 +426,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 +518,13 @@ end Stream_Element_Buffer;
...
@@ -530,12 +518,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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment