Fix Yocto cross-compiles
authorbradford barr <bradford@density.io>
Mon, 7 Aug 2017 18:17:09 +0000 (14:17 -0400)
committerbradford barr <bradford@density.io>
Mon, 7 Aug 2017 18:54:47 +0000 (14:54 -0400)
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.

SConstruct

index 3927e3acc908a9295ac8f2c520588486687b48b7..c86a256af58d7d8ee8acf58ea224e3cd3028276e 100644 (file)
@@ -142,7 +142,7 @@ env['RANLIB'] = prefix + "ranlib"
 
 if not GetOption("help"):
     try:
-        compiler_ver = subprocess.check_output([env['CXX'], "-dumpversion"]).strip()
+        compiler_ver = subprocess.check_output(env['CXX'].split() + ["-dumpversion"]).strip()
     except OSError:
         print("ERROR: Compiler '%s' not found" % env['CXX'])
         Exit(1)