a small build system with a focus on speed

Related tags

Build Systems ninja
Overview

Ninja

Ninja is a small build system with a focus on speed. https://ninja-build.org/

See the manual or doc/manual.asciidoc included in the distribution for background and more details.

Binaries for Linux, Mac, and Windows are available at GitHub. Run ./ninja -h for Ninja help.

Installation is not necessary because the only required file is the resulting ninja binary. However, to enable features like Bash completion and Emacs and Vim editing modes, some files in misc/ must be copied to appropriate locations.

If you're interested in making changes to Ninja, read CONTRIBUTING.md first.

Building Ninja itself

You can either build Ninja via the custom generator script written in Python or via CMake. For more details see the wiki.

Python

./configure.py --bootstrap

This will generate the ninja binary and a build.ninja file you can now use to build Ninja with itself.

CMake

cmake -Bbuild-cmake -H.
cmake --build build-cmake

The ninja binary will now be inside the build-cmake directory (you can choose any other name you like).

To run the unit tests:

./build-cmake/ninja_test
Issues
  • Added support for environment variable NINJA_FLAGS

    Added support for environment variable NINJA_FLAGS

    The value of the variable is parsed like command line arguments. You can for instance use less cores than available (-j), or limit the parallelism based on the system load (-l). For instance, on a build server used by multiple users, you may want to set NINJA_FLAGS=-l 1 on the system level, so that the server never gets overloaded by parallel ninja builds. Command line parameters override the flags set with NINJA_FLAGS.

    opened by ocroquette 71
  • Ninja UTF8 conversion: Using native windows API for conversion.

    Ninja UTF8 conversion: Using native windows API for conversion.

    WIP for issue #1195. Updated version using windows native API for converting between wide and utf8 for increased speed. Fixed buildissue for mingw and added needed defines to the cmake script.

    Metrics for building chromium ` Ninja Master metric count avg (us) total (ms) .ninja parse 4849 1931.3 9364.8 canonicalize str 1889079 0.0 58.5 canonicalize path 1985429 0.0 42.8 lookup node 1932008 0.0 36.7 .ninja_log load 1 1504.0 1.5 .ninja_deps load 1 1314.0 1.3 node stat 7363 285.0 2098.4 depfile load 22 184.6 4.1 StartEdge 823 5840.9 4807.1 FinishCommand 822 3970.5 3263.8 CLParser::Parse 753 618.3 465.6

    Ninja UTF8-version metric count avg (us) total (ms) .ninja parse 4849 2104.7 10205.6 canonicalize str 1889079 0.0 90.5 canonicalize path 1985429 0.0 60.8 lookup node 1933885 0.1 169.9 .ninja_log load 1 2000.0 2.0 .ninja_log recompact 1 14878.0 14.9 node stat 8748 260.8 2281.1 .ninja_deps load 1 3960.0 4.0 depfile load 22 209.7 4.6 StartEdge 823 5909.6 4863.6 FinishCommand 822 908.7 746.9 CLParser::Parse 753 615.2 463.2 `

    windows 
    opened by jlonnberg 43
  • missingdeps tool, take 2

    missingdeps tool, take 2

    This is a tool that detects some classes of random build failure causes around generated files (in Chrome, these are usually generated headers for C/C++). It takes several seconds to run, (more if the optional scan for files with no generator is used), and allows fixing a significant number of build system issues before they happen to randomly break someone's build.

    The check relies on the correctness of depfile information, and on having all generator outputs listed. These things are usually easier to get right than proper deps. There's some overlap between this and gn check, but unlike gn check, this checks the actual ninja build graph and sees all issues.

    This is a redo of https://github.com/ninja-build/ninja/pull/1031, it's been a while so I think it maybe better to start from scratch.

    opened by ilor 39
  • Provide resiliency against inputs changing during the build

    Provide resiliency against inputs changing during the build

    This is a better, faster approach than #1753 for providing robustness against inputs changing during the build. It fixes #1162 and #1940.

    When recording the outputs' mtimes when the command finishes, use the remembered temporary file's mtime from when the edge started for recording in the build log. Subsequent runs will use that as the mtime for the output.

    This provides robustness against inputs changing while the command itself is running. If an input is changed, the subsequent run will detect the output as dirty since its recorded mtime reflects when the build command began, not when the output was actually written to disk.

    opened by jdrouhard 38
  • Build ninja with C++11

    Build ninja with C++11

    In order to allow future use of std::chrono to make the stats code portable it is desirable to compile with C++11. Doing so also allows use of std::unordered_map, and reduces the number of #ifdefs in the ninja source code.

    Switching to C++11 requires modifying both CMakeLists.txt and configure.py, for MSVC and for other build systems. For MSVC the required change is adding /Zc:__cplusplus to tell the compiler to give a more accurate value for the __cplusplus macro. For other platforms the change is to add -std=c++11 or the CMake equivalent.

    This change makes some progress towards resolving issue #2004.

    opened by randomascii 36
  • C++ standard in use?

    C++ standard in use?

    I've been reviewing the source for ninja, and see a lot of areas where c++11 or newer features would be nice to have, but aren't currently used, like the "= default;" keyword for constructors and destructors, ranged based for loops, nullptr, lambdas, constexpr, so on.

    What's the maximum c++ version that ninja's codebase abides by?

    opened by jonesmz 34
  • ninja: error: loading 'build.ninja': No such file or directory

    ninja: error: loading 'build.ninja': No such file or directory

    environment :Mac
    Install ninja with the brew intsall ninja command then on terminal execute ninja occur ninja: error: loading 'build.ninja': No such file or directory 。 ➜ ~ ninja ninja: error: loading 'build.ninja': No such file or directory ➜ ~

    Why is this problem still occurring when you have successfully installed ninja?

    opened by MRYangY 32
  • Fix depfile parser handling of multiple rules

    Fix depfile parser handling of multiple rules

    Currently we handle Makefile rules of the form:

    out: in1 in2 in3
    

    and the form:

    out: in1 \
         in2 \
         in3
    

    Teach the depfile parser to handle the additional form:

    out: in1
    out: in2
    out: in3
    

    This is also valid Makefile syntax and is the depfile format generated by the Intel Compiler for Windows.

    opened by bradking 32
  • Add option to force rebuild

    Add option to force rebuild

    Ninja lacks an option to force re-building of a particular target, like the make -B option.

    I would be willing to implement this if someone could guide me through what needs to be done.

    feature 
    opened by mgaunard 32
  • Be smarter about mtimes when stat()'ing symlinks.

    Be smarter about mtimes when stat()'ing symlinks.

    Before this change, symlinks were always followed when retrieving mtimes. This can cause ninja to think targets are stale when outputs are symlinks.

    This patch introduces the following stat() logic for symlinks:

    1. When Stat()ing inputs, use the newer of the symlink or what it points to.
    • By looking at both, it maintains the pre-existing behaviour, where you could use a symlink as an input and ninja would know to rebuild when the thing it points to changes.
      1. When Stat()ing outputs, always use the timestamp of the symlink.
    • If it's listed as an output, then it contains the only mtime ninja should care about.

    Fixes Bug #1186

    opened by agrieve 29
  • Too-long command lines should be handled

    Too-long command lines should be handled

    On Windows (XP or greater), Command lines are limited in length to 8,191 bytes.

    Windows compiler toolsets (and gcc) get around this by allowing the @filepath syntax on the command line.

    e.g. link.exe @Temp\MyLongLinkLinesInAFile.rsp

    will run link.exe, which will then use the contents of the file Temp\MyLongLinkLinesInAFile.rsp as if they were on the command line.

    This issue is to suggest that it is only ninja that could know the command line is being exceeded. A generator of .ninja files could know they are getting close, but couldn't know that 8.191 bytes exactly has been reached.

    This issue is raised to ask if a patch to ninja that wrote >8191 character command lines into a file then called the build rule with the file (ninja to name the file) could be acceptable. If so, what exactly should the patch do? I propose:

    ninja detects it's on Windows and total command line to run is >8,191 characters ninja creates a .rsp file in Temp with a unique name ninja writes command line argument contents into that file ninja invokes the original command line first argument but with the @filename syntax ninja cleans up the .rsp file

    Do others have any thoughts on this?

    opened by philipcraig 28
  • Handle ERROR_DIRECTORY when calling FindFirstFileExA

    Handle ERROR_DIRECTORY when calling FindFirstFileExA

    If a directory referenced by .ninja_deps has changed to a regular file since the last build, FindFirstFileExA will return ERROR_DIRECTORY.

    Fixes #2159

    opened by zmodem 0
  • "error: FindFirstFileExA(...): The directory name is invalid." when directory in .ninja_deps changes to regular file on Windows

    To reproduce on Windows:

    C:\src\temp\ninja_bug>type build.ninja
    msvc_deps_prefix = Note: including file:
    rule cc
      deps = msvc
      command = cl -showIncludes -c $in -Fo$out
    
    build foo.obj: cc foo.c
    
    C:\src\temp\ninja_bug>type foo.c
    #include "bar/bar.h"
    
    C:\src\temp\ninja_bug>type bar\bar.h
    void f() {}
    
    C:\src\temp\ninja_bug>ninja foo.obj
    [1/1] cl -showIncludes -c foo.c -Fofoo.obj
    Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29336 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    C:\src\temp\ninja_bug>ren bar baz
    
    C:\src\temp\ninja_bug>echo > bar
    
    C:\src\temp\ninja_bug>ninja foo.obj
    ninja: error: FindFirstFileExA(bar): The directory name is invalid.
    

    The problem is that StatAllFilesInDir() does not handle FindFirstFileExA returning ERROR_DIRECTORY. A fix for this was already merged as 6c864097ef11da366fb4070e6ab9f34d6a293766 a few years ago, but later reverted in 49626c3610826a49f5fa7aee139415fe03d650fd. It's not clear why it was reverted (problems with the test?), but I believe the fix was correct.

    (We hit this in Chromium after a reverted update of libc++ changed __string from a directory to a regular file, see http://crbug.com/1337238)

    windows bug 
    opened by zmodem 0
  • Escape sequences sometimes do not work in Windows Terminal since Ninja 1.11

    Escape sequences sometimes do not work in Windows Terminal since Ninja 1.11

    Since upgrading to Ninja 1.11, I sometimes see output like the following when building with ninja in a Powershell in Windows Terminal:

    [58/26320] [...] Compiling C:/some/folder/something.c←[Ksome_incomplete_path/foo.cpp←[Kbar.cpp←[K←[KK

    This does not happen for all builds and unfortunately, since our project is quite large and complicated, I have not yet been able to reproduce the circumstances that cause escape sequences to misbehave. As a consequence, I am also not sure whether this is a bug in Windows Terminal or ninja. What I do know, however, is that this issue does not occur in 1.10.2, ~which suggests it may be related to the following change: https://github.com/ninja-build/ninja/pull/2085~

    windows bug 
    opened by mbs-c 4
  • C++11: Use range based for loops where practical

    C++11: Use range based for loops where practical

    This is the first of 6 patches for ninja from the Splinter project which depend on C++11.

    Now that C++11 is enabled on all platforms, I propose this patch to be merged into the ninja code, allowing contributors to have a much more understandable and modern codebase.

    While I would have preferred to see https://github.com/ninja-build/ninja/pull/1958 merged first (Editing this PR to not explicitly depend on 1958 took a good 40 minutes...), I've been waiting years for https://github.com/ninja-build/ninja/pull/1958 to be merged.

    I won't open a PR for any of my other C++11 patches at the time, as removing their dependency relationship on each other would be more time than I have available currently.

    Ideally this PR will be merged promptly so that the next patch can be taken as-is.

    opened by jonesmz 0
  • Remove the contributing guideline for adding Google Inc. as copyright holder to all contributions

    Remove the contributing guideline for adding Google Inc. as copyright holder to all contributions

    Per discussion here https://github.com/ninja-build/ninja/pull/1812#discussion_r456275065: Google does not request this, and claims to not have any ownership of the Ninja project.

    This request in CONTRIBUTING.md is a legal liability, as well as unethical, to ask people to claim that Google holds the copyright for code that Google does not own, and did not contribute to the project.

    This is also not very compatible with the Github user agreement, which specifies that code contributions to a project are, by default, licensed under the project's configured license, but explicitly says that the copyright of the code remains the original authors copyright.

    https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#3-ownership-of-content-right-to-post-and-license-grants https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#6-contributions-under-repository-license

    Finally, this requirement IS turning away potential contributors, who feel that it is an unreasonable contributing guideline, or who are otherwise forbidden/unable, regardless of willingness, from assigning copyright to Google Inc. without a real contributor license agreement that can be reviewed and signed.

    Both the Google and Microsoft legal departments have commented on this (see linked issue above) saying that this requirement is either not asked for (by Google), or not acceptable (by Microsoft).

    Note also that all maintainers of this project have been pinged at least once on the issue, and have refused to comment on it for several years now: https://github.com/ninja-build/ninja/pull/1616#discussion_r310374298

    opened by jonesmz 0
Releases(v1.11.0)
CMake module to speed up builds.

cotire Cotire (compile time reducer) is a CMake module that speeds up the build process of CMake based build systems by fully automating techniques as

Sascha Kratky 1.3k Jun 15, 2022
Tundra is a code build system that tries to be accurate and fast for incremental builds

Tundra, a build system Tundra is a high-performance code build system designed to give the best possible incremental build times even for very large s

Andreas Fredriksson 370 Jun 24, 2022
muon is an implementation of the meson build system in C with minimal dependencies.

muon muon is an implementation of the meson build system in C with minimal dependencies. Non-features bug-for-bug compatibility with meson. In fact, m

Stone Tickle 38 Jun 22, 2022
A basic build system for the Skript scripting language.

skib A basic build system for the Skript scripting language. Features #include other files recursively #define preprocessor symbols and macros Usage #

Daniel 1 Feb 3, 2022
NeoWorld is a resampler using the CMake build system

NeoWorld is a resampler using the CMake build system. It's designed for utsu, OpenUTAU, and UTAU.

null 4 Jun 24, 2022
Improved build system generator for CPython C, C++, Cython and Fortran extensions

scikit-build Improved build system generator for CPython C/C++/Fortran/Cython extensions. Better support is available for additional compilers, build

null 328 Jun 24, 2022
Arduino CMake Build system

Arduino Cmake Example Project This is the Cmake project settings for the Arduino platform. You can use this project as an example to develop C++ progr

Francois Campbell 55 May 23, 2022
An Enhancement Suite for the CMake Build System

A CMake Enhancement Suite Usage Look through the files in the package. Most functions will be commented and the other's usage can be inferred. All fun

Tobias Becker 393 Jun 20, 2022
nabs is a single-header library for writing build recipes in C++

nabs is a single-header library for writing build recipes in C++. It is directly inspired by nobuild, but with more feature (bloat) and built-in support for makefile-like dependency resolution.

zhiayang 6 May 8, 2021
Yet another post-build step and class to bring reflection to C++ enumerations.

enum_values Yet another post-build step and class to bring reflection to C++ enumerations! Fair warning: this project has not undergone much testing (

null 12 May 11, 2022
curl cmake module libcurl build with msvc x86

curl-msvc Infomation curl cmake module libcurl build with MSVC10.0 arch (x86 | i386) source from https://github.com/curl/curl tags: curl-7_79_1 Usage

Jason Payne 0 May 16, 2022
Project to enable using CMake from a Maven build.

CMake-Maven-Project Introduction A Maven project for the CMake build system. It can be used by including it as a plugin within your Maven project's po

null 59 May 27, 2022
Examples of using Hunter package manager to build and run Android application.

Examples of using Hunter package manager to build and run Android application. Requirements Android NDK Go to download page and choose NDK for your pl

null 34 Mar 13, 2022
CMake and other scripts to help build process of FlyEM software

The BuildEM System The buildem repo is a modular CMake-based system that leverages CMake's ExternalProject to simplify and automate a complex build pr

null 27 Jun 9, 2022
📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Setup-free CMake dependency management CPM.cmake is a CMake script that adds dependency management capabilities to CMake. It's built as a thin wrapper

CPM.cmake 1.2k Jun 27, 2022
A small c++ template with modern CMake

C++/CMake modern boilerplate This is a template for new projects, gives a good CMake base and a few dependencies you most likely want in your project.

Clément Grégoire 257 Jun 18, 2022
By putting in a lot of speed, the speed sequence is sorted and divided, three types of speed interval distribution maps are generated.(including broken line graph,histogram and curve graph)

Auto-drawing-speed-range-map By putting in a lot of speed, the speed sequence is sorted and divided, three types of speed interval distribution maps a

wellwellAllwen 4 May 14, 2022
A cross-platform HTTP client library with a focus on usability and speed

EasyHttp A cross-platform HTTP client library with a focus on usability and speed. Under its hood, EasyHttp uses POCO C++ Libraries and derives many o

Sony 141 Jun 17, 2022
Speed Running and Competition Doom. For strictly vanilla speed runs and competitions - forked from CNDoom

Speed Running and Competition Doom Speed Running and Competition Doom is based on Chocolate Doom and aims to accurately reproduce the original DOS ver

Gibbon 3 May 24, 2022
Orbit is a multiplatform-focus graphical engine build on top of OpenGl, ImGui

Orbit Engine Orbit is a multiplatform-focus graphical engine build on top of OpenGl, ImGui and more... The development of the engine is documented via

Madsycode 11 Jul 3, 2021
Entity-Component-System (ECS) with a focus on ease-of-use, runtime extensibility and compile-time type safety and clarity.

Kengine The Koala engine is a type-safe and self-documenting implementation of an Entity-Component-System (ECS), with a focus on runtime extensibility

Nicolas Phister 451 Jun 7, 2022
A fast build system that encourages the creation of small, reusable modules over a variety of platforms and languages.

Buck Buck is a build tool. To see what Buck can do for you, check out the documentation at http://buck.build/. Installation Since Buck is used to buil

Facebook 8.3k Jun 24, 2022
Duktape - embeddable Javascript engine with a focus on portability and compact footprint

Duktape ⚠️ Master branch is undergoing incompatible changes for Duktape 3.x. To track Duktape 2.x, follow the v2-maintenance branch. Introduction Dukt

Sami Vaarala 5.3k Jun 23, 2022
This is a fork of prboom+ with extra tooling for demo recording and playback, with a focus on speedrunning.

dsda-doom v0.15.1 This is a fork of prboom+ with extra tooling for demo recording and playback, with a focus on speedrunning. Heretic Support (beta) D

Ryan Krafnick 97 Jun 20, 2022
Nano is a digital payment protocol designed to be accessible and lightweight, with a focus on removing inefficiencies present in other cryptocurrencies.

Nano is a digital payment protocol designed to be accessible and lightweight, with a focus on removing inefficiencies present in other cryptocurrencies. With ultrafast transactions and zero fees on a secure, green and decentralized network, this makes Nano ideal for everyday transactions.

Nano 3.4k Jun 23, 2022
Nano is a digital payment protocol designed to be accessible and lightweight, with a focus on removing inefficiencies present in other cryptocurrencies.

Nano is a digital payment protocol designed to be accessible and lightweight, with a focus on removing inefficiencies present in other cryptocurrencies. With ultrafast transactions and zero fees on a secure, green and decentralized network, this makes Nano ideal for everyday transactions.

Nano 3.1k May 5, 2021
C XML Minimalistic Library (CXML) - An XML library for C with a focus on simplicity and ease of use.

cxml (C XML Minimalistic Library) is a powerful and flexible XML library for C with a focus on simplicity and ease of use, coupled with features that enables quick processing of XML documents.

null 28 Feb 11, 2022
frost is a programming language with a focus on low-friction systems programming.

❄️ frost frost programming language About frost is a programming language with a focus on low-friction systems programming.

null 4 Nov 12, 2021
A model viewer for Quake 1 and Hexen 2 with a focus on accurate representation.

LunarViewer A model viewer for Quake 1 and Hexen 2 with a focus on accurate representation. Powered by raylib and dear imgui! Features Support for Qua

Luna Ryuko Zaremba 31 May 4, 2022