Linux command
ninja 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Build project
ninja
Build specific target
ninja [target]
Build with multiple jobs
ninja -j [8]
Build in a different directory
ninja -C [build_dir]
Clean build
ninja -t clean
Dry run
ninja -n
Verbose output
ninja -v
Keep going after errors
ninja -k [0]
Use specific build file
ninja -f [build.ninja]
Show build graph
ninja -t graph [target]
说明
ninja is a small, fast build system closest in spirit to Make. It focuses on speed and correctness, taking a different approach by having its input files be generated by a higher-level build system rather than written by hand. Build files (build.ninja) are typically generated by CMake, Meson, or GN. Ninja was designed to replace Make as the build executor for large projects like Chromium.
参数
- -j _N_
- Run N jobs in parallel (0 means infinity) default=number of CPUs.
- -f _FILE_
- Specify input build file default=build.ninja.
- -C _DIR_
- Change to DIR before doing anything else.
- -v
- Show all command lines while building.
- -n
- Dry run (don't run commands but act like they succeeded).
- -k _N_
- Keep going until N jobs fail (0 means infinity) default=1.
- -l _N_
- Do not start new jobs if the load average is greater than N.
- -t _TOOL_
- Run a subtool (use -t list to list subtools).
- -d _MODE_
- Enable debugging (use -d list to list modes).
- -w _FLAG_
- Adjust warnings (use -w list to list warnings).
- --version
- Print ninja version.
- --help
- Display help information.
FAQ
What is the ninja command used for?
ninja is a small, fast build system closest in spirit to Make. It focuses on speed and correctness, taking a different approach by having its input files be generated by a higher-level build system rather than written by hand. Build files (build.ninja) are typically generated by CMake, Meson, or GN. Ninja was designed to replace Make as the build executor for large projects like Chromium.
How do I run a basic ninja example?
Run `ninja` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -j _N_ do in ninja?
Run N jobs in parallel (0 means infinity) default=number of CPUs.