Commit 56d70e33 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

For RTEMS, the Ocarina-generated Makefile depends on proper RTEMS_MAKEFILE_PATH

Learn the compiler and linker flags, by calling out into
a temporary Makefile that includes the Ocarina-generated one
(see instructions from Jerome in ticket 311)

But don't do this for RTEMS! Because for this to work, we
need to wait for access to the EnvVars information...
The Ocarina-generated makefile depends on proper setting
of RTEMS_MAKEFILE_PATH, which itself depends on the
deployment processor.
parent edb6cea3
...@@ -2033,42 +2033,55 @@ def ParsePartitionInformation(): ...@@ -2033,42 +2033,55 @@ def ParsePartitionInformation():
if partitionNameWithoutSuffix in existingPartitionNamesWithoutSuffix: if partitionNameWithoutSuffix in existingPartitionNamesWithoutSuffix:
panic("\nYou can't use two partitions with the same name (%s)!" % partitionNameWithoutSuffix) panic("\nYou can't use two partitions with the same name (%s)!" % partitionNameWithoutSuffix)
existingPartitionNamesWithoutSuffix.append(partitionNameWithoutSuffix) existingPartitionNamesWithoutSuffix.append(partitionNameWithoutSuffix)
if 'RTEMS' in data[2]:
SetEnvForRTEMS(data[2])
g_distributionNodes[partitionName] = [] g_distributionNodes[partitionName] = []
# New detection logic for platform-level CC, CFLAGS and LDFLAGS to use
# (from ticket 311) def getCompilerAndLinkerFlags():
makefilename = "/tmp/Makefile" + str(os.getpid()) # New detection logic for platform-level CC, CFLAGS and LDFLAGS to use
f = open(makefilename, "w") # (from ticket 311)
f.write('include GlueAndBuild/deploymentview_final/' + partitionName + '/Makefile\n') makefilename = "/tmp/Makefile" + str(os.getpid())
f.write('\n') f = open(makefilename, "w")
f.write('printCC:\n') f.write('include GlueAndBuild/deploymentview_final/' + partitionName + '/Makefile\n')
f.write('\t@$(info $(CC))\n\n') f.write('\n')
f.write('printCflags:\n') f.write('printCC:\n')
f.write('\t@$(info $(CFLAGS))\n\n') f.write('\t@$(info $(CC))\n\n')
f.write('printLdflags:\n') f.write('printCflags:\n')
f.write('\t@$(info $(LDFLAGS))\n\n') f.write('\t@$(info $(CFLAGS))\n\n')
f.close() f.write('printLdflags:\n')
try: f.write('\t@$(info $(LDFLAGS))\n\n')
cc = getSingleLineFromCmdOutput("make -s -f " + makefilename + " printCC 2>&1").split()[0] f.close()
if cc == "cc": try:
prefix = "" cc = getSingleLineFromCmdOutput("make -s -f " + makefilename + " printCC 2>&1").split()[0]
else: if cc == "cc":
prefix = re.sub(r'gcc$', '', cc) prefix = ""
except: else:
panic("Failed to detect a proper compiler for " + partitionName) prefix = re.sub(r'gcc$', '', cc)
cf = getSingleLineFromCmdOutput("make -s -f " + makefilename + " printCflags 2>&1") except:
cf = cf.replace("-DRTEMS_PURE", "") panic("Failed to detect a proper compiler for " + partitionName)
ld = getSingleLineFromCmdOutput("make -s -f " + makefilename + " printLdflags 2>&1") cf = getSingleLineFromCmdOutput("make -s -f " + makefilename + " printCflags 2>&1")
os.unlink(makefilename) cf = cf.replace("-DRTEMS_PURE", "")
if partitionNameWithoutSuffix not in g_customCFlagsForUserCodeOnlyPerNode: ld = getSingleLineFromCmdOutput("make -s -f " + makefilename + " printLdflags 2>&1")
g_customCFlagsForUserCodeOnlyPerNode.setdefault(partitionNameWithoutSuffix, []).append(cf) os.unlink(makefilename)
if partitionNameWithoutSuffix not in g_customLDFlagsPerNode: if partitionNameWithoutSuffix not in g_customCFlagsForUserCodeOnlyPerNode:
g_customLDFlagsPerNode.setdefault(partitionNameWithoutSuffix, []).append(ld) g_customCFlagsForUserCodeOnlyPerNode.setdefault(partitionNameWithoutSuffix, []).append(cf)
g_log.write('for ' + partitionNameWithoutSuffix + ', identified CC:\n' + cc + '\n') if partitionNameWithoutSuffix not in g_customLDFlagsPerNode:
g_log.write('for ' + partitionNameWithoutSuffix + ', identified CFLAGS:\n' + cf + '\n') g_customLDFlagsPerNode.setdefault(partitionNameWithoutSuffix, []).append(ld)
g_log.write('for ' + partitionNameWithoutSuffix + ', identified LDFLAGS:\n' + ld + '\n') g_log.write('for ' + partitionNameWithoutSuffix + ', identified CC:\n' + cc + '\n')
g_distributionNodesPlatform[partitionName] = [data[2], prefix] g_log.write('for ' + partitionNameWithoutSuffix + ', identified CFLAGS:\n' + cf + '\n')
g_log.write('for ' + partitionNameWithoutSuffix + ', identified LDFLAGS:\n' + ld + '\n')
g_distributionNodesPlatform[partitionName] = [data[2], prefix]
return prefix
if 'RTEMS' not in data[2]:
# Learn the compiler and linker flags, by calling out into
# a temporary Makefile that includes the Ocarina-generated one
# (see instructions from Jerome in ticket 311)
#
# But don't do this for RTEMS! Because for this to work, we
# need to wait for access to the EnvVars information... The
# Ocarina-generated makefile depends on proper setting of
# RTEMS_MAKEFILE_PATH, which itself depends on the deployment
# processor!
prefix = getCompilerAndLinkerFlags()
try: try:
if 'coverage' in data[3:]: if 'coverage' in data[3:]:
g_customCFlagsPerNode.setdefault(partitionName, []).append("-g -fprofile-arcs -ftest-coverage -DCOVERAGE") g_customCFlagsPerNode.setdefault(partitionName, []).append("-g -fprofile-arcs -ftest-coverage -DCOVERAGE")
...@@ -2082,20 +2095,22 @@ def ParsePartitionInformation(): ...@@ -2082,20 +2095,22 @@ def ParsePartitionInformation():
idx = envVarAssignment.find('=') idx = envVarAssignment.find('=')
if idx == -1: if idx == -1:
panic('Unexpected EnvVars value:\n\t' + envVarAssignment) panic('Unexpected EnvVars value:\n\t' + envVarAssignment)
# Why we don't just split on '='?
# If you are wondering why we don't just split on '=', # Because an env var setting can be like this one:
# think of an env var setting like...
#
# FOOBAR="BAR=1 BAZ=2" # FOOBAR="BAR=1 BAZ=2"
key = envVarAssignment[:idx] key = envVarAssignment[:idx]
value = envVarAssignment[idx+1:] value = envVarAssignment[idx+1:]
print(key, '==>', value) print(key, '==>', value)
platform = g_distributionNodesPlatform[partitionName][0]
os.putenv(key, value) os.putenv(key, value)
os.environ[key] = value os.environ[key] = value
# If we just read RTEMS_MAKEFILE_PATH related settings, the target was
# an RTEMS one - so we first set the env up, and THEN call out into the
# Ocarina-generated Makefile to learn the compilation and linking flags
# for this RTEMS target.
platform = g_distributionNodesPlatform.get(partitionName, [data[2], None])[0]
if 'RTEMS' in platform: if 'RTEMS' in platform:
SetEnvForRTEMS(platform) SetEnvForRTEMS(platform)
prefix = getCompilerAndLinkerFlags()
else: else:
g_fromFunctionToPartition[line] = partitionNameWithoutSuffix g_fromFunctionToPartition[line] = partitionNameWithoutSuffix
if line not in g_distributionNodes[partitionName]: if line not in g_distributionNodes[partitionName]:
......
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