|
|
|
@ -1,28 +1,79 @@
|
|
|
|
|
###############################################################################
|
|
|
|
|
# MESON SETUP
|
|
|
|
|
|
|
|
|
|
project(
|
|
|
|
|
'firmware',
|
|
|
|
|
['c'],
|
|
|
|
|
default_options: ['optimization=2', 'cpp_std=c++17', 'b_staticpic=false']
|
|
|
|
|
['c', 'cpp'],
|
|
|
|
|
default_options: ['optimization=2', 'cpp_std=c++20', 'b_staticpic=false',
|
|
|
|
|
'b_lto=false', 'warning_level=3', 'default_library=static']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# MAIN BUILD CONFIGURATION
|
|
|
|
|
|
|
|
|
|
flash_origin = 0
|
|
|
|
|
flash_size = 0
|
|
|
|
|
stack_size = 2048
|
|
|
|
|
bsp = 'bsp-BOARD'
|
|
|
|
|
target = get_option('build_target')
|
|
|
|
|
target_name = meson.project_name() + '_' + target
|
|
|
|
|
|
|
|
|
|
if target == 'main'
|
|
|
|
|
sources = [
|
|
|
|
|
'src/main.c',
|
|
|
|
|
]
|
|
|
|
|
includes = [
|
|
|
|
|
'src',
|
|
|
|
|
]
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# SYSTEM DEPENDENCIES
|
|
|
|
|
|
|
|
|
|
## END USER MUST MODIFY: KEEP ONLY THE 10x or 30x BLOCK
|
|
|
|
|
ch32v10x_proj = subproject('ch32v10x')
|
|
|
|
|
ch32v10x_proj = subproject('ch32v10x', default_options: [
|
|
|
|
|
f'flash_size=@flash_size@',
|
|
|
|
|
f'flash_origin=@flash_origin@',
|
|
|
|
|
f'stack_size=@stack_size@',
|
|
|
|
|
])
|
|
|
|
|
ch32v10x_dep = ch32v10x_proj.get_variable('ch32v10x_dep')
|
|
|
|
|
ch32v10x_sys_dep = ch32v10x_proj.get_variable('ch32v10x_sys_dep')
|
|
|
|
|
dependencies = [ch32v10x_dep, ch32v10x_sys_dep]
|
|
|
|
|
|
|
|
|
|
## END USER MUST MODIFY: KEEP ONLY THE 10x or 30x BLOCK
|
|
|
|
|
ch32v30x_proj = subproject('ch32v30x', default_options: ['variant=CH32V307'])
|
|
|
|
|
ch32v30x_proj = subproject('ch32v30x', default_options: [
|
|
|
|
|
'variant=CH32V307',
|
|
|
|
|
f'flash_size=@flash_size@',
|
|
|
|
|
f'flash_origin=@flash_origin@',
|
|
|
|
|
f'stack_size=@stack_size@',
|
|
|
|
|
])
|
|
|
|
|
ch32v30x_dep = ch32v30x_proj.get_variable('ch32v30x_dep')
|
|
|
|
|
ch32v30x_sys_dep = ch32v30x_proj.get_variable('ch32v30x_sys_dep')
|
|
|
|
|
dependencies = [ch32v30x_dep, ch32v30x_sys_dep]
|
|
|
|
|
|
|
|
|
|
sources = [
|
|
|
|
|
'src/main.c',
|
|
|
|
|
]
|
|
|
|
|
bsp_proj = subproject(bsp)
|
|
|
|
|
dependencies += bsp_proj.get_variable('bsp_dep')
|
|
|
|
|
|
|
|
|
|
info_dep = vcs_tag(
|
|
|
|
|
command: ['git', 'describe', '--always', '--dirty'],
|
|
|
|
|
fallback: 'no-git',
|
|
|
|
|
input: 'version.h.in',
|
|
|
|
|
output: 'version.h',
|
|
|
|
|
replace_string: 'GITINFO',
|
|
|
|
|
)
|
|
|
|
|
sources += info_dep
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# APPLICATION DEPENDENCIES
|
|
|
|
|
|
|
|
|
|
xutil_proj = subproject('xutil', default_options: [
|
|
|
|
|
'with_cpp=true',
|
|
|
|
|
'with_task=false',
|
|
|
|
|
])
|
|
|
|
|
dependencies += xutil_proj.get_variable('xutil_dep')
|
|
|
|
|
|
|
|
|
|
includes = [
|
|
|
|
|
'src',
|
|
|
|
|
]
|
|
|
|
|
###############################################################################
|
|
|
|
|
# BUILD TARGETS
|
|
|
|
|
|
|
|
|
|
_incl_dirs = include_directories(includes)
|
|
|
|
|
|
|
|
|
@ -31,21 +82,21 @@ objdump = find_program('objdump')
|
|
|
|
|
size = find_program('size')
|
|
|
|
|
|
|
|
|
|
main = executable(
|
|
|
|
|
meson.project_name() + '.elf',
|
|
|
|
|
target_name + '.elf',
|
|
|
|
|
sources,
|
|
|
|
|
include_directories: _incl_dirs,
|
|
|
|
|
dependencies: dependencies,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
main_hex = custom_target(
|
|
|
|
|
meson.project_name() + '.hex',
|
|
|
|
|
target_name + '.hex',
|
|
|
|
|
command: [
|
|
|
|
|
objcopy,
|
|
|
|
|
'-O', 'ihex',
|
|
|
|
|
'@INPUT@', '@OUTPUT@'
|
|
|
|
|
],
|
|
|
|
|
input: main,
|
|
|
|
|
output: meson.project_name() + '.hex',
|
|
|
|
|
output: target_name + '.hex',
|
|
|
|
|
build_by_default: true,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -66,13 +117,13 @@ elf_for_make = custom_target(
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
main_disas = custom_target(
|
|
|
|
|
meson.project_name() + '.disas',
|
|
|
|
|
target_name + '.disas',
|
|
|
|
|
command: [
|
|
|
|
|
objdump,
|
|
|
|
|
'-SC', '@INPUT@'
|
|
|
|
|
'-SC', '--visualize-jumps', '@INPUT@'
|
|
|
|
|
],
|
|
|
|
|
input: main,
|
|
|
|
|
output: meson.project_name() + '.disas',
|
|
|
|
|
output: target_name + '.disas',
|
|
|
|
|
build_by_default: true,
|
|
|
|
|
capture: true,
|
|
|
|
|
)
|
|
|
|
|