Skip to content

Commit 6b9b780

Browse files
committed
Merge branch 'release/v0.2.0'
2 parents c0dd80e + 8949d43 commit 6b9b780

File tree

16 files changed

+167
-19
lines changed

16 files changed

+167
-19
lines changed

HISTORY.rst

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Release History
2+
===============
3+
4+
0.2.0 (2014-06-15)
5+
------------------
6+
7+
* Resolved `issue #1 "Build referred libraries" <https://github.com/ivankravets/platformio/issues/1>`_
8+
* Renamed project's "libs" directory to "lib"
9+
* Added `arduino-internal-library <https://github.com/ivankravets/platformio/tree/develop/examples/arduino-internal-library>`_ example
10+
* Changed to beta status
11+
12+
13+
0.1.0 (2014-06-13)
14+
------------------
15+
16+
* Birth! First alpha release

README.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ instruments.
3535

3636
**Platformio** is well suited for **embedded development**. It can:
3737

38-
* Compile frameworks and libraries sources to static libraries
38+
* Automatically analyse dependency
39+
* Reliably detect build changes
40+
* Build framework or library source code to static library
3941
* Build *ELF* (executable and linkable firmware)
4042
* Convert *ELF* to *HEX* or *BIN* file
4143
* Extract *EEPROM* data
@@ -285,14 +287,14 @@ Initialize new platformio based project.
285287
# Example
286288
$ platformio init
287289
Project successfully initialized.
288-
Please put your source code to `src` directory, external libraries to `libs`
290+
Please put your source code to `src` directory, external libraries to `lib`
289291
and setup environments in `platformio.ini` file.
290292
Then process project with `platformio run` command.
291293
292294
After this command ``platformio`` will create:
293295
294296
* ``.pioenvs`` - a temporary working directory.
295-
* ``libs`` - a directory for project specific libraries. Platformio will
297+
* ``lib`` - a directory for project specific libraries. Platformio will
296298
compile their to static libraries and link to executable file
297299
* ``src`` - a source directory. Put code here.
298300
* ``platformio.ini`` - a configuration file for project
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Arduino Example: Build code with internal library
2+
=================================================
3+
4+
1. Download ``platformio``
5+
`sources <https://github.com/ivankravets/platformio/archive/develop.zip>`_
6+
2. Extract ZIP archive
7+
3. Then run these commands:
8+
9+
.. code-block:: bash
10+
11+
# Change directory to example
12+
$ cd platformio-develop/examples/arduino-internal-library/
13+
14+
# Install Atmel AVR development platform with Arduino Framework
15+
$ platformio install atmelavr
16+
17+
# Process example project
18+
$ platformio run
19+
20+
.. image:: console-result.png
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (C) Ivan Kravets <[email protected]>
2+
# See LICENSE for details.
3+
4+
[env:arduino_pro5v]
5+
platform = atmelavr
6+
framework = arduino
7+
board = pro16MHzatmega168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Copyright (C) Ivan Kravets <[email protected]>
3+
* See LICENSE for details.
4+
*/
5+
6+
/*
7+
* EEPROM Read
8+
*
9+
* Reads the value of each byte of the EEPROM and prints it
10+
* to the computer.
11+
* This example code is in the public domain.
12+
*
13+
* https://github.com/arduino/Arduino/blob/master/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino
14+
*/
15+
16+
#include <Arduino.h>
17+
#include <EEPROM.h>
18+
19+
// start reading from the first byte (address 0) of the EEPROM
20+
int address = 0;
21+
byte value;
22+
23+
void setup()
24+
{
25+
// initialize serial and wait for port to open:
26+
Serial.begin(9600);
27+
while (!Serial) {
28+
; // wait for serial port to connect. Needed for Leonardo only
29+
}
30+
}
31+
32+
void loop()
33+
{
34+
// read a byte from the current address of the EEPROM
35+
value = EEPROM.read(address);
36+
37+
Serial.print(address);
38+
Serial.print("\t");
39+
Serial.print(value, DEC);
40+
Serial.println();
41+
42+
// advance to the next address of the EEPROM
43+
address = address + 1;
44+
45+
// there are only 512 bytes of EEPROM, from 0 to 511, so if we're
46+
// on address 512, wrap around to address 0
47+
if (address == 512)
48+
address = 0;
49+
50+
delay(500);
51+
}

platformio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) Ivan Kravets <[email protected]>
22
# See LICENSE for details.
33

4-
VERSION = (0, 1, 0)
4+
VERSION = (0, 2, 0)
55
__version__ = ".".join([str(s) for s in VERSION])
66

77
__title__ = "platformio"

platformio/builder/main.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@
4141
PLATFORMFW_DIR=join("$PLATFORM_DIR", "frameworks", "$FRAMEWORK"),
4242
PLATFORMTOOLS_DIR=join("$PLATFORM_DIR", "tools"),
4343

44-
BUILD_DIR=join("$PROJECT_DIR", ".pioenvs", "$PIOENV")
44+
BUILD_DIR=join("$PROJECT_DIR", ".pioenvs", "$PIOENV"),
45+
LIBSOURCE_DIRS=[
46+
join("$PROJECT_DIR", "lib"),
47+
join("$PLATFORMFW_DIR", "libraries"),
48+
]
4549
)
4650

4751
env = DefaultEnvironment()

platformio/builder/scripts/frameworks/arduino.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"-DARDUINO=%d" % ARDUINO_VERSION,
2424
"-DARDUINO_%s" % BOARD_OPTIONS['build.board']
2525
]
26+
2627
# usb flags
2728
if "build.usb_product" in BOARD_OPTIONS:
2829
ARDUINO_FLAGS += [
@@ -32,12 +33,18 @@
3233
'"', "")
3334
]
3435

36+
# include board variant
37+
env.VariantDir(
38+
join("$BUILD_DIR", "variant"),
39+
join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant'])
40+
)
41+
3542
env.Append(
3643
ASFLAGS=ARDUINO_FLAGS,
3744
CCFLAGS=ARDUINO_FLAGS,
3845
CPPPATH=[
3946
join("$BUILD_DIR", "core"),
40-
join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant'])
47+
join("$BUILD_DIR", "variant")
4148
]
4249
)
4350

platformio/builder/scripts/frameworks/energia.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@
2424
"-DENERGIA=%d" % ENERGIA_VERSION
2525
]
2626

27+
# include board variant
28+
env.VariantDir(
29+
join("$BUILD_DIR", "variant"),
30+
join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant'])
31+
)
32+
2733
env.Append(
2834
ASFLAGS=ENERGIA_FLAGS,
2935
CCFLAGS=ENERGIA_FLAGS,
3036
CPPPATH=[
3137
join("$BUILD_DIR", "core"),
32-
join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant'])
38+
join("$BUILD_DIR", "variant")
3339
]
3440
)
3541

platformio/builder/tools/platformio.py

+39-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Copyright (C) Ivan Kravets <[email protected]>
22
# See LICENSE for details.
33

4-
from os import walk
5-
from os.path import isfile, join
4+
import re
5+
from os import listdir, walk
6+
from os.path import isdir, isfile, join
67
from time import sleep
78

89
from serial import Serial
@@ -17,10 +18,34 @@ def BuildLibrary(env, variant_dir, library_dir):
1718
)
1819

1920

21+
def BuildDependentLibraries(env, src_dir):
22+
libs = []
23+
for deplibfile in env.GetDependentLibraries(src_dir):
24+
for lsd_dir in env['LIBSOURCE_DIRS']:
25+
lsd_dir = env.subst(lsd_dir)
26+
if not isdir(lsd_dir):
27+
continue
28+
for libname in listdir(lsd_dir):
29+
if not isfile(join(lsd_dir, libname, deplibfile)):
30+
continue
31+
_libbuild_dir = join("$BUILD_DIR", libname)
32+
env.Append(CPPPATH=[_libbuild_dir])
33+
libs.append(
34+
env.BuildLibrary(_libbuild_dir, join(lsd_dir, libname)))
35+
return libs
36+
37+
2038
def BuildFirmware(env, libslist):
2139
src = env.Clone()
22-
vdirs = src.VariantDirRecursive(join("$BUILD_DIR", "src"),
23-
join("$PROJECT_DIR", "src"))
40+
vdirs = src.VariantDirRecursive(
41+
join("$BUILD_DIR", "src"), join("$PROJECT_DIR", "src"))
42+
43+
# build source's dependent libs
44+
for vdir in vdirs:
45+
_libs = src.BuildDependentLibraries(vdir)
46+
if _libs:
47+
libslist += _libs
48+
2449
return src.Program(
2550
join("$BUILD_DIR", "firmware"),
2651
[src.GlobCXXFiles(vdir) for vdir in vdirs],
@@ -38,6 +63,14 @@ def GlobCXXFiles(env, path):
3863
return files
3964

4065

66+
def GetDependentLibraries(env, src_dir):
67+
deplibs = []
68+
regexp = re.compile(r"^#include\s+<([^>]+)>", re.M)
69+
for node in env.GlobCXXFiles(src_dir):
70+
deplibs += regexp.findall(node.get_text_contents())
71+
return deplibs
72+
73+
4174
def VariantDirRecursive(env, variant_dir, src_dir, duplicate=True):
4275
# add root dir by default
4376
variants = [variant_dir]
@@ -101,8 +134,10 @@ def exists(_):
101134

102135
def generate(env):
103136
env.AddMethod(BuildLibrary)
137+
env.AddMethod(BuildDependentLibraries)
104138
env.AddMethod(BuildFirmware)
105139
env.AddMethod(GlobCXXFiles)
140+
env.AddMethod(GetDependentLibraries)
106141
env.AddMethod(VariantDirRecursive)
107142
env.AddMethod(ParseBoardOptions)
108143
env.AddMethod(ResetDevice)

platformio/commands/init.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ def cli():
1616

1717
if isfile("platformio.ini") and isdir("src"):
1818
raise ProjectInitialized()
19-
for d in (".pioenvs", "libs", "src"):
19+
for d in (".pioenvs", "lib", "src"):
2020
if not isdir(d):
2121
makedirs(d)
2222
if not isfile("platformio.ini"):
2323
copyfile(join(get_source_dir(), "projectconftpl.ini"),
2424
"platformio.ini")
2525
secho("Project successfully initialized.\n"
2626
"Please put your source code to `src` directory, "
27-
"external libraries to `libs` and "
27+
"external libraries to `lib` and "
2828
"setup environments in `platformio.ini` file.\n"
2929
"Then process project with `platformio run` command.",
3030
fg="green")

platformio/platforms/atmelavr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AtmelavrPlatform(BasePlatform):
2626

2727
"framework-arduinoavr": {
2828
"path": join("frameworks", "arduino"),
29-
"default": False
29+
"default": True
3030
}
3131
}
3232

platformio/platforms/timsp430.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Timsp430Platform(BasePlatform):
2626

2727
"framework-energiamsp430": {
2828
"path": join("frameworks", "energia"),
29-
"default": False
29+
"default": True
3030
}
3131
}
3232

requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
click==2.0
1+
click==2.1
22
colorama==0.3.1
33
pyserial==2.7
4-
requests=2.3.0
5-
scons=2.3.0
4+
requests==2.3.0
5+
scons==2.3.0

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
]
3131
},
3232
classifiers=[
33-
"Development Status :: 3 - Alpha",
33+
"Development Status :: 4 - Beta",
3434
"Environment :: Console",
3535
"Intended Audience :: Developers",
3636
"License :: OSI Approved :: MIT License",

0 commit comments

Comments
 (0)