xfiles: Meson Cross-compilation files
A collection of cross-compilation files for use with Meson. Pretty self-explanatory. The project tries to provide sane defaults for platforms that need to be compiled without runtime type checking or exception handling. This simplifies a project's meson.build file significantly, and makes it more readable.
Install in root fs (requires root permissions):
meson setup build . --prefix=/usr
meson install -C buildInstall in user fs (does not require permissions):
meson setup build . --prefix=~/.local
meson install -C buildBuilding a project for Arduino:
meson setup build . \
--cross-file=avr \
--cross-file=arduino
ninja -C buildBuilding a project for a baremetal ATmega328P:
meson setup build . \
--cross-file=avr \
--cross-file=atmega328p
ninja -C buildThe cross-files try to include as much of the gcc/binutils toolchain as possible. Most of these binaries are provided without the toolchain prefix. As such, binaries like the toolchain specific objcopy can be used with a project file like in the following example.
project('simple', 'c')
objcopy = find_program('objcopy')
elf_file = executable('example', 'example.c')
eep_file = custom_target('example.eep',
input: elf_file,
output: 'example.eep',
command: [objcopy]
+ meson.get_external_property('avr_extract_eeprom')
+ ['@INPUT@', '@OUTPUT@']
])
hex_file = custom_target('example.hex',
input: elf_file,
output: 'example.hex',
command: [objcopy]
+ meson.get_external_property('avr_extract_flash')
+ ['@INPUT@', '@OUTPUT@']
])Some targets also include target specific tools such as avrdude.
avrdude = find_program('avrdude')
run_target('exmaple.upload',
depends: hex_file,
command: [avrdude, '-v', '-v', '-v', '-v',
'-patmega328p', -'carduino', '-P/dev/ttyACM0', '-b115200',
'-D', '-Uflash:w:@0@:i'.format(hex_file.full_path()),
])