mbedmicro/mbed — pull request #683 by PrzemekWirkus (2014-11-11 16:49:37+00:00)
Title: Updated exporters' capabilities to support CppUTest project exports

## Description
In workflow:
```
build.py -m K64F,LPC1768 -t ARM,GCC_ARM --cpputest -j 4
project.py -m K64F,LPC1768 -i uvision -b -n UT_1
```
* build.py didn't support CppUTest library build support. New --cppcheck switch is introduced to compile and build CppUTest library file with header files. Also CppUTest header files were not copied to build/cpputest directory.
* project.py was unable to pass macros related to CppUTest compilation.
* project.py was unable to properly include CppUTest header files.

## Changes
* Added new switch --cpputest to build.py so now we can build CppUTest library. For details how to use CppUTest library with mbed SDK pelase refer to [Introduction - CppUTest in Mbed SDK testing](http://developer.mbed.org/teams/SDK-Development/wiki/Mbed-SDK-cpputest-usage)
* Added missing exporter support for extra macros needed to build particular library.
* Aligned exporters for ARM/uARM and GCC_ARM toolchain.
* Added new functionality to -m switch in project.py script. Now user can define more than one platform for exporting, just separate each platform by comma sign (please do not leave any space between platform names)

Below command will export to Keil uVision project UT_1 for K64F and LPC1768 platforms:
```
project.py -m K64F,LPC1768 -i uvision -b -n UT_1
```

* For more information about build scripts please visit our Wiki:
* [Mbed SDK build script environment](http://developer.mbed.org/teams/SDK-Development/wiki/Mbed-SDK-build-script-introduction)
* [Mbed SDK automated test suite](http://developer.mbed.org/teams/SDK-Development/wiki/Mbed-SDK-automated-test-suite)

## Validation

Building mbed SDK with CppUTest library for K64F and LPC1768 platforms:
```
[git:cpputest-export*] c:\Work\mbed-przemek\workspace_tools> build.py -m K64F,LPC1768 -t ARM,GCC_ARM --cpputest -j 4
Building library CMSIS (K64F, ARM)
Building library MBED (K64F, ARM)
Building library CPPUTEST (K64F, ARM)
Building library CMSIS (LPC1768, ARM)
Building library MBED (LPC1768, ARM)
Building library CPPUTEST (LPC1768, ARM)
Building library CMSIS (K64F, GCC_ARM)
Building library MBED (K64F, GCC_ARM)
Building library CPPUTEST (K64F, GCC_ARM)
Building library CMSIS (LPC1768, GCC_ARM)
Building library MBED (LPC1768, GCC_ARM)
Building library CPPUTEST (LPC1768, GCC_ARM)
Completed in: (1.85)s

Build successes:
* ARM::K64F
* ARM::LPC1768
* GCC_ARM::K64F
* GCC_ARM::LPC1768
```

Exporting to Keil uVision project UT_1 for K64F and LPC1768 platforms:
```
[git:cpputest-export*] c:\Work\mbed-przemek\workspace_tools> project.py -m K64F,LPC1768 -i uvision -b -n UT_1
Successful exports:
* K64F::uvision C:\Work\mbed-przemek\build\export\UT_1_uvision_K64F.zip
* LPC1768::uvision C:\Work\mbed-przemek\build\export\UT_1_uvision_LPC1768.zip
```

Exporting to GCC ARM (Makefile) project UT_1 for K64F and LPC1768 platforms:
```
[git:cpputest-export*] c:\Work\mbed-przemek\workspace_tools> project.py -m K64F,LPC1768 -i gcc_arm -b -n UT_1
Successful exports:
* K64F::gcc_arm C:\Work\mbed-przemek\build\export\UT_1_gcc_arm_K64F.zip
* LPC1768::gcc_arm C:\Work\mbed-przemek\build\export\UT_1_gcc_arm_LPC1768.zip
```

### Validation results:

Export compilation for GCC ARM, platform K64F:
```
[git:cpputest-export*] c:\Work\mbed-przemek\build\export\UT_1> make
C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin/arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -T./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld -L./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM -L./cpputest/TARGET_K64F/TOOLCHAIN_GCC_ARM -o UT_1.elf basic.o env/test_env.o mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/board.o mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/cmsis_nvic.o mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/mbed_overrides.o mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/retarget.o mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.o mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/system_MK64F12.o -lCppUTest -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lCppUTest -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin/arm-none-eabi-objcopy -O binary UT_1.elf UT_1.bin
```

Export compilation for GCC ARM, platform LPC1768:
```
[git:cpputest-export*] c:\Work\mbed-przemek\build\export\UT_1> make
C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin/arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-rtti -MMD -MP -DNDEBUG -Os -DTARGET_LPC1768 -DTARGET_M3 -DTARGET_CORTEX_M -DTARGET_NXP -DTARGET_LPC176X -DTARGET_MBED_LPC1768 -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M3 -DARM_MATH_CM3 -DMBED_BUILD_TIMESTAMP=1415724089.81 -D__MBED__=1 -DCPPUTEST_USE_MEM_LEAK_DETECTION=0 -DCPPUTEST_USE_STD_CPP_LIB=0 -DCPPUTEST=1 -std=gnu++98 -I. -I./cpputest -I./cpputest/TARGET_LPC1768 -I./cpputest/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -I./env -I./mbed -I./mbed/TARGET_LPC1768 -I./mbed/TARGET_LPC1768/TARGET_NXP -I./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X -I./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768 -I./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -o basic.o basic.cpp
C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin/arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-rtti -MMD -MP -DNDEBUG -Os -DTARGET_LPC1768 -DTARGET_M3 -DTARGET_CORTEX_M -DTARGET_NXP -DTARGET_LPC176X -DTARGET_MBED_LPC1768 -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M3 -DARM_MATH_CM3 -DMBED_BUILD_TIMESTAMP=1415724089.81 -D__MBED__=1 -DCPPUTEST_USE_MEM_LEAK_DETECTION=0 -DCPPUTEST_USE_STD_CPP_LIB=0 -DCPPUTEST=1 -std=gnu++98 -I. -I./cpputest -I./cpputest/TARGET_LPC1768 -I./cpputest/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -I./env -I./mbed -I./mbed/TARGET_LPC1768 -I./mbed/TARGET_LPC1768/TARGET_NXP -I./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X -I./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768 -I./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -o env/test_env.o env/test_env.cpp
C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin/arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -T./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld -L./cpputest/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -L./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -o UT_1.elf basic.o env/test_env.o mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/board.o mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/cmsis_nvic.o mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/retarget.o mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/startup_LPC17xx.o mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/system_LPC17xx.o -lCppUTest -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lCppUTest -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin/arm-none-eabi-objcopy -O binary UT_1.elf UT_1.bin
```

Keil uVision export for K64F, compilation for UT_1 project with CppUTest:
![keil_export_1](https://cloud.githubusercontent.com/assets/6360720/4996888/6a8f112e-69c2-11e4-805f-9911c76f7673.png)

Keil uVision export for LPC1768, compilation for UT_1 project with CppUTest:
![keil_export_2](https://cloud.githubusercontent.com/assets/6360720/4996890/6df4db00-69c2-11e4-8a11-e70124943e47.png)