A command line tool for compiling Arduino sketches
Go C++ C
Latest commit 29cf4c8 Jun 13, 2018
Permalink
Failed to load latest commit information.
arduino-builder Release 1.4.0 Jun 11, 2018
builder_utils Added missing part of b03ecab Jun 1, 2018
client Fix import in example grpc client Jan 23, 2018
constants Add runtime.ide.path env variable Apr 20, 2018
ctags Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
gohasissues Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
grpc Remove watcher, add endpoint to explicitely drop cache Jan 10, 2018
hardware Updated tools for arduino-preprocessor Jan 10, 2018
i18n Do not ignore command errors in ExecRecipeCollectStdErr Jan 10, 2018
phases Allow multiple precompiled libraries to be included and linked May 30, 2018
test update arduino-preprocessor to 0.1.5 Jan 24, 2018
types Merge remote-tracking branch 'facchinm/rpc_experiments' May 31, 2018
utils Removed KeysOfMapOfString* method Jun 8, 2018
.gitignore Added buildOptions refactoring to main.go May 3, 2016
.travis.yml Fix Travis build if new dependencies are added Jan 23, 2018
CONTRIBUTING.md First implementation Sep 11, 2015
LICENSE.txt First implementation Sep 11, 2015
README.md Update README.md Jun 13, 2018
add_additional_entries_to_context.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
add_build_board_property_if_missing.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
add_missing_build_properties_from_parent_platform_txt_files.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
additional_sketch_files_copier.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
builder.go Move arduino-proprocessor under experimental flag May 22, 2018
container_add_prototypes.go Pass FileToRead to ReadFileAndStoreInContext explicitly Jan 10, 2018
container_build_options.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
container_find_includes.go ContainerFindIncludes: Add some temporary variables Jan 10, 2018
container_merge_copy_sketch_files.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
container_setup.go Make progress smoother Jan 23, 2018
create_build_options_map.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
create_cmake_rule.go Fix merge conflicts Jan 10, 2018
ctags_runner.go Use utils.ExecCommand for running ctags Jun 1, 2018
ctags_target_file_saver.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
dump_build_properties.go Removed KeysOfMapOfString* method Jun 8, 2018
ensure_buildpath_exists.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
fail_if_buildpath_equals_sketchpath.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
fail_if_imported_library_is_wrong.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
filter_sketch_source.go [CMAKE] export only preprocessed source Jan 10, 2018
gcc_preproc_runner.go Fix removal of -MMD option when running the preprocessor Jan 10, 2018
generate_buildpath_if_missing.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
hardware_loader.go Removed useless parameters in loadBoards (and back up in the call chain) Feb 27, 2018
includes_finder_with_regexp.go Convert IncludesFinderWithRegExp to a normal function Jan 10, 2018
libraries_loader.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
load_previous_build_options.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
load_vid_pid_specific_properties.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
merge_sketch_with_bootloader.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
platform_keys_rewrite_loader.go Removed KeysOfMapOfString* method Jun 8, 2018
preprocess_sketch.go Move arduino-proprocessor under experimental flag May 22, 2018
print_preprocessed_source.go Mute ctx.SourceGccMinusE if empty Jan 10, 2018
print_used_and_not_used_libraries.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
print_used_libraries_if_verbose.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
prototypes_adder.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
read_file_and_store_in_context.go Pass FileToRead to ReadFileAndStoreInContext explicitly Jan 10, 2018
recipe_runner.go Merge ExecRecipeCollectStdErr into ExecRecipe Jan 10, 2018
resolve_library.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
resolve_library_test.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
rewrite_hardware_keys.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
set_custom_build_properties.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
setup_build_properties.go Add runtime.ide.path env variable Apr 20, 2018
sketch_loader.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
sketch_saver.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
sketch_source_merger.go Revert "[CMAKE] include Arduino.h in main sketch file" Jan 24, 2018
store_build_options_map.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
target_board_resolver.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
tools_loader.go remove debug print Jan 10, 2018
unused_compiled_libraries_remover.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
warn_about_arch_incompatible_libraries.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
warn_about_platform_rewrites.go Converted the project into a valid go package. Modules "properties" a… Dec 20, 2017
wipeout_build_path_if_build_options_changed.go Wipe build dir only if txt build rules has changed Jan 24, 2018

README.md

Arduino Builder Build Status

A command line tool for compiling Arduino sketches

This tool is able to parse Arduino Hardware specifications, properly run gcc and produce compiled sketches.

An Arduino sketch differs from a standard C program in that it misses a main (provided by the Arduino core), function prototypes are not mandatory, and libraries inclusion is automagic (you just have to #include them). This tool generates function prototypes and gathers library paths, providing gcc with all the needed -I params.

Usage

  • -compile or -dump-prefs or -preprocess: Optional. If omitted, defaults to -compile. -dump-prefs will just print all build preferences used, -compile will use those preferences to run the actual compiler, -preprocess will only print preprocessed code to stdout.

  • -hardware: Mandatory. Folder containing Arduino platforms. An example is the hardware folder shipped with the Arduino IDE, or the packages folder created by Arduino Boards Manager. Can be specified multiple times. If conflicting hardware definitions are specified, the last one wins.

  • -tools: Mandatory. Folder containing Arduino tools (gcc, avrdude...). An example is the hardware/tools folder shipped with the Arduino IDE, or the packages folder created by Arduino Boards Manager. Can be specified multiple times.

  • -libraries: Optional. Folder containing Arduino libraries. An example is the libraries folder shipped with the Arduino IDE. Can be specified multiple times.

  • -fqbn: Mandatory. Fully Qualified Board Name, e.g.: arduino:avr:uno

  • -build-path: Optional. Folder where to save compiled files. If omitted, a folder will be created in the temporary folder specified by your OS.

  • -prefs=key=value: Optional. It allows to override some build properties.

  • -warnings: Optional, can be "none", "default", "more" and "all". Defaults to "none". Used to tell gcc which warning level to use (-W flag).

  • -verbose: Optional, turns on verbose mode.

  • -quiet: Optional, supresses almost every output.

  • -debug-level: Optional, defaults to "5". Used for debugging. Set it to 10 when submitting an issue.

  • -core-api-version: Optional, defaults to "10600". The version of the Arduino IDE which is using this tool.

  • -logger: Optional, can be "human", "humantags" or "machine". Defaults to "human". If "humantags" the messages are qualified with a prefix that indicates their level (info, debug, error). If "machine", messages emitted will be in a format which the Arduino IDE understands and that it uses for I18N.

  • -version: if specified, prints version and exits.

  • -build-options-file: it specifies path to a local build.options.json file (see paragraph below), which allows you to omit specifying params such as -hardware, -tools, -libraries, -fqbn, -pref and -ide-version.

  • -vid-pid: when specified, VID/PID specific build properties are used, if boards supports them.

Final mandatory parameter is the sketch to compile (of course).

What is and how to use build.options.json file

Every time you run this tool, it will create a build.options.json file in build path. It's used to understand if build options (such as hardware folders, fqbn and so on) were changed when compiling the same sketch. If they changed, the whole build path is wiped out. If they didn't change, previous compiled files will be reused if the corresponding source files didn't change as well. You can save this file locally and use it instead of specifying -hardware, -tools, -libraries, -fqbn, -pref and -ide-version.

Using it for continuously verify your libraries or cores

See Doing continuous integration with arduino builder.

Building from source

You need a recent version of Go (>=1.8.0).

To build, run the following commands:

go get github.com/go-errors/errors
go get github.com/stretchr/testify
go get github.com/jstemmer/go-junit-report
go get -u github.com/arduino/go-properties-map
go get -u github.com/arduino/go-timeutils
go get google.golang.org/grpc
go get github.com/golang/protobuf/proto
go get golang.org/x/net/context
go get github.com/fsnotify/fsnotify
go get github.com/arduino/arduino-builder
go build github.com/arduino/arduino-builder/arduino-builder

TDD

In order to run the tests, type:

go test github.com/arduino/arduino-builder/...

This runs all tests, showing any failures and a summary at the end. Add the -v option to show each test as it is being ran. Currently, arduino-builder itself also generates copious output, even for non-failing testcases and without -v, and testing does not stop at the first failure, so you probably want to redirect test output so you can scroll back to find any failures.

To run a single test, use the -run option, which accepts a regular expression (see also go help testflag).

go test github.com/arduino/arduino-builder/... -run 'TestBuilderEmptySketch'
go test github.com/arduino/arduino-builder/... -run 'TestPrototypesAdder.*'

In jenkins, use

go test -v github.com/arduino/arduino-builder/... | bin/go-junit-report > report.xml

The first time you run the tests, some needed files (toolchains and source files) will be downloaded, which needs about 1GB of space (at the time of writing). If you have a slow connection, this download might exceed the default 10 minute timeout for a single test. If you run into this, add -timeout 60m or similar to the commandline to extend the timeout. If you are running on slower system (like a rasbperry pi), increasing the timeout might be needed as well.

License and Copyright

arduino-builder is licensed under General Public License version 2, as published by the Free Software Foundation. See LICENSE.txt.

Copyright (C) 2017 Arduino AG and contributors

See https://www.arduino.cc/ and https://github.com/arduino/arduino-builder/graphs/contributors