6856950bd3
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.
134 lines
2.7 KiB
Python
134 lines
2.7 KiB
Python
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
|
|
import sys
|
|
|
|
import waflib
|
|
|
|
BOARDS = {}
|
|
|
|
PROJECT_ENV = waflib.ConfigSet.ConfigSet()
|
|
|
|
def define_board(func, name, parent_name=None):
|
|
if parent_name is None:
|
|
parent = PROJECT_ENV
|
|
elif parent_name not in BOARDS:
|
|
print("Undefined parent board '%s' for '%s'" % (parent_name, name))
|
|
sys.exit(1)
|
|
else:
|
|
parent = BOARDS[parent_name]
|
|
|
|
env = parent.derive().detach()
|
|
if name in BOARDS:
|
|
print("Multiple definitions of " + name)
|
|
sys.exit(1)
|
|
BOARDS[name] = env
|
|
func(env)
|
|
|
|
# Use a dictionary instead of the convetional list for definitions to
|
|
# make easy to override them. Convert back to list before consumption.
|
|
PROJECT_ENV.DEFINES = {}
|
|
|
|
PROJECT_ENV.CFLAGS += [
|
|
'-ffunction-sections',
|
|
'-fdata-sections',
|
|
'-fsigned-char',
|
|
|
|
'-Wformat',
|
|
'-Wall',
|
|
'-Wshadow',
|
|
'-Wpointer-arith',
|
|
'-Wcast-align',
|
|
'-Wno-unused-parameter',
|
|
'-Wno-missing-field-initializers',
|
|
]
|
|
|
|
PROJECT_ENV.CXXFLAGS += [
|
|
'-std=gnu++11',
|
|
|
|
'-fdata-sections',
|
|
'-ffunction-sections',
|
|
'-fno-exceptions',
|
|
'-fsigned-char',
|
|
|
|
'-Wformat',
|
|
'-Wall',
|
|
'-Wshadow',
|
|
'-Wpointer-arith',
|
|
'-Wcast-align',
|
|
'-Wno-unused-parameter',
|
|
'-Wno-missing-field-initializers',
|
|
'-Wno-reorder',
|
|
'-Werror=format-security',
|
|
'-Werror=array-bounds',
|
|
'-Wfatal-errors',
|
|
'-Werror=unused-but-set-variable',
|
|
'-Werror=uninitialized',
|
|
'-Werror=init-self',
|
|
'-Wno-missing-field-initializers',
|
|
]
|
|
|
|
PROJECT_ENV.LINKFLAGS += [
|
|
'-Wl,--gc-sections',
|
|
]
|
|
|
|
# NOTE: Keeping all the board definitions together so we can easily
|
|
# identify opportunities to simplify common flags. In the future might
|
|
# be worthy to keep board definitions in files of their own.
|
|
|
|
def sitl(env):
|
|
env.DEFINES.update(
|
|
CONFIG_HAL_BOARD = 'HAL_BOARD_SITL',
|
|
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_NONE',
|
|
)
|
|
|
|
env.CXXFLAGS += [
|
|
'-O3',
|
|
]
|
|
|
|
env.LIB += [
|
|
'm',
|
|
'pthread',
|
|
]
|
|
|
|
env.AP_LIBRARIES += [
|
|
'AP_HAL_SITL',
|
|
'SITL',
|
|
]
|
|
|
|
define_board(sitl, 'sitl')
|
|
|
|
|
|
def linux(env):
|
|
env.DEFINES.update(
|
|
CONFIG_HAL_BOARD = 'HAL_BOARD_LINUX',
|
|
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_LINUX_NONE',
|
|
)
|
|
|
|
env.CXXFLAGS += [
|
|
'-O3',
|
|
]
|
|
|
|
env.LIB += [
|
|
'm',
|
|
'pthread',
|
|
'rt',
|
|
]
|
|
|
|
env.AP_LIBRARIES = [
|
|
'AP_HAL_Linux',
|
|
]
|
|
|
|
define_board(linux, 'linux')
|
|
|
|
|
|
def minlure(env):
|
|
env.DEFINES.update(
|
|
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_LINUX_MINLURE',
|
|
)
|
|
|
|
define_board(minlure, 'minlure', 'linux')
|
|
|
|
def get_boards_names():
|
|
return sorted(list(BOARDS.keys()))
|