Giter Club home page Giter Club logo

n2's Introduction

n2, an alternative ninja implementation

CI status

n2 (pronounced "into") implements enough of Ninja to successfully build some projects that build with Ninja. Compared to Ninja, n2 missing some features but is faster to build and has a better UI; see a more detailed comparison.

Here's a small demo of n2 building some of Clang.

Install

$ cargo install --git https://github.com/evmar/n2
# (installs into ~/.cargo/bin/)

$ n2 -C some/build/dir some-target

Using with CMake

When CMake generates Ninja files it attempts run a program named ninja with some particular Ninja behaviors. In particular, it attempts to inform Ninja/n2 that its generated build files are up to date so that the build system doesn't attempt to rebuild them.

n2 can emulate the expected CMake behavior when invoked as ninja. To do this you create a symlink named ninja somewhere in your $PATH, such that CMake can discover it.

  • UNIX: ln -s path/to/n2 ninja
  • Windows(cmd): mklink ninja.exe path\to\n2
  • Windows(PowerShell): New-Item -Type Symlink ninja.exe -Target path\to\n2

Warning
If you don't have Ninja installed at all, you must install such a symlink because CMake attempts to invoke ninja itself!

The console output

While building, n2 displays build progress like this:

[=========================---------       ] 2772/4459 done, 8/930 running
Building foo/bar (2s)
Building foo/baz

The progress bar always covers all build steps needed for the targets, regardless of whether they need to be executed or not.

The bar shows three categories of state:

  • Done: The = signs show the build steps that are already up to date.
  • In progress: The - signs show steps that are in-progress; if you had enough CPUs they would all be executing. The 8/930 running after shows that n2 is currently executing 8 of the 930 available steps.
  • Unknown: The remaining empty space indicates steps whose status is yet to be known, as they depend on the in progress steps. For example, if an intermediate step doesn't write its outputs n2 may not need to execute the dependent steps.

The lines below the progress bar show some build steps that are currrently running, along with how long they've been running if it has been a while. Their text is controlled by the input build.ninja file.

More reading

I wrote n2 to explore some alternative ideas I had around how to structure a build system. In a very real sense the exploration is more important than the actual software itself, so you can view the design notes as one of the primary artifacts of this.

n2's People

Contributors

evmar avatar nico avatar colecf avatar philipcraig avatar piscisaureus avatar clemenswasser avatar dae avatar chromy avatar grigorenkopv avatar travbid avatar jamesr avatar sztomi avatar tru avatar uran0sh avatar tschuett avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.