Skip to content

Commit ff4bb73

Browse files
ivankravetsigrr
authored andcommitted
Integration with @platformio Build System
1 parent 1557b1e commit ff4bb73

File tree

4 files changed

+175
-0
lines changed

4 files changed

+175
-0
lines changed

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "framework-arduinoespressif8266",
3+
"description": "Arduino Wiring-based Framework (ESP8266 Core)",
4+
"url": "https://github.com/esp8266/Arduino",
5+
"version": "2.4.0-rc.1"
6+
}

tests/common.sh

+56
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,53 @@ function build_package()
122122
./build_boards_manager_package.sh
123123
}
124124

125+
126+
function install_platformio()
127+
{
128+
pip install -U https://github.com/platformio/platformio/archive/develop.zip
129+
platformio platform install https://github.com/platformio/platform-espressif8266.git#feature/stage
130+
sed -i 's/https:\/\/github\.com\/esp8266\/Arduino\.git/*/' ~/.platformio/platforms/espressif8266_stage/platform.json
131+
ln -s $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif8266
132+
# Install dependencies:
133+
# - esp8266/examples/ConfigFile
134+
pio lib install ArduinoJson
135+
}
136+
137+
function build_sketches_with_platformio()
138+
{
139+
set +e
140+
local srcpath=$1
141+
local build_arg=$2
142+
local sketches=$(find $srcpath -name *.ino)
143+
for sketch in $sketches; do
144+
local sketchdir=$(dirname $sketch)
145+
local sketchdirname=$(basename $sketchdir)
146+
local sketchname=$(basename $sketch)
147+
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
148+
echo "Skipping $sketch, beacause it is not the main sketch file";
149+
continue
150+
fi;
151+
if [[ -f "$sketchdir/.test.skip" ]]; then
152+
echo -e "\n ------------ Skipping $sketch ------------ \n";
153+
continue
154+
fi
155+
local build_cmd="pio ci $sketchdir $build_arg"
156+
echo -e "\n ------------ Building $sketch ------------ \n";
157+
echo "$build_cmd"
158+
time ($build_cmd >build.log)
159+
local result=$?
160+
if [ $result -ne 0 ]; then
161+
echo "Build failed ($1)"
162+
echo "Build log:"
163+
cat build.log
164+
set -e
165+
return $result
166+
fi
167+
rm build.log
168+
done
169+
set -e
170+
}
171+
125172
function run_travis_ci_build()
126173
{
127174
# Build documentation using Sphinx
@@ -165,6 +212,15 @@ function run_travis_ci_build()
165212
echo -e "travis_fold:start:size_report"
166213
cat size.log
167214
echo -e "travis_fold:end:size_report"
215+
216+
# PlatformIO
217+
echo -e "travis_fold:start:install_platformio"
218+
install_platformio
219+
echo -e "travis_fold:end:install_platformio"
220+
221+
echo -e "travis_fold:start:build_sketches_with_platformio"
222+
build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose"
223+
echo -e "travis_fold:end:build_sketches_with_platformio"
168224
}
169225

170226
set -e

tools/platformio-build.py

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Copyright (c) 2014-present PlatformIO <[email protected]>
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
Arduino
17+
18+
Arduino Wiring-based Framework allows writing cross-platform software to
19+
control devices attached to a wide range of Arduino boards to create all
20+
kinds of creative coding, interactive objects, spaces or physical experiences.
21+
22+
http://arduino.cc/en/Reference/HomePage
23+
"""
24+
25+
# Extends: https://github.com/platformio/platform-espressif8266/blob/develop/builder/main.py
26+
27+
from os.path import isdir, join
28+
29+
from SCons.Script import DefaultEnvironment
30+
31+
env = DefaultEnvironment()
32+
platform = env.PioPlatform()
33+
34+
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif8266")
35+
assert isdir(FRAMEWORK_DIR)
36+
37+
38+
env.Prepend(
39+
CPPDEFINES=[
40+
("ARDUINO", 10600),
41+
"LWIP_OPEN_SRC"
42+
],
43+
CPPPATH=[
44+
join(FRAMEWORK_DIR, "tools", "sdk", "include"),
45+
join(FRAMEWORK_DIR, "tools", "sdk", "lwip", "include"),
46+
join(FRAMEWORK_DIR, "tools", "sdk", "libc",
47+
"xtensa-lx106-elf", "include"),
48+
join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core"))
49+
],
50+
LIBPATH=[
51+
join(FRAMEWORK_DIR, "tools", "sdk", "lib"),
52+
join(FRAMEWORK_DIR, "tools", "sdk", "ld"),
53+
join(FRAMEWORK_DIR, "tools", "sdk", "libc", "xtensa-lx106-elf", "lib")
54+
],
55+
LIBS=[
56+
"mesh", "wpa2", "smartconfig", "espnow", "pp", "main", "wpa", "lwip_gcc",
57+
"net80211", "wps", "crypto", "phy", "hal", "axtls", "gcc",
58+
"m", "c", "stdc++"
59+
]
60+
)
61+
62+
env.Append(
63+
LIBSOURCE_DIRS=[
64+
join(FRAMEWORK_DIR, "libraries")
65+
],
66+
LINKFLAGS=[
67+
"-Wl,-wrap,system_restart_local",
68+
"-Wl,-wrap,spi_flash_read"
69+
]
70+
)
71+
72+
#
73+
# Target: Build Core Library
74+
#
75+
76+
libs = []
77+
78+
if "build.variant" in env.BoardConfig():
79+
env.Append(
80+
CPPPATH=[
81+
join(FRAMEWORK_DIR, "variants",
82+
env.BoardConfig().get("build.variant"))
83+
]
84+
)
85+
libs.append(env.BuildLibrary(
86+
join("$BUILD_DIR", "FrameworkArduinoVariant"),
87+
join(FRAMEWORK_DIR, "variants", env.BoardConfig().get("build.variant"))
88+
))
89+
90+
libs.append(env.BuildLibrary(
91+
join("$BUILD_DIR", "FrameworkArduino"),
92+
join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core"))
93+
))
94+
95+
env.Prepend(LIBS=libs)

tools/sdk/ld/eagle.app.v6.common.ld

+18
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ SECTIONS
157157
*.c.o( EXCLUDE_FILE (umm_malloc.c.o) .literal*, \
158158
EXCLUDE_FILE (umm_malloc.c.o) .text*)
159159
*.cpp.o(.literal*, .text*)
160+
*.pioenvs\\*\\lib*.a:(EXCLUDE_FILE (umm_malloc.o) .literal*, \
161+
EXCLUDE_FILE (umm_malloc.o) .text*)
162+
*.pioenvs/*/lib*.a:(EXCLUDE_FILE (umm_malloc.o) .literal*, \
163+
EXCLUDE_FILE (umm_malloc.o) .text*)
164+
*.pioenvs\\*\\lib\*.a:(EXCLUDE_FILE (umm_malloc.o) .literal*, \
165+
EXCLUDE_FILE (umm_malloc.o) .text*)
166+
*.pioenvs/*/lib/*.a:(EXCLUDE_FILE (umm_malloc.o) .literal*, \
167+
EXCLUDE_FILE (umm_malloc.o) .text*)
168+
*.pioenvs\\*\\src\\*.o(EXCLUDE_FILE (umm_malloc.o) .literal*, \
169+
EXCLUDE_FILE (umm_malloc.o) .text*)
170+
*.pioenvs/*/src/*.o(EXCLUDE_FILE (umm_malloc.o) .literal*, \
171+
EXCLUDE_FILE (umm_malloc.o) .text*)
160172
*libc.a:(.literal .text .literal.* .text.*)
161173
*libm.a:(.literal .text .literal.* .text.*)
162174
*libgcc.a:_umoddi3.o(.literal .text)
@@ -205,6 +217,12 @@ SECTIONS
205217
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
206218
*.cpp.o(.iram.text)
207219
*.c.o(.iram.text)
220+
*.pioenvs\\*\\lib*.a:(.iram.text)
221+
*.pioenvs/*/lib*.a:(.iram.text)
222+
*.pioenvs\\*\\lib\\*.a:(.iram.text)
223+
*.pioenvs/*/lib/*.a:(.iram.text)
224+
*.pioenvs\\*\\src\\*.o(.iram.text)
225+
*.pioenvs/*/src/*.o(.iram.text)
208226
*(.fini.literal)
209227
*(.fini)
210228
*(.gnu.version)

0 commit comments

Comments
 (0)