builder

package module
Version: v0.0.0-...-bbf7051 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2018 License: GPL-2.0 Imports: 27 Imported by: 0

README

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.

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

Documentation

Index

Constants

View Source
const DEFAULT_BUILD_CORE = "arduino"
View Source
const DEFAULT_DEBUG_LEVEL = 5
View Source
const DEFAULT_SOFTWARE = "ARDUINO"
View Source
const DEFAULT_WARNINGS_LEVEL = "none"

Variables

View Source
var ADDITIONAL_FILE_VALID_EXTENSIONS = map[string]bool{".h": true, ".c": true, ".hpp": true, ".hh": true, ".cpp": true, ".s": true}
View Source
var ADDITIONAL_FILE_VALID_EXTENSIONS_NO_HEADERS = map[string]bool{".c": true, ".cpp": true, ".s": true}
View Source
var DOTAEXTENSION = map[string]bool{".a": true}
View Source
var DOTHEXTENSION = map[string]bool{".h": true, ".hh": true, ".hpp": true}
View Source
var INCLUDE_REGEXP = regexp.MustCompile("(?ms)^\\s*#[ \t]*include\\s*[<\"](\\S+)[\">]")
View Source
var LIBRARY_CATEGORIES = map[string]bool{
	"Display":             true,
	"Communication":       true,
	"Signal Input/Output": true,
	"Sensors":             true,
	"Device Control":      true,
	"Timing":              true,
	"Data Storage":        true,
	"Data Processing":     true,
	"Other":               true,
	"Uncategorized":       true,
}
View Source
var MAIN_FILE_VALID_EXTENSIONS = map[string]bool{".ino": true, ".pde": true}
View Source
var VALID_EXPORT_EXTENSIONS = map[string]bool{".h": true, ".c": true, ".hpp": true, ".hh": true, ".cpp": true, ".s": true, ".a": true}

Functions

func GCCPreprocRunner

func GCCPreprocRunner(ctx *types.Context, sourceFilePath string, targetFilePath string, includes []string) error

func GCCPreprocRunnerForDiscoveringIncludes

func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath string, targetFilePath string, includes []string) ([]byte, error)

func GeneratePreprocPatternFromCompile

func GeneratePreprocPatternFromCompile(compilePattern string) string

func IncludesFinderWithRegExp

func IncludesFinderWithRegExp(ctx *types.Context, source string) string

func PrintRingNameIfDebug

func PrintRingNameIfDebug(ctx *types.Context, command types.Command)

func ResolveLibrary

func ResolveLibrary(ctx *types.Context, header string) *types.Library

func RunBuilder

func RunBuilder(ctx *types.Context) error

func RunParseHardwareAndDumpBuildProperties

func RunParseHardwareAndDumpBuildProperties(ctx *types.Context) error

func RunPreprocess

func RunPreprocess(ctx *types.Context) error

Types

type AddAdditionalEntriesToContext

type AddAdditionalEntriesToContext struct{}

func (*AddAdditionalEntriesToContext) Run

type AddBuildBoardPropertyIfMissing

type AddBuildBoardPropertyIfMissing struct{}

func (*AddBuildBoardPropertyIfMissing) Run

type AddMissingBuildPropertiesFromParentPlatformTxtFiles

type AddMissingBuildPropertiesFromParentPlatformTxtFiles struct{}

func (*AddMissingBuildPropertiesFromParentPlatformTxtFiles) Run

type AdditionalSketchFilesCopier

type AdditionalSketchFilesCopier struct{}

func (*AdditionalSketchFilesCopier) Run

type ArduinoPreprocessorRunner

type ArduinoPreprocessorRunner struct{}

func (*ArduinoPreprocessorRunner) Run

type Builder

type Builder struct{}

func (*Builder) Run

func (s *Builder) Run(ctx *types.Context) error

type CTagsRunner

type CTagsRunner struct{}

func (*CTagsRunner) Run

func (s *CTagsRunner) Run(ctx *types.Context) error

type CTagsTargetFileSaver

type CTagsTargetFileSaver struct {
	Source         *string
	TargetFileName string
}

func (*CTagsTargetFileSaver) Run

func (s *CTagsTargetFileSaver) Run(ctx *types.Context) error

type ContainerAddPrototypes

type ContainerAddPrototypes struct{}

func (*ContainerAddPrototypes) Run

type ContainerBuildOptions

type ContainerBuildOptions struct{}

func (*ContainerBuildOptions) Run

type ContainerFindIncludes

type ContainerFindIncludes struct{}

func (*ContainerFindIncludes) Run

type ContainerMergeCopySketchFiles

type ContainerMergeCopySketchFiles struct{}

func (*ContainerMergeCopySketchFiles) Run

type ContainerSetupHardwareToolsLibsSketchAndProps

type ContainerSetupHardwareToolsLibsSketchAndProps struct{}

func (*ContainerSetupHardwareToolsLibsSketchAndProps) Run

type CreateBuildOptionsMap

type CreateBuildOptionsMap struct{}

func (*CreateBuildOptionsMap) Run

type DumpBuildProperties

type DumpBuildProperties struct{}

func (*DumpBuildProperties) Run

func (s *DumpBuildProperties) Run(ctx *types.Context) error

type EnsureBuildPathExists

type EnsureBuildPathExists struct{}

func (*EnsureBuildPathExists) Run

type ExportProjectCMake

type ExportProjectCMake struct {
	// Was there an error while compiling the sketch?
	SketchError bool
}

func (*ExportProjectCMake) Run

func (s *ExportProjectCMake) Run(ctx *types.Context) error

type FailIfBuildPathEqualsSketchPath

type FailIfBuildPathEqualsSketchPath struct{}

func (*FailIfBuildPathEqualsSketchPath) Run

type FailIfImportedLibraryIsWrong

type FailIfImportedLibraryIsWrong struct{}

func (*FailIfImportedLibraryIsWrong) Run

type FilterSketchSource

type FilterSketchSource struct {
	Source            *string
	RemoveLineMarkers bool
}

func (*FilterSketchSource) Run

func (s *FilterSketchSource) Run(ctx *types.Context) error

type GenerateBuildPathIfMissing

type GenerateBuildPathIfMissing struct{}

func (*GenerateBuildPathIfMissing) Run

type HardwareLoader

type HardwareLoader struct{}

func (*HardwareLoader) Run

func (s *HardwareLoader) Run(ctx *types.Context) error

type LibrariesLoader

type LibrariesLoader struct{}

func (*LibrariesLoader) Run

func (s *LibrariesLoader) Run(ctx *types.Context) error

type LoadPreviousBuildOptionsMap

type LoadPreviousBuildOptionsMap struct{}

func (*LoadPreviousBuildOptionsMap) Run

type LoadVIDPIDSpecificProperties

type LoadVIDPIDSpecificProperties struct{}

func (*LoadVIDPIDSpecificProperties) Run

type MergeSketchWithBootloader

type MergeSketchWithBootloader struct{}

func (*MergeSketchWithBootloader) Run

type OutputCodeCompletions

type OutputCodeCompletions struct{}

func (*OutputCodeCompletions) Run

type ParseHardwareAndDumpBuildProperties

type ParseHardwareAndDumpBuildProperties struct{}

func (*ParseHardwareAndDumpBuildProperties) Run

type PlatformKeysRewriteLoader

type PlatformKeysRewriteLoader struct{}

func (*PlatformKeysRewriteLoader) Run

type Preprocess

type Preprocess struct{}

func (*Preprocess) Run

func (s *Preprocess) Run(ctx *types.Context) error

type PreprocessSketch

type PreprocessSketch struct{}

func (*PreprocessSketch) Run

func (s *PreprocessSketch) Run(ctx *types.Context) error

type PreprocessSketchArduino

type PreprocessSketchArduino struct{}

func (*PreprocessSketchArduino) Run

type PrintPreprocessedSource

type PrintPreprocessedSource struct{}

func (*PrintPreprocessedSource) Run

type PrintUsedAndNotUsedLibraries

type PrintUsedAndNotUsedLibraries struct {
	// Was there an error while compiling the sketch?
	SketchError bool
}

func (*PrintUsedAndNotUsedLibraries) Run

type PrintUsedLibrariesIfVerbose

type PrintUsedLibrariesIfVerbose struct{}

func (*PrintUsedLibrariesIfVerbose) Run

type PrototypesAdder

type PrototypesAdder struct{}

func (*PrototypesAdder) Run

func (s *PrototypesAdder) Run(ctx *types.Context) error

type ReadFileAndStoreInContext

type ReadFileAndStoreInContext struct {
	FileToRead string
	Target     *string
}

func (*ReadFileAndStoreInContext) Run

type RecipeByPrefixSuffixRunner

type RecipeByPrefixSuffixRunner struct {
	Prefix string
	Suffix string
}

func (*RecipeByPrefixSuffixRunner) Run

type RewriteHardwareKeys

type RewriteHardwareKeys struct{}

func (*RewriteHardwareKeys) Run

func (s *RewriteHardwareKeys) Run(ctx *types.Context) error

type SetCustomBuildProperties

type SetCustomBuildProperties struct{}

func (*SetCustomBuildProperties) Run

type SetupBuildProperties

type SetupBuildProperties struct{}

func (*SetupBuildProperties) Run

func (s *SetupBuildProperties) Run(ctx *types.Context) error

type SketchLoader

type SketchLoader struct{}

func (*SketchLoader) Run

func (s *SketchLoader) Run(ctx *types.Context) error

type SketchSaver

type SketchSaver struct{}

func (*SketchSaver) Run

func (s *SketchSaver) Run(ctx *types.Context) error

type SketchSourceMerger

type SketchSourceMerger struct{}

func (*SketchSourceMerger) Run

func (s *SketchSourceMerger) Run(ctx *types.Context) error

type StoreBuildOptionsMap

type StoreBuildOptionsMap struct{}

func (*StoreBuildOptionsMap) Run

func (s *StoreBuildOptionsMap) Run(ctx *types.Context) error

type TargetBoardResolver

type TargetBoardResolver struct{}

func (*TargetBoardResolver) Run

func (s *TargetBoardResolver) Run(ctx *types.Context) error

type ToolsLoader

type ToolsLoader struct{}

func (*ToolsLoader) Run

func (s *ToolsLoader) Run(ctx *types.Context) error

type UnusedCompiledLibrariesRemover

type UnusedCompiledLibrariesRemover struct{}

func (*UnusedCompiledLibrariesRemover) Run

type WarnAboutArchIncompatibleLibraries

type WarnAboutArchIncompatibleLibraries struct{}

func (*WarnAboutArchIncompatibleLibraries) Run

type WarnAboutPlatformRewrites

type WarnAboutPlatformRewrites struct{}

func (*WarnAboutPlatformRewrites) Run

type WipeoutBuildPathIfBuildOptionsChanged

type WipeoutBuildPathIfBuildOptionsChanged struct{}

func (*WipeoutBuildPathIfBuildOptionsChanged) Run

Directories

Path Synopsis
Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
proto
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL