Commit 7eb48050 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

STM32 single/double precision workaround for Ada builds.

Just read the lengthy comment description in the commit itself.
parent da4ca654
......@@ -672,11 +672,45 @@ def BuildAdaSystems_C_code(adaSubsystems, unused_CDirectories, uniqueSetOfAdaPac
panic("Ada zip file did not contain a %s dir..." % (baseDir))
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/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))
#
# Ada files should no longer need to be copied, since we now use ADA_INCLUDE_PATH.
#
# Detailed description
# ====================
# When building Ada code of Functional blocks, we used to copy the files that were 'with'-ed,
# into the folders we were compiling them in. Maxime has now found out that by using
# ADA_INCLUDE_PATH we can point to these folders instead - and everything will be just fine.
#
# So we commented the copies of the ASN.1 Ada RTL below, and set ADA_INCLUDE_PATH to point
# to any one of the glue<AdaFunctionalBlock> folders - since the invocations of ASN1SCC
# inside them have created all the necessary files.
#
# This is also made all the more necessary because of the brain-dead STM32 floating point
# mess. The Crazyflies can't deal with double precisions - they can only work with 'float',
# not 'double's (see also "--fp-word-size 4" elsewhere in the orchestrator). This means
# that ASN1SCC has to be invoked in the 'special' mode that creates 'dumb-STM32-compatible'
# type declarations for the REAL variables.
#
# This in turn means that the .ads/.adb files created are NOW DIFFERENT when targeting STM32
# (i.e. when 'make'-ing the Ocarina Makefiles that build for STM32, we NEED to point ADA_INCLUDE_PATH
# to the .ads/.adb files generated by ASN1SCC when it creates the glue for any one of the Ada
# Functional Blocks that "live" inside STM32).
#
# So when building our AdaIncludePath (see further below - section ADA_STM32_INSANITY)
# we need to 'hack' it to prepend a path towards one of the glue<AdaFunctionalBlock> folders).
# And this HAS to be up-front, so that GNAT finds it first.
#
# In other words, the simplicity of 'invoke ASN1SCC just once, compiled for everyone else'
# is completely messed up by the insanity of STM32 FP handling.
#
# P.S. The next time someone tells me to abandon the orchestrator and 'just use Makefiles'
# I will point to this comment. You have been warned :-)
#
#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/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))
mysystem("for i in %s_vm_if.c %s_vm_if.h vm_callback.c ; do if [ -f ../$i ] ; then cp ../$i . ; fi ; done" %
(baseDir, baseDir))
mysystem("for i in hpredef.h invoke_ri.c vm_callback.h ; do if [ -f ../$i ] ; then cp ../$i . ; fi ; done")
......@@ -1166,6 +1200,46 @@ def InvokeOcarinaMakefiles(
if AdaIncludePath is None:
cmd = "cd '" + root + "' && %s EXTERNAL_OBJECTS=\""
else:
# ADA_STM32_INSANITY
# ==================
#
# When building Ada code of Functional blocks, we used to copy the files that were 'with'-ed,
# into the folders we were compiling them in. Maxime has now found out that by using
# ADA_INCLUDE_PATH we can point to these folders instead - and everything will be just fine.
#
# So we commented the copies of the ASN.1 Ada RTL, and set ADA_INCLUDE_PATH to point
# to any one of the glue<AdaFunctionalBlock> folders - since the invocations of ASN1SCC
# inside them have created all the necessary files.
#
# This is also made all the more necessary because of the brain-dead STM32 floating point
# mess. The Crazyflies can't deal with double precisions - they can only work with 'float',
# not 'double's (see also "--fp-word-size 4" elsewhere in the orchestrator). This means
# that ASN1SCC has to be invoked in the 'special' mode that creates 'dumb-STM32-compatible'
# type declarations for the REAL variables.
#
# This in turn means that the .ads/.adb files created are NOW DIFFERENT when targeting STM32
# (i.e. when 'make'-ing the Ocarina Makefiles that build for STM32, we NEED to point ADA_INCLUDE_PATH
# to the .ads/.adb files generated by ASN1SCC when it creates the glue for any one of the Ada
# Functional Blocks that "live" inside STM32).
#
# So when building our AdaIncludePath we need to 'hack' it to prepend a path towards one of the
# glue<AdaFunctionalBlock> folders. And this HAS to be up-front, so that GNAT finds it first.
#
# In other words, the simplicity of 'invoke ASN1SCC just once, compile the code for everyone else'
# is completely messed up by the insanity of STM32 FP handling.
#
# P.S. The next time someone tells me to abandon the orchestrator and 'just use Makefiles'
# I will point to this comment. You have been warned :-)
#
#
# Look at each one of the Functional blocks that are written in Ada
for baseDir, ss in adaSubsystems.items():
# Are they a part of this target?
if baseDir in g_distributionNodes[node]:
# They are; so prepend their glue folder into the ADA_INCLUDE_PATH, so that the
# STM32-specific .ads/.adb RTL files will be seen first.
AdaIncludePath = os.path.abspath("../GlueAndBuild/glue" + baseDir) + ":" + AdaIncludePath
break
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("-"))
......
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