a6/meson.build

155 lines
4.0 KiB
Meson

project('a6', 'c',
default_options: ['optimization=2', 'debug=true', 'strip=false',
'warning_level=2', 'c_std=gnu11'],
)
python = import('python')
keyval = import('keyval')
prog_python = python.find_installation('python3')
#############################################################################
# OK, quick primer on how to build A6 components.
#
# Native executables to be used as tools in the build (dex_builder) should be
# built with:
# - native: true
# - include_directories: inc_native
#
# DLL files should be built as *executables*, not shared libraries (the ELF
# headers are different). The following options should be used:
# - c_args: c_args_dll
# - include_directories: inc
# - link_with: link_with
# - link_whole: link_whole
# - link_args: link_args
# - export_dynamic: true (meson hack to make it let us link with these)
#
# Static libraries should use:
# - include_directories: inc
#
# The kernel executable uses -fpie.
#----------------------------------------------------------------------------
# Configure the project
build_hash = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
link_with = []
link_whole = []
link_args = []
linker_script = meson.get_external_property('linker_script', '')
if linker_script != ''
fn = meson.source_root() / linker_script
link_args += '-T' + fn
endif
gcc_info_fn = meson.build_root() / 'gcc_info.txt'
gcc_info_r = run_command(prog_python, 'toolchain/gcc_info.py',
meson.get_compiler('c').cmd_array()[-1],
gcc_info_fn
)
gcc_info = keyval.load(gcc_info_fn)
add_project_link_arguments(gcc_info['LIBGCC_A'], language: ['c', 'cpp'])
strip = find_program('strip', required: true)
objcopy = find_program('objcopy', required: true)
board = get_option('board')
adjust_objects = get_option('adjust_objects')
foreach n: [true, false]
add_project_arguments([
'-Wno-unused-parameter',
], language: ['c', 'cpp'], native: n)
endforeach
inc_native = [
include_directories('dll_system/include'),
include_directories('dll_ld/include'),
]
inc = inc_native + [
include_directories('dll_kernel/include'),
]
# Make sure everybody, including subprojects, can get libc headers.
add_global_arguments(
'-isystem' + meson.current_source_dir() / 'toolchain/stubinc',
language: ['c', 'cpp']
)
c_args_dll = ['-fpic', '-fvisibility=hidden']
c_args_exe = []
#----------------------------------------------------------------------------
# External dependencies
picolibc_proj = subproject('picolibc', default_options: [
'multilib=false',
'picocrt=false',
'picolib=false',
'semihost=false',
'io-long-long=true',
'io-pos-args=true',
'atomic-ungetc=false',
'format-default=integer',
'newlib-iconv-encodings=us_ascii'
])
lib_c = picolibc_proj.get_variable('lib_c')
inc += picolibc_proj.get_variable('inc')
libclist_proj = subproject('c-list')
libclist_dep = libclist_proj.get_variable('libclist_dep')
#----------------------------------------------------------------------------
# Dive into subdirs now
subdir('a_runtime')
link_whole += a_runtime
subdir('dll_system')
link_with += dll_system
subdir('gendrv') # provides inc_gendrv and a_gd_*
subdir('dll_ld') # provides dll_ld and dex_builder
link_with += dll_ld
subdir('dll_kernel')
link_with += dll_kernel
subdir('exe_a6')
subdir('bootloader')
#----------------------------------------------------------------------------
# Finally, pack it all up
srec_fn = 'superfs_' + board + '.srec'
superfs_args = [
'--db', dex_builder.full_path(),
'--strip', strip.full_path(),
'--objcopy', objcopy.full_path(),
'@SOURCE_ROOT@/superfs_' + board,
'-t',
'-o', meson.build_root(),
'-m', board + '.map',
'--sort-map', 'address',
]
if adjust_objects
superfs_args += '-a'
endif
superfs_srec = custom_target(
srec_fn,
output: srec_fn,
input: [dll_system, dll_ld, exe_a6, 'superfs_' + board + '/SUPERFS.INI'],
command: [
prog_python,
'@SOURCE_ROOT@/toolchain/run_superfs_builder.py',
] + superfs_args + ['@OUTPUT@'],
build_by_default: true,
)