|
@@ -1,10 +1,36 @@
|
|
|
import os
|
|
|
import sys
|
|
|
import rtconfig
|
|
|
+import platform
|
|
|
+import subprocess
|
|
|
|
|
|
from rtconfig import RTT_ROOT
|
|
|
import sys
|
|
|
|
|
|
+def generate_ldscript(input, output):
|
|
|
+
|
|
|
+ if not os.path.exists(input):
|
|
|
+ print('Error: file', input, 'not found')
|
|
|
+ return
|
|
|
+
|
|
|
+ if os.path.exists(output):
|
|
|
+ os.remove(output)
|
|
|
+
|
|
|
+ if rtconfig.PLATFORM == 'gcc':
|
|
|
+
|
|
|
+ gcc_cmd = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
|
|
|
+
|
|
|
+ # gcc -E -P -x c $input -o $output
|
|
|
+ if (platform.system() == 'Windows'):
|
|
|
+ child = subprocess.Popen([gcc_cmd, '-E', '-P', '-x', 'c', input, '-o', output], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
|
+ else:
|
|
|
+ child = subprocess.Popen(gcc_cmd + f' -E -P -x c {input} -o {output}', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
|
+
|
|
|
+ child.communicate()
|
|
|
+
|
|
|
+ print(output, 'is generated from', input)
|
|
|
+
|
|
|
+
|
|
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
|
|
from building import *
|
|
|
|
|
@@ -26,12 +52,7 @@ Export('rtconfig')
|
|
|
# prepare building environment
|
|
|
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
|
|
|
|
|
|
-stack_size = 4096
|
|
|
-
|
|
|
-stack_lds = open('link_stacksize.lds', 'w')
|
|
|
-if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
|
|
|
-stack_lds.write('__STACKSIZE__ = %d;' % stack_size)
|
|
|
-stack_lds.close()
|
|
|
+generate_ldscript('link.lds', 'link.lds.generated')
|
|
|
|
|
|
# make a building
|
|
|
DoBuilding(TARGET, objs)
|