Support inclusion of entire subprojects

46 views
Skip to first unread message

rexroni

unread,
Feb 10, 2022, 1:34:38 AMFeb 10
to ninja-build
If I'm writing a larger build system that glues other build systems together, it would be nice if the parent build system could hook into the child build system without any modification to the child build system.  If both build systems are CMake, then CMake will let you do this in the CMake layer (only one ninja build system is generated afterwards).

I would like to be able to do this at the ninja layer, rather than the CMake layer.  This would be cool because ninja is generated by a wide variety of build systems.  So if one ninja build system could hook into another ninja build system, then it would be possible for e.g. a Meson-based parent build system to meaningfully include a CMake-based child build system as a subcomponent.  With how wide-spread ninja is, suddenly a lot of build systems could interact with each other about as easily as CMake lets you include another CMake project with add_subdirectory().

I've started a draft of the work to make sure it was possible to do this.  It's not hard; as far as I can tell:
  • when ninja is reading the ninja files in a subproject, it needs to prefix all of the input and output paths with the name of the subdirectory during parsing
  • the subproject should run in a scope with no shared information from the parent's BindingEnv (except certain globals like the phony rule), which is different behavior than `include` or `subninja`.
  • when evaluating commands, it needs to chdir into the subdirectory before running the command, and the $in and $out variables need to be expanded without the implicitly added prefix.  Since $in and $out are already handled specially, this creates very little new special-casing.

jha...@gmail.com

unread,
Feb 10, 2022, 1:55:23 AMFeb 10
to ninja-build

rexroni

unread,
Feb 10, 2022, 9:51:42 AMFeb 10
to jha...@gmail.com, ninja-build
Oh, yeah that's extremely similar to what I wrote.

It also looks pretty stalled. Is there anything I can help with to make
that PR a reality? Even something unrelated (if there's just too much
to do)?
> --
> You received this message because you are subscribed to a topic in the Google
> Groups "ninja-build" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/
> ninja-build/djwhkEQqam0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ninja-build...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/
> ninja-build/a11f96e1-5d29-4af8-826b-a7c5a41c5050n%40googlegroups.com.

LaMont Jones

unread,
Feb 10, 2022, 2:14:26 PMFeb 10
to rexroni, jha...@gmail.com, ninja-build
I'm also interested in getting https://github.com/ninja-build/ninja/pull/1578 landed.  I'll take a longer look at it sometime this week or next.

You received this message because you are subscribed to the Google Groups "ninja-build" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ninja-build/YgUiaxGVuHCcddx4%40archenemy.localdomain.
Reply all
Reply to author
Forward
0 new messages