### Install Ninja on OpenSUSE Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use zypper to install the Ninja build system on OpenSUSE. ```bash zypper in ninja ``` -------------------------------- ### Install Ninja on Gentoo Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use emerge to install the Ninja build system on Gentoo. ```bash emerge dev-build/ninja ``` -------------------------------- ### Install Ninja on FreeBSD Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use pkg to install the Ninja build system on FreeBSD. ```bash pkg install ninja ``` -------------------------------- ### Install Ninja with Pip Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use pip to install the Ninja build system. ```bash python -m pip install ninja ``` -------------------------------- ### Install Ninja with Spack Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use spack to install the Ninja build system. ```bash spack install ninja ``` -------------------------------- ### Install Ninja on Windows with WinGet Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use winget to install the Ninja build system on Windows. ```bash winget install Ninja-build.Ninja ``` -------------------------------- ### Install Ninja on Fedora Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use dnf to install the Ninja build system on Fedora. ```bash dnf install ninja-build ``` -------------------------------- ### Install Ninja on Windows with Scoop Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use scoop to install the Ninja build system on Windows. ```bash scoop install ninja ``` -------------------------------- ### Install Ninja on Void Linux Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use xbps-install to install the Ninja build system on Void Linux. ```bash xbps-install -S ninja ``` -------------------------------- ### Build Ninja Manual Source: https://github.com/ninja-build/ninja/wiki/Home Installs asciidoc and builds the Ninja manual. ```bash sudo apt-get install asciidoc --no-install-recommends ./ninja manual ``` -------------------------------- ### Install Ninja on Windows with Chocolatey Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use choco to install the Ninja build system on Windows. ```bash choco install ninja ``` -------------------------------- ### Configure and Bootstrap Ninja (Python) Source: https://github.com/ninja-build/ninja/blob/master/README.md Generates the ninja binary and a build.ninja file for building Ninja with itself. Use this for initial setup. ```bash ./configure.py --bootstrap ``` -------------------------------- ### Install Ninja on Debian/Ubuntu Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use apt-get to install the Ninja build system on Debian or Ubuntu-based systems. ```bash apt-get install ninja-build ``` -------------------------------- ### Install Ninja on macOS with Homebrew Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use brew to install the Ninja build system on macOS. ```bash brew install ninja ``` -------------------------------- ### Install Ninja on Arch Linux Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use pacman to install the Ninja build system on Arch Linux. ```bash pacman -S ninja ``` -------------------------------- ### Build Ninja Code Documentation Source: https://github.com/ninja-build/ninja/wiki/Home Installs doxygen and builds the code documentation for Ninja. ```bash sudo apt-get install doxygen ./ninja doxygen ``` -------------------------------- ### Install Ninja with Conda Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use conda to install Ninja from the conda-forge channel. ```bash conda install -c conda-forge ninja ``` -------------------------------- ### Install Ninja on Alpine Linux Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use apk to install the Ninja build system on Alpine Linux. ```bash apk add ninja ``` -------------------------------- ### Install Ninja on macOS with MacPorts Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Use port to install the Ninja build system on macOS. ```bash port install ninja ``` -------------------------------- ### Install Ninja on Rocky Linux Source: https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages Install Ninja on Rocky Linux by enabling the CodeReady Linux Builder (CRB) repository and then using dnf. ```bash dnf install dnf-plugins-core # Rocky 8 dnf config-manager --set-enabled powertools # Rocky 9+ dnf config-manager --set-enabled crb dnf install ninja-build ``` -------------------------------- ### Install Ninja Binary Source: https://github.com/ninja-build/ninja/blob/master/CMakeLists.txt Installs the ninja executable if the NINJA_BUILD_BINARY option is enabled. This makes the ninja binary available after the build process. ```cmake if(NINJA_BUILD_BINARY) install(TARGETS ninja) endif() ``` -------------------------------- ### Generate Doxygen Documentation Source: https://github.com/ninja-build/ninja/blob/master/README.md Builds Doxygen documentation for navigating Ninja's C++ code. Requires 'doxygen' to be installed. The documentation can be viewed by opening index.html in a browser. ```bash ./configure.py ``` ```bash ninja doxygen ``` -------------------------------- ### GCC Compilation in a Subdirectory Source: https://github.com/ninja-build/ninja/wiki/Batching-feature-roadmap Example of changing the current directory to 'obj/' before compiling C source files with GCC. ```sh $ cd obj/ $ gcc -c ../src/foo.c ../src/bar.c $ cd ../src ``` -------------------------------- ### Analyze Ninja Build Timing Statistics Source: https://github.com/ninja-build/ninja/wiki/Timing-Numbers Run Ninja with the '-d stats' flag to get detailed timing information for various build stages. This helps in identifying performance bottlenecks. ```bash C:\Users\evmar\chrome\src>ninja -C out\Debug -d stats chrome ninja: Entering directory `out\Debug' ninja: no work to do. metric count avg (us) total (ms) .ninja parse 843 641.1 540.4 canonicalize str 138729 0.0 0.1 canonicalize path 3058444 0.0 1.6 lookup node 3058444 0.0 13.7 .ninja_log load 1 21766.0 21.8 node stat 39061 685.9 26792.4 depfile load 9524 13010.2 123909.2 path->node hash load 0.19 (50685 entries / 262144 buckets) ``` ```bash C:\Users\evmar\chrome\src>ninja -C out\Debug -d stats chrome ninja: Entering directory `out\Debug' ninja: no work to do. metric count avg (us) total (ms) .ninja parse 843 662.4 558.4 canonicalize str 138729 0.0 0.0 canonicalize path 3058444 0.0 0.4 lookup node 3058444 0.0 0.7 .ninja_log load 1 21500.0 21.5 node stat 39061 150.1 5864.5 depfile load 9524 190.7 1816.3 path->node hash load 0.19 (50685 entries / 262144 buckets) ``` -------------------------------- ### Run afl-fuzz with ASan on Ninja (macOS) Source: https://github.com/ninja-build/ninja/wiki/Home Runs afl-fuzz to test the ASan-enabled Ninja binary on macOS. DYLD_LIBRARY_PATH may need adjustment based on your Clang version and installation. ```bash DYLD_LIBRARY_PATH=path/to//lib/clang/3.7.0/lib/darwin/ \ afl-fuzz -i misc/afl-fuzz -o /tmp/afl-fuzz-out ./ninja -n -f @@ ``` -------------------------------- ### Build Ninja on Windows with Visual Studio Source: https://github.com/ninja-build/ninja/wiki/Home Steps to build Ninja on Windows using Visual Studio, including setting up the build environment and running the configure script. ```batch > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 > python configure.py --bootstrap > ninja --help ``` -------------------------------- ### Generate Ninja Manual (PDF) Source: https://github.com/ninja-build/ninja/blob/master/README.md Generates the PDF version of the Ninja manual. Requires 'dblatext' to be in the system's PATH. Ensure configure.py has been run if not done previously. ```bash ./configure.py ``` ```bash ninja doc/manual.pdf ``` -------------------------------- ### Configure Ninja for Windows via MinGW on Linux (Ubuntu Precise) Source: https://github.com/ninja-build/ninja/wiki/Home Sets up environment variables for cross-compiling Ninja for Windows using MinGW-w64 on Ubuntu Precise. ```bash sudo apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 wine export CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ AR=i686-w64-mingw32-ar ``` -------------------------------- ### Non-optimal Full Build Execution Source: https://github.com/ninja-build/ninja/wiki/Batching-feature-roadmap Illustrates the command-line execution of a non-batched Ninja build, showing individual commands for compilation and linking. ```sh $ ninja [1/3] cc foo.c -o foo.o [2/3] cc bar.c -o bar.o [3/3] ld foo.o bar.o -o a.out ``` -------------------------------- ### Test-Driven Development Workflow for Ninja Source: https://github.com/ninja-build/ninja/wiki/Home Set up a command to build and run a specific Ninja test. This allows for iterative development and verification. ```bash ./ninja ninja_test && ./ninja_test --gtest_filter=MyTest.Name ``` -------------------------------- ### Configure Ninja for Windows via MinGW on Linux (Ubuntu Lucid) Source: https://github.com/ninja-build/ninja/wiki/Home Sets up environment variables for cross-compiling Ninja for Windows using MinGW on Ubuntu Lucid. ```bash sudo apt-get install gcc-mingw32 wine export CC=i586-mingw32msvc-cc CXX=i586-mingw32msvc-c++ AR=i586-mingw32msvc-ar ``` -------------------------------- ### Build Ninja with CMake (Enable Tests) Source: https://github.com/ninja-build/ninja/blob/master/README.md Builds the Ninja binary using CMake. To run unit tests after building, execute the ninja_test binary located in the build directory. ```bash cmake -Bbuild-cmake ``` ```bash cmake --build build-cmake ``` ```bash build-cmake/ninja_test ``` -------------------------------- ### Optimized Batch Build Execution Source: https://github.com/ninja-build/ninja/wiki/Batching-feature-roadmap Demonstrates the command-line execution of an optimized Ninja build using batching, where multiple files are processed by a single compiler command. ```sh $ ninja [1/2] cc --multiple foo.c foo.o bar.c bar.o [2/2] ld foo.o bar.o -o a.out ``` -------------------------------- ### Linux Build Stats (Slow Disk, Warm Cache) Source: https://github.com/ninja-build/ninja/wiki/Timing-Numbers Presents timing for the same Linux build as above, but with a warm cache, demonstrating a dramatic reduction in overall build time. ```bash $ time ninja -d stats -C out/Release chrome ninja: Entering directory `out/Release' [1/1] RULE Generate assembly offsets ../...n_asm_offsets_vp8.gen/asm_enc_offsets.o metric count avg (us) total (ms) .ninja parse 660 334.6 220.9 canonicalize str 101010 0.1 13.7 canonicalize path 1446311 0.1 104.0 lookup node 1446311 0.1 129.1 .ninja_log load 1 8407.0 8.4 node stat 39018 0.8 32.9 depfile load 9702 49.3 478.4 StartEdge 1 477.0 0.5 FinishEdge 1 5416.0 5.4 path->node hash load 0.50 (49319 entries / 98317 buckets) real 0m0.742s ``` -------------------------------- ### Linux Build Stats (Slow Disk, Cold Cache) Source: https://github.com/ninja-build/ninja/wiki/Timing-Numbers Shows timing for a Chrome build on Linux with a fast CPU but slow disk and cold cache, highlighting significantly increased depfile and node stat times. ```bash $ time ninja -d stats -C out/Release chrome ninja: Entering directory `out/Release' [1/1] RULE Generate assembly offsets ../...n_asm_offsets_vp8.gen/asm_enc_offsets.o metric count avg (us) total (ms) .ninja parse 660 1225.8 809.0 canonicalize str 101010 0.2 15.3 canonicalize path 1446311 0.1 151.0 lookup node 1446311 0.1 189.0 .ninja_log load 1 93559.0 93.6 node stat 39018 444.5 17343.1 depfile load 9702 2536.9 24613.1 StartEdge 1 779.0 0.8 FinishEdge 1 6757.0 6.8 path->node hash load 0.50 (49319 entries / 98317 buckets) real 0m43.043s ``` -------------------------------- ### Configure Ninja for Windows via MinGW on Arch Linux Source: https://github.com/ninja-build/ninja/wiki/Home Sets up environment variables for cross-compiling Ninja for Windows using MinGW-w64 on Arch Linux. Requires uncommenting the [multilib] section in pacman.conf. ```bash sudo pacman -S mingw-w64-gcc wine export CC=x86_64-w64-mingw32-cc CXX=x86_64-w64-mingw32-c++ AR=x86_64-w64-mingw32-ar export CFLAGS=-I/usr/x86_64-w64-mingw32/include ``` -------------------------------- ### Configure Ninja for Windows via Visual Studio Source: https://github.com/ninja-build/ninja/wiki/Home Configures Ninja for Windows using Python and Visual Studio command prompt. ```bash python configure.py --bootstrap ``` -------------------------------- ### Build Ninja with GoogleTest Support (Python) Source: https://github.com/ninja-build/ninja/blob/master/README.md Builds Ninja and its tests, specifying the path to the GoogleTest source directory. After building, run ninja_test to execute the test suite. ```bash ./configure.py --bootstrap --gtest-source-dir=/path/to/googletest ``` ```bash ./ninja all ``` ```bash ./ninja_test ``` -------------------------------- ### Generate Ninja Manual (HTML) Source: https://github.com/ninja-build/ninja/blob/master/README.md Generates the HTML version of the Ninja manual. Requires 'asciidoc' and 'xsltproc' to be in the system's PATH. ```bash ./configure.py ``` ```bash ninja manual doc/manual.html ``` -------------------------------- ### Linux Build Stats (Cold Cache) Source: https://github.com/ninja-build/ninja/wiki/Timing-Numbers Provides detailed statistics for a Chrome build on Linux with a cold cache, showing parse times, string canonicalization, path lookups, and file loading metrics. ```text %n -d stats chrome ninja: Entering directory `out/Release' ninja: no work to do. metric count avg (us) total (ms) .ninja parse 619 403.7 249.9 canonicalize str 96655 0.2 16.9 canonicalize path 1283411 0.1 95.5 lookup node 1283411 0.1 118.7 .ninja_log load 1 13398.0 13.4 node stat 36391 1.9 67.4 depfile load 8993 48.4 435.7 path->node hash load 0.94 (46017 entries / 49157 buckets) 0.57s user 0.15s system 98% cpu 0.728 total ``` -------------------------------- ### Basic Ninja Build Rules Source: https://github.com/ninja-build/ninja/wiki/Batching-feature-roadmap Defines basic rules for a compiler and a linker, and specifies build targets using these rules. This represents a non-batched build scenario. ```ninja rule cc command = cc $in -o $out rule link command = ld $in -o $out build foo.o: cc foo.c | baz.h build bar.o: cc bar.c | baz.h build a.out: foo.o bar.o ``` -------------------------------- ### Windows Build Stats (Slow Disk, Cold Cache) Source: https://github.com/ninja-build/ninja/wiki/Timing-Numbers Shows timing for a Chrome base_unittests build on Windows 7 with a slow disk and cold cache, indicating very high parse and depfile load times. ```powershell C:\Users\evmar\chrome\src> ninja -C out\Debug -d stats base_unittests ninja: Entering directory `out\Debug' ninja: no work to do. metric count avg (us) total (ms) .ninja parse 843 4975.8 4194.6 canonicalize str 138729 0.0 0.5 canonicalize path 187273 0.0 0.1 lookup node 187273 0.0 1.3 .ninja_log load 1 37763.0 37.8 node stat 1879 543.0 1020.3 depfile load 635 6834.0 4339.6 path->node hash load 0.15 (39437 entries / 262144 buckets) ``` -------------------------------- ### Build Ninja with afl-clang++ for Fuzzing Source: https://github.com/ninja-build/ninja/wiki/Home Configures and builds Ninja using afl-clang++ for fuzz testing. Ensure afl-clang++ is in your PATH. ```bash CXX=path/to/afl-1.20b/afl-clang++ ./configure.py ninja ``` -------------------------------- ### Clone and Checkout Ninja Repository Source: https://github.com/ninja-build/ninja/wiki/Home Clone the Ninja repository and checkout the release branch. This is a prerequisite for building Ninja. ```bash git clone https://github.com/ninja-build/ninja.git && cd ninja git checkout release ``` -------------------------------- ### Build Ninja with ASan and afl-clang++ Source: https://github.com/ninja-build/ninja/wiki/Home Configures and builds Ninja with AddressSanitizer (ASan) and afl-clang++. The '-isysroot' flag is for macOS; adjust as needed. Ensure LLVM checkout includes libc++ if needed. ```bash CFLAGS="-fsanitize=address -isysroot $(xcrun -show-sdk-path)" \ LDFLAGS=-fsanitize=address CXX=path/to/afl-1.20b/afl-clang++ \ ./configure.py AFL_CXX=path/to/clang++ ninja ``` -------------------------------- ### Configure and Build Ninja for Windows via MinGW on Linux Source: https://github.com/ninja-build/ninja/wiki/Home Configures Ninja for MinGW cross-compilation on Linux and builds the executable using a Linux Ninja binary. ```bash ./configure.py --platform=mingw --host=linux /path/to/linux/ninja ``` -------------------------------- ### Mac Build Stats (HDD, Cold Cache) Source: https://github.com/ninja-build/ninja/wiki/Timing-Numbers Details timing for a Chrome build on Mac OS X with an HDD and cold cache, showing high parse and depfile load times. ```bash $ ninja -C out/Release/ chrome -d stats ninja: Entering directory `out/Release/' ninja: no work to do. metric count avg (us) total (ms) .ninja parse 685 827.5 566.8 canonicalize str 117297 0.3 31.6 canonicalize path 1160719 0.2 181.0 lookup node 1160719 0.2 210.0 .ninja_log load 1 39455.0 39.5 node stat 39611 4.6 183.3 depfile load 9784 90.7 887.8 path->node hash load 0.50 (49370 entries / 98317 buckets) Empty build takes 1.33s warm-cache, 58s cold-cache ``` -------------------------------- ### Windows Build Stats (Hot Cache) Source: https://github.com/ninja-build/ninja/wiki/Timing-Numbers Presents timing for the same Windows build as above, but with a hot cache, showing a significant reduction in parse and depfile load times. ```powershell C:\Users\evmar\chrome\src> ninja -C out\Debug -d stats base_unittests ninja: Entering directory `out\Debug' ninja: no work to do. metric count avg (us) total (ms) .ninja parse 843 693.6 584.7 canonicalize str 138729 0.0 0.4 canonicalize path 187273 0.0 0.1 lookup node 187273 0.0 0.3 .ninja_log load 1 23197.0 23.2 node stat 1879 110.1 206.9 depfile load 635 78.3 49.7 path->node hash load 0.15 (39437 entries / 262144 buckets) ``` -------------------------------- ### Mac Build Stats (SSD, Warm Cache) Source: https://github.com/ninja-build/ninja/wiki/Timing-Numbers Presents timing for a Chrome build on Mac OS X with an SSD and warm cache, showing significantly faster performance compared to cold cache or HDD. ```text ninja -C out/Release/ chrome -d stats ninja: Entering directory `out/Release/' ninja: no work to do. metric count avg (us) total (ms) .ninja parse 685 550.7 377.2 canonicalize str 117383 0.2 19.4 canonicalize path 1161235 0.1 97.4 lookup node 1161235 0.1 130.1 .ninja_log load 1 15513.0 15.5 node stat 39611 2.7 107.6 depfile load 9783 53.3 521.5 path->node hash load 0.50 (49367 entries / 98317 buckets) Empty build takes 0.77s warm-cache, 8s cold-cache ``` -------------------------------- ### Run Ninja for Windows via MinGW on Linux Source: https://github.com/ninja-build/ninja/wiki/Home Runs the built Ninja executable for Windows using wine on a Linux system. ```bash ./ninja.exe ``` -------------------------------- ### Reconfigure Ninja for Windows via MinGW on Windows Source: https://github.com/ninja-build/ninja/wiki/Home Reconfigures Ninja for Windows using MinGW and Python. ```bash python configure.py ``` -------------------------------- ### Alternative Ninja Rule Syntax for Batching Source: https://github.com/ninja-build/ninja/wiki/Batching-feature-roadmap Presents an alternative proposed syntax for Ninja rules to support batching, using '$ins' and '$outs' variables. ```ninja rule cc: cc $ins --outputs $outs ``` -------------------------------- ### Generate Coverage Reports with gcov Source: https://github.com/ninja-build/ninja/wiki/Home Runs the Ninja test binary to generate coverage data files and then uses gcov to create human-readable coverage reports. ```bash ./ninja_test gcov build/*.o ``` -------------------------------- ### Configure Google Test Fetching Source: https://github.com/ninja-build/ninja/blob/master/CMakeLists.txt Fetches Google Test if it's not found, ensuring compatibility with the project's minimum CMake version. This is used for building tests. ```cmake if(BUILD_TESTING) # Can be removed if cmake min version is >=3.24 if (POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() find_package(GTest) if(NOT GTest_FOUND) include(FetchContent) FetchContent_Declare( googletest # GoogleTest v1.17.0 requires at least cmake 3.16, v1.16.0 requires at least cmake 3.13 which # is within the ninja project minimum requirement. URL https://github.com/google/googletest/releases/download/v1.16.0/googletest-1.16.0.tar.gz URL_HASH SHA256=78c676fc63881529bf97bf9d45948d905a66833fbfa5318ea2cd7478cb98f399 ) FetchContent_MakeAvailable(googletest) endif() # Tests all build into ninja_test executable. add_executable(ninja_test src/build_log_test.cc src/build_test.cc src/clean_test.cc src/clparser_test.cc src/depfile_parser_test.cc src/deps_log_test.cc src/disk_interface_test.cc src/dyndep_parser_test.cc src/edit_distance_test.cc src/elide_middle_test.cc src/explanations_test.cc src/graph_test.cc src/jobserver_test.cc src/json_test.cc src/lexer_test.cc src/manifest_parser_test.cc src/missing_deps_test.cc src/ninja_test.cc src/state_test.cc src/string_piece_test.cc src/string_piece_util_test.cc src/subprocess_test.cc src/test.cc src/util_test.cc ) if(WIN32) target_sources(ninja_test PRIVATE src/includes_normalize_test.cc src/msvc_helper_test.cc windows/ninja.manifest) if(MSVC) # Silence warnings about using unlink rather than _unlink target_compile_definitions(ninja_test PRIVATE _CRT_NONSTDC_NO_DEPRECATE) endif() endif() find_package(Threads REQUIRED) target_link_libraries(ninja_test PRIVATE libninja libninja-re2c GTest::gtest Threads::Threads) foreach(perftest build_log_perftest canon_perftest clparser_perftest depfile_parser_perftest elide_middle_perftest hash_collision_bench manifest_parser_perftest ) add_executable(${perftest} src/${perftest}.cc) target_link_libraries(${perftest} PRIVATE libninja libninja-re2c) endforeach() if(CMAKE_SYSTEM_NAME STREQUAL "AIX" AND CMAKE_SIZEOF_VOID_P EQUAL 4) # These tests require more memory than will fit in the standard AIX shared stack/heap (256M) target_link_options(hash_collision_bench PRIVATE "-Wl,-bmaxdata:0x80000000") target_link_options(manifest_parser_perftest PRIVATE "-Wl,-bmaxdata:0x80000000") endif() add_test(NAME NinjaTest COMMAND ninja_test) endif() ``` -------------------------------- ### Run afl-fuzz on Ninja Source: https://github.com/ninja-build/ninja/wiki/Home Executes afl-fuzz to fuzz test the Ninja binary. The '-n -f @@' arguments are specific to how Ninja handles input files. ```bash afl-fuzz -i misc/afl-fuzz -o /tmp/afl-fuzz-out ./ninja -n -f @@ ``` -------------------------------- ### Generate Release Credits Source: https://github.com/ninja-build/ninja/blob/master/RELEASING.md Generate a list of committers for the release notes using git shortlog. ```git git shortlog -s --no-merges REV.. ``` -------------------------------- ### Update Website Repository Source: https://github.com/ninja-build/ninja/blob/master/RELEASING.md Execute the update-docs.sh script within the ninja-build.github.io repository to update documentation. ```shell ./update-docs.sh ``` -------------------------------- ### Clean and Build Ninja Tests with Coverage Flags Source: https://github.com/ninja-build/ninja/wiki/Home Performs a clean debug build of Ninja with coverage flags enabled and then builds and runs the Ninja tests. ```bash CFLAGS=-coverage LDFLAGS=-coverage ./configure.py --debug ninja -t clean ninja_test && ninja ninja_test ``` -------------------------------- ### Configure Ninja with Clang Compiler Source: https://github.com/ninja-build/ninja/wiki/Home Set the CXX environment variable to clang++ when configuring Ninja to use the Clang compiler. ```bash CXX=clang++ ./configure.py ``` -------------------------------- ### Configure Ninja in Debug Mode Source: https://github.com/ninja-build/ninja/wiki/Home Build Ninja in debug mode for faster development cycles, especially on Windows. This disables optimizations. ```bash ./configure.py --debug ``` -------------------------------- ### Ninja Rule with Batching Command Source: https://github.com/ninja-build/ninja/wiki/Batching-feature-roadmap Defines a Ninja rule that includes a 'batch_command' for handling multiple input/output files in a single invocation. This is a proposed syntax for batching. ```ninja rule cc command = cc $in -o $out batch_command = cc --multiple $batch{$in $out} ``` -------------------------------- ### Configure CMake Build for Ninja (Disable Tests) Source: https://github.com/ninja-build/ninja/blob/master/README.md Configures the CMake build for Ninja, disabling the building of unit tests. The ninja binary will be placed in the specified build directory. ```bash cmake -Bbuild-cmake -DBUILD_TESTING=OFF ``` ```bash cmake --build build-cmake ``` -------------------------------- ### Add Browse Mode to Ninja Binary Source: https://github.com/ninja-build/ninja/blob/master/CMakeLists.txt Conditionally adds browse mode to the ninja binary if the host platform supports it. This involves inlining a Python script into a header file. ```cmake if(platform_supports_ninja_browse) # Inlines src/browse.py into the browse_py.h header, so that it can be included # by src/browse.cc add_custom_command( OUTPUT build/browse_py.h MAIN_DEPENDENCY src/browse.py DEPENDS src/inline.sh COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/build COMMAND src/inline.sh kBrowsePy < src/browse.py > ${PROJECT_BINARY_DIR}/build/browse_py.h WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM ) if(NINJA_BUILD_BINARY) target_compile_definitions(ninja PRIVATE NINJA_HAVE_BROWSE) target_sources(ninja PRIVATE src/browse.cc) endif() set_source_files_properties(src/browse.cc PROPERTIES OBJECT_DEPENDS "${PROJECT_BINARY_DIR}/build/browse_py.h" INCLUDE_DIRECTORIES "${PROJECT_BINARY_DIR}" COMPILE_DEFINITIONS NINJA_PYTHON="${NINJA_PYTHON}" ) endif() ``` -------------------------------- ### Measure Ninja Performance Impact Source: https://github.com/ninja-build/ninja/wiki/Home Use the measure.py script to assess the performance impact of changes by repeatedly running a command and summarizing its runtime. ```bash path/to/misc/measure.py path/to/my/ninja chrome ``` -------------------------------- ### Ninja Rule with Batch Command and Depfile Source: https://github.com/ninja-build/ninja/wiki/Batching-feature-roadmap Defines a Ninja rule for a C compiler that supports batch compilation and dependency file generation. ```ninja rule cc command = cc $in -o $out --dep-file $out.d batch_command = cc --multiple-with-deps $batch{$in $out $out.d} depfile = $out.d ``` -------------------------------- ### Ninja Rule with Batch Command and Separate Batch Depfile Source: https://github.com/ninja-build/ninja/wiki/Batching-feature-roadmap Defines a Ninja rule for a C compiler supporting batch compilation with a separate dependency file for the batch. ```ninja rule cc command = cc $in -o $out --dep-file $out.d batch_command = cc --multiple $batch{$in $out} --dep-file $batch_name.d batch_depfile = $batch_name.d ``` -------------------------------- ### Commit Website Changes Source: https://github.com/ninja-build/ninja/blob/master/RELEASING.md Commit the changes made to the website repository after running the update script and updating the index.html. ```git git commit -m 'run update-docs.sh, 1.5.0 release' git push origin master ``` -------------------------------- ### Tag and Push Release Source: https://github.com/ninja-build/ninja/blob/master/RELEASING.md Commit the release tag, push the release branch, and push tags to the remote repository. Also, push the version update on the master branch. ```git git commit -am v1.5.0; git push origin release git tag v1.5.0; git push --tags # Push the 1.5.0.git change on master too: git checkout master; git push origin master ``` -------------------------------- ### Commit Version Update Source: https://github.com/ninja-build/ninja/blob/master/RELEASING.md Commit the change to src/version.cc after updating the version number. ```git git commit -am 'mark this 1.5.0.git' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.