Commit Graph

142 Commits

Author SHA1 Message Date
Gustavo Jose de Sousa 393bea8945 waf: boards: use classes for boards definition
In order to provide board-specific behavior. For example, the incoming PX4
build will require custom build behavior.
2016-02-18 14:33:46 -02:00
Gustavo Jose de Sousa 8655fdfd7f waf: use git_submodule tool through GIT_SUBMODULES variable
With this change, there's no need to verify if the submodule is initialized,
because the submodules in GIT_SUBMODULES are automatically initialized and
updated if necessary before the build tasks are performed.

One downside of this change is that Google Benchmark configuration is now done
only during build. However that is minor, since now there are easy ways to
separately build different targets and program groups, so that a fail in
benchmark build doesn't really affect the other targets.
2016-02-06 10:25:08 -02:00
Gustavo Jose de Sousa fdc87df074 waf: create taskgen for gtest in _build_common_taskgens
So that it belongs to 'build' group.
2016-02-06 10:25:08 -02:00
Gustavo Jose de Sousa 264c3e2d28 waf: prepare for using git_submodule tool
We define three build groups and set post_mode as POST_LAZY, which makes one
group be posted only after the previous one. That enables us to correctly
define dynamic sources with submodules and generators that may or may not
depend on submodules (e.g. mavgen - this one depends on mavlink submodule).

The groups are defined below, in that order:
 1. git_submodules: contains taskgens that initialize and update submodules.
 2. dynamic_sources: contains taskgens that generate sources used by the build.
 3. build: contains the normal taskgens.
2016-02-06 10:25:08 -02:00
Gustavo Jose de Sousa 1a17d63114 waf: reorganize imports in main wscript 2016-02-06 10:25:08 -02:00
Gustavo Jose de Sousa f13e71a80c waf: explicitly distinct routines in build
That enhances readability and defines a clear separation of responsibilities of
build routines.
2016-02-03 12:24:21 -02:00
Gustavo Jose de Sousa 1d92a54429 waf: reorganize recursion
That makes the code cleaner and better readable. Futhermore, it's easier to add
a pattern for recursion.

Additionally, this commit remove Tools from the exclusion list as that is not
necessary.
2016-02-03 12:24:21 -02:00
Gustavo Jose de Sousa fff14f6262 waf: add check-all shortcut
A shortcut for `waf check --alltests`.
2016-02-01 14:08:39 -02:00
Gustavo Jose de Sousa 8718f5be4f waf: ardupilotwaf: rename build_shortcut() to build_command()
Rationale:
 1. That function creates a separate build context class instead of just
    creating a wrapper for calling build (previous approach).
 2. The check command isn't a build shortcut since there's no way of calling it
    without using 'check' explicitly.
2016-02-01 14:08:39 -02:00
Gustavo Jose de Sousa 6901a2cdf6 waf: define command check as a build shortcut
Now that the concept of programs group is used and 'bin' is the default program
group, the command check needed to be adapted so that (i) it is consistent with
the other build command and (ii) it defines 'all' as its target programs group.
2016-02-01 14:08:38 -02:00
Gustavo Jose de Sousa 1682be2596 waf: add documentation for build shortcuts 2016-02-01 14:08:38 -02:00
Gustavo Jose de Sousa 9d7eaa7913 waf: create build shortcuts for program groups 2016-02-01 14:08:38 -02:00
Gustavo Jose de Sousa a867dcdd07 waf: ardupilotwaf: make build_shortcut create build context class
Instead of just creating a wrapper. With that, the option targets is visible
only to that command instead of all commands in Options.commands.
2016-02-01 14:08:38 -02:00
Gustavo Jose de Sousa 51505a82bb waf: set variant for all build context classes
That way there's no need to manually add a newly defined build context class to
the list in the iteration.
2016-02-01 14:08:38 -02:00
Gustavo Jose de Sousa b93c3d1772 waf: add option --program-group 2016-02-01 14:08:10 -02:00
Gustavo Jose de Sousa c2e3f05dbf waf: ardupilotwaf: prefix build context methods with ap_
It helps to distinguish between things from waf and things from ardupilotwaf.
2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa a89a1a8a8a waf: use ardupilotwaf as a Waf tool
That will make it possible to replace calls of the form
`ardupilotwaf.<method>(bld, <keyword-args...>)` with
`bld.<method>(<keyword-args...>)` in the wscripts.

Advantages of that approach:
 - there is no need to import ardupilotwaf in every single wscript
 - it follows the same standard used by c and cxx tools (like bld.program,
   bld.stlib etc)
 - semantically, ap_program, ap_stlib, example etc are all build related
   methods, so it makes sense to bind them to the build context
 - from the wscripts' perspective, the code is cleaner, since ardupilotwaf,
   which is not specific to just build contexts, isn't *explictly* used
2016-01-22 20:10:28 -02:00
Gustavo Jose de Sousa cf432e8b3e waf: ardupilotwaf: rename vehicle_stlib to ap_stlib
That function is not only for vehicles.
2016-01-22 20:10:28 -02:00
Gustavo Jose de Sousa e9195a3989 waf: link tests with gtest library from submodule
That makes it possible to build tests on distributions that don't provide
official packages for gtest. For example, the travis environment is Ubuntu,
which doesn't have official package for gtest library.
2016-01-19 00:21:15 -02:00
Lucas De Marchi 7f04e0106e waf: change binary names
APMrover2 -> ardurover
AntennaTracker -> antennatracker
ArduCopter -> arducopter
ArduPlane -> arduplane
2016-01-18 16:56:08 -02:00
Gustavo Jose de Sousa 5c41b48621 waf: run tests failed before on check
That avoids a failing test to "hide" behind some tests that were just modified
and fixed.
2016-01-15 20:37:48 -02:00
Gustavo Jose de Sousa 60abd4ff2f waf: don't differentiate taskgen names from targets for programs
waf's terminology might be a bit confusing regarding the word 'target'. As an
attribute for a task generator, it means the paths of the files supposed to be
built. As a command line option (--target), it means the list of names of the
task generators to be used in the build.

Before this commit, only vehicles programs had their task generators' target
parameter value different from the name parameter. Now, there's no distinction
between those two parameters for the case of programs.
2016-01-15 16:46:41 -02:00
Gustavo Jose de Sousa 5f6debd186 waf: create build shortcuts for the vehicles 2016-01-15 16:46:41 -02:00
Gustavo Jose de Sousa 46449ee032 waf: mavgen: use output_dir instead of target
The option target for the waf task generator is meant for actual files that are
going to be build. Since our target files are dynamic, let's change the code to
use a new parameter output_dir instead.
2016-01-15 07:28:48 +11:00
Gustavo Jose de Sousa 282c254897 waf: define include path for mavlink only if necessary
By using the export_includes, the include paths for mavlink are enabled only
for libs or programs that depend on it.
2016-01-15 07:28:48 +11:00
Gustavo Jose de Sousa 17e5d99509 waf: allow partial builds with new mavlink as submodule
The task generator for the mavlink headers is given a name 'mavlink' and is
added as a dependency to all local static libraries, because all of them use
sources that include mavlink headers. It would be nice to have a good way to
detect sources that use mavlink headers or to declare list of libraries that
use the headers, so that the dependency could be added automatically.

Additionally, there's a minor change in syntax for the task generator: using
strings directly instead of lists.
2016-01-15 07:28:48 +11:00
Gustavo Jose de Sousa e5c66de554 waf: mavgen: ensure order without bld.add_group()
This is a better approach, because there's no need of calling add_group() for
each time a mavgen task generator is created.
2016-01-15 07:28:48 +11:00
Siddharth Bharat Purohit 11b82474de waf: generate mavlink headers for waf build 2016-01-15 07:28:47 +11:00
Gustavo Jose de Sousa e21d41afe3 waf: enable fully static linking
Some boards (e.g. bebop) require fully statically linked binaries.
2016-01-11 16:31:59 -02:00
Gustavo Jose de Sousa e7312a1f81 waf: add toolchain tool for cross-compiling 2016-01-11 16:31:59 -02:00
Gustavo Jose de Sousa 7aa43d36d2 waf: process board and project configuration before toolchain
Several boards require cross compilation. The objective of this change is to
allow to specify the target architecture in the board definition, so that the
correct toolchain is selected. The cross compilation mechanism will be
implemented in the next commits.
2016-01-11 16:31:59 -02:00
Gustavo Jose de Sousa d6b4e98a88 waf: remove already fixed TODOs
The TODOs removed with this patch were already fixed. Below is the explanation
for each.

 - TODO: add support for unit tests.
    - Supported already added.

 - TODO: Check if we should simply use the signed 'waf' "binary" (after
   verifying it) instead of generating it ourselves from the sources.
    - We're using a submodule for waf.

 - TODO: evaluate if we need shortcut commands for the common targets
   (vehicles). currently using waf --targets=NAME the target name must contain
   the board extension so make it less convenient, maybe hook to support
   automatic filling this extension?
    - There's no need of adding the extension anymore.

 - TODO: Once HAL patches get in, need to filter out the HAL based on the
   bld.env.BOARD.
    - The board-specific HAL library folders is indicated in
      bld.env.AP_LIBRARIES.
2016-01-09 14:08:07 -02:00
Gustavo Jose de Sousa b5a364504a waf: make each board a build variant
With that, we don't have to recompile unnecessarily when switching between
boards. Now, each board has it's own build directory in build/<board_name>.
2016-01-05 10:21:42 -02:00
Caio Marcelo de Oliveira Filho 6856950bd3 waf: use ConfigSet for board environments
Instead of a dictionary of dictionaries, have a dictionary of
ConfigSets. Using ConfigSet have two benefits: (1) allow easily copying
values from other, (2) have syntax for specifying the keys directly as
attributes.

With this change now it's easier to specify minlure without
repetition. New boards can override a value, append or prepend depending
on the need.

DEFINES attribute is treated as a dictionary instead of a list, so
that's easier to override values (at expense of ordering). When reading
the board environment, the code converts back to a list.

The board configuration is now stored in a separate file, there's also a
function to get the boards names.
2015-12-03 07:54:32 +11:00
Gustavo Jose de Sousa 16eceec09f waf: add command 'list_boards'
The command will be used to allow travis script to know which boards are
already supported by the waf build system. This is useful while the transition
to the new build system is on going. The command can be removed when the
transition is done and it's not used anywhere besides travis script.
2015-12-03 07:54:32 +11:00
Gustavo Jose de Sousa 2828f66a6a waf: enable writing and building benchmarks 2015-12-03 07:54:31 +11:00
Gustavo Jose de Sousa e2790f4f3b waf: use -O3 for all current boards 2015-12-03 07:54:31 +11:00
Gustavo Jose de Sousa 6b4a6f5389 waf: use gtest for tests
It was implemented in such a way that gtest is required only if the user wants
to build and run tests. Initially we're considering all tests should be gtests.
We can change that assumption in the future if necessary.
2015-12-03 07:54:31 +11:00
Gustavo Jose de Sousa 8556b5dfb8 waf: add support to run (unit) tests
We're currently using the tests standard error for reporting tests. We can add
TAP later to integrate with other tools.

Additionally, this patch simplifies the exclude patterns passed to
collect_dirs_to_recurse.
2015-12-03 07:54:31 +11:00
Gustavo Jose de Sousa d77b308f72 waf: make collect_dirs_to_recurse() accept list of patterns 2015-12-03 07:54:31 +11:00
Lucas De Marchi 3be4144b72 waf: enable clang build database
This database allows to integrate clang tools and compilers with editors and
IDEs.
2015-12-03 07:54:30 +11:00
Caio Marcelo de Oliveira Filho 6e7b73610d waf: add waf support 2015-12-03 07:54:30 +11:00