Jump to content

Use Ninja instead of Make


Recommended Posts

  • Forum Moderator

Hello guys,

Recently I have been updating my whole workflow and I discovered Ninja. To be concise, Ninja is basically a more modern and lightweight equivalent to "Make" that we (almost) all use. Its motto is simple, avoid being too complex to allow for a faster build & rebuild time, while allowing a human-readable syntax. I will just paraphrase them :

"When you are in a edit-compile cycle you want it to be as fast as possible — you want the build system to do the minimum work necessary to figure out what needs to be built immediately. [...] Ninja contains the barest functionality necessary to describe arbitrary dependency graphs. Its lack of syntax makes it impossible to express complex decisions."

Long story short, using it, you will basically build slightly faster & rebuild your project even faster.

Spoiler

As everything related to work-flow & FreeBSD, I advise you to be as up to date as possible, so I all forward you to this tutorial if you didn't do it, and I even advise you to go the extra mile and update to clang15.

 

Let's get started!

Spoiler

This is the hidden content, please

Then you are good! As a rule of thumb, you can use the following commands the same way you use your previous Make commands:

Clean your solution:

ninja -t clean

Build your solution using a number of workers:

ninja -j<number_of_workers>

 

Have a nice day!

Edited by Gurgarath
  • Metin2 Dev 83
  • Not Good 1
  • Scream 2
  • Good 11
  • Love 2
  • Love 25

Gurgarath
coming soon

Link to comment
Share on other sites

  • 2 weeks later...
  • Forum Moderator
On 1/25/2023 at 12:24 PM, GenraliDev said:

If you'd show a practical example of the performance improvement or comparison, that would make it more attractive for people.

My goal is not to make it attractive to people nor to convince them to use it, but to share something that they can add if they want or if they see fit.

The main difference between Ninja and Make is that Ninja is around 30 year newer than Make and is supported by Google for Chromium build (a very large project). You can find various Benchmarks online, for example this one from 2015. There are of course many others benchmarks here and there, as well as a nice YouTube video. As I explained in the post, Ninja is really good when you do incremental building (recompile just a few files) and the bigger your project, the better the gains.

 

Gurgarath
coming soon

Link to comment
Share on other sites

On 1/16/2023 at 9:47 PM, Gurgarath said:

May you elaborate?

I guess you already answered yourself in your last post 😛 
Ninja is indeed faster when it comes to parsing large build files and it's only beneficial when it's a humongous project such as chromium.

The down side of having it on a metin2 project is that it wont' make a difference when it comes to build time... And of course GNU make syntax is simpler and easier to read.

Link to comment
Share on other sites

  • Forum Moderator
5 hours ago, PeaceMaker said:

I guess you already answered yourself in your last post 😛 
Ninja is indeed faster when it comes to parsing large build files and it's only beneficial when it's a humongous project such as chromium.

The down side of having it on a metin2 project is that it wont' make a difference when it comes to build time... And of course GNU make syntax is simpler and easier to read.

As I said, it is beneficial mostly for incremental build, which is something most of us use (or should use). Unless people do a full gmake clean followed by a gmake, Ninja will be more efficient for that. Considering the syntax, Ninja is arguably easier to read, that was actually one goal of the project, but anyway, I think most of us should use generators for that, such as CMake. Writing Makefiles or build.ninja is something we can afford not to do using modern toolsets. In the end, it's up to personal preferences, if you don't see it fit for your project, it is perfectly fine, I was just here to provide people with a way to add it if they have the use for it 😄

 

  • Love 2

Gurgarath
coming soon

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.