From 4c2948a8e6caac5777fcf18c47312cfe93d04a2f Mon Sep 17 00:00:00 2001 From: Richard Wackerbarth Date: Wed, 29 Jul 2015 10:45:24 -0500 Subject: [PATCH 1/2] PlatformIO Build Configurations See http://platformio.org/ --- PlatformIOAddons/.gitignore | 2 ++ PlatformIOAddons/Readme.md | 9 ++++++++ PlatformIOAddons/platformio.ini | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 PlatformIOAddons/.gitignore create mode 100644 PlatformIOAddons/Readme.md create mode 100644 PlatformIOAddons/platformio.ini diff --git a/PlatformIOAddons/.gitignore b/PlatformIOAddons/.gitignore new file mode 100644 index 000000000..5113a62aa --- /dev/null +++ b/PlatformIOAddons/.gitignore @@ -0,0 +1,2 @@ +.pioenvs +*.dblite \ No newline at end of file diff --git a/PlatformIOAddons/Readme.md b/PlatformIOAddons/Readme.md new file mode 100644 index 000000000..e3a154486 --- /dev/null +++ b/PlatformIOAddons/Readme.md @@ -0,0 +1,9 @@ +This folder contains the project file to build and install Marlin firmware using the PlatformIO development environment. + +1) Install platformio (See http://platformio.org/) + +.... + +x) From this directory + platformio run + diff --git a/PlatformIOAddons/platformio.ini b/PlatformIOAddons/platformio.ini new file mode 100644 index 000000000..921296479 --- /dev/null +++ b/PlatformIOAddons/platformio.ini @@ -0,0 +1,41 @@ +# +# Project Configuration File +# +# A detailed documentation with the EXAMPLES is located here: +# http://docs.platformio.org/en/latest/projectconf.html +# + +# A sign `#` at the beginning of the line indicates a comment +# Comment lines are ignored. + +# Automatic targets - enable auto-uploading +# targets = upload + +[platformio] +src_dir = ../Marlin + +[env:mega2560] +platform = atmelavr +framework = arduino +board = megaatmega2560 +board_f_cpu = 16000000L + +[env:mega1280] +platform = atmelavr +framework = arduino +board = megaatmega1280 +board_f_cpu = 16000000L + +[env:printrboard] +platform = teensy +framework = arduino +board = teensy20pp +build_flags = -D MOTHERBOARD=BOARD_PRINTRBOARD +# Bug in arduino framework does not allow boards running at 20Mhz +#board_f_cpu = 20000000L + +[env:brainwavepro] +platform = teensy +framework = arduino +board = teensy20pp +build_flags = -D MOTHERBOARD=BOARD_BRAINWAVE_PRO -D AT90USBxx_TEENSYPP_ASSIGNMENTS From 8afd94ed3a96790f385d35f6b6853788d9d22b24 Mon Sep 17 00:00:00 2001 From: Richard Wackerbarth Date: Fri, 31 Jul 2015 08:56:26 -0500 Subject: [PATCH 2/2] Version Generator for PlatformIO Builds --- .../generate_version_header_for_marlin | 57 +++++++++++++++++++ PlatformIOAddons/platformio.ini | 10 +++- 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100755 PlatformIOAddons/generate_version_header_for_marlin diff --git a/PlatformIOAddons/generate_version_header_for_marlin b/PlatformIOAddons/generate_version_header_for_marlin new file mode 100755 index 000000000..03d7cad15 --- /dev/null +++ b/PlatformIOAddons/generate_version_header_for_marlin @@ -0,0 +1,57 @@ +#/usr/bin/env python - +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() + +import os +import errno + +def make_sure_path_exists(path): + try: + os.makedirs(path) + except OSError as exception: + if exception.errno != errno.EEXIST: + raise + +import subprocess + +make_sure_path_exists(env.subst('$BUILDSRC_DIR')) + +from datetime import datetime +import time +import string +import re + +p = subprocess.Popen(['git', 'symbolic-ref', '-q', '--short', 'HEAD'], stdout=subprocess.PIPE) +BRANCH = p.stdout.readline().rstrip() +p = subprocess.Popen(['git', 'describe', '--tags', '--first-parent'], stdout=subprocess.PIPE) +RAW_VERSION = p.stdout.readline().rstrip() +s = re.search('(.*)(-.*)(-.*)',RAW_VERSION) +SHORT_VERSION = s.group(1)+' '+BRANCH +DETAILED_VERSION = string.replace(RAW_VERSION,'-',' '+BRANCH+'-',1) +p = subprocess.Popen(['git', 'config', '--local', '--get', 'remote.origin.url'], stdout=subprocess.PIPE) + + +try: + s = re.search('(.*github.com:)(.*)', p.stdout.readline().rstrip()) + URL = string.replace("https://github.com/"+s.group(2), ".git", "/") + + url_text = """#define SOURCE_CODE_URL "%s" +// Deprecated URL definition +#define FIRMWARE_URL "%s" +""" % (URL, URL) +except Exception, e: + url_text = "" + +version_header_text = """/* This file is automatically generated by a compile time hook + * Do not manually edit it + * It does not get committed to the repository + */ + +#define BUILD_UNIX_DATETIME %s +#define STRING_DISTRIBUTION_DATE "%s" +#define SHORT_BUILD_VERSION "%s" +#define DETAILED_BUILD_VERSION "%s" +%s""" % (int(time.time()), datetime.now().strftime('%Y-%m-%d %H:%M'),SHORT_VERSION, DETAILED_VERSION, url_text) + +open(env.subst('$BUILDSRC_DIR/_Version.h'), 'w').write(version_header_text) diff --git a/PlatformIOAddons/platformio.ini b/PlatformIOAddons/platformio.ini index 921296479..12215b173 100644 --- a/PlatformIOAddons/platformio.ini +++ b/PlatformIOAddons/platformio.ini @@ -18,19 +18,24 @@ src_dir = ../Marlin platform = atmelavr framework = arduino board = megaatmega2560 +extra_script = ./generate_version_header_for_marlin +build_flags = -D USE_AUTOMATIC_VERSIONING -I $BUILDSRC_DIR board_f_cpu = 16000000L [env:mega1280] platform = atmelavr framework = arduino board = megaatmega1280 +extra_script = ./generate_version_header_for_marlin +build_flags = -D USE_AUTOMATIC_VERSIONING -I $BUILDSRC_DIR board_f_cpu = 16000000L [env:printrboard] platform = teensy framework = arduino board = teensy20pp -build_flags = -D MOTHERBOARD=BOARD_PRINTRBOARD +extra_script = ./generate_version_header_for_marlin +build_flags = -D USE_AUTOMATIC_VERSIONING -I $BUILDSRC_DIR -D MOTHERBOARD=BOARD_PRINTRBOARD # Bug in arduino framework does not allow boards running at 20Mhz #board_f_cpu = 20000000L @@ -38,4 +43,5 @@ build_flags = -D MOTHERBOARD=BOARD_PRINTRBOARD platform = teensy framework = arduino board = teensy20pp -build_flags = -D MOTHERBOARD=BOARD_BRAINWAVE_PRO -D AT90USBxx_TEENSYPP_ASSIGNMENTS +extra_script = ./generate_version_header_for_marlin +build_flags = -D USE_AUTOMATIC_VERSIONING -I $BUILDSRC_DIR -D MOTHERBOARD=BOARD_BRAINWAVE_PRO -D AT90USBxx_TEENSYPP_ASSIGNMENTS