forked from platformio/platformio-core
Merge branch 'release/v0.2.0'
This commit is contained in:
16
HISTORY.rst
Normal file
16
HISTORY.rst
Normal file
@ -0,0 +1,16 @@
|
||||
Release History
|
||||
===============
|
||||
|
||||
0.2.0 (2014-06-15)
|
||||
------------------
|
||||
|
||||
* Resolved `issue #1 "Build referred libraries" <https://github.com/ivankravets/platformio/issues/1>`_
|
||||
* Renamed project's "libs" directory to "lib"
|
||||
* Added `arduino-internal-library <https://github.com/ivankravets/platformio/tree/develop/examples/arduino-internal-library>`_ example
|
||||
* Changed to beta status
|
||||
|
||||
|
||||
0.1.0 (2014-06-13)
|
||||
------------------
|
||||
|
||||
* Birth! First alpha release
|
@ -35,7 +35,9 @@ instruments.
|
||||
|
||||
**Platformio** is well suited for **embedded development**. It can:
|
||||
|
||||
* Compile frameworks and libraries sources to static libraries
|
||||
* Automatically analyse dependency
|
||||
* Reliably detect build changes
|
||||
* Build framework or library source code to static library
|
||||
* Build *ELF* (executable and linkable firmware)
|
||||
* Convert *ELF* to *HEX* or *BIN* file
|
||||
* Extract *EEPROM* data
|
||||
@ -285,14 +287,14 @@ Initialize new platformio based project.
|
||||
# Example
|
||||
$ platformio init
|
||||
Project successfully initialized.
|
||||
Please put your source code to `src` directory, external libraries to `libs`
|
||||
Please put your source code to `src` directory, external libraries to `lib`
|
||||
and setup environments in `platformio.ini` file.
|
||||
Then process project with `platformio run` command.
|
||||
|
||||
After this command ``platformio`` will create:
|
||||
|
||||
* ``.pioenvs`` - a temporary working directory.
|
||||
* ``libs`` - a directory for project specific libraries. Platformio will
|
||||
* ``lib`` - a directory for project specific libraries. Platformio will
|
||||
compile their to static libraries and link to executable file
|
||||
* ``src`` - a source directory. Put code here.
|
||||
* ``platformio.ini`` - a configuration file for project
|
||||
|
20
examples/arduino-internal-library/README.rst
Normal file
20
examples/arduino-internal-library/README.rst
Normal file
@ -0,0 +1,20 @@
|
||||
Arduino Example: Build code with internal library
|
||||
=================================================
|
||||
|
||||
1. Download ``platformio``
|
||||
`sources <https://github.com/ivankravets/platformio/archive/develop.zip>`_
|
||||
2. Extract ZIP archive
|
||||
3. Then run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
$ cd platformio-develop/examples/arduino-internal-library/
|
||||
|
||||
# Install Atmel AVR development platform with Arduino Framework
|
||||
$ platformio install atmelavr
|
||||
|
||||
# Process example project
|
||||
$ platformio run
|
||||
|
||||
.. image:: console-result.png
|
BIN
examples/arduino-internal-library/console-result.png
Normal file
BIN
examples/arduino-internal-library/console-result.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 806 KiB |
7
examples/arduino-internal-library/platformio.ini
Normal file
7
examples/arduino-internal-library/platformio.ini
Normal file
@ -0,0 +1,7 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
[env:arduino_pro5v]
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = pro16MHzatmega168
|
51
examples/arduino-internal-library/src/main.cpp
Normal file
51
examples/arduino-internal-library/src/main.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
* See LICENSE for details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* EEPROM Read
|
||||
*
|
||||
* Reads the value of each byte of the EEPROM and prints it
|
||||
* to the computer.
|
||||
* This example code is in the public domain.
|
||||
*
|
||||
* https://github.com/arduino/Arduino/blob/master/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
// start reading from the first byte (address 0) of the EEPROM
|
||||
int address = 0;
|
||||
byte value;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// read a byte from the current address of the EEPROM
|
||||
value = EEPROM.read(address);
|
||||
|
||||
Serial.print(address);
|
||||
Serial.print("\t");
|
||||
Serial.print(value, DEC);
|
||||
Serial.println();
|
||||
|
||||
// advance to the next address of the EEPROM
|
||||
address = address + 1;
|
||||
|
||||
// there are only 512 bytes of EEPROM, from 0 to 511, so if we're
|
||||
// on address 512, wrap around to address 0
|
||||
if (address == 512)
|
||||
address = 0;
|
||||
|
||||
delay(500);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
VERSION = (0, 1, 0)
|
||||
VERSION = (0, 2, 0)
|
||||
__version__ = ".".join([str(s) for s in VERSION])
|
||||
|
||||
__title__ = "platformio"
|
||||
|
@ -41,7 +41,11 @@ DefaultEnvironment(
|
||||
PLATFORMFW_DIR=join("$PLATFORM_DIR", "frameworks", "$FRAMEWORK"),
|
||||
PLATFORMTOOLS_DIR=join("$PLATFORM_DIR", "tools"),
|
||||
|
||||
BUILD_DIR=join("$PROJECT_DIR", ".pioenvs", "$PIOENV")
|
||||
BUILD_DIR=join("$PROJECT_DIR", ".pioenvs", "$PIOENV"),
|
||||
LIBSOURCE_DIRS=[
|
||||
join("$PROJECT_DIR", "lib"),
|
||||
join("$PLATFORMFW_DIR", "libraries"),
|
||||
]
|
||||
)
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
@ -23,6 +23,7 @@ ARDUINO_FLAGS = [
|
||||
"-DARDUINO=%d" % ARDUINO_VERSION,
|
||||
"-DARDUINO_%s" % BOARD_OPTIONS['build.board']
|
||||
]
|
||||
|
||||
# usb flags
|
||||
if "build.usb_product" in BOARD_OPTIONS:
|
||||
ARDUINO_FLAGS += [
|
||||
@ -32,12 +33,18 @@ if "build.usb_product" in BOARD_OPTIONS:
|
||||
'"', "")
|
||||
]
|
||||
|
||||
# include board variant
|
||||
env.VariantDir(
|
||||
join("$BUILD_DIR", "variant"),
|
||||
join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant'])
|
||||
)
|
||||
|
||||
env.Append(
|
||||
ASFLAGS=ARDUINO_FLAGS,
|
||||
CCFLAGS=ARDUINO_FLAGS,
|
||||
CPPPATH=[
|
||||
join("$BUILD_DIR", "core"),
|
||||
join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant'])
|
||||
join("$BUILD_DIR", "variant")
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -24,12 +24,18 @@ ENERGIA_FLAGS = [
|
||||
"-DENERGIA=%d" % ENERGIA_VERSION
|
||||
]
|
||||
|
||||
# include board variant
|
||||
env.VariantDir(
|
||||
join("$BUILD_DIR", "variant"),
|
||||
join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant'])
|
||||
)
|
||||
|
||||
env.Append(
|
||||
ASFLAGS=ENERGIA_FLAGS,
|
||||
CCFLAGS=ENERGIA_FLAGS,
|
||||
CPPPATH=[
|
||||
join("$BUILD_DIR", "core"),
|
||||
join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant'])
|
||||
join("$BUILD_DIR", "variant")
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from os import walk
|
||||
from os.path import isfile, join
|
||||
import re
|
||||
from os import listdir, walk
|
||||
from os.path import isdir, isfile, join
|
||||
from time import sleep
|
||||
|
||||
from serial import Serial
|
||||
@ -17,10 +18,34 @@ def BuildLibrary(env, variant_dir, library_dir):
|
||||
)
|
||||
|
||||
|
||||
def BuildDependentLibraries(env, src_dir):
|
||||
libs = []
|
||||
for deplibfile in env.GetDependentLibraries(src_dir):
|
||||
for lsd_dir in env['LIBSOURCE_DIRS']:
|
||||
lsd_dir = env.subst(lsd_dir)
|
||||
if not isdir(lsd_dir):
|
||||
continue
|
||||
for libname in listdir(lsd_dir):
|
||||
if not isfile(join(lsd_dir, libname, deplibfile)):
|
||||
continue
|
||||
_libbuild_dir = join("$BUILD_DIR", libname)
|
||||
env.Append(CPPPATH=[_libbuild_dir])
|
||||
libs.append(
|
||||
env.BuildLibrary(_libbuild_dir, join(lsd_dir, libname)))
|
||||
return libs
|
||||
|
||||
|
||||
def BuildFirmware(env, libslist):
|
||||
src = env.Clone()
|
||||
vdirs = src.VariantDirRecursive(join("$BUILD_DIR", "src"),
|
||||
join("$PROJECT_DIR", "src"))
|
||||
vdirs = src.VariantDirRecursive(
|
||||
join("$BUILD_DIR", "src"), join("$PROJECT_DIR", "src"))
|
||||
|
||||
# build source's dependent libs
|
||||
for vdir in vdirs:
|
||||
_libs = src.BuildDependentLibraries(vdir)
|
||||
if _libs:
|
||||
libslist += _libs
|
||||
|
||||
return src.Program(
|
||||
join("$BUILD_DIR", "firmware"),
|
||||
[src.GlobCXXFiles(vdir) for vdir in vdirs],
|
||||
@ -38,6 +63,14 @@ def GlobCXXFiles(env, path):
|
||||
return files
|
||||
|
||||
|
||||
def GetDependentLibraries(env, src_dir):
|
||||
deplibs = []
|
||||
regexp = re.compile(r"^#include\s+<([^>]+)>", re.M)
|
||||
for node in env.GlobCXXFiles(src_dir):
|
||||
deplibs += regexp.findall(node.get_text_contents())
|
||||
return deplibs
|
||||
|
||||
|
||||
def VariantDirRecursive(env, variant_dir, src_dir, duplicate=True):
|
||||
# add root dir by default
|
||||
variants = [variant_dir]
|
||||
@ -101,8 +134,10 @@ def exists(_):
|
||||
|
||||
def generate(env):
|
||||
env.AddMethod(BuildLibrary)
|
||||
env.AddMethod(BuildDependentLibraries)
|
||||
env.AddMethod(BuildFirmware)
|
||||
env.AddMethod(GlobCXXFiles)
|
||||
env.AddMethod(GetDependentLibraries)
|
||||
env.AddMethod(VariantDirRecursive)
|
||||
env.AddMethod(ParseBoardOptions)
|
||||
env.AddMethod(ResetDevice)
|
||||
|
@ -16,7 +16,7 @@ def cli():
|
||||
|
||||
if isfile("platformio.ini") and isdir("src"):
|
||||
raise ProjectInitialized()
|
||||
for d in (".pioenvs", "libs", "src"):
|
||||
for d in (".pioenvs", "lib", "src"):
|
||||
if not isdir(d):
|
||||
makedirs(d)
|
||||
if not isfile("platformio.ini"):
|
||||
@ -24,7 +24,7 @@ def cli():
|
||||
"platformio.ini")
|
||||
secho("Project successfully initialized.\n"
|
||||
"Please put your source code to `src` directory, "
|
||||
"external libraries to `libs` and "
|
||||
"external libraries to `lib` and "
|
||||
"setup environments in `platformio.ini` file.\n"
|
||||
"Then process project with `platformio run` command.",
|
||||
fg="green")
|
||||
|
@ -26,7 +26,7 @@ class AtmelavrPlatform(BasePlatform):
|
||||
|
||||
"framework-arduinoavr": {
|
||||
"path": join("frameworks", "arduino"),
|
||||
"default": False
|
||||
"default": True
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class Timsp430Platform(BasePlatform):
|
||||
|
||||
"framework-energiamsp430": {
|
||||
"path": join("frameworks", "energia"),
|
||||
"default": False
|
||||
"default": True
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
click==2.0
|
||||
click==2.1
|
||||
colorama==0.3.1
|
||||
pyserial==2.7
|
||||
requests=2.3.0
|
||||
scons=2.3.0
|
||||
requests==2.3.0
|
||||
scons==2.3.0
|
||||
|
Reference in New Issue
Block a user