2015-10-09 11:03:59 -03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
|
2015-11-30 11:41:45 -04:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2015-10-09 11:03:59 -03:00
|
|
|
import os.path
|
2019-02-26 01:25:16 -04:00
|
|
|
import os
|
2015-10-09 11:03:59 -03:00
|
|
|
import sys
|
2019-02-26 01:25:16 -04:00
|
|
|
import subprocess
|
2021-01-05 17:43:03 -04:00
|
|
|
import json
|
|
|
|
import fnmatch
|
2015-10-09 11:03:59 -03:00
|
|
|
sys.path.insert(0, 'Tools/ardupilotwaf/')
|
|
|
|
|
|
|
|
import ardupilotwaf
|
2015-11-26 10:34:24 -04:00
|
|
|
import boards
|
2015-12-10 14:22:07 -04:00
|
|
|
|
2016-06-21 10:05:36 -03:00
|
|
|
from waflib import Build, ConfigSet, Configure, Context, Utils
|
2021-01-05 17:43:03 -04:00
|
|
|
from waflib.Configure import conf
|
2016-06-21 10:05:36 -03:00
|
|
|
|
2021-09-30 08:06:19 -03:00
|
|
|
# Ref: https://stackoverflow.com/questions/40590192/getting-an-error-attributeerror-module-object-has-no-attribute-run-while
|
|
|
|
try:
|
|
|
|
from subprocess import CompletedProcess
|
|
|
|
except ImportError:
|
|
|
|
# Python 2
|
|
|
|
class CompletedProcess:
|
|
|
|
|
|
|
|
def __init__(self, args, returncode, stdout=None, stderr=None):
|
|
|
|
self.args = args
|
|
|
|
self.returncode = returncode
|
|
|
|
self.stdout = stdout
|
|
|
|
self.stderr = stderr
|
|
|
|
|
|
|
|
def check_returncode(self):
|
|
|
|
if self.returncode != 0:
|
|
|
|
err = subprocess.CalledProcessError(self.returncode, self.args, output=self.stdout)
|
|
|
|
raise err
|
|
|
|
return self.returncode
|
|
|
|
|
|
|
|
def sp_run(*popenargs, **kwargs):
|
|
|
|
input = kwargs.pop("input", None)
|
|
|
|
check = kwargs.pop("handle", False)
|
2021-09-30 08:33:19 -03:00
|
|
|
kwargs.pop("capture_output", True)
|
2021-09-30 08:06:19 -03:00
|
|
|
if input is not None:
|
|
|
|
if 'stdin' in kwargs:
|
|
|
|
raise ValueError('stdin and input arguments may not both be used.')
|
|
|
|
kwargs['stdin'] = subprocess.PIPE
|
|
|
|
process = subprocess.Popen(*popenargs, **kwargs)
|
|
|
|
try:
|
|
|
|
outs, errs = process.communicate(input)
|
|
|
|
except:
|
|
|
|
process.kill()
|
|
|
|
process.wait()
|
|
|
|
raise
|
|
|
|
returncode = process.poll()
|
|
|
|
if check and returncode:
|
|
|
|
raise subprocess.CalledProcessError(returncode, popenargs, output=outs)
|
|
|
|
return CompletedProcess(popenargs, returncode, stdout=outs, stderr=errs)
|
|
|
|
|
|
|
|
subprocess.run = sp_run
|
|
|
|
# ^ This monkey patch allows it work on Python 2 or 3 the same way
|
|
|
|
|
|
|
|
|
2015-10-09 11:03:59 -03:00
|
|
|
# TODO: implement a command 'waf help' that shows the basic tasks a
|
|
|
|
# developer might want to do: e.g. how to configure a board, compile a
|
|
|
|
# vehicle, compile all the examples, add a new example. Should fit in
|
|
|
|
# less than a terminal screen, ideally commands should be copy
|
|
|
|
# pastable. Add the 'export waf="$PWD/waf"' trick to be copy-pastable
|
|
|
|
# as well.
|
|
|
|
|
2016-05-05 19:16:23 -03:00
|
|
|
# TODO: replace defines with the use of the generated ap_config.h file
|
2015-10-09 11:03:59 -03:00
|
|
|
# this makes recompilation at least when defines change. which might
|
|
|
|
# be sufficient.
|
|
|
|
|
2018-03-29 01:00:13 -03:00
|
|
|
# Default installation prefix for Linux boards
|
|
|
|
default_prefix = '/usr/'
|
|
|
|
|
2018-09-01 21:30:36 -03:00
|
|
|
# Override Build execute and Configure post_recurse methods for autoconfigure purposes
|
|
|
|
Build.BuildContext.execute = ardupilotwaf.ap_autoconfigure(Build.BuildContext.execute)
|
|
|
|
Configure.ConfigurationContext.post_recurse = ardupilotwaf.ap_configure_post_recurse()
|
|
|
|
|
|
|
|
|
|
|
|
def _set_build_context_variant(board):
|
2016-07-29 11:24:59 -03:00
|
|
|
for c in Context.classes:
|
|
|
|
if not issubclass(c, Build.BuildContext):
|
|
|
|
continue
|
2018-09-01 21:30:36 -03:00
|
|
|
c.variant = board
|
2016-07-29 11:24:59 -03:00
|
|
|
|
2015-12-10 14:22:07 -04:00
|
|
|
def init(ctx):
|
2021-01-05 17:43:03 -04:00
|
|
|
# Generate Task List, so that VS Code extension can keep track
|
|
|
|
# of changes to possible build targets
|
|
|
|
generate_tasklist(ctx, False)
|
2015-12-10 14:22:07 -04:00
|
|
|
env = ConfigSet.ConfigSet()
|
|
|
|
try:
|
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:26:28 -03:00
|
|
|
p = os.path.join(Context.out_dir, Build.CACHE_DIR, Build.CACHE_SUFFIX)
|
|
|
|
env.load(p)
|
2018-09-01 21:30:36 -03:00
|
|
|
except EnvironmentError:
|
2015-12-10 14:22:07 -04:00
|
|
|
return
|
|
|
|
|
2016-07-28 18:46:42 -03:00
|
|
|
Configure.autoconfig = 'clobber' if env.AUTOCONFIG else False
|
|
|
|
|
2018-09-01 21:30:36 -03:00
|
|
|
board = ctx.options.board or env.BOARD
|
|
|
|
|
|
|
|
if not board:
|
2016-05-06 18:44:12 -03:00
|
|
|
return
|
|
|
|
|
2015-12-10 14:22:07 -04:00
|
|
|
# define the variant build commands according to the board
|
2018-09-01 21:30:36 -03:00
|
|
|
_set_build_context_variant(board)
|
2015-12-10 14:22:07 -04:00
|
|
|
|
2015-10-09 11:03:59 -03:00
|
|
|
def options(opt):
|
2016-01-02 07:22:36 -04:00
|
|
|
opt.load('compiler_cxx compiler_c waf_unit_test python')
|
2016-02-17 08:48:08 -04:00
|
|
|
opt.load('ardupilotwaf')
|
2016-05-25 12:24:58 -03:00
|
|
|
opt.load('build_summary')
|
2016-02-17 08:48:08 -04:00
|
|
|
|
|
|
|
g = opt.ap_groups['configure']
|
2016-05-23 10:48:39 -03:00
|
|
|
|
2016-02-17 08:35:29 -04:00
|
|
|
boards_names = boards.get_boards_names()
|
2018-11-20 06:44:41 -04:00
|
|
|
removed_names = boards.get_removed_boards()
|
2016-02-17 08:35:29 -04:00
|
|
|
g.add_option('--board',
|
2016-05-23 10:48:39 -03:00
|
|
|
action='store',
|
2018-09-01 21:30:36 -03:00
|
|
|
default=None,
|
|
|
|
help='Target board to build, choices are %s.' % ', '.join(boards_names))
|
2015-10-09 11:03:59 -03:00
|
|
|
|
2016-07-28 15:18:01 -03:00
|
|
|
g.add_option('--debug',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Configure as debug variant.')
|
|
|
|
|
2021-06-19 13:20:19 -03:00
|
|
|
g.add_option('--disable-watchdog',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Build with watchdog disabled.')
|
|
|
|
|
2021-05-21 05:51:31 -03:00
|
|
|
g.add_option('--coverage',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Configure coverage flags.')
|
|
|
|
|
2020-04-23 23:26:54 -03:00
|
|
|
g.add_option('--Werror',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='build with -Werror.')
|
|
|
|
|
2019-02-21 10:33:37 -04:00
|
|
|
g.add_option('--toolchain',
|
|
|
|
action='store',
|
|
|
|
default=None,
|
|
|
|
help='Override default toolchain used for the board. Use "native" for using the host toolchain.')
|
|
|
|
|
2018-09-02 11:30:47 -03:00
|
|
|
g.add_option('--disable-gccdeps',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Disable the use of GCC dependencies output method and use waf default method.')
|
|
|
|
|
2018-08-02 02:22:30 -03:00
|
|
|
g.add_option('--enable-asserts',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='enable OS level asserts.')
|
2018-10-29 05:48:25 -03:00
|
|
|
|
2022-02-21 23:22:19 -04:00
|
|
|
g.add_option('--save-temps',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='save compiler temporary files.')
|
|
|
|
|
2020-11-13 01:09:37 -04:00
|
|
|
g.add_option('--enable-malloc-guard',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='enable malloc guard regions.')
|
2021-04-15 14:43:08 -03:00
|
|
|
|
|
|
|
g.add_option('--enable-stats',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='enable OS level thread statistics.')
|
2020-11-13 01:09:37 -04:00
|
|
|
|
2018-06-16 07:00:54 -03:00
|
|
|
g.add_option('--bootloader',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Configure for building a bootloader.')
|
|
|
|
|
2016-07-28 18:46:42 -03:00
|
|
|
g.add_option('--no-autoconfig',
|
|
|
|
dest='autoconfig',
|
|
|
|
action='store_false',
|
|
|
|
default=True,
|
2018-03-27 04:32:22 -03:00
|
|
|
help='''Disable autoconfiguration feature. By default, the build system
|
|
|
|
triggers a reconfiguration whenever it thinks it's necessary - this
|
|
|
|
option disables that.
|
2016-07-28 18:46:42 -03:00
|
|
|
''')
|
|
|
|
|
2016-02-19 12:44:32 -04:00
|
|
|
g.add_option('--no-submodule-update',
|
2016-05-23 10:48:39 -03:00
|
|
|
dest='submodule_update',
|
|
|
|
action='store_false',
|
|
|
|
default=True,
|
2018-03-27 04:32:22 -03:00
|
|
|
help='''Don't update git submodules. Useful for building with
|
|
|
|
submodules at specific revisions.
|
2017-06-05 10:22:09 -03:00
|
|
|
''')
|
|
|
|
|
2018-03-28 01:04:48 -03:00
|
|
|
g.add_option('--enable-header-checks', action='store_true',
|
2018-03-27 04:16:30 -03:00
|
|
|
default=False,
|
2018-03-28 01:04:48 -03:00
|
|
|
help="Enable checking of headers")
|
2018-03-27 04:16:30 -03:00
|
|
|
|
|
|
|
g.add_option('--default-parameters',
|
|
|
|
default=None,
|
|
|
|
help='set default parameters to embed in the firmware')
|
|
|
|
|
2018-09-30 20:04:20 -03:00
|
|
|
g.add_option('--enable-math-check-indexes',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enable checking of math indexes")
|
|
|
|
|
2019-06-17 19:25:27 -03:00
|
|
|
g.add_option('--disable-scripting', action='store_true',
|
2018-11-03 18:59:08 -03:00
|
|
|
default=False,
|
2019-06-17 19:25:27 -03:00
|
|
|
help="Disable onboard scripting engine")
|
2018-11-03 18:59:08 -03:00
|
|
|
|
2020-11-05 19:36:26 -04:00
|
|
|
g.add_option('--no-gcs', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Disable GCS code")
|
|
|
|
|
2018-11-03 18:59:08 -03:00
|
|
|
g.add_option('--scripting-checks', action='store_true',
|
|
|
|
default=True,
|
|
|
|
help="Enable runtime scripting sanity checks")
|
|
|
|
|
2021-06-14 08:07:27 -03:00
|
|
|
g.add_option('--enable-onvif', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enables and sets up ONVIF camera control")
|
|
|
|
|
2021-10-16 21:05:56 -03:00
|
|
|
g.add_option('--scripting-docs', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="enable generation of scripting documentation")
|
|
|
|
|
2018-03-27 04:16:30 -03:00
|
|
|
g = opt.ap_groups['linux']
|
|
|
|
|
2018-03-27 04:49:41 -03:00
|
|
|
linux_options = ('--prefix', '--destdir', '--bindir', '--libdir')
|
|
|
|
for k in linux_options:
|
|
|
|
option = opt.parser.get_option(k)
|
|
|
|
if option:
|
|
|
|
opt.parser.remove_option(k)
|
|
|
|
g.add_option(option)
|
|
|
|
|
2018-03-28 02:25:42 -03:00
|
|
|
g.add_option('--apstatedir',
|
|
|
|
action='store',
|
|
|
|
default='',
|
|
|
|
help='''Where to save data like parameters, log and terrain.
|
2018-06-18 02:15:03 -03:00
|
|
|
This is the --localstatedir + ArduPilots subdirectory [default:
|
2018-03-28 02:25:42 -03:00
|
|
|
board-dependent, usually /var/lib/ardupilot]''')
|
|
|
|
|
2017-06-05 10:22:09 -03:00
|
|
|
g.add_option('--rsync-dest',
|
|
|
|
dest='rsync_dest',
|
|
|
|
action='store',
|
|
|
|
default='',
|
2018-03-27 04:32:22 -03:00
|
|
|
help='''Destination for the rsync Waf command. It can be passed during
|
|
|
|
configuration in order to save typing.
|
2016-05-23 10:48:39 -03:00
|
|
|
''')
|
2016-02-19 12:44:32 -04:00
|
|
|
|
2016-02-17 09:13:37 -04:00
|
|
|
g.add_option('--enable-benchmarks',
|
2016-05-23 10:48:39 -03:00
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Enable benchmarks.')
|
2016-02-17 09:13:37 -04:00
|
|
|
|
2018-03-27 04:21:33 -03:00
|
|
|
g.add_option('--enable-lttng', action='store_true',
|
2016-05-25 23:06:19 -03:00
|
|
|
default=False,
|
2018-03-27 04:21:33 -03:00
|
|
|
help="Enable lttng integration")
|
2016-05-25 23:06:19 -03:00
|
|
|
|
2016-05-27 08:21:20 -03:00
|
|
|
g.add_option('--disable-libiio', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Don't use libiio even if supported by board and dependencies available")
|
|
|
|
|
2016-07-13 10:50:31 -03:00
|
|
|
g.add_option('--disable-tests', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Disable compilation and test execution")
|
|
|
|
|
2018-07-01 20:35:41 -03:00
|
|
|
g.add_option('--enable-sfml', action='store_true',
|
2018-07-01 07:10:08 -03:00
|
|
|
default=False,
|
2018-07-01 20:35:41 -03:00
|
|
|
help="Enable SFML graphics library")
|
2018-07-01 07:10:08 -03:00
|
|
|
|
2020-11-12 17:13:15 -04:00
|
|
|
g.add_option('--enable-sfml-joystick', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enable SFML joystick input library")
|
|
|
|
|
2019-03-19 23:37:22 -03:00
|
|
|
g.add_option('--enable-sfml-audio', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enable SFML audio library")
|
|
|
|
|
2020-08-30 18:45:21 -03:00
|
|
|
g.add_option('--osd', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enable OSD support")
|
2020-08-31 02:31:14 -03:00
|
|
|
|
|
|
|
g.add_option('--osd-fonts', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enable OSD support with fonts")
|
2020-08-30 18:45:21 -03:00
|
|
|
|
2019-05-16 00:41:03 -03:00
|
|
|
g.add_option('--sitl-osd', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enable SITL OSD")
|
|
|
|
|
|
|
|
g.add_option('--sitl-rgbled', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enable SITL RGBLed")
|
|
|
|
|
2021-09-21 05:34:46 -03:00
|
|
|
g.add_option('--sitl-32bit', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Enable SITL 32bit")
|
|
|
|
|
2019-06-13 07:30:21 -03:00
|
|
|
g.add_option('--build-dates', action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="Include build date in binaries. Appears in AUTOPILOT_VERSION.os_sw_version")
|
|
|
|
|
2019-01-21 00:20:56 -04:00
|
|
|
g.add_option('--sitl-flash-storage',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
2021-06-10 23:33:53 -03:00
|
|
|
help='Use flash storage emulation.')
|
2020-04-11 19:25:09 -03:00
|
|
|
|
|
|
|
g.add_option('--disable-ekf2',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Configure without EKF2.')
|
|
|
|
|
|
|
|
g.add_option('--disable-ekf3',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Configure without EKF3.')
|
2021-05-04 08:12:52 -03:00
|
|
|
|
|
|
|
g.add_option('--ekf-double',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Configure EKF as double precision.')
|
|
|
|
|
|
|
|
g.add_option('--ekf-single',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Configure EKF as single precision.')
|
2019-01-21 00:20:56 -04:00
|
|
|
|
2016-07-12 23:26:24 -03:00
|
|
|
g.add_option('--static',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='Force a static build')
|
|
|
|
|
2021-06-22 02:57:34 -03:00
|
|
|
g.add_option('--postype-single',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help='force single precision postype_t')
|
|
|
|
|
2021-06-18 14:05:43 -03:00
|
|
|
g.add_option('--extra-hwdef',
|
|
|
|
action='store',
|
|
|
|
default=None,
|
|
|
|
help='Extra hwdef.dat file for custom build.')
|
|
|
|
|
2021-07-22 19:29:12 -03:00
|
|
|
g.add_option('--assert-cc-version',
|
|
|
|
default=None,
|
|
|
|
help='fail configure if not using the specified gcc version')
|
|
|
|
|
2016-06-21 10:07:44 -03:00
|
|
|
def _collect_autoconfig_files(cfg):
|
|
|
|
for m in sys.modules.values():
|
|
|
|
paths = []
|
2018-08-06 23:39:40 -03:00
|
|
|
if hasattr(m, '__file__') and m.__file__ is not None:
|
2016-06-21 10:07:44 -03:00
|
|
|
paths.append(m.__file__)
|
|
|
|
elif hasattr(m, '__path__'):
|
|
|
|
for p in m.__path__:
|
2018-08-06 23:39:40 -03:00
|
|
|
if p is not None:
|
|
|
|
paths.append(p)
|
2016-06-21 10:07:44 -03:00
|
|
|
|
|
|
|
for p in paths:
|
|
|
|
if p in cfg.files or not os.path.isfile(p):
|
|
|
|
continue
|
|
|
|
|
|
|
|
with open(p, 'rb') as f:
|
|
|
|
cfg.hash = Utils.h_list((cfg.hash, f.read()))
|
|
|
|
cfg.files.append(p)
|
|
|
|
|
2015-10-09 11:03:59 -03:00
|
|
|
def configure(cfg):
|
2019-02-26 01:25:16 -04:00
|
|
|
# we need to enable debug mode when building for gconv, and force it to sitl
|
2018-09-01 21:30:36 -03:00
|
|
|
if cfg.options.board is None:
|
|
|
|
cfg.options.board = 'sitl'
|
|
|
|
|
2019-03-06 16:58:56 -04:00
|
|
|
boards_names = boards.get_boards_names()
|
|
|
|
if not cfg.options.board in boards_names:
|
|
|
|
for b in boards_names:
|
|
|
|
if b.upper() == cfg.options.board.upper():
|
|
|
|
cfg.options.board = b
|
|
|
|
break
|
|
|
|
|
2015-12-10 14:22:07 -04:00
|
|
|
cfg.env.BOARD = cfg.options.board
|
2019-02-26 01:25:16 -04:00
|
|
|
cfg.env.DEBUG = cfg.options.debug
|
2021-05-21 05:51:31 -03:00
|
|
|
cfg.env.COVERAGE = cfg.options.coverage
|
2016-07-28 18:46:42 -03:00
|
|
|
cfg.env.AUTOCONFIG = cfg.options.autoconfig
|
2016-05-06 18:44:12 -03:00
|
|
|
|
2018-09-01 21:30:36 -03:00
|
|
|
_set_build_context_variant(cfg.env.BOARD)
|
|
|
|
cfg.setenv(cfg.env.BOARD)
|
2015-12-10 14:22:07 -04:00
|
|
|
|
2015-11-25 11:48:45 -04:00
|
|
|
cfg.env.BOARD = cfg.options.board
|
2016-05-06 18:44:12 -03:00
|
|
|
cfg.env.DEBUG = cfg.options.debug
|
2021-05-21 05:51:31 -03:00
|
|
|
cfg.env.COVERAGE = cfg.options.coverage
|
2021-09-21 05:34:46 -03:00
|
|
|
cfg.env.SITL32BIT = cfg.options.sitl_32bit
|
2018-08-02 02:22:30 -03:00
|
|
|
cfg.env.ENABLE_ASSERTS = cfg.options.enable_asserts
|
2018-06-16 07:00:54 -03:00
|
|
|
cfg.env.BOOTLOADER = cfg.options.bootloader
|
2020-11-13 01:09:37 -04:00
|
|
|
cfg.env.ENABLE_MALLOC_GUARD = cfg.options.enable_malloc_guard
|
2021-04-15 14:43:08 -03:00
|
|
|
cfg.env.ENABLE_STATS = cfg.options.enable_stats
|
2022-02-21 23:22:19 -04:00
|
|
|
cfg.env.SAVE_TEMPS = cfg.options.save_temps
|
2016-05-06 18:44:12 -03:00
|
|
|
|
2021-06-18 14:05:43 -03:00
|
|
|
cfg.env.HWDEF_EXTRA = cfg.options.extra_hwdef
|
2021-06-25 04:43:54 -03:00
|
|
|
if cfg.env.HWDEF_EXTRA:
|
|
|
|
cfg.env.HWDEF_EXTRA = os.path.abspath(cfg.env.HWDEF_EXTRA)
|
2021-06-18 14:05:43 -03:00
|
|
|
|
2018-09-01 21:30:36 -03:00
|
|
|
cfg.env.OPTIONS = cfg.options.__dict__
|
|
|
|
|
2016-05-19 09:53:20 -03:00
|
|
|
# Allow to differentiate our build from the make build
|
|
|
|
cfg.define('WAF_BUILD', 1)
|
|
|
|
|
2016-07-28 18:46:42 -03:00
|
|
|
cfg.msg('Autoconfiguration', 'enabled' if cfg.options.autoconfig else 'disabled')
|
|
|
|
|
2016-07-12 23:26:24 -03:00
|
|
|
if cfg.options.static:
|
2016-07-19 12:10:21 -03:00
|
|
|
cfg.msg('Using static linking', 'yes', color='YELLOW')
|
|
|
|
cfg.env.STATIC_LINKING = True
|
2016-07-12 23:26:24 -03:00
|
|
|
|
2016-07-25 19:02:09 -03:00
|
|
|
cfg.load('ap_library')
|
|
|
|
|
2016-05-06 18:44:12 -03:00
|
|
|
cfg.msg('Setting board to', cfg.options.board)
|
2016-05-20 15:36:15 -03:00
|
|
|
cfg.get_board().configure(cfg)
|
2015-11-25 11:48:45 -04:00
|
|
|
|
2015-10-26 23:27:55 -03:00
|
|
|
cfg.load('clang_compilation_database')
|
2015-10-30 12:50:44 -03:00
|
|
|
cfg.load('waf_unit_test')
|
2016-01-02 07:22:36 -04:00
|
|
|
cfg.load('mavgen')
|
2017-04-02 11:56:50 -03:00
|
|
|
cfg.load('uavcangen')
|
2016-07-22 19:19:44 -03:00
|
|
|
|
|
|
|
cfg.env.SUBMODULE_UPDATE = cfg.options.submodule_update
|
|
|
|
|
|
|
|
cfg.start_msg('Source is git repository')
|
|
|
|
if cfg.srcnode.find_node('.git'):
|
|
|
|
cfg.end_msg('yes')
|
|
|
|
else:
|
|
|
|
cfg.end_msg('no')
|
|
|
|
cfg.env.SUBMODULE_UPDATE = False
|
|
|
|
|
2016-08-18 18:22:59 -03:00
|
|
|
cfg.msg('Update submodules', 'yes' if cfg.env.SUBMODULE_UPDATE else 'no')
|
|
|
|
cfg.load('git_submodule')
|
2016-07-22 19:19:44 -03:00
|
|
|
|
2016-02-17 09:13:37 -04:00
|
|
|
if cfg.options.enable_benchmarks:
|
|
|
|
cfg.load('gbenchmark')
|
2016-01-18 12:41:21 -04:00
|
|
|
cfg.load('gtest')
|
2016-01-07 07:16:53 -04:00
|
|
|
cfg.load('static_linking')
|
2016-05-25 12:24:58 -03:00
|
|
|
cfg.load('build_summary')
|
2015-11-12 17:39:30 -04:00
|
|
|
|
|
|
|
cfg.start_msg('Benchmarks')
|
|
|
|
if cfg.env.HAS_GBENCHMARK:
|
|
|
|
cfg.end_msg('enabled')
|
|
|
|
else:
|
|
|
|
cfg.end_msg('disabled', color='YELLOW')
|
2015-10-09 11:03:59 -03:00
|
|
|
|
2016-01-18 12:41:21 -04:00
|
|
|
cfg.start_msg('Unit tests')
|
|
|
|
if cfg.env.HAS_GTEST:
|
|
|
|
cfg.end_msg('enabled')
|
|
|
|
else:
|
|
|
|
cfg.end_msg('disabled', color='YELLOW')
|
2015-10-30 13:14:28 -03:00
|
|
|
|
2018-09-27 18:59:57 -03:00
|
|
|
cfg.start_msg('Scripting')
|
2019-06-17 19:25:27 -03:00
|
|
|
if cfg.options.disable_scripting:
|
2018-09-27 18:59:57 -03:00
|
|
|
cfg.end_msg('disabled', color='YELLOW')
|
2019-06-17 19:25:27 -03:00
|
|
|
else:
|
|
|
|
cfg.end_msg('enabled')
|
2020-05-10 06:37:50 -03:00
|
|
|
cfg.recurse('libraries/AP_Scripting')
|
2018-09-27 18:59:57 -03:00
|
|
|
|
2020-08-27 00:06:36 -03:00
|
|
|
cfg.recurse('libraries/AP_GPS')
|
|
|
|
|
2018-11-03 18:59:08 -03:00
|
|
|
cfg.start_msg('Scripting runtime checks')
|
|
|
|
if cfg.options.scripting_checks:
|
|
|
|
cfg.end_msg('enabled')
|
|
|
|
else:
|
|
|
|
cfg.end_msg('disabled', color='YELLOW')
|
|
|
|
|
2021-05-21 05:51:19 -03:00
|
|
|
cfg.start_msg('Debug build')
|
|
|
|
if cfg.env.DEBUG:
|
|
|
|
cfg.end_msg('enabled')
|
|
|
|
else:
|
|
|
|
cfg.end_msg('disabled', color='YELLOW')
|
|
|
|
|
2021-05-21 05:51:31 -03:00
|
|
|
cfg.start_msg('Coverage build')
|
|
|
|
if cfg.env.COVERAGE:
|
|
|
|
cfg.end_msg('enabled')
|
|
|
|
else:
|
|
|
|
cfg.end_msg('disabled', color='YELLOW')
|
|
|
|
|
2021-09-21 05:34:46 -03:00
|
|
|
cfg.start_msg('SITL 32-bit build')
|
|
|
|
if cfg.env.SITL32BIT:
|
|
|
|
cfg.end_msg('enabled')
|
|
|
|
else:
|
|
|
|
cfg.end_msg('disabled', color='YELLOW')
|
|
|
|
|
2016-02-05 12:09:21 -04:00
|
|
|
cfg.env.append_value('GIT_SUBMODULES', 'mavlink')
|
|
|
|
|
2015-10-09 11:03:59 -03:00
|
|
|
cfg.env.prepend_value('INCLUDES', [
|
2016-01-02 07:22:36 -04:00
|
|
|
cfg.srcnode.abspath() + '/libraries/',
|
2016-01-13 16:52:56 -04:00
|
|
|
])
|
2015-10-09 11:03:59 -03:00
|
|
|
|
2017-06-05 10:22:09 -03:00
|
|
|
cfg.find_program('rsync', mandatory=False)
|
|
|
|
if cfg.options.rsync_dest:
|
|
|
|
cfg.msg('Setting rsync destination to', cfg.options.rsync_dest)
|
|
|
|
cfg.env.RSYNC_DEST = cfg.options.rsync_dest
|
|
|
|
|
2018-03-28 01:04:48 -03:00
|
|
|
if cfg.options.enable_header_checks:
|
|
|
|
cfg.msg('Enabling header checks', cfg.options.enable_header_checks)
|
|
|
|
cfg.env.ENABLE_HEADER_CHECKS = True
|
2017-08-06 06:24:04 -03:00
|
|
|
else:
|
2018-03-28 01:04:48 -03:00
|
|
|
cfg.env.ENABLE_HEADER_CHECKS = False
|
2017-08-06 06:24:04 -03:00
|
|
|
|
2015-10-09 11:03:59 -03:00
|
|
|
# TODO: Investigate if code could be changed to not depend on the
|
|
|
|
# source absolute path.
|
|
|
|
cfg.env.prepend_value('DEFINES', [
|
|
|
|
'SKETCHBOOK="' + cfg.srcnode.abspath() + '"',
|
|
|
|
])
|
|
|
|
|
2016-04-19 01:29:44 -03:00
|
|
|
# Always use system extensions
|
|
|
|
cfg.define('_GNU_SOURCE', 1)
|
|
|
|
|
2022-02-20 22:53:24 -04:00
|
|
|
cfg.write_config_header(os.path.join(cfg.variant, 'ap_config.h'), guard='_AP_CONFIG_H_')
|
2016-04-05 17:09:48 -03:00
|
|
|
|
2020-09-01 01:09:42 -03:00
|
|
|
# add in generated flags
|
|
|
|
cfg.env.CXXFLAGS += ['-include', 'ap_config.h']
|
|
|
|
|
2016-06-21 10:07:44 -03:00
|
|
|
_collect_autoconfig_files(cfg)
|
|
|
|
|
2021-11-11 07:14:48 -04:00
|
|
|
def generate_dronecan_dsdlc(cfg):
|
2021-11-11 08:18:06 -04:00
|
|
|
dsdlc_gen_path = cfg.bldnode.make_node('modules/DroneCAN/libcanard/dsdlc_generated').abspath()
|
2021-10-22 02:09:13 -03:00
|
|
|
src = cfg.srcnode.ant_glob('modules/DroneCAN/DSDL/* libraries/AP_UAVCAN/dsdl/*', dir=True, src=False)
|
2021-11-11 07:14:48 -04:00
|
|
|
dsdlc_path = cfg.srcnode.make_node('modules/DroneCAN/dronecan_dsdlc/dronecan_dsdlc.py').abspath()
|
2021-10-17 17:29:17 -03:00
|
|
|
if not os.path.exists(dsdlc_path):
|
|
|
|
print("Please update submodules with: git submodule update --recursive --init")
|
|
|
|
sys.exit(1)
|
2021-09-30 06:13:08 -03:00
|
|
|
src = ' '.join([s.abspath() for s in src])
|
|
|
|
cmd = '{} {} -O {} {}'.format(cfg.env.get_flat('PYTHON'),
|
2021-10-17 17:29:17 -03:00
|
|
|
dsdlc_path,
|
2021-09-30 06:13:08 -03:00
|
|
|
dsdlc_gen_path,
|
|
|
|
src)
|
2021-10-12 07:55:58 -03:00
|
|
|
print("Generating DSDLC for CANARD: " + cmd)
|
2021-10-17 20:08:57 -03:00
|
|
|
ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
2021-09-30 06:13:08 -03:00
|
|
|
if ret.returncode != 0:
|
|
|
|
print('Failed to run: ', cmd)
|
|
|
|
print(ret.stdout.decode('utf-8'))
|
|
|
|
print(ret.stderr.decode('utf-8'))
|
|
|
|
raise RuntimeError('Failed to generate DSDL C bindings')
|
|
|
|
|
2015-11-04 09:34:11 -04:00
|
|
|
def collect_dirs_to_recurse(bld, globs, **kw):
|
2015-10-09 11:03:59 -03:00
|
|
|
dirs = []
|
2015-12-10 14:22:07 -04:00
|
|
|
globs = Utils.to_list(globs)
|
2016-03-09 18:36:35 -04:00
|
|
|
|
|
|
|
if bld.bldnode.is_child_of(bld.srcnode):
|
|
|
|
kw['excl'] = Utils.to_list(kw.get('excl', []))
|
|
|
|
kw['excl'].append(bld.bldnode.path_from(bld.srcnode))
|
|
|
|
|
2015-11-04 09:34:11 -04:00
|
|
|
for g in globs:
|
|
|
|
for d in bld.srcnode.ant_glob(g + '/wscript', **kw):
|
|
|
|
dirs.append(d.parent.relpath())
|
2015-10-09 11:03:59 -03:00
|
|
|
return dirs
|
|
|
|
|
2015-11-30 11:41:45 -04:00
|
|
|
def list_boards(ctx):
|
2015-11-26 10:34:24 -04:00
|
|
|
print(*boards.get_boards_names())
|
2015-11-30 11:41:45 -04:00
|
|
|
|
2021-01-19 11:54:23 -04:00
|
|
|
def list_ap_periph_boards(ctx):
|
|
|
|
print(*boards.get_ap_periph_boards())
|
|
|
|
|
2021-01-05 17:43:03 -04:00
|
|
|
@conf
|
|
|
|
def ap_periph_boards(ctx):
|
|
|
|
return boards.get_ap_periph_boards()
|
|
|
|
|
|
|
|
def generate_tasklist(ctx, do_print=True):
|
|
|
|
boardlist = boards.get_boards_names()
|
|
|
|
ap_periph_targets = boards.get_ap_periph_boards()
|
|
|
|
tasks = []
|
|
|
|
with open(os.path.join(Context.top_dir, "tasklist.json"), "w") as tlist:
|
|
|
|
for board in boardlist:
|
|
|
|
task = {}
|
|
|
|
task['configure'] = board
|
|
|
|
if board in ap_periph_targets:
|
|
|
|
if 'sitl' not in board:
|
|
|
|
# we only support AP_Periph and bootloader builds
|
|
|
|
task['targets'] = ['AP_Periph', 'bootloader']
|
|
|
|
else:
|
|
|
|
task['targets'] = ['AP_Periph']
|
|
|
|
elif 'iofirmware' in board:
|
|
|
|
task['targets'] = ['iofirmware', 'bootloader']
|
|
|
|
else:
|
|
|
|
if 'sitl' in board or 'SITL' in board:
|
|
|
|
task['targets'] = ['antennatracker', 'copter', 'heli', 'plane', 'rover', 'sub', 'replay']
|
|
|
|
elif 'linux' in board:
|
|
|
|
task['targets'] = ['antennatracker', 'copter', 'heli', 'plane', 'rover', 'sub']
|
|
|
|
else:
|
|
|
|
task['targets'] = ['antennatracker', 'copter', 'heli', 'plane', 'rover', 'sub', 'bootloader']
|
|
|
|
task['buildOptions'] = '--upload'
|
|
|
|
tasks.append(task)
|
|
|
|
tlist.write(json.dumps(tasks))
|
|
|
|
if do_print:
|
|
|
|
print(json.dumps(tasks))
|
|
|
|
|
2018-03-27 05:13:50 -03:00
|
|
|
def board(ctx):
|
|
|
|
env = ConfigSet.ConfigSet()
|
|
|
|
try:
|
|
|
|
p = os.path.join(Context.out_dir, Build.CACHE_DIR, Build.CACHE_SUFFIX)
|
|
|
|
env.load(p)
|
|
|
|
except:
|
|
|
|
print('No board currently configured')
|
|
|
|
return
|
|
|
|
|
2018-09-01 21:30:36 -03:00
|
|
|
print('Board configured to: {}'.format(env.BOARD))
|
2018-03-27 05:13:50 -03:00
|
|
|
|
2016-02-03 08:53:19 -04:00
|
|
|
def _build_cmd_tweaks(bld):
|
2016-01-27 12:39:40 -04:00
|
|
|
if bld.cmd == 'check-all':
|
|
|
|
bld.options.all_tests = True
|
|
|
|
bld.cmd = 'check'
|
|
|
|
|
2016-02-03 08:53:19 -04:00
|
|
|
if bld.cmd == 'check':
|
|
|
|
if not bld.env.HAS_GTEST:
|
|
|
|
bld.fatal('check: gtest library is required')
|
2016-07-28 14:15:18 -03:00
|
|
|
bld.options.clear_failed_tests = True
|
2016-02-03 08:53:19 -04:00
|
|
|
|
2016-02-05 08:28:11 -04:00
|
|
|
def _build_dynamic_sources(bld):
|
2018-06-25 03:12:54 -03:00
|
|
|
if not bld.env.BOOTLOADER:
|
|
|
|
bld(
|
|
|
|
features='mavgen',
|
2022-01-30 01:19:49 -04:00
|
|
|
source='modules/mavlink/message_definitions/v1.0/all.xml',
|
2018-06-25 03:12:54 -03:00
|
|
|
output_dir='libraries/GCS_MAVLink/include/mavlink/v2.0/',
|
|
|
|
name='mavlink',
|
|
|
|
# this below is not ideal, mavgen tool should set this, but that's not
|
|
|
|
# currently possible
|
|
|
|
export_includes=[
|
2016-01-13 16:52:56 -04:00
|
|
|
bld.bldnode.make_node('libraries').abspath(),
|
|
|
|
bld.bldnode.make_node('libraries/GCS_MAVLink').abspath(),
|
2018-06-25 03:12:54 -03:00
|
|
|
],
|
|
|
|
)
|
2016-01-02 07:22:36 -04:00
|
|
|
|
2021-09-29 15:35:18 -03:00
|
|
|
if (bld.get_board().with_can or bld.env.HAL_NUM_CAN_IFACES) and not bld.env.AP_PERIPH:
|
2017-04-02 11:56:50 -03:00
|
|
|
bld(
|
|
|
|
features='uavcangen',
|
2021-11-18 18:30:30 -04:00
|
|
|
source=bld.srcnode.ant_glob('modules/DroneCAN/DSDL/* libraries/AP_UAVCAN/dsdl/*', dir=True, src=False),
|
2017-04-02 11:56:50 -03:00
|
|
|
output_dir='modules/uavcan/libuavcan/include/dsdlc_generated',
|
|
|
|
name='uavcan',
|
|
|
|
export_includes=[
|
|
|
|
bld.bldnode.make_node('modules/uavcan/libuavcan/include/dsdlc_generated').abspath(),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2021-06-14 08:07:27 -03:00
|
|
|
|
2016-07-28 13:53:01 -03:00
|
|
|
def write_version_header(tsk):
|
|
|
|
bld = tsk.generator.bld
|
|
|
|
return bld.write_version_header(tsk.outputs[0].abspath())
|
|
|
|
|
|
|
|
bld(
|
|
|
|
name='ap_version',
|
|
|
|
target='ap_version.h',
|
|
|
|
vars=['AP_VERSION_ITEMS'],
|
|
|
|
rule=write_version_header,
|
|
|
|
)
|
|
|
|
|
2016-05-05 19:16:23 -03:00
|
|
|
bld.env.prepend_value('INCLUDES', [
|
|
|
|
bld.bldnode.abspath(),
|
|
|
|
])
|
|
|
|
|
2016-02-05 08:28:11 -04:00
|
|
|
def _build_common_taskgens(bld):
|
2015-10-09 11:03:59 -03:00
|
|
|
# NOTE: Static library with vehicle set to UNKNOWN, shared by all
|
|
|
|
# the tools and examples. This is the first step until the
|
|
|
|
# dependency on the vehicles is reduced. Later we may consider
|
|
|
|
# split into smaller pieces with well defined boundaries.
|
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-21 09:47:10 -04:00
|
|
|
bld.ap_stlib(
|
2015-10-09 11:03:59 -03:00
|
|
|
name='ap',
|
2016-07-25 17:31:08 -03:00
|
|
|
ap_vehicle='UNKNOWN',
|
|
|
|
ap_libraries=bld.ap_get_all_libraries(),
|
2015-10-09 11:03:59 -03:00
|
|
|
)
|
2016-02-02 16:38:42 -04:00
|
|
|
|
2016-07-13 10:50:31 -03:00
|
|
|
if bld.env.HAS_GTEST:
|
|
|
|
bld.libgtest(cxxflags=['-include', 'ap_config.h'])
|
2016-02-05 08:59:13 -04:00
|
|
|
|
2016-02-17 17:34:48 -04:00
|
|
|
if bld.env.HAS_GBENCHMARK:
|
|
|
|
bld.libbenchmark()
|
|
|
|
|
2016-02-03 08:53:19 -04:00
|
|
|
def _build_recursion(bld):
|
2016-02-02 16:38:42 -04:00
|
|
|
common_dirs_patterns = [
|
|
|
|
# TODO: Currently each vehicle also generate its own copy of the
|
|
|
|
# libraries. Fix this, or at least reduce the amount of
|
|
|
|
# vehicle-dependent libraries.
|
|
|
|
'*',
|
|
|
|
'Tools/*',
|
|
|
|
'libraries/*/examples/*',
|
2016-07-25 16:44:20 -03:00
|
|
|
'libraries/*/tests',
|
|
|
|
'libraries/*/utility/tests',
|
|
|
|
'libraries/*/benchmarks',
|
2016-02-02 16:38:42 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
common_dirs_excl = [
|
|
|
|
'modules',
|
|
|
|
'libraries/AP_HAL_*',
|
|
|
|
]
|
|
|
|
|
|
|
|
hal_dirs_patterns = [
|
2016-10-25 15:29:29 -03:00
|
|
|
'libraries/%s/tests',
|
2016-07-25 16:44:20 -03:00
|
|
|
'libraries/%s/*/tests',
|
|
|
|
'libraries/%s/*/benchmarks',
|
2016-02-02 16:38:42 -04:00
|
|
|
'libraries/%s/examples/*',
|
|
|
|
]
|
|
|
|
|
|
|
|
dirs_to_recurse = collect_dirs_to_recurse(
|
|
|
|
bld,
|
|
|
|
common_dirs_patterns,
|
|
|
|
excl=common_dirs_excl,
|
|
|
|
)
|
2018-09-18 07:54:20 -03:00
|
|
|
if bld.env.IOMCU_FW is not None:
|
|
|
|
if bld.env.IOMCU_FW:
|
|
|
|
dirs_to_recurse.append('libraries/AP_IOMCU/iofirmware')
|
2019-05-26 22:46:24 -03:00
|
|
|
|
|
|
|
if bld.env.PERIPH_FW is not None:
|
|
|
|
if bld.env.PERIPH_FW:
|
|
|
|
dirs_to_recurse.append('Tools/AP_Periph')
|
|
|
|
|
2020-05-10 06:37:50 -03:00
|
|
|
dirs_to_recurse.append('libraries/AP_Scripting')
|
|
|
|
|
2021-06-14 08:07:27 -03:00
|
|
|
if bld.env.ENABLE_ONVIF:
|
|
|
|
dirs_to_recurse.append('libraries/AP_ONVIF')
|
|
|
|
|
2016-02-02 16:38:42 -04:00
|
|
|
for p in hal_dirs_patterns:
|
|
|
|
dirs_to_recurse += collect_dirs_to_recurse(
|
|
|
|
bld,
|
|
|
|
[p % l for l in bld.env.AP_LIBRARIES],
|
|
|
|
)
|
2015-10-09 11:03:59 -03:00
|
|
|
|
|
|
|
# NOTE: we need to sort to ensure the repeated sources get the
|
|
|
|
# same index, and random ordering of the filesystem doesn't cause
|
|
|
|
# recompilation.
|
2016-02-02 16:38:42 -04:00
|
|
|
dirs_to_recurse.sort()
|
|
|
|
|
|
|
|
for d in dirs_to_recurse:
|
2015-10-09 11:03:59 -03:00
|
|
|
bld.recurse(d)
|
2015-10-30 12:50:44 -03:00
|
|
|
|
2016-07-28 14:15:18 -03:00
|
|
|
def _build_post_funs(bld):
|
|
|
|
if bld.cmd == 'check':
|
|
|
|
bld.add_post_fun(ardupilotwaf.test_summary)
|
|
|
|
else:
|
|
|
|
bld.build_summary_post_fun()
|
|
|
|
|
|
|
|
if bld.env.SUBMODULE_UPDATE:
|
|
|
|
bld.git_submodule_post_fun()
|
2016-05-05 19:16:23 -03:00
|
|
|
|
2018-09-01 20:59:21 -03:00
|
|
|
def _load_pre_build(bld):
|
2018-03-01 03:26:28 -04:00
|
|
|
'''allow for a pre_build() function in build modules'''
|
2021-09-30 05:43:53 -03:00
|
|
|
if bld.cmd == 'clean':
|
|
|
|
return
|
2018-03-01 03:26:28 -04:00
|
|
|
brd = bld.get_board()
|
2021-09-30 06:13:08 -03:00
|
|
|
if bld.env.AP_PERIPH:
|
2021-11-11 08:18:06 -04:00
|
|
|
dsdlc_gen_path = bld.bldnode.make_node('modules/DroneCAN/libcanard/dsdlc_generated/include').abspath()
|
2021-09-30 06:13:08 -03:00
|
|
|
#check if canard dsdlc directory empty
|
|
|
|
# check if directory exists
|
|
|
|
if not os.path.exists(dsdlc_gen_path) or not os.listdir(dsdlc_gen_path):
|
2021-11-11 07:14:48 -04:00
|
|
|
generate_dronecan_dsdlc(bld)
|
2018-03-01 03:26:28 -04:00
|
|
|
if getattr(brd, 'pre_build', None):
|
|
|
|
brd.pre_build(bld)
|
|
|
|
|
2016-02-03 08:53:19 -04:00
|
|
|
def build(bld):
|
2016-05-20 09:16:01 -03:00
|
|
|
config_hash = Utils.h_file(bld.bldnode.make_node('ap_config.h').abspath())
|
|
|
|
bld.env.CCDEPS = config_hash
|
|
|
|
bld.env.CXXDEPS = config_hash
|
2016-04-05 17:09:48 -03:00
|
|
|
|
2016-02-05 08:28:11 -04:00
|
|
|
bld.post_mode = Build.POST_LAZY
|
|
|
|
|
2016-02-03 08:53:19 -04:00
|
|
|
bld.load('ardupilotwaf')
|
|
|
|
|
2016-07-25 19:02:09 -03:00
|
|
|
bld.env.AP_LIBRARIES_OBJECTS_KW.update(
|
2017-04-02 11:56:50 -03:00
|
|
|
use=['mavlink'],
|
2016-07-25 19:02:09 -03:00
|
|
|
cxxflags=['-include', 'ap_config.h'],
|
|
|
|
)
|
2018-03-01 03:26:28 -04:00
|
|
|
|
2018-09-01 20:59:21 -03:00
|
|
|
_load_pre_build(bld)
|
2018-03-01 03:26:28 -04:00
|
|
|
|
2020-05-31 08:50:44 -03:00
|
|
|
if bld.get_board().with_can:
|
2017-04-02 11:56:50 -03:00
|
|
|
bld.env.AP_LIBRARIES_OBJECTS_KW['use'] += ['uavcan']
|
2016-07-25 19:02:09 -03:00
|
|
|
|
2016-02-03 08:53:19 -04:00
|
|
|
_build_cmd_tweaks(bld)
|
2016-02-05 08:28:11 -04:00
|
|
|
|
2016-02-19 12:44:32 -04:00
|
|
|
if bld.env.SUBMODULE_UPDATE:
|
|
|
|
bld.add_group('git_submodules')
|
|
|
|
for name in bld.env.GIT_SUBMODULES:
|
|
|
|
bld.git_submodule(name)
|
2016-02-05 08:28:11 -04:00
|
|
|
|
|
|
|
bld.add_group('dynamic_sources')
|
|
|
|
_build_dynamic_sources(bld)
|
|
|
|
|
|
|
|
bld.add_group('build')
|
2016-05-20 15:36:15 -03:00
|
|
|
bld.get_board().build(bld)
|
2016-02-05 08:28:11 -04:00
|
|
|
_build_common_taskgens(bld)
|
|
|
|
|
2016-02-03 08:53:19 -04:00
|
|
|
_build_recursion(bld)
|
2015-10-30 12:50:44 -03:00
|
|
|
|
2016-07-28 14:15:18 -03:00
|
|
|
_build_post_funs(bld)
|
2016-05-05 19:16:23 -03:00
|
|
|
|
2016-01-27 12:16:37 -04:00
|
|
|
ardupilotwaf.build_command('check',
|
2016-01-27 12:07:36 -04:00
|
|
|
program_group_list='all',
|
|
|
|
doc='builds all programs and run tests',
|
|
|
|
)
|
2016-01-27 12:39:40 -04:00
|
|
|
ardupilotwaf.build_command('check-all',
|
|
|
|
program_group_list='all',
|
|
|
|
doc='shortcut for `waf check --alltests`',
|
|
|
|
)
|
2016-01-15 12:14:00 -04:00
|
|
|
|
2021-03-18 00:13:21 -03:00
|
|
|
for name in ('antennatracker', 'copter', 'heli', 'plane', 'rover', 'sub', 'blimp', 'bootloader','iofirmware','AP_Periph','replay'):
|
2016-03-24 17:18:06 -03:00
|
|
|
ardupilotwaf.build_command(name,
|
|
|
|
program_group_list=name,
|
|
|
|
doc='builds %s programs' % name,
|
|
|
|
)
|
2016-01-27 08:57:29 -04:00
|
|
|
|
2021-07-05 06:39:39 -03:00
|
|
|
for program_group in ('all', 'bin', 'tool', 'examples', 'tests', 'benchmarks'):
|
2016-01-27 12:16:37 -04:00
|
|
|
ardupilotwaf.build_command(program_group,
|
2016-01-27 11:58:48 -04:00
|
|
|
program_group_list=program_group,
|
|
|
|
doc='builds all programs of %s group' % program_group,
|
|
|
|
)
|
2017-06-05 09:39:14 -03:00
|
|
|
|
|
|
|
class LocalInstallContext(Build.InstallContext):
|
|
|
|
"""runs install using BLD/install as destdir, where BLD is the build variant directory"""
|
2017-06-29 17:58:35 -03:00
|
|
|
cmd = 'localinstall'
|
2017-06-05 09:39:14 -03:00
|
|
|
|
|
|
|
def __init__(self, **kw):
|
|
|
|
super(LocalInstallContext, self).__init__(**kw)
|
|
|
|
self.local_destdir = os.path.join(self.variant_dir, 'install')
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
old_destdir = self.options.destdir
|
|
|
|
self.options.destdir = self.local_destdir
|
|
|
|
r = super(LocalInstallContext, self).execute()
|
|
|
|
self.options.destdir = old_destdir
|
|
|
|
return r
|
2017-06-05 10:22:09 -03:00
|
|
|
|
|
|
|
class RsyncContext(LocalInstallContext):
|
2017-06-29 17:58:35 -03:00
|
|
|
"""runs localinstall and then rsyncs BLD/install with the target system"""
|
2017-06-05 10:22:09 -03:00
|
|
|
cmd = 'rsync'
|
|
|
|
|
|
|
|
def __init__(self, **kw):
|
|
|
|
super(RsyncContext, self).__init__(**kw)
|
|
|
|
self.add_pre_fun(RsyncContext.create_rsync_taskgen)
|
|
|
|
|
|
|
|
def create_rsync_taskgen(self):
|
|
|
|
if 'RSYNC' not in self.env:
|
|
|
|
self.fatal('rsync program seems not to be installed, can\'t continue')
|
|
|
|
|
|
|
|
self.add_group()
|
|
|
|
|
|
|
|
tg = self(
|
|
|
|
name='rsync',
|
|
|
|
rule='${RSYNC} -a ${RSYNC_SRC}/ ${RSYNC_DEST}',
|
|
|
|
always=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
tg.env.RSYNC_SRC = self.local_destdir
|
|
|
|
if self.options.rsync_dest:
|
|
|
|
self.env.RSYNC_DEST = self.options.rsync_dest
|
|
|
|
|
|
|
|
if 'RSYNC_DEST' not in tg.env:
|
|
|
|
self.fatal('Destination for rsync not defined. Either pass --rsync-dest here or during configuration.')
|
|
|
|
|
|
|
|
tg.post()
|