Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jun 15, 2014
2 parents c0dd80e + 8949d43 commit 6b9b780
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 19 deletions.
16 changes: 16 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions examples/arduino-internal-library/README.rst
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/arduino-internal-library/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (C) Ivan Kravets <[email protected]>
# See LICENSE for details.

[env:arduino_pro5v]
platform = atmelavr
framework = arduino
board = pro16MHzatmega168
51 changes: 51 additions & 0 deletions examples/arduino-internal-library/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (C) Ivan Kravets <[email protected]>
* 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);
}
2 changes: 1 addition & 1 deletion platformio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <[email protected]>
# See LICENSE for details.

VERSION = (0, 1, 0)
VERSION = (0, 2, 0)
__version__ = ".".join([str(s) for s in VERSION])

__title__ = "platformio"
Expand Down
6 changes: 5 additions & 1 deletion platformio/builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
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()
Expand Down
9 changes: 8 additions & 1 deletion platformio/builder/scripts/frameworks/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"-DARDUINO=%d" % ARDUINO_VERSION,
"-DARDUINO_%s" % BOARD_OPTIONS['build.board']
]

# usb flags
if "build.usb_product" in BOARD_OPTIONS:
ARDUINO_FLAGS += [
Expand All @@ -32,12 +33,18 @@
'"', "")
]

# 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")
]
)

Expand Down
8 changes: 7 additions & 1 deletion platformio/builder/scripts/frameworks/energia.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
"-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")
]
)

Expand Down
43 changes: 39 additions & 4 deletions platformio/builder/tools/platformio.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright (C) Ivan Kravets <[email protected]>
# 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
Expand All @@ -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],
Expand All @@ -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]
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions platformio/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ 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"):
copyfile(join(get_source_dir(), "projectconftpl.ini"),
"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")
2 changes: 1 addition & 1 deletion platformio/platforms/atmelavr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AtmelavrPlatform(BasePlatform):

"framework-arduinoavr": {
"path": join("frameworks", "arduino"),
"default": False
"default": True
}
}

Expand Down
2 changes: 1 addition & 1 deletion platformio/platforms/timsp430.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Timsp430Platform(BasePlatform):

"framework-energiamsp430": {
"path": join("frameworks", "energia"),
"default": False
"default": True
}
}

Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
]
},
classifiers=[
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit 6b9b780

Please sign in to comment.