meson icon indicating copy to clipboard operation
meson copied to clipboard

Allow subprojects to be built for both the build and host machine

Open dcbaker opened this issue 2 years ago • 22 comments

Currently, subprojects can only be built for the host machine. This is obviously not a great situation, as you may need to build dependencies for the build machine. This series fixes that (hopefully for both cmake and native subprojects), but allowing a subproject to be configured twice.

This is accomplished by creating copies of the core datastructures (Build, Environment, and CoreData), with the per-machine attributes set so that both the host and the build point to the overall build configuration. All install targets from build machine subprojects have been dropped, to avoid such unsupported installation. In addition, I've ensured that in a host == build setup only one subproject will be configured, so that in the case of

d = dependency('foo', native : false, allow_fallback : true)
d_build = dependency('foo', native : true, allow_fallback : true)

that d_build is just a reference to d

This also requires tracking a number of things on a per-machine basis that weren't before. Namely program overrides. In general we want to override for the host machine, but in some cases it makes sense to override for the build machine (such as for build only subprojects), so a native keyword has been added. This may be useful in cases where different output is needed for the host and build machine anyway.

I've made an effort to split out boilerplate changes (and there are several of them), to make this easier to review.

I won't be surprised if there's still some bugs in this, I've run it through some cross compilation on my system, but it's a large complicated set of changes.

dcbaker avatar Sep 15 '23 17:09 dcbaker