Difference between revisions of "Documentation/Labs/Ninja"
(Created page with '__TOC__ = Ninja = Ninja is a small build system written with the goal of reducing build time of large projects like Slicer. Ninja currently works well on linux and mac. It als…') |
m (Text replacement - "\[http:\/\/www\.slicer\.org\/slicerWiki\/index\.php\/([^ ]+) ([^]]+)]" to "$2") |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 19: | Line 19: | ||
git clone git://github.com/martine/ninja.git | git clone git://github.com/martine/ninja.git | ||
cd ninja | cd ninja | ||
− | ./ | + | ./configure.py --bootstrap |
</pre> | </pre> | ||
Line 30: | Line 30: | ||
git clone git://github.com/martine/ninja.git | git clone git://github.com/martine/ninja.git | ||
cd ninja | cd ninja | ||
− | .\ | + | .\configure.py --bootstrap |
</pre> | </pre> | ||
Line 39: | Line 39: | ||
For example, installing the ninja package on Ubuntu can be done using: | For example, installing the ninja package on Ubuntu can be done using: | ||
− | < | + | <pre>sudo apt-get install ninja-build</pre> |
= Using it = | = Using it = | ||
Line 52: | Line 52: | ||
ccmake ../src -GNinja | ccmake ../src -GNinja | ||
</pre> | </pre> | ||
+ | |||
+ | *Once configured using CMake, simply run the <code>ninja</code> in the build directory. | ||
*QtCreator has Ninja support beginning version 2.6 | *QtCreator has Ninja support beginning version 2.6 | ||
Line 58: | Line 60: | ||
I was able to use Ninja to build Slicer on Mac OSX and Linux Ubuntu. | I was able to use Ninja to build Slicer on Mac OSX and Linux Ubuntu. | ||
− | All the dependencies of Slicer built fine and build time was reduced considerably. Time | + | All the dependencies of Slicer built fine and build time was reduced considerably. |
+ | |||
+ | The following table shows time statistics for a normal Slicer build on [[Documentation/4.2/Developers/Factory|Factory]] machine on MacOSX. | ||
+ | |||
+ | {| border="1" | ||
+ | |- | ||
+ | ! Build Type !! Command Used !! Time taken(seconds) | ||
+ | |- | ||
+ | | rowspan="2" align="center" | Fresh Build || align="center" | <code>make all -j9</code> || align="center" style="color:blue" | 1681 | ||
+ | |- | ||
+ | | align="center" | <code>ninja -j9</code> || align="center" style="color:blue" | 1671 | ||
+ | |- | ||
+ | | rowspan="2" align="center" | Re-Build without editing source || align="center" | <code>make all -j9</code> || align="center" style="color:red" | 102 | ||
+ | |- | ||
+ | | align="center" | <code>ninja -j9</code> || align="center" style="color:green" | 2 | ||
+ | |- | ||
+ | | rowspan="2" align="center" | Re-Build with minor edit || align="center" | <code>make all -j9</code> || align="center" style="color:red" | 1108 | ||
+ | |- | ||
+ | | align="center" | <code>ninja -j9</code> || align="center" style="color:green" | 5 | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | As observed, a fresh build takes approximately the same amount of time using both make and ninja. However, successive builds are much faster. | ||
+ | |||
+ | '''NOTE:''' Ninja uses all CPU cores by default but for comparison purposes I use the same number of cores for both the build systems. | ||
I have tried using VS compiler on Windows for building Slicer using the above method. However, it was an unsuccessful attempt. | I have tried using VS compiler on Windows for building Slicer using the above method. However, it was an unsuccessful attempt. |
Latest revision as of 02:28, 27 November 2019
Home < Documentation < Labs < NinjaContents
Ninja
Ninja is a small build system written with the goal of reducing build time of large projects like Slicer.
Ninja currently works well on linux and mac. It also works on windows, but that's very new and may have issues. It works as an alternative to more commonly known make or GNU Make (gmake) build systems.
For more details, head on to http://martine.github.com/ninja/
Installation
Building from source
Linux / MacOSX
Open up a terminal and execute the following commands:
git clone git://github.com/martine/ninja.git cd ninja ./configure.py --bootstrap
NOTE: Make sure git is in the path.
Windows
Open up a Visual Studio command prompt and execute the following commands:
git clone git://github.com/martine/ninja.git cd ninja .\configure.py --bootstrap
NOTE: Make sure git is in the path.
Linux packages
There are packaged versions available for Ninja on various Linux flavors.
For example, installing the ninja package on Ubuntu can be done using:
sudo apt-get install ninja-build
Using it
- CMake has Ninja generator support beginning version 2.8.8
All one needs to do is choose Ninja as the generator for the project in cmake-gui (GUI for CMake)
OR
cd Slicer/bld ccmake ../src -GNinja
- Once configured using CMake, simply run the
ninja
in the build directory.
- QtCreator has Ninja support beginning version 2.6
Test
I was able to use Ninja to build Slicer on Mac OSX and Linux Ubuntu.
All the dependencies of Slicer built fine and build time was reduced considerably.
The following table shows time statistics for a normal Slicer build on Factory machine on MacOSX.
Build Type | Command Used | Time taken(seconds) |
---|---|---|
Fresh Build | make all -j9 |
1681 |
ninja -j9 |
1671 | |
Re-Build without editing source | make all -j9 |
102 |
ninja -j9 |
2 | |
Re-Build with minor edit | make all -j9 |
1108 |
ninja -j9 |
5 |
As observed, a fresh build takes approximately the same amount of time using both make and ninja. However, successive builds are much faster.
NOTE: Ninja uses all CPU cores by default but for comparison purposes I use the same number of cores for both the build systems.
I have tried using VS compiler on Windows for building Slicer using the above method. However, it was an unsuccessful attempt. There were errors reported in building Python and ITK.
I will soon post my results of using QtCreator on Windows for building Slicer.