mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.51k stars 1.6k forks source link

Layering Improvement: "Include" a cross/native base within the file #6805

Open phillipjohnston opened 4 years ago

phillipjohnston commented 4 years ago

I cross-compile quite a bit for different processors. Cross file layering has been quite helpful, because I can have a common GCC ARM definition, and layer processor-specific flags on as needed.

Something that would simplify the workflow would be the ability to include a cross-file/native-file base, similar to 'subdir'.

E.g., imagine I have a base GCC ARM file:

[binaries]
c = 'arm-none-eabi-gcc'
cpp = 'arm-none-eabi-c++'
ar = 'arm-none-eabi-ar'
strip = 'arm-none-eabi-strip'
c_ld = 'arm-none-eabi-ld'
cpp_ld = 'arm-none-eabi-ld'

# Keep this set, or the sanity check won't pass
needs_exe_wrapper = true

[host_machine]
system = 'none'
cpu_family = 'arm'
endian = 'little'

And then a Cortex-M4 hard FP derivative:

[properties]
c_args = [ '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16', '-mabi=aapcs', '-mthumb',]
c_link_args = [ '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16', '-mabi=aapcs', '-mthumb',]
cpp_args = [ '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16', '-mabi=aapcs', '-mthumb',]
cpp_link_args = [ '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16', '-mabi=aapcs', '-mthumb',]

[host machine]
cpu = 'cortex-m4'

It would be nice to be able to do this instead of needing two command-line arguments:

include('arm-gcc-base.txt')

[properties]
c_args = [ '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16', '-mabi=aapcs', '-mthumb',]
c_link_args = [ '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16', '-mabi=aapcs', '-mthumb',]
cpp_args = [ '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16', '-mabi=aapcs', '-mthumb',]
cpp_link_args = [ '-mcpu=cortex-m4', '-mfloat-abi=hard', '-mfpu=fpv4-sp-d16', '-mabi=aapcs', '-mthumb',]

[host machine]
cpu = 'cortex-m4'
phillipjohnston commented 4 years ago

The search rules can be the same as the standard cross-file search rules that are already defined.

Happy to take a stab at this if it's something y'all think is reasonable to incorporate.

phillipjohnston commented 4 years ago

I looked at the architecture for this code path while implementing #6815, I didn't see a clean way to implement such support.