@@ -8,6 +8,7 @@ TOOLCHAIN = os.environ.get('TOOLCHAIN', '')
88TINYGO = os .path .dirname (os .path .realpath (__file__ ))
99MCU = os .environ .get ('TINYGO_MCU' ) or None
1010LTO = bool (int (os .environ .get ('TINYGO_LTO' )))
11+ PORT = os .environ ['TINYGO_PORT' ]
1112
1213CC = TOOLCHAIN + 'gcc'
1314GCCGO = TOOLCHAIN + 'gccgo'
@@ -36,17 +37,13 @@ def get_lib_path(name):
3637 sys .exit (cmd .returncode )
3738 return cmd .stdout .decode ('utf-8' ).strip ()
3839
39- port = 'unix'
40- if MCU == 'esp32' :
41- port = 'esp32'
42-
4340def wrapActionCompileC ():
4441 # Compiling C code
4542 cmd [0 ] = CC
4643 cmd .extend (FLAGS )
4744 cmd .append ('-I%s/goroot/src/runtime' % TINYGO )
4845 cmd .append ('-I%s/gcc/libgo/runtime' % TINYGO )
49- cmd .append ('-I%s/ports/%s' % (TINYGO , port ))
46+ cmd .append ('-I%s/ports/%s' % (TINYGO , PORT ))
5047 cmd .append ('-fplan9-extensions' )
5148
5249def wrapActionCompileGo ():
@@ -56,7 +53,7 @@ def wrapActionCompileGo():
5653 if MCU == 'esp32' :
5754 cmd .append ('-mlongcalls' )
5855 cmd .append ('-nostdlib' )
59- cmd .append ('-L%s/ports/%s/build' % (TINYGO , port ))
56+ cmd .append ('-L%s/ports/%s/build' % (TINYGO , PORT ))
6057
6158def wrapActionArMerge ():
6259 # Merge multiple object files together
@@ -68,9 +65,11 @@ def wrapActionLink():
6865 cmd .extend (FLAGS )
6966 cmd .append ('-Wl,--gc-sections' )
7067 cmd .append ('-Wno-lto-type-mismatch' )
71- cmd .append ('%s/ports/%s/build/syscall.o' % (TINYGO , port ))
72- cmd .append ('%s/ports/%s/build/os.o' % (TINYGO , port ))
73- cmd .append ('%s/ports/%s/build/libruntime.a' % (TINYGO , port ))
68+ cmd .append ('%s/ports/%s/build/syscall.o' % (TINYGO , PORT ))
69+ cmd .append ('%s/ports/%s/build/os.o' % (TINYGO , PORT ))
70+ cmd .append ('%s/ports/%s/build/libruntime.a' % (TINYGO , PORT ))
71+ if os .path .exists ('%s/ports/%s/build/machine.o' % (TINYGO , PORT )):
72+ cmd .append ('%s/ports/%s/build/machine.o' % (TINYGO , PORT ))
7473 if MCU == 'esp32' :
7574 #cmd[0] = LD
7675 SDK = os .environ ['ESPIDF' ]
@@ -92,12 +91,12 @@ def wrapActionLink():
9291 cmd .append ('-lwpa2' )
9392 cmd .append (SDK + '/components/newlib/lib/libc.a' )
9493 cmd .append (SDK + '/components/newlib/lib/libm.a' )
95- cmd .append (SDK + '/components/' + port + '/libhal.a' )
94+ cmd .append (SDK + '/components/' + PORT + '/libhal.a' )
9695 cmd .append ('-Wl,--end-group' )
97- cmd .append ('-L%s/components/%s/ld' % (SDK , port ))
98- cmd .append ('-L%s/components/%s/lib' % (SDK , port ))
96+ cmd .append ('-L%s/components/%s/ld' % (SDK , PORT ))
97+ cmd .append ('-L%s/components/%s/lib' % (SDK , PORT ))
9998 cmd .append ('-T' )
100- cmd .append ('%s/ports/%s/build/esp32_out.ld' % (TINYGO , port ))
99+ cmd .append ('%s/ports/%s/build/esp32_out.ld' % (TINYGO , PORT ))
101100 cmd .append ('-T' )
102101 cmd .append ('esp32.common.ld' )
103102 cmd .append ('-T' )
0 commit comments