Skip to content

Commit 8d418ab

Browse files
committed
Fix Yocto cross-compiles
Yocto defines it's compilers in the environment complete with some arch flags. For example: ``` CC="arm-poky-linux-gnueabi-gcc \ -march=armv7-a \ -mfloat-abi=hard \ -mfpu=neon \ -mtune=cortex-a9 \ --sysroot=/home/ubuntu/device/build/tmp/sysroots/pico-imx6" ``` The SConstruct file would fail to find the compiler because it was calling python's subprocess.check_output which expects the first argument of the list to be _only_ the name of the executable. This patch allows the SConstruct script to check the version of the compiler even with funny environment variables. Instead of appending to the compiler string and passing `shell=True` to subprocess, split `env['CXX']` into an array and append `-dumpversion` to that array. Python warns against the use of `shell=True` in subprocess calls.
1 parent db0e610 commit 8d418ab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ env['RANLIB'] = prefix + "ranlib"
142142

143143
if not GetOption("help"):
144144
try:
145-
compiler_ver = subprocess.check_output([env['CXX'], "-dumpversion"]).strip()
145+
compiler_ver = subprocess.check_output(env['CXX'].split() + ["-dumpversion"]).strip()
146146
except OSError:
147147
print("ERROR: Compiler '%s' not found" % env['CXX'])
148148
Exit(1)

0 commit comments

Comments
 (0)