Commit f8d44dba authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

Merged from mainline (SVN)

parent 54e51fa2
#!/usr/bin/env python
#!/usr/bin/env python2
'''
This is the orchestrator that builds all TASTE systems - completely automating
the build process, invoking all necessary tools and code generators
'''
#
# (C) Semantix Information Technologies.
#
# Copyright 2014-2015 IB Krates <info@krates.ee>
# QGenc code generator integration
#
# Semantix Information Technologies is licensing the code of the
# Data Modelling Tools (DMT) in the following dual-license mode:
#
# Commercial Developer License:
# The DMT Commercial Developer License is the appropriate version
# to use for the development of proprietary and/or commercial software.
# This version is for developers/companies who do not want to share
# the source code they develop with others or otherwise comply with the
# terms of the GNU General Public License version 2.1.
#
# GNU GPL v. 2.1:
# This version of DMT is the one to use for the development of
# non-commercial applications, when you are willing to comply
......@@ -131,6 +131,11 @@ class ColorFormatter(logging.Formatter):
msg = self.formatter_msg(self.FORMAT)
logging.Formatter.__init__(self, msg)
@staticmethod
def bold_string(s):
fore_color = 30 + ColorFormatter.COLORS['WARNING']
return ColorFormatter.COLOR_SEQ % fore_color + s + ColorFormatter.RESET_SEQ
def formatter_msg(self, msg):
if self.use_color:
msg = msg.replace("$RESET", self.RESET_SEQ).replace("$BOLD", self.BOLD_SEQ)
......@@ -173,9 +178,9 @@ def mysystem(x, outputDir=None):
if g_bRetry:
if os.getenv('CLEANUP') is not None:
print "Exception in user code:"
print '-'*60
print '-' * 60
traceback.print_stack()
print '-'*60
print '-' * 60
sys.stderr.write("Failed while executing:\n" + x + "\nFrom this directory:\n" + os.getcwd())
sys.stdout.flush()
sys.stderr.flush()
......@@ -191,7 +196,7 @@ def getSingleLineFromCmdOutput(cmd):
try:
f = os.popen(cmd)
returnedLine = f.readlines()[0].strip()
if None != f.close():
if f.close() is not None:
print "Failed! Output was:\n", returnedLine
raise Exception()
return returnedLine
......@@ -202,7 +207,7 @@ def getSingleLineFromCmdOutput(cmd):
def banner(msg):
'''Splashes message in big green letters'''
if sys.stdout.isatty():
print "\n"+chr(27)+"[32m" + msg + chr(27) + "[0m\n"
print "\n" + chr(27) + "[32m" + msg + chr(27) + "[0m\n"
else:
print "\n" + msg + "\n"
if not g_bFast:
......@@ -213,7 +218,7 @@ def banner(msg):
def usage():
'''Shows all available cmd line arguments'''
panic("TASTE/ASSERT orchestrator, revision: $Rev: 7811 $\n"
panic("TASTE/ASSERT orchestrator, revision: $Rev: 8102 $\n"
"Usage: " + os.path.basename(sys.argv[0]) + " <options>\nWhere <options> are:\n\n"
"-f, --fast\n\tSkip waiting for ENTER between stages\n\n"
"-g, --debug\n\tEnable debuging options\n\n"
......@@ -236,7 +241,8 @@ def usage():
"-e, --with-extra-C-code deploymentPartition:directoryWithCfiles\n\tDirectory containing additional .c files to be compiled and linked in for deploymentPartition\n\n"
"-d, --with-extra-Ada-code deploymentPartition:directoryWithADBfiles\n\tDirectory containing additional .adb files to be compiled and linked in for deploymentPartition\n\n"
"-l, --with-extra-lib deploymentPartition:/path/to/libLibrary1.a<,/path/to/libLibrary2.a,...>\n\tAdditional libraries to be linked in for deploymentPartition\n\n"
"-w, --with-cv-attributes properties_filename\n\tUpdate thread priorities, stack size and offset/phase during the build")
"-w, --with-cv-attributes properties_filename\n\tUpdate thread priorities, stack size and offset/phase during the build\n\n"
"-x, --timer granularityInMilliseconds\n\tSet timer resolution (default: 100ms)")
def md5hash(filename):
......@@ -348,8 +354,8 @@ def CalculateCFLAGS(node, withPOHIC=True):
result += ' '.join(g_customCFlagsPerNode[key])
break
# Let the user specify -fdata-sections -ffunction-sections if he wants.
#if "-pg" not in result and not any(map(lambda x: x in kind, ["LEON", "COMPCERT"])):
# result += " -fdata-sections -ffunction-sections "
# if "-pg" not in result and not any(map(lambda x: x in kind, ["LEON", "COMPCERT"])):
# result += " -fdata-sections -ffunction-sections "
return result
......@@ -524,7 +530,7 @@ def CommonBuildingPart(
partitionName = g_fromFunctionToPartition[baseDir]
if partitionName in CDirectories:
for d in CDirectories[partitionName]:
extraCdirIncludes += "-I \""+d + "\" "
extraCdirIncludes += "-I \"" + d + "\" "
if (baseDir in g_distributionNodesPlatform.keys()):
UpdateEnvForNode(baseDir)
cflags = cflagsSoFar + extraCdirIncludes + CalculateCFLAGS(baseDir) + CalculateUserCodeOnlyCFLAGS(baseDir)
......@@ -590,7 +596,7 @@ def BuildAdaSystems_C_code(adaSubsystems, unused_CDirectories, uniqueSetOfAdaPac
os.chdir(baseDir + os.sep + baseDir)
CheckDirectives(baseDir)
mysystem("for i in `/bin/ls ../../GlueAndBuild/glue%s/*.ad? 2>/dev/null | grep -v '/asn1_'` ; do cp \"$i\" . ; done" % baseDir)
#mysystem("cp ../../GlueAndBuild/glue%s/asn1_types.ads ." % baseDir)
# mysystem("cp ../../GlueAndBuild/glue%s/asn1_types.ads ." % baseDir)
mysystem("cp ../../GlueAndBuild/glue%s/adaasn1rtl.ad? . 2>/dev/null ; exit 0" % baseDir)
for modulebase in uniqueSetOfAdaPackages.keys():
mysystem("cp ../../GlueAndBuild/glue%s/%s.ad? . 2>/dev/null ; exit 0" % (baseDir, modulebase))
......@@ -600,12 +606,12 @@ def BuildAdaSystems_C_code(adaSubsystems, unused_CDirectories, uniqueSetOfAdaPac
mysystem("cp ../*polyorb_interface.h . 2>/dev/null || exit 0")
mysystem("rm -f ../dataview.ad[sb] 2>/dev/null || exit 0")
# obsolete: compilation of Ada code is done via Ocarina's makefiles, not by the orchestrator
#mysystem("\"$GNATGCC\" -g -c *.adb")
#mysystem("for i in *.ads ; do [ ! -f ${i/.ads/.adb} ] && \"$GNATGCC\" -g -c *.ads || break ; done")
# mysystem("\"$GNATGCC\" -g -c *.adb")
# mysystem("for i in *.ads ; do [ ! -f ${i/.ads/.adb} ] && \"$GNATGCC\" -g -c *.ads || break ; done")
if (baseDir in g_distributionNodesPlatform.keys()):
UpdateEnvForNode(baseDir)
mysystem("\"$GNATGCC\" -c %s -I ../../GlueAndBuild/glue%s/ -I ../../auto-src/ *.c" %
(cflagsSoFar+CalculateCFLAGS(baseDir)+CalculateUserCodeOnlyCFLAGS(baseDir), baseDir))
(cflagsSoFar + CalculateCFLAGS(baseDir) + CalculateUserCodeOnlyCFLAGS(baseDir), baseDir))
os.chdir("..")
cflags = cflagsSoFar + CalculateCFLAGS(baseDir) + CalculateUserCodeOnlyCFLAGS(baseDir)
mysystem("\"$GNATGCC\" -c -I ../GlueAndBuild/glue%s/ -I ../auto-src/ %s *.c" % (baseDir, cflags))
......@@ -624,12 +630,7 @@ def BuildObjectGeodeSystems(ogSubsystems, CDirectories, cflagsSoFar):
# This is for ObjectGeode code
os.chdir(baseDir + os.sep + "ext")
CheckDirectives(baseDir)
#mysystem("cp \"$DMT\"/asn2aadlPlus/privateHeap/malloc.c .")
#mysystem("cp \"$DMT\"/asn2aadlPlus/privateHeap/staticMoreCore.[ch] .")
#mysystem("for i in ../../auto-src/*.h ; do ln -s \"$i\" ; done")
#mysystem("ln -s \"../../GlueAndBuild/%s\"" % TheInitializationOfTheHeapSourceFile)
mysystem("if [ ! -f \"$WORKDIR/GlueAndBuild/glue%s/OG_ASN1_Types.h\" ] ; then touch \"$WORKDIR/GlueAndBuild/glue%s/OG_ASN1_Types.h\" ; fi" % (ss, ss))
#mysystem("if [ -f vm_callback.c ] ; then mv vm_callback.c vm_callback.c.disabled ; fi")
mysystem("cp ../*polyorb_interface.? . 2>/dev/null || exit 0")
mysystem("cp ../Context-*.? . 2>/dev/null || exit 0")
mysystem("rm -f ../*-uniq.? *-uniq.? 2>/dev/null || exit 0")
......@@ -638,11 +639,11 @@ def BuildObjectGeodeSystems(ogSubsystems, CDirectories, cflagsSoFar):
partitionName = g_fromFunctionToPartition[baseDir]
if partitionName in CDirectories:
for d in CDirectories[partitionName]:
extraCdirIncludes += "-I \""+d + "\" "
extraCdirIncludes += "-I \"" + d + "\" "
if (baseDir in g_distributionNodesPlatform.keys()):
UpdateEnvForNode(baseDir)
mysystem("for i in *.c ; do \"$GNATGCC\" -c %s -I \"$WORKDIR/auto-src/\" -I \"$WORKDIR/GlueAndBuild/glue%s/\" \"$i\" || exit 1 ; done" %
(cflagsSoFar+extraCdirIncludes+CalculateCFLAGS(ss)+CalculateUserCodeOnlyCFLAGS(ss), ss))
(cflagsSoFar + extraCdirIncludes + CalculateCFLAGS(ss) + CalculateUserCodeOnlyCFLAGS(ss), ss))
os.chdir("../..")
......@@ -668,11 +669,11 @@ def BuildRTDSsystems(rtdsSubsystems, CDirectories, cflagsSoFar):
partitionName = g_fromFunctionToPartition[baseDir]
if partitionName in CDirectories:
for d in CDirectories[partitionName]:
extraCdirIncludes += "-I \""+d + "\" "
extraCdirIncludes += "-I \"" + d + "\" "
if (baseDir in g_distributionNodesPlatform.keys()):
UpdateEnvForNode(baseDir)
mysystem("\"$GNATGCC\" -c -DRTDS_NO_SCHEDULER %s %s -I ../../GlueAndBuild/glue%s/ -I ../../auto-src/ -I ../profile *.c" %
(cflagsSoFar+CalculateCFLAGS(baseDir)+CalculateUserCodeOnlyCFLAGS(baseDir), extraCdirIncludes, baseDir))
(cflagsSoFar + CalculateCFLAGS(baseDir) + CalculateUserCodeOnlyCFLAGS(baseDir), extraCdirIncludes, baseDir))
os.chdir("../..")
......@@ -688,12 +689,12 @@ def BuildVHDLsystems_C_code(vhdlSubsystems, CDirectories, cflagsSoFar):
partitionName = g_fromFunctionToPartition[baseDir]
if partitionName in CDirectories:
for d in CDirectories[partitionName]:
extraCdirIncludes += "-I \""+d + "\" "
extraCdirIncludes += "-I \"" + d + "\" "
if len([x for x in os.listdir(".") if x.endswith("polyorb_interface.c")])>0:
if (baseDir in g_distributionNodesPlatform.keys()):
UpdateEnvForNode(baseDir)
mysystem("\"$GNATGCC\" -c %s %s -I ../GlueAndBuild/glue%s/ -I ../auto-src/ *.c" %
(cflagsSoFar+CalculateCFLAGS(baseDir)+CalculateUserCodeOnlyCFLAGS(baseDir), extraCdirIncludes, baseDir))
(cflagsSoFar + CalculateCFLAGS(baseDir) + CalculateUserCodeOnlyCFLAGS(baseDir), extraCdirIncludes, baseDir))
os.chdir("..")
......@@ -706,8 +707,8 @@ def BuildGUIs(guiSubsystems, cflagsSoFar, asn1Grammar):
if not os.path.isdir(baseDir):
panic("No directory %s! (pwd=%s)" % (baseDir, os.getcwd()))
# This is for GUI code
if not os.path.exists(baseDir + os.sep + baseDir+"_gui_code.c"):
panic("GUI generated code did not contain a %s ..." % (baseDir+os.sep+baseDir+"_gui_code.c"))
if not os.path.exists(baseDir + os.sep + baseDir + "_gui_code.c"):
panic("GUI generated code did not contain a %s ..." % (baseDir + os.sep + baseDir + "_gui_code.c"))
os.chdir(baseDir)
mkdirIfMissing("ext")
mysystem('for i in * ; do if [ -f "$i" -a ! -e ext/"$i" ] ; then ln -s ../"$i" ext/ ; fi ; done')
......@@ -740,64 +741,12 @@ def BuildGUIs(guiSubsystems, cflagsSoFar, asn1Grammar):
os.chdir("GUI")
mysystem("cp \"$DMT\"/AutoGUI/* .")
mysystem("cat Makefile | sed 's,DataView,%s,g' > a_temp_name && mv a_temp_name Makefile" % os.path.splitext(os.path.basename(asn1Grammar))[0])
mysystem("cat Makefile | sed 's,applicationName,%s,g' > a_temp_name && mv a_temp_name Makefile" % (baseDir+"_GUI"))
# mysystem("cp -u ../../GlueAndBuild/glue" + baseDir + "/My* .")
# mysystem("cp -u ../../GlueAndBuild/glue" + baseDir + "/telecmds.* .")
mysystem("cat Makefile | sed 's,applicationName,%s,g' > a_temp_name && mv a_temp_name Makefile" % (baseDir + "_GUI"))
mysystem("cp -u ../../GlueAndBuild/glue" + baseDir + "/C_*.[ch] .")
#mysystem("cp ../auto-src/* .")
# mysystem("cp ../auto-src/* .")
if baseDir.endswith('probe_console'):
os.chdir("../..")
continue
# g_stageLog.info("Creating GUI: " + baseDir)
# mysystem("make")
#
# # Generation of Gnuplot support scripts
# gnuplotMeasurements = "../../GlueAndBuild/glue" + baseDir + os.sep + "gnuplot"
# if os.path.exists(gnuplotMeasurements) and 0 != len(open(gnuplotMeasurements, 'r').readlines()):
# outputIndex = 0
# lines = []
# gnuplotScript = open("../../" + baseDir + ".pl", "w")
# gnuplotScript.write('''#!/usr/bin/perl -w
#use strict;
#
#select((select(STDOUT), $| = 1)[0]);
#
#open DATA, "../%s_GUI |";
#
#while(<DATA>) {
#''' % baseDir)
# for line in open("../../GlueAndBuild/glue" + baseDir + os.sep + "gnuplot").readlines():
# lines.append(line.strip())
# commentMe = "# " if outputIndex>4 else ""
# gnuplotScript.write('''%s if (/^%s\D+([\d\.]+)/) {
#%s print "%d:$1\\n";
#%s }
#''' % (commentMe, line.strip().replace("::", ".*").replace("_", "[_-]"), commentMe, outputIndex, commentMe))
# outputIndex = outputIndex + 1
# if outputIndex>5:
# commentedGUIfilters.append(baseDir+".pl")
# gnuplotScript.write('''
#}
#close DATA;
#''')
# gnuplotScript.close()
# mysystem("chmod +x ../../" + baseDir + ".pl")
# gnuplot_gui = open("../../" + baseDir + "_RunAndPlot.sh", "w")
# gnuplot_gui.write("#!/bin/bash\n\n")
# gnuplot_gui.write("./%s.pl | taste-gnuplot-streams %d " % (baseDir, outputIndex))
# if outputIndex>0:
# for i in range(0, outputIndex):
# # number of sample for each window
# gnuplot_gui.write("50 ")
# for line in lines:
# # label of each window
# gnuplot_gui.write('\'' + line + "\' ")
# for i in range(0, outputIndex):
# # size and position of each window (len x wid + posX + posY)
# gnuplot_gui.write("336x256+%d+0 " % (i * 360))
# gnuplot_gui.write("\n")
# gnuplot_gui.close()
# mysystem("chmod +x ../../" + baseDir + "_RunAndPlot.sh")
os.chdir("../..")
return commentedGUIfilters
......@@ -809,8 +758,6 @@ def BuildPythonStubs(pythonSubsystems, asn1Grammar, acnFile):
for baseDir in pythonSubsystems:
if not os.path.isdir(baseDir):
panic("No directory %s! (pwd=%s)" % (baseDir, os.getcwd()))
if not os.path.exists(baseDir + os.sep + "PythonAccess.i"):
panic("Python generated code did not contain a %s ..." % (baseDir+os.sep+"PythonAccess.i"))
olddir = os.getcwd()
pattern = re.compile(r'.*?glue([^/]*)')
findFV = re.match(pattern, baseDir)
......@@ -826,7 +773,7 @@ def BuildPythonStubs(pythonSubsystems, asn1Grammar, acnFile):
mysystem("cp \"%s\" ." % asn1Grammar)
mysystem("cp \"%s\" ." % acnFile)
mkdirIfMissing("asn2dataModel")
mysystem("\"$ASN2DATAMODEL\" -o asn2dataModel -toPython " + os.path.basename(asn1Grammar))
mysystem("asn2dataModel -o asn2dataModel -toPython " + os.path.basename(asn1Grammar))
os.chdir("asn2dataModel")
mysystem("cp \"%s\" ." % acnFile)
......@@ -843,14 +790,16 @@ def BuildPythonStubs(pythonSubsystems, asn1Grammar, acnFile):
installPath = getSingleLineFromCmdOutput("taste-config --prefix")
mysystem('cp "%s"/share/gui-udp/Makefile.python .' % installPath)
mysystem("cp \"%s\"/%s/interface_enum.h ." % (g_absOutputDir, FVname))
mysystem("make -f Makefile.python taste")
mysystem("make -f Makefile.python")
os.chdir("..")
mysystem("cp asn2dataModel/asn1crt.h asn2dataModel/Stubs.py asn2dataModel/DV.py asn2dataModel/_DV.* .")
mysystem("cp asn2dataModel/asn1crt.h asn2dataModel/Stubs.py asn2dataModel/DV* asn2dataModel/*.so .")
mysystem("cp asn2dataModel/%s.h ." % os.path.splitext(os.path.basename(asn1Grammar))[0])
mysystem("cp asn2dataModel/%s_asn.py ." % os.path.splitext(os.path.basename(asn1Grammar))[0].replace("-", "_"))
mysystem("swig -Wall -includeall -outdir . -python ./PythonAccess.i")
mysystem("gcc -g -fPIC -c `python-config --cflags` gui_swig.c queue_manager.c timeInMS.c debug_messages.c PythonAccess_wrap.c")
mysystem("gcc -g -shared -o _PythonAccess.so PythonAccess_wrap.o gui_swig.o queue_manager.o timeInMS.o debug_messages.o `python-config --ldflags` -lrt")
# mysystem("swig -Wall -includeall -outdir . -python ./PythonAccess.i")
# mysystem("gcc -g -fPIC -c `python-config --cflags` gui_api.c queue_manager.c timeInMS.c debug_messages.c PythonAccess_wrap.c")
mysystem("gcc -g -fPIC -c `python-config --cflags` gui_api.c queue_manager.c timeInMS.c debug_messages.c")
# mysystem("gcc -g -shared -o _PythonAccess.so PythonAccess_wrap.o gui_swig.o queue_manager.o timeInMS.o debug_messages.o `python-config --ldflags` -lrt")
mysystem("gcc -g -shared -o PythonAccess.so gui_api.o queue_manager.o timeInMS.o debug_messages.o `python-config --ldflags` -lrt")
os.chdir(olddir)
......@@ -892,8 +841,8 @@ def RenameCommonlyNamedSymbols(scadeSubsystems, simulinkSubsystems, cSubsystems,
systemPlatform, pref = g_distributionNodesPlatform[baseDir]
prefixes[pref] = systemPlatform
appendTarget = getTarget(baseDir)
if 0 != len([x for x in os.listdir("GlueAndBuild/glue"+baseDir) if x.endswith(".o")]):
mysystem("mv GlueAndBuild/glue"+baseDir+"/*.o " + baseDir + appendTarget)
if 0 != len([x for x in os.listdir("GlueAndBuild/glue" + baseDir) if x.endswith(".o")]):
mysystem("mv GlueAndBuild/glue" + baseDir + "/*.o " + baseDir + appendTarget)
for prefix, systemPlatform in prefixes.items():
renamingDirs = 0
......@@ -913,7 +862,7 @@ def RenameCommonlyNamedSymbols(scadeSubsystems, simulinkSubsystems, cSubsystems,
cmd += ' "' + baseDir.replace(' ', '_') + '"'
renamingDirs += 1
if renamingDirs > 1:
os.putenv("OBJCOPY", prefix+"objcopy")
os.putenv("OBJCOPY", prefix + "objcopy")
asn1SccFolder = "auto-src_" + systemPlatform
if os.path.isdir(asn1SccFolder):
cmd += ' ' + asn1SccFolder + "/"
......@@ -1000,7 +949,7 @@ def InvokeOcarinaMakefiles(
os.mkdir(asn1target)
os.chdir(asn1target)
mysystem("cp ../auto-src/*.[ch] .")
mysystem("\"$GNATGCC\" -c %s *.c" % (cflagsSoFar+CalculateCFLAGS(node)+CalculateUserCodeOnlyCFLAGS(node)))
mysystem("\"$GNATGCC\" -c %s *.c" % (cflagsSoFar + CalculateCFLAGS(node) + CalculateUserCodeOnlyCFLAGS(node)))
os.chdir("..")
if bNeedAdaBuildWorkaround:
......@@ -1018,8 +967,8 @@ def InvokeOcarinaMakefiles(
TasteAda.write('package TasteAda is\n')
TasteAda.write('end TasteAda;\n')
TasteAda.close()
#open("conf.ec",'w').write("pragma No_Run_Time;\n")
#mysystem("gnatmake -c -I../../auto-src " + baseDir + " " + x + " -gnatec=conf.ec")
# open("conf.ec",'w').write("pragma No_Run_Time;\n")
# mysystem("gnatmake -c -I../../auto-src " + baseDir + " " + x + " -gnatec=conf.ec")
mysystem("\"$GNATMAKE\" -c %s -I. -gnat2012 tasteada.ads" % mflags(node))
if not os.path.exists("tasteada.ali"):
panic("WARNING: No tasteada.ali file was generated")
......@@ -1028,9 +977,9 @@ def InvokeOcarinaMakefiles(
mysystem("\"$GNATMAKE\" -c %s %s -gnat2012 ada-start.adb" % (dbg, mflags(node)))
for line in open("ada-start.adb").readlines():
if -1 != line.find("adalib"):
poHiAdaLinkCmd = line.strip().replace ("--", "")
poHiAdaLinkCmd = line.strip().replace("--", "")
runtimePath = " " + line.strip().replace("-L", "-Wl,-R") + " "
poHiAdaLinkCmd += runtimePath.replace ("--", "")
poHiAdaLinkCmd += runtimePath.replace("--", "")
if poHiAdaLinkCmd == "":
panic("There was no line containing 'adalib' inside 'ada-start.adb'")
poHiAdaLinkCmd += " -lgnat -lgnarl"
......@@ -1086,9 +1035,9 @@ def InvokeOcarinaMakefiles(
os.chdir(extraCdir)
# banner("You use AADLv2 and external code, I don't know what flags to compile it with!!!")
if bUseEmptyInitializers:
mysystem("\"$GNATGCC\" %s -c -DEMPTY_LOCAL_INIT *.c" % (CalculateCFLAGS(node)+CalculateUserCodeOnlyCFLAGS(node)))
mysystem("\"$GNATGCC\" %s -c -DEMPTY_LOCAL_INIT *.c" % (CalculateCFLAGS(node) + CalculateUserCodeOnlyCFLAGS(node)))
else:
mysystem("\"$GNATGCC\" %s -c *.c" % (CalculateCFLAGS(node)+CalculateUserCodeOnlyCFLAGS(node)))
mysystem("\"$GNATGCC\" %s -c *.c" % (CalculateCFLAGS(node) + CalculateUserCodeOnlyCFLAGS(node)))
os.chdir(pwd)
if partitionNameWithoutSuffix in CDirectories:
......@@ -1109,9 +1058,11 @@ def InvokeOcarinaMakefiles(
for aplc in g_distributionNodes[node]:
if aplc in vhdlSubsystems.keys():
if g_bPolyORB_HI_C:
externals += ' "' + getSingleLineFromCmdOutput("echo $DMT").strip() + '/OG/libESAFPGAforC.a" '
# externals += ' "' + getSingleLineFromCmdOutput("echo $DMT").strip() + '/OG/libESAFPGAforC.a" '
externals += ' "' + getSingleLineFromCmdOutput("echo $DMT").strip() + '/ZestSC1/libZestSC1.a" /lib/i386-linux-gnu/libusb-0.1.so.4 '
else:
externals += ' "' + getSingleLineFromCmdOutput("echo $DMT").strip() + '/OG/libESAFPGA.a" '
# externals += ' "' + getSingleLineFromCmdOutput("echo $DMT").strip() + '/OG/libESAFPGA.a" '
externals += ' "' + getSingleLineFromCmdOutput("echo $DMT").strip() + '/ZestSC1/libZestSC1.a" /lib/i386-linux-gnu/libusb-0.1.so.4'
break # If you meet even one VHDL component for this node, the library was added to externals, no need to check further
userLDFlags += " -lm "
......@@ -1121,7 +1072,7 @@ def InvokeOcarinaMakefiles(
if g_bPolyORB_HI_C and len(adaSubsystems) != 0:
userLDFlags += poHiAdaLinkCmd
#mysystem("cd '"+root+"' && cp ../../../*/*_sync.ads .")
# mysystem("cd '"+root+"' && cp ../../../*/*_sync.ads .")
driversConfigPath = os.path.abspath("../DriversConfig/")
if os.path.exists(driversConfigPath):
driversConfigs = os.listdir(driversConfigPath)
......@@ -1129,9 +1080,12 @@ def InvokeOcarinaMakefiles(
if AdaIncludePath is None:
AdaIncludePath = driversConfigPath + "/" + dC
else:
AdaIncludePath += ":"+driversConfigPath + "/" + dC
AdaIncludePath += ":" + driversConfigPath + "/" + dC
cmd = "cd '"+root+"' && ADA_INCLUDE_PATH=\""+AdaIncludePath+"\" %s EXTERNAL_OBJECTS=\""
if AdaIncludePath is None:
cmd = "cd '" + root + "' && %s EXTERNAL_OBJECTS=\""
else:
cmd = "cd '" + root + "' && ADA_INCLUDE_PATH=\"" + AdaIncludePath + "\" %s EXTERNAL_OBJECTS=\""
# Just before invoking ocarina-generated Makefiles, make sure that only one C_ASN1_Types.o is used:
externalFiles = ' '.join(x for x in externals.split(' ') if not x.startswith("-"))
os.system("rm -f `/bin/ls %s | grep C_ASN1_Types.o | sed 1d` ; exit 0" % externalFiles)
......@@ -1169,10 +1123,10 @@ def InvokeOcarinaMakefiles(
userCFlags += " " + cflagsSoFar.replace('"', '\\"') + " "
userCFlags = userCFlags.strip()
if userCFlags != "":
userCFlags = ' '+userCFlags
userCFlags = ' ' + userCFlags
userLDFlags = userLDFlags.strip()
if userLDFlags != "":
userLDFlags = ' '+userLDFlags
userLDFlags = ' ' + userLDFlags
if len(cppSubsystems)>0:
userLDFlags += " -lstdc++ "
......@@ -1192,23 +1146,39 @@ def InvokeOcarinaMakefiles(
userCFlags = keepOnlyFirstCompilationOption(userCFlags)
userLDFlags = keepOnlyFirstCompilationOption(userLDFlags)
customFlags = (' USER_CFLAGS="${USER_CFLAGS}%s" USER_LDFLAGS="${USER_LDFLAGS}%s"' % (userCFlags, userLDFlags))
mysystem((cmd % customFlags) + extra + externals+"\" make")
mysystem((cmd % customFlags) + extra + externals + "\" make")
return AdaIncludePath
def GatherAllExecutableOutput(unused_outputDir, pythonSubsystems, tmpDirName, commentedGUIfilters, bDebug, i_aadlFile):
def GatherAllExecutableOutput(unused_outputDir, pythonSubsystems, vhdlSubsystems, tmpDirName, commentedGUIfilters, bDebug, i_aadlFile):
'''Gathers all binaries generated (Ocarina,GUIs,Python,PeekPoke,etc) and moves them under .../binaries'''
g_stageLog.info("Gathering all executable output")
outputDir = g_absOutputDir
os.chdir(outputDir)
mkdirIfMissing(outputDir + os.sep + "/binaries")
os.chdir("..")
if len(vhdlSubsystems)>0:
msg = "VHDL bit files built:"
g_stageLog.info('-' * len(msg))
g_stageLog.info(msg)
cmd = "find '%s' -type f -iname '*bit'" % " ".join(vhdlSubsystems.keys())
for line in os.popen(cmd).readlines():
line = line.strip()
targetFolder = outputDir + os.sep + "binaries" + os.sep
mysystem('cp "' + line + '" "' + targetFolder + '"')
print " " + ColorFormatter.bold_string(targetFolder + os.path.basename(line))
os.chdir(outputDir)
mysystem("find '%s'/GlueAndBuild -type f -perm /111 ! -iname '*.so' -a ! -iname '*.pyd' | while read ANS ; do file \"$ANS\" | egrep 'ELF|PE32' >/dev/null 2>/dev/null && mv \"$ANS\" \"%s/binaries/\" ; done ; exit 0" % (g_absOutputDir, g_absOutputDir))
mysystem("find '%s'/ -name binaries -prune -o -type f -perm /111 -iname '*_GUI' -exec sh -c 'F=\"{}\"; D=$(dirname \"$F\"); B=$(basename \"$F\") ; B=\"${B/_GUI/}\"; mv \"$F\" \"%s/binaries/\" ; mv \"$D\"/../../../${B}.pl \"%s/binaries/\" ; mv \"$D\"/../../../${B}_RunAndPlot.sh \"%s/binaries/\" ; ' ';' 2>/dev/null" % (g_absOutputDir, g_absOutputDir, g_absOutputDir, g_absOutputDir))
if len(pythonSubsystems)>0:
g_stageLog.info("Python bridges built under %s:" % outputDir)
for line in os.popen("find '%s' -type f -iname _PythonAccess.so -perm /111" % (g_absOutputDir)).readlines():
g_stageLog.info(" Shared library: " + line.strip())
# if len(pythonSubsystems)>0:
# msg = "Python bridges built under %s:" % outputDir
# g_stageLog.info('-' * len(msg))
# g_stageLog.info(msg)
# g_stageLog.info("Python bridges built under %s:" % outputDir)
# for line in os.popen("find '%s' -type f -iname PythonAccess.so -perm /111" % (g_absOutputDir)).readlines():
# g_stageLog.info(" Shared library: " + line.strip())
# g_stageLog.info('-' * 70)
# Strip binaries:
if not bDebug:
for n in g_distributionNodesPlatform.keys():
......@@ -1239,7 +1209,7 @@ def GatherAllExecutableOutput(unused_outputDir, pythonSubsystems, tmpDirName, co
installPath = getSingleLineFromCmdOutput("taste-config --prefix")
mysystem('cp "%s"/bin/taste-gnuplot-streams ./driveGnuPlotsStreams.pl' % installPath)
mysystem('for i in peekpoke.py PeekPoke.glade ; do cp "%s"/share/peekpoke/$i . ; done' % installPath)
#mysystem('echo Untaring pyinstaller.speedometer.tar.bz2... ; tar jxf "%s"/share/speedometer/pyinstaller.speedometer.tar.bz2' % installPath)
# mysystem('echo Untaring pyinstaller.speedometer.tar.bz2... ; tar jxf "%s"/share/speedometer/pyinstaller.speedometer.tar.bz2' % installPath)
g_stageLog.info("A PeekPoke subfolder was also created under binaries")
g_stageLog.info("for easy run-time monitoring and control of inner variables.")
break
......@@ -1251,9 +1221,9 @@ def GatherAllExecutableOutput(unused_outputDir, pythonSubsystems, tmpDirName, co
for line in os.popen(
"find '%s'/binaries -type f -perm /111 | grep -v /PeekPoke/ ; exit 0" % (g_absOutputDir)).readlines():
line = line.strip()
if line.endswith('.so'):
if line.endswith('.so') or '/GUI-' in line:
continue
g_stageLog.info(" Binary: " + line.strip())
print " " + ColorFormatter.bold_string(line.strip())
mysystem("rm -rf \"%s\"" % tmpDirName)
l = len(commentedGUIfilters)
......@@ -1271,40 +1241,31 @@ def GatherAllExecutableOutput(unused_outputDir, pythonSubsystems, tmpDirName, co
guiFName = guiFName.strip()
stubs = {
'gui': guiFName,
'glue': outputDir+'/GlueAndBuild/glue'+guiFName+'/',
'target': outputDir+"/binaries/"+guiFName+"-GUI",
'GUItarget': outputDir+"/binaries/GUI-"+guiFName,
'glue': outputDir + '/GlueAndBuild/glue' + guiFName + '/',
'target': outputDir + "/binaries/" + guiFName + "-GUI",
'GUItarget': outputDir + "/binaries/GUI-" + guiFName,
'IFview': i_aadlFile,
'DView': outputDir+"/dataview-uniq.asn"
'DView': outputDir + "/dataview-uniq.asn"
}
mysystem('mkdir -p "%(target)s"' % stubs)
mysystem('cp "%(glue)s/"*.py "%(target)s"' % stubs)
mysystem('cp "%(glue)s/guilayout.ui" "%(target)s"' % stubs)
mysystem('cp "%(glue)s/python/"*.py "%(target)s"' % stubs)
mysystem('echo "errCodes = $($(taste-config --prefix)/share/asn1-editor/errCode.py %(glue)s/python/dataview-uniq.h)" >> "%(target)s/datamodel.py"' % stubs)
mysystem('echo "errCodes = $(taste-asn1-errCodes %(glue)s/python/dataview-uniq.h)" >> "%(target)s/datamodel.py"' % stubs)
mysystem('cp "%(glue)s/python/"*.so "%(target)s"' % stubs)
mysystem('cp "%(glue)s/python/asn2dataModel/"*.pyd "%(target)s" 2>/dev/null || exit 0' % stubs)
mysystem('cp "%(glue)s/python/asn2dataModel/"*.so "%(target)s" 2>/dev/null || exit 0' % stubs)
mysystem('cp -r "$(taste-config --prefix)/share/speedometer/content" "%(target)s"' % stubs)
mysystem('cp -r "$(taste-config --prefix)/share/speedometer/dialcontrol.qml" "%(target)s"' % stubs)
mysystem('echo \'A=$(dirname "$0") ; cd "$A/%(gui)s-GUI" && PYTHONPATH=$(taste-config --prefix)/share:$PYTHONPATH $(taste-config --prefix)/share/asn1-editor/gui.py "$@"\' > "%(GUItarget)s" && chmod +x "%(GUItarget)s"' % stubs)
mysystem('cp "$(taste-config --prefix)/share/asn1-editor/tasteLogo_white.png" "%(target)s"' % stubs)
mysystem('cp "%(glue)s/python/asn2dataModel/"DV_Types.py "%(target)s" 2>/dev/null || exit 0' % stubs)
# mysystem('cp -r "$(taste-config --prefix)/share/speedometer/content" "%(target)s"' % stubs)
# mysystem('cp -r "$(taste-config --prefix)/share/speedometer/dialcontrol.qml" "%(target)s"' % stubs)
mysystem('echo \'A=$(dirname "$0") ; cd "$A/%(gui)s-GUI" && PYTHONPATH=$(taste-config --prefix)/share:$PYTHONPATH taste-gui "$@"\' > "%(GUItarget)s" && chmod +x "%(GUItarget)s"' % stubs)
# mysystem('cp "$(taste-config --prefix)/share/asn1-editor/tasteLogo_white.png" "%(target)s"' % stubs)
mysystem('cp "%(IFview)s" "%(target)s"/InterfaceView.aadl' % stubs)
mysystem('cp "%(IFview)s" "%(target)s"/InterfaceView.aadl' % stubs)
mysystem('cp "%(DView)s" "%(target)s"/' % stubs)
# os.chdir(outputDir)
# mysystem("mkdir -p binaries/bb_device")
# mysystem("cp bb_device/interface_enum.h binaries/bb_device/")
# mysystem("cp $(taste-config --prefix)/share/asn1-editor/InterfaceEnum.i binaries/bb_device/")
# mysystem('''\
#cd binaries/bb_device && \
#swig -includeall -outdir . -python ./InterfaceEnum.i && \
#gcc -g -shared -fPIC `python-config --includes` -o _InterfaceEnum.so InterfaceEnum_wrap.c && \
#cp _InterfaceEnum.so ../testgui-GUI''')
for line in os.popen("find '%s'/binaries/ -maxdepth 1 -type f -perm /111 -iname 'GUI*' ; exit 0" % (g_absOutputDir)):
g_stageLog.info(" Python GUI: " + line.strip())
print " " + ColorFormatter.bold_string(line.strip())
def CopyDatabaseFolderIfExisting():
......@@ -1360,7 +1321,7 @@ def ParseCommandLineArgs():
g_stageLog.info("Parsing Command Line Args")
try:
args = sys.argv[1:]
optlist, args = getopt.gnu_getopt(args, "fgpbrvhjn:o:s:c:i:S:M:C:B:A:G:P:V:e:d:l:w:", ['fast', 'debug', 'no-retry', 'with-polyorb-hi-c', 'with-empty-init', 'with-coverage', 'aadlv2', 'gprof', 'keep-case', 'nodeOptions=', 'output=', 'stack=', 'deploymentView=', 'interfaceView=', 'subSCADE=', 'subSIMULINK=', 'subC=', 'subCPP=', 'subAda=', 'subOG=', 'subRTDS=', 'subVHDL=', 'with-extra-C-code=', 'with-extra-Ada-code=', 'with-extra-lib=', 'with-cv-attributes'])
optlist, args = getopt.gnu_getopt(args, "fgpbrvhjn:o:s:c:i:S:M:C:B:A:G:P:V:QC:QA:e:d:l:w:x:", ['fast', 'debug', 'no-retry', 'with-polyorb-hi-c', 'with-empty-init', 'with-coverage', 'aadlv2', 'gprof', 'keep-case', 'nodeOptions=', 'output=', 'stack=', 'deploymentView=', 'interfaceView=', 'subSCADE=', 'subSIMULINK=', 'subC=', 'subCPP=', 'subAda=', 'subOG=', 'subRTDS=', 'subVHDL=', 'subQGenC=', 'subQGenAda=', 'with-extra-C-code=', 'with-extra-Ada-code=', 'with-extra-lib=', 'with-cv-attributes', '--timer='])
except:
usage()
if args != []:
......@@ -1380,9 +1341,12 @@ def ParseCommandLineArgs():
i_aadlFile = ""
stackOptions = ""
cvAttributesFile = ""
timerResolution = "100"
scadeSubsystems = {}
simulinkSubsystems = {}
cSubsystems = {}
qgencSubsystems = {}
qgenadaSubsystems = {}
cppSubsystems = {}
adaSubsystems = {}
ogSubsystems = {}
......@@ -1422,6 +1386,8 @@ def ParseCommandLineArgs():
i_aadlFile = arg
elif opt in ("-w", "--with-cv-attributes"):
cvAttributesFile = arg
elif opt in ("-x", "--timer"):
timerResolution = arg
elif opt in ("-n", "--nodeOptions"):
subName = arg.split('@')[0]
onOffLookup = {'on': True, 'off': False}
......@@ -1460,6 +1426,11 @@ def ParseCommandLineArgs():
if len(arg.split(':')) <= 1:
panic('SIMULINK subsystems must be specified in the form subsysAadlName:zipFile')
simulinkSubsystems[simulinkSubName] = arg.split(':')[1]
elif opt in ("-QC", "--subQGenC"):
qgencSubName = arg.split(':')[0]
if len(arg.split(':')) <= 1:
panic('QGenC subsystems must be specified in the form subsysAadlName:zipFile')
cSubsystems[qgencSubName] = arg.split(':')[1]
elif opt in ("-C", "--subC"):
cSubName = arg.split(':')[0]
if len(arg.split(':')) <= 1:
......@@ -1475,6 +1446,12 @@ def ParseCommandLineArgs():
if len(arg.split(':')) <= 1:
panic('Ada subsystems must be specified in the form subsysAadlName:zipFile')
adaSubsystems[adaSubName] = arg.split(':')[1]
elif opt in ("-QA", "--subQGenAda"):
adaSubName = arg.split(':')[0]
if len(arg.split(':')) <= 1:
panic('QGenAda subsystems must be specified in the form subsysAadlName:zipFile')
qgenadaSubsystems[adaSubName] = arg.split(':')[1]
adaSubsystems[adaSubName] = arg.split(':')[1]
elif opt in ("-G", "--subOG"):
ogSubName = arg.split(':')[0]
if len(arg.split(':')) <= 1:
......@@ -1504,7 +1481,7 @@ def ParseCommandLineArgs():
extraADAdir = os.path.abspath(extraADAdir)
AdaDirectories.setdefault(partition, []).append(extraADAdir)
if AdaIncludePath is not None:
AdaIncludePath += ":"+extraADAdir
AdaIncludePath += ":" + extraADAdir
else:
AdaIncludePath = extraADAdir
os.putenv("ADA_INCLUDE_PATH", AdaIncludePath)
......@@ -1541,8 +1518,8 @@ disable this check with the -z command line argument or by setting
mysystem("date", outputDir=g_absOutputDir)
# Removed check for bash, 2011/Apr/8 : all bashisms are gone now (I think)
#banner("Checking for valid shell")