Implemented "build_flags" option for environments // closed issue #4

This commit is contained in:
Ivan Kravets
2014-06-21 22:27:58 +03:00
parent fd1fc9941a
commit a2402c31b7
10 changed files with 62 additions and 43 deletions

View File

@@ -1,11 +1,14 @@
Release History
===============
0.3.0 (?)
0.3.0 (2014-06-21)
---------
* Allowed to pass multiple "SomePlatform" to install/uninstall commands
* Added "IDE Integration" section to README with Eclipse project examples
* Created auto installer script for *PlatformIO* (`issue #3 <https://github.com/ivankravets/platformio/issues/3>`_)
* Added "Super-Quick" way to Installation section (README)
* Implemented "build_flags" option for environments (`issue #4 <https://github.com/ivankravets/platformio/issues/4>`_)
0.2.0 (2014-06-15)

View File

@@ -16,3 +16,4 @@ board = lpmsp430g2553
platform = titiva
framework = energia
board = lplm4f120h5qr
build_flags = "-DLED_PIN=GREEN_LED"

View File

@@ -8,27 +8,22 @@
with intervals of 1 second (1000 milliseconds)
*/
#ifdef ENERGIA
#include "Energia.h"
#define WLED RED_LED
#else
#include "Arduino.h"
#define WLED 13 // Most Arduino boards already have an LED attached to pin 13 on the board itself
#ifndef LED_PIN
#define LED_PIN 13 // Most Arduino boards already have an LED attached to pin 13 on the board itself
#endif
void setup()
{
pinMode(WLED, OUTPUT); // set pin as output
pinMode(LED_PIN, OUTPUT); // set pin as output
}
void loop()
{
digitalWrite(WLED, HIGH); // set the LED on
digitalWrite(LED_PIN, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(WLED, LOW); // set the LED off
digitalWrite(LED_PIN, LOW); // set the LED off
delay(1000); // wait for a second
}

View File

@@ -16,6 +16,7 @@ commonvars.AddVariables(
("PIOENV",),
("PLATFORM",),
("FRAMEWORK",),
("BUILD_FLAGS",),
# board options
("BOARD",),

View File

@@ -26,9 +26,9 @@ env.Replace(
ASFLAGS=[
"-g", # include debugging info (so errors include line numbers)
"-x", "assembler-with-cpp",
"-mmcu=$BOARD_MCU",
"-DF_CPU=$BOARD_F_CPU"
"-mmcu=$BOARD_MCU"
],
CCFLAGS=[
"-g", # include debugging info (so errors include line numbers)
"-Os", # optimize for size
@@ -36,11 +36,15 @@ env.Replace(
"-ffunction-sections", # place each function in its own section
"-fdata-sections",
"-MMD", # output dependancy info
"-mmcu=$BOARD_MCU",
"-DF_CPU=$BOARD_F_CPU"
"-mmcu=$BOARD_MCU"
],
CXXFLAGS=["-fno-exceptions"],
CPPDEFINES=[
"F_CPU=$BOARD_F_CPU"
],
LINKFLAGS=[
"-Os",
"-Wl,--gc-sections",
@@ -62,6 +66,9 @@ env.Replace(
UPLOADEEPCMD="$UPLOADER $UPLOADERFLAGS -U eeprom:w:$SOURCES:i"
)
if "BUILD_FLAGS" in env:
env.MergeFlags(env['BUILD_FLAGS'])
env.Append(
BUILDERS=dict(
ElfToEep=Builder(

View File

@@ -19,18 +19,14 @@ BOARD_OPTIONS = env.ParseBoardOptions(
ARDUINO_VERSION = int(
open(join(env.subst("$PLATFORMFW_DIR"),
"version.txt")).read().replace(".", "").strip())
ARDUINO_FLAGS = [
"-DARDUINO=%d" % ARDUINO_VERSION,
"-DARDUINO_%s" % BOARD_OPTIONS['build.board']
]
# usb flags
ARDUINO_USBDEFINES = []
if "build.usb_product" in BOARD_OPTIONS:
ARDUINO_FLAGS += [
"-DUSB_VID=%s" % BOARD_OPTIONS['build.vid'],
"-DUSB_PID=%s" % BOARD_OPTIONS['build.pid'],
"-DUSB_PRODUCT=%s" % BOARD_OPTIONS['build.usb_product'].replace(
'"', "")
ARDUINO_USBDEFINES = [
"USB_VID=%s" % BOARD_OPTIONS['build.vid'],
"USB_PID=%s" % BOARD_OPTIONS['build.pid'],
"USB_PRODUCT=%s" % BOARD_OPTIONS['build.usb_product'].replace('"', "")
]
# include board variant
@@ -40,8 +36,10 @@ env.VariantDir(
)
env.Append(
ASFLAGS=ARDUINO_FLAGS,
CCFLAGS=ARDUINO_FLAGS,
CPPDEFINES=[
"ARDUINO=%d" % ARDUINO_VERSION,
"ARDUINO_%s" % BOARD_OPTIONS['build.board']
] + ARDUINO_USBDEFINES,
CPPPATH=[
join("$BUILD_DIR", "core"),
join("$BUILD_DIR", "variant")

View File

@@ -19,10 +19,6 @@ BOARD_OPTIONS = env.ParseBoardOptions(
ENERGIA_VERSION = int(
open(join(env.subst("$PLATFORMFW_DIR"),
"version.txt")).read().replace(".", "").strip())
ENERGIA_FLAGS = [
"-DARDUINO=101",
"-DENERGIA=%d" % ENERGIA_VERSION
]
# include board variant
env.VariantDir(
@@ -31,8 +27,10 @@ env.VariantDir(
)
env.Append(
ASFLAGS=ENERGIA_FLAGS,
CCFLAGS=ENERGIA_FLAGS,
CPPDEFINES=[
"ARDUINO=101",
"ENERGIA=%d" % ENERGIA_VERSION
],
CPPPATH=[
join("$BUILD_DIR", "core"),
join("$BUILD_DIR", "variant")

View File

@@ -28,9 +28,9 @@ env.Replace(
ASFLAGS=[
"-g", # include debugging info (so errors include line numbers)
"-x", "-assembler-with-cpp",
"-mmcu=$BOARD_MCU",
"-DF_CPU=$BOARD_F_CPU"
"-mmcu=$BOARD_MCU"
],
CCFLAGS=[
"-g", # include debugging info (so errors include line numbers)
"-Os", # optimize for size
@@ -38,8 +38,11 @@ env.Replace(
"-ffunction-sections", # place each function in its own section
"-fdata-sections",
"-MMD", # output dependancy info
"-mmcu=$BOARD_MCU",
"-DF_CPU=$BOARD_F_CPU"
"-mmcu=$BOARD_MCU"
],
CPPDEFINES=[
"F_CPU=$BOARD_F_CPU"
],
LINK="$CC",
@@ -57,6 +60,9 @@ env.Replace(
UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"'
)
if "BUILD_FLAGS" in env:
env.MergeFlags(env['BUILD_FLAGS'])
env.Append(
BUILDERS=dict(
ElfToHex=Builder(

View File

@@ -31,8 +31,7 @@ env.Replace(
"-mcpu=cortex-m4",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-fsingle-precision-constant",
"-DF_CPU=$BOARD_F_CPU"
"-fsingle-precision-constant"
],
CCFLAGS=[
@@ -47,8 +46,7 @@ env.Replace(
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-fsingle-precision-constant",
"-MMD", # output dependancy info
"-DF_CPU=$BOARD_F_CPU"
"-MMD" # output dependancy info
],
CXXFLAGS=[
@@ -56,6 +54,10 @@ env.Replace(
"-fno-exceptions"
],
CPPDEFINES=[
"F_CPU=$BOARD_F_CPU"
],
LINKFLAGS=[
"-Os",
"-nostartfiles",
@@ -73,6 +75,9 @@ env.Replace(
UPLOADCMD="$UPLOADER $SOURCES"
)
if "BUILD_FLAGS" in env:
env.MergeFlags(env['BUILD_FLAGS'])
env.Append(
BUILDERS=dict(
ElfToBin=Builder(

View File

@@ -11,6 +11,11 @@
#[env:mybaseenv]
#platform = %INSTALLED_PLATFORM_NAME_HERE%
# Environment with specific build flags
#[env:specbuildflags]
#platform = %INSTALLED_PLATFORM_NAME_HERE%
#build_flags = "-I/opt/include -L/opt/lib -lfoo -DMYDEFINE=13"
#
# Atmel AVR based board
#