scons icon indicating copy to clipboard operation
scons copied to clipboard

Ninja Generation Tool

Open bdbaddog opened this issue 4 years ago • 4 comments

Summary This tool attempts to generically take a SCons build and generate a ninja file which is representative of the build and can be built by Ninja.

Ninja is a very fast build system, which is meant to have its build files generated by other systems. Ninja is especially good at iterative rebuilds and quick traversing a build graph to determine what needs to be rebuilt.

This PR is to introduce the ninja tool based off the ninja tool from mongodb's site tools.

This PR scope is BETA functionality of the ninja tool. It will not work well with all other tools and is primarily aimed at cross platform (win32/linux/osx) C/C++ builds. The goal of this PR is to get the tool to a point that it can be integrated in beta form.

Feature/Test List

Test Name Test Description Implemented
generate_and_build.py Generate and build simple C program X
generate_and_build_cxx.py Generate and build simple CPP program and check header deps X
generate_source.py Generate source with built C program and build C program from generated source X
multi_env.py Build two C programs with two seperate envs with one ninja file X
shell_commands.py Simple shell command to take in sources and build targets X
copy_function_command.py SCons "Copy" function action converted to command line for ninja X
build_libraries.py Build and linking C shared and static libraries X
iterative_speedup.py Make sure Ninja is faster than SCons in single file change rebuild (Would love to see this fail one day) X
output_orders.py Make sure outputs are ordered correctly in ninja file
existing_targets.py Make sure response files generate correctly even if existing targets are already built
unhandled_actions.py Unhandled actions will reinvoke scons without ninja to build just those targets
ninja_rule.py Create and register a custom ninja rule
command_line_targets.py Specify Alias and targets from command to build
non_ninja_nodes.py Make sure Scons is reinvoked on nodes which are not FS or Alias

Known Issues

Known Issue Description Github Issue
SCons doesn't have representive job pools to translate to ninja #3667
Ninja tool is global, affects all environments regardless of what environment its invoked in
Compilation Databases interactions between SCons and Ninja
Response files are always used even when not necessary
Targets and -j are not propagated to ninja correctly
TEMPLATE aggregation destroys order (need interactive mode)

Associated PRs

PR # Description
#3642 Initial experimental tool implemenation

Other Implementations NCAR/eol_scons's ninja implementation

Contributor Checklist:

  • [x] I have created a new test or updated the unit tests to cover the basic use.
  • [ ] I have created a new test or updated the unit tests to cover ninja specific Methods.
  • [ ] I have updated src/CHANGES.txt (and read the README.txt in that directory)
  • [ ] I have updated the appropriate documentation

bdbaddog avatar Apr 13 '21 21:04 bdbaddog

TEMPLATE aggregation destroys order (need interactive mode) is fixed by https://github.com/SCons/scons/pull/4039

dmoody256 avatar Apr 10 '22 06:04 dmoody256

Response files are always used even when not necessary may be fixed by #4133

dmoody256 avatar Apr 11 '22 18:04 dmoody256

Targets and -j are not propagated to ninja correctly fixed in #4140

dmoody256 avatar Jun 15 '22 04:06 dmoody256

Compilation Databases interactions between SCons and Ninja fixed in #4039.

In that PR ninja will defer to scons if the compilation database tool is in use, otherwise it will use ninjas compilation database.

dmoody256 avatar Jun 15 '22 04:06 dmoody256