mirror of https://github.com/ArduPilot/ardupilot
waf: added --enable-new-checking option
this allows CI to check for violations of new, calling without NEW_NOTHROW
This commit is contained in:
parent
4a5ca0114b
commit
93f1bb576b
|
@ -4,6 +4,7 @@ from collections import OrderedDict
|
||||||
import re
|
import re
|
||||||
import sys, os
|
import sys, os
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
import platform
|
||||||
|
|
||||||
import waflib
|
import waflib
|
||||||
from waflib import Utils
|
from waflib import Utils
|
||||||
|
@ -45,8 +46,8 @@ class Board:
|
||||||
cfg.load('toolchain')
|
cfg.load('toolchain')
|
||||||
cfg.load('cxx_checks')
|
cfg.load('cxx_checks')
|
||||||
|
|
||||||
# check elf symbols by default
|
# don't check elf symbols by default
|
||||||
cfg.env.CHECK_SYMBOLS = True
|
cfg.env.CHECK_SYMBOLS = False
|
||||||
|
|
||||||
env = waflib.ConfigSet.ConfigSet()
|
env = waflib.ConfigSet.ConfigSet()
|
||||||
def srcpath(path):
|
def srcpath(path):
|
||||||
|
@ -751,6 +752,11 @@ class sitl(Board):
|
||||||
'SITL',
|
'SITL',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# wrap malloc to ensure memory is zeroed
|
||||||
|
# don't do this on MacOS as ld doesn't support --wrap
|
||||||
|
if platform.system() != 'Darwin':
|
||||||
|
env.LINKFLAGS += ['-Wl,--wrap,malloc']
|
||||||
|
|
||||||
if cfg.options.enable_sfml:
|
if cfg.options.enable_sfml:
|
||||||
if not cfg.check_SFML(env):
|
if not cfg.check_SFML(env):
|
||||||
cfg.fatal("Failed to find SFML libraries")
|
cfg.fatal("Failed to find SFML libraries")
|
||||||
|
@ -794,8 +800,6 @@ class sitl(Board):
|
||||||
|
|
||||||
if Utils.unversioned_sys_platform() == 'cygwin':
|
if Utils.unversioned_sys_platform() == 'cygwin':
|
||||||
env.CXXFLAGS += ['-DCYGWIN_BUILD']
|
env.CXXFLAGS += ['-DCYGWIN_BUILD']
|
||||||
# can't do symbol checking on cygwin due to exception usage in system libraries
|
|
||||||
env.CHECK_SYMBOLS = False
|
|
||||||
|
|
||||||
if 'clang++' in cfg.env.COMPILER_CXX:
|
if 'clang++' in cfg.env.COMPILER_CXX:
|
||||||
print("Disabling SLP for clang++")
|
print("Disabling SLP for clang++")
|
||||||
|
@ -1007,6 +1011,8 @@ class esp32(Board):
|
||||||
env.CXXFLAGS.remove('-Werror=undef')
|
env.CXXFLAGS.remove('-Werror=undef')
|
||||||
env.CXXFLAGS.remove('-Werror=shadow')
|
env.CXXFLAGS.remove('-Werror=shadow')
|
||||||
|
|
||||||
|
# wrap malloc to ensure memory is zeroed
|
||||||
|
env.LINKFLAGS += ['-Wl,--wrap,malloc']
|
||||||
|
|
||||||
env.INCLUDES += [
|
env.INCLUDES += [
|
||||||
cfg.srcnode.find_dir('libraries/AP_HAL_ESP32/boards').abspath(),
|
cfg.srcnode.find_dir('libraries/AP_HAL_ESP32/boards').abspath(),
|
||||||
|
@ -1260,6 +1266,16 @@ class chibios(Board):
|
||||||
cfg.msg("Checking for intelhex module:", 'disabled', color='YELLOW')
|
cfg.msg("Checking for intelhex module:", 'disabled', color='YELLOW')
|
||||||
env.HAVE_INTEL_HEX = False
|
env.HAVE_INTEL_HEX = False
|
||||||
|
|
||||||
|
if cfg.options.enable_new_checking:
|
||||||
|
env.CHECK_SYMBOLS = True
|
||||||
|
else:
|
||||||
|
# disable new checking on ChibiOS by default to save flash
|
||||||
|
# we enable it in a CI test to catch incorrect usage
|
||||||
|
env.CXXFLAGS += [
|
||||||
|
"-DNEW_NOTHROW=new",
|
||||||
|
"-fcheck-new", # rely on -fcheck-new ensuring nullptr checks
|
||||||
|
]
|
||||||
|
|
||||||
def build(self, bld):
|
def build(self, bld):
|
||||||
super(chibios, self).build(bld)
|
super(chibios, self).build(bld)
|
||||||
bld.ap_version_append_str('CHIBIOS_GIT_VERSION', bld.git_submodule_head_hash('ChibiOS', short=True))
|
bld.ap_version_append_str('CHIBIOS_GIT_VERSION', bld.git_submodule_head_hash('ChibiOS', short=True))
|
||||||
|
@ -1289,9 +1305,6 @@ class linux(Board):
|
||||||
self.with_can = True
|
self.with_can = True
|
||||||
super(linux, self).configure_env(cfg, env)
|
super(linux, self).configure_env(cfg, env)
|
||||||
|
|
||||||
# can't do symbol checking on Linux due to exception usage in libc++
|
|
||||||
env.CHECK_SYMBOLS = False
|
|
||||||
|
|
||||||
env.BOARD_CLASS = "LINUX"
|
env.BOARD_CLASS = "LINUX"
|
||||||
|
|
||||||
env.DEFINES.update(
|
env.DEFINES.update(
|
||||||
|
@ -1319,6 +1332,9 @@ class linux(Board):
|
||||||
'AP_HAL_Linux',
|
'AP_HAL_Linux',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# wrap malloc to ensure memory is zeroed
|
||||||
|
env.LINKFLAGS += ['-Wl,--wrap,malloc']
|
||||||
|
|
||||||
if cfg.options.force_32bit:
|
if cfg.options.force_32bit:
|
||||||
env.DEFINES.update(
|
env.DEFINES.update(
|
||||||
HAL_FORCE_32BIT = 1,
|
HAL_FORCE_32BIT = 1,
|
||||||
|
|
5
wscript
5
wscript
|
@ -441,6 +441,11 @@ configuration in order to save typing.
|
||||||
type='int',
|
type='int',
|
||||||
default=0,
|
default=0,
|
||||||
help='zero time on boot in microseconds')
|
help='zero time on boot in microseconds')
|
||||||
|
|
||||||
|
g.add_option('--enable-new-checking',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help='enables checking of new to ensure NEW_NOTHROW is used')
|
||||||
|
|
||||||
def _collect_autoconfig_files(cfg):
|
def _collect_autoconfig_files(cfg):
|
||||||
for m in sys.modules.values():
|
for m in sys.modules.values():
|
||||||
|
|
Loading…
Reference in New Issue