Commit Graph

70 Commits

Author SHA1 Message Date
Gustavo Jose de Sousa d3ed17f047 waf: reconfigure for any changes in loaded modules
Waf's autoconfig feature works only for wscripts loaded by the recurse()
function. This patch extends that functionality to all loaded modules, which
includes Waf tools.
2016-06-23 18:22:55 -03:00
Gustavo Jose de Sousa 2566a13e1b waf: use Configure.autoconfig = 'clobber'
That makes reconfiguration be automatically triggered when wscripts used in
configuration are changed.
2016-06-23 18:22:55 -03:00
Lucas De Marchi 0af8b42ade build: include ap_config.h in libgtest
This is also needed while compiling libgtest because it's using our
cmath wrapper header. Otherwise it will end up entering the
"ifndef WAF_BUILD" part and fail to compile on gcc 5.3.1.
2016-06-14 15:42:43 -03:00
Gustavo Jose de Sousa 260de62f94 waf: print build summary 2016-05-25 17:47:00 -03:00
Gustavo Jose de Sousa afcabda21c waf: use better style for add_option() calls
Setting the "help" keyword argument may not fit in one line sometimes. This
patch adds the following convention to calls to add_option() in order to
address that issue in a better way:

    1) The "help" keyword must always be the last argument to be passed.

    2) If the help string is a literal string or a literal string with some
    operation (e.g. "%" operator) and setting the "help" keyword in the code
    doesn't fit a line (considering the limit of characters in a line), then
    the help string must be a triple-quoted string. That has the advantage of
    not having to have several "+" operations for long help strings. In that
    case, the help message must start on the next line and the closing
    triple-quotes must be on a separate line together with the closing
    parenthesis.

The requirement (1) makes it easier to make the style exception in (2)
acceptable.
2016-05-25 17:47:00 -03:00
Gustavo Jose de Sousa 844222870c waf: boards: bind get_board() to configure and build contexts
A convenience, since we don't expect the board to change for a given
configuration.
2016-05-25 17:47:00 -03:00
Andrew Tridgell 7e7c21d114 waf: update for MAVLink2 build 2016-05-21 15:25:17 +10:00
Gustavo Jose de Sousa 0e09d0b996 waf: rename config_header variable to config_hash
That's a better name. The other name would give the wrong idea that that
variable would store a path to the header.
2016-05-20 09:45:53 -03:00
Lucas De Marchi a9ae5476f3 waf: fix configure not using WAF_BUILD
The configure phase need the WAF_BUILD var defined, otherwise it will
execute code that's only meant for the make build system.
2016-05-19 09:53:41 -03:00
Lucas De Marchi 11e508e3a6 waf: define WAF_BUILD to allow different behavior in make 2016-05-18 22:56:50 -03:00
Gustavo Jose de Sousa 472dae3ed9 waf: don't use hard-coded path for environment cache path
The path for the "non-board" environment cache file was hard-coded, which was
causing the error below when the build was configured with the --out option
value different from the default path.

Traceback (most recent call last):
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Scripting.py", line 161, in waf_entry_point
    run_commands()
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Scripting.py", line 263, in run_commands
    ctx = run_command(cmd_name)
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Scripting.py", line 247, in run_command
    ctx.execute()
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Scripting.py", line 598, in execute
    return execute_method(self)
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Build.py", line 250, in execute
    self.execute_build()
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Build.py", line 263, in execute_build
    self.recurse([self.run_dir])
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Context.py", line 304, in recurse
    user_function(self)
  File "/home/gjsousa/ardupilot/wscript", line 246, in build
    config_header = Utils.h_file(bld.bldnode.make_node('ap_config.h').abspath())
  File "/home/gjsousa/ardupilot/modules/waf/waflib/Utils.py", line 208, in h_file
    f = open(fname, 'rb')
IOError: [Errno 2] No such file or directory: '/tmp/build/ap_config.h'
2016-05-17 15:48:55 -03:00
Gustavo Jose de Sousa ff46384258 waf: add --debug configuration option
That sets a variant <board>-debug.
2016-05-07 22:55:03 -03:00
Lucas De Marchi 9e3ec3a16d waf: define git versions in a generated ap_version.h header 2016-05-06 13:11:28 -03:00
Lucas De Marchi 5f80858cba waf: use system extensions
In several places we use functions like asprintf() that are only
available in libc when _GNU_SOURCE is defined. Always define _GNU_SOURCE
since we always want to use them.

This fixes the build on Windows using cygwin.
2016-04-19 19:02:25 -03:00
Lucas De Marchi 169c350e85 waf: rename AP_Config.h to ap_config.h
The usual name for this header is config.h, but that's already used by
vehicles. Using uppercase could give the impression this is a
file to be modified, but it's not. Use lowercase instead.
2016-04-05 21:06:25 -07:00
Ricardo de Almeida Gonzaga 5e45c9dfb0 waf: add cxx_checks tool
In order to start generating AP_Config header and detect
parameter such as the existence of cmath functions.
2016-04-05 20:44:15 -07:00
Gustavo Jose de Sousa 93473f68ce waf: use program group for main products build commands
Use program group name instead of task generator name. That way all programs
belonging to a product are built. That will be the case for different frames
for copter.
2016-03-26 15:43:08 -03:00
Gustavo Jose de Sousa 0883fb72ac waf: add shortcut for antennatracker 2016-03-24 12:27:58 -03:00
Gustavo Jose de Sousa 841771096d waf: let toolchain loading in charge of the Board class
That allows boards (i.e. subclasses of Board) to use toolchain related
information for configuration. The upcoming PX4 build is an example.
2016-03-14 11:54:31 -03:00
Gustavo Jose de Sousa 8664c0344d waf: allow boards to tweak build
We define a function build() that can be overrode by Board subclasses.
2016-03-14 11:54:30 -03:00
Gustavo Jose de Sousa 76bae701a8 waf: exclude build directory in collect_dirs_to_recurse()
Without this patch, if nodes that don't yet exist in the filesystem in
bld.bldnode were created before calls to this function, they'll be removed from
the tree in memory because "*" is passed to ant_glob() and the "remove" keyword
argument defaults to True.
2016-03-14 11:54:29 -03:00
Gustavo Jose de Sousa 86c1c6da5c waf: fix environment boolean values
It is more natural to use `env.FOO = True` then `env.foo = [True]`.
2016-03-03 14:58:03 -03:00
Gustavo Jose de Sousa c609b27afc waf: gbenchmark: use cmake tool
A little addition in the root wscript was also necessary.
2016-02-22 15:36:48 -03:00
Gustavo Jose de Sousa b7d97b6354 waf: add option --enable-benchmarks
In the future, gbenchmark will be build using a cmake waf tool, which will
require cmake to be installed. We add this option so that users without cmake
can continue use the build system with no problems.
2016-02-22 15:36:48 -03:00
Gustavo Jose de Sousa 662e45fda2 waf: move --check-verbose option declaration
We move it to the correct "scope", that is, ardupilotwaf.py, where it's really
used.
2016-02-22 15:36:48 -03:00
Gustavo Jose de Sousa 8c4d4f3f2a waf: make options groups accessible for any tool
That allows options being declared where they're really used. Additionally, we
load ardupilotwaf after the other tools so that we can create our groups after
all non-ardupilot option groups are created. That makes our groups appear as
the last ones in the help message, which makes it easier to locate them.
2016-02-22 15:36:48 -03:00
Gustavo Jose de Sousa fd88e39408 waf: make all options belong to an option group
That makes it easier for the user to distinguish between a general waf option
and project specific option.
2016-02-22 15:36:47 -03:00
Gustavo Jose de Sousa 3566052d6a waf: add option --no-submodule-update
That is useful when the user wants to build with one or more submodules at a
specific revision. In case of a developer, that is useful for when a submodule
is in modification process and she needs to (constantly) test the build.
2016-02-19 19:19:25 -02:00
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