New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing order in which the platformio.ini build_flags are passed to respective toolchains? #191

Closed
Hermiedapwdrman opened this Issue May 5, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@Hermiedapwdrman

Hermiedapwdrman commented May 5, 2015

Hello,

I am having an issue with the build flags when trying to configure the USB descriptors for the Teensy 3.1 board. Specifically I want to access the HID Keyboard/Mouse/Joystick functionality included in the Teensy libraries. These are contained within a preprocessor #if/#elif/#elif block determined by which value is defined during the compiler invocation. E.g.

#if defined(USB_SERIAL)
    <Setupo as CDC serial device>
#elif defined(USB_HID)
    <Setup as HID keyboard/mouse/joystick>
#endif

For the Teensy framework, you have defined USB_SERIAL within the teensy base platform and this is passed to the compiler during the run command. As per the platformio instructions to use build_flags rather than create new platforms, I tried using the following platformio.ini setup.

[env:teensy31]
platform = teensy 
framework = arduino
board = teensy31
build_flags =  -UUSB_SERIAL -DUSB_HID  

With the intent to un-define the included USB_SERIAL value and define USB_HID to enable that portion of the USB code. The problem I have encountered is the order which the build_flags are passed to the compiler. The above configuration fails to compile (due to undeclared functions which are declared within the USB_HID conditional code block). The console output after platformio run is:

arm-none-eabi-g++ -o .pioenvs/teensy31/src/mymain.o -c -fno-rtti -fno-exceptions -std=gnu++0x -felide-constructors -UUSB_SERIAL -g -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -MMD -DF_CPU=72000000L -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX256__ -DUSB_HID -DARDUINO=10600 -DTEENSYDUINO=121 -DPLATFORMIO=010400 -I.pioenvs/teensy31/FrameworkArduino .pioenvs/teensy31/src/mymain.cpp

The '-UUSB_SERAL' option I declared is passed before the platform inherent '-DUSB_SERIAL' option, and as such does not clear it. I have not found a way to alter this order and this is preventing me from clearing the value and compiling my code. Note: If I manually rearrange the flags so the -U command follows, it will successfully compile as expected.

Should the platformio.ini build flags be passed last to rectify this issue?

Thanks for the great work so far!
-Patrick

@Hermiedapwdrman Hermiedapwdrman changed the title from Confusing order for passing the platformio.ini build_flags are passed to respective toolchains? to Confusing order in which the platformio.ini build_flags are passed to respective toolchains? May 5, 2015

@ivankravets ivankravets added this to the 1.5.0 milestone May 6, 2015

@ivankravets ivankravets self-assigned this May 6, 2015

@ivankravets ivankravets added the bug label May 6, 2015

@ivankravets

This comment has been minimized.

Member

ivankravets commented May 6, 2015

PlatformIO passes all build_flags to Scons env.MergeFlags(flags). Looks like it doesn't support -U name option. I will contact with Scons developers and discuss it. If they say that env.MergeFlags doesn't parse -U, then I will implement own mechanism for this option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment