Skip to content

Commit 8e7b241

Browse files
Earle F. Philhower, IIIEarle F. Philhower, III
authored andcommitted
Cache core.a for CI builds
Hopefull give a significant speedup to the Arduino CI process.
1 parent 4c04c63 commit 8e7b241

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

tests/common.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function build_sketches()
4242
local build_mod=$4
4343
local build_rem=$5
4444
mkdir -p $build_dir
45-
local build_cmd="python tools/build.py -b generic -v -w all -s 4M1M -v -k -p $PWD/$build_dir $build_arg "
45+
local build_cmd="python tools/build.py -b generic -v -w all -s 4M1M -v -k --build_cache $cache_dir -p $PWD/$build_dir $build_arg "
4646
local sketches=$(find $srcpath -name *.ino | sort)
4747
print_size_info >size.log
4848
export ARDUINO_IDE_PATH=$arduino
@@ -219,6 +219,8 @@ if [ -z "$TRAVIS_BUILD_DIR" ]; then
219219
echo "TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR"
220220
fi
221221

222+
cache_dir=$(mktemp -d)
223+
222224
if [ "$BUILD_TYPE" = "build" ]; then
223225
install_arduino nodebug
224226
build_sketches_with_arduino 1 0
@@ -248,6 +250,8 @@ elif [ "$BUILD_TYPE" = "platformio_odd" ]; then
248250
build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 2 1
249251
else
250252
echo "BUILD_TYPE not set or invalid"
253+
rm -rf $cache_dir
251254
exit 1
252255
fi
253256

257+
rm -rf $cache_dir

tools/build.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
import tempfile
3030
import shutil
3131

32-
def compile(tmp_dir, sketch, tools_dir, hardware_dir, ide_path, f, args):
32+
def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args):
3333
cmd = ide_path + '/arduino-builder '
3434
cmd += '-compile -logger=human '
3535
cmd += '-build-path "' + tmp_dir + '" '
3636
cmd += '-tools "' + ide_path + '/tools-builder" '
37+
if cache != "":
38+
cmd += '-build-cache "' + cache + '" '
3739
if args.library_path:
3840
for lib_dir in args.library_path:
3941
cmd += '-libraries "' + lib_dir + '" '
@@ -95,6 +97,7 @@ def parse_args():
9597
parser.add_argument('--debug_port', help='Debug port',
9698
choices=['Serial', 'Serial1'])
9799
parser.add_argument('--debug_level', help='Debug level')
100+
parser.add_argument('--build_cache', help='Build directory to cache core.a', default='')
98101
parser.add_argument('sketch_path', help='Sketch file path')
99102
return parser.parse_args()
100103

@@ -124,14 +127,15 @@ def main():
124127
if args.verbose:
125128
print("Sketch: ", sketch_path)
126129
print("Build dir: ", tmp_dir)
130+
print("Cache dir: ", args.build_cache)
127131
print("Output: ", output_name)
128132

129133
if args.verbose:
130134
f = sys.stdout
131135
else:
132136
f = open(tmp_dir + '/build.log', 'w')
133137

134-
res = compile(tmp_dir, sketch_path, tools_dir, hardware_dir, ide_path, f, args)
138+
res = compile(tmp_dir, sketch_path, args.build_cache, tools_dir, hardware_dir, ide_path, f, args)
135139
if res != 0:
136140
return res
137141

0 commit comments

Comments
 (0)