Skip to content

Commit 70cce8c

Browse files
committed
Merge branch 'master' into release
2 parents b25c08b + 08ecbd6 commit 70cce8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4536
-756
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
insert_final_newline = true
8+
end_of_line = lf
9+
10+
[CMakeLists.txt]
11+
indent_style = tab

.github/workflows/linux.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Linux
2+
3+
on:
4+
pull_request:
5+
push:
6+
release:
7+
types: published
8+
9+
jobs:
10+
build:
11+
runs-on: [ubuntu-latest]
12+
container:
13+
image: centos:7
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Install dependencies
17+
run: |
18+
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2-Linux-x86_64.sh
19+
chmod +x cmake-3.16.2-Linux-x86_64.sh
20+
./cmake-3.16.2-Linux-x86_64.sh --skip-license --prefix=/usr/local
21+
curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-16.02-10.el7.x86_64.rpm
22+
curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-plugins-16.02-10.el7.x86_64.rpm
23+
rpm -U --quiet p7zip-16.02-10.el7.x86_64.rpm
24+
rpm -U --quiet p7zip-plugins-16.02-10.el7.x86_64.rpm
25+
yum install -y make gcc-c++
26+
- name: Build ninja
27+
shell: bash
28+
run: |
29+
mkdir build && cd build
30+
cmake -DCMAKE_BUILD_TYPE=Release ..
31+
cmake --build . --parallel --config Release
32+
ctest -vv
33+
strip ninja
34+
- name: Create ninja archive
35+
run: |
36+
mkdir artifact
37+
7z a artifact/ninja-linux.zip ./build/ninja
38+
39+
# Upload ninja binary archive as an artifact
40+
- name: Upload artifact
41+
uses: actions/upload-artifact@v1
42+
with:
43+
name: ninja-binary-archives
44+
path: artifact
45+
46+
- name: Upload release asset
47+
if: github.event.action == 'published'
48+
uses: actions/[email protected]
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
upload_url: ${{ github.event.release.upload_url }}
53+
asset_path: ./artifact/ninja-linux.zip
54+
asset_name: ninja-linux.zip
55+
asset_content_type: application/zip

.github/workflows/macos.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: macOS
2+
3+
on:
4+
pull_request:
5+
push:
6+
release:
7+
types: published
8+
9+
jobs:
10+
build:
11+
runs-on: macOS-latest
12+
13+
steps:
14+
- uses: actions/checkout@v1
15+
16+
- name: Install dependencies
17+
run: brew install re2c p7zip cmake
18+
19+
- name: Build ninja
20+
shell: bash
21+
run: |
22+
mkdir build && cd build
23+
cmake -DCMAKE_BUILD_TYPE=Release ..
24+
cmake --build . --parallel --config Release
25+
ctest -vv
26+
27+
- name: Create ninja archive
28+
shell: bash
29+
run: |
30+
mkdir artifact
31+
7z a artifact/ninja-mac.zip ./build/ninja
32+
33+
# Upload ninja binary archive as an artifact
34+
- name: Upload artifact
35+
uses: actions/upload-artifact@v1
36+
with:
37+
name: ninja-binary-archives
38+
path: artifact
39+
40+
- name: Upload release asset
41+
if: github.event.action == 'published'
42+
uses: actions/[email protected]
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
with:
46+
upload_url: ${{ github.event.release.upload_url }}
47+
asset_path: ./artifact/ninja-mac.zip
48+
asset_name: ninja-mac.zip
49+
asset_content_type: application/zip

.github/workflows/windows.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Windows
2+
3+
on:
4+
pull_request:
5+
push:
6+
release:
7+
types: published
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
13+
steps:
14+
- uses: actions/checkout@v1
15+
16+
- name: Install dependencies
17+
run: choco install re2c
18+
19+
- name: Build ninja
20+
shell: bash
21+
run: |
22+
mkdir build && cd build
23+
cmake -DCMAKE_BUILD_TYPE=Release ..
24+
cmake --build . --parallel --config Release
25+
ctest -vv
26+
27+
- name: Create ninja archive
28+
shell: bash
29+
run: |
30+
mkdir artifact
31+
7z a artifact/ninja-win.zip ./build/Release/ninja.exe
32+
33+
# Upload ninja binary archive as an artifact
34+
- name: Upload artifact
35+
uses: actions/upload-artifact@v1
36+
with:
37+
name: ninja-binary-archives
38+
path: artifact
39+
40+
- name: Upload release asset
41+
if: github.event.action == 'published'
42+
uses: actions/[email protected]
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
with:
46+
upload_url: ${{ github.event.release.upload_url }}
47+
asset_path: ./artifact/ninja-win.zip
48+
asset_name: ninja-win.zip
49+
asset_content_type: application/zip

.gitignore

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
*.exe
44
*.pdb
55
*.ilk
6-
TAGS
7-
/build
6+
/build*/
87
/build.ninja
98
/ninja
109
/ninja.bootstrap
@@ -18,8 +17,8 @@ TAGS
1817
/graph.png
1918
/doc/manual.html
2019
/doc/doxygen
21-
/gtest-1.6.0
2220
*.patch
21+
.DS_Store
2322

2423
# Eclipse project files
2524
.project
@@ -35,3 +34,7 @@ TAGS
3534

3635
# Visual Studio Code project files
3736
/.vscode/
37+
/.ccls-cache/
38+
39+
# Qt Creator project files
40+
/CMakeLists.txt.user

.travis.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
matrix:
22
include:
33
- os: linux
4+
dist: precise
45
compiler: gcc
56
- os: linux
7+
dist: precise
68
compiler: clang
9+
- os: linux
10+
dist: trusty
11+
compiler: gcc
12+
- os: linux
13+
dist: trusty
14+
compiler: clang
15+
- os: linux
16+
dist: xenial
17+
compiler: gcc
18+
- os: linux
19+
dist: xenial
20+
compiler: clang
21+
- os: osx
22+
osx_image: xcode10
723
- os: osx
24+
osx_image: xcode10.1
825
sudo: false
926
language: cpp
27+
before_install:
28+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install re2c ; fi
29+
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install re2c python ; fi
1030
script:
11-
- ./configure.py --bootstrap
31+
- ./misc/ci.py
32+
- python3 configure.py --bootstrap
1233
- ./ninja all
1334
- ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots
1435
- ./misc/ninja_syntax_test.py

CMakeLists.txt

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
cmake_policy(SET CMP0091 NEW)
3+
project(ninja)
4+
5+
if(CMAKE_BUILD_TYPE MATCHES "Release")
6+
cmake_policy(SET CMP0069 NEW)
7+
include(CheckIPOSupported)
8+
check_ipo_supported(RESULT lto_supported OUTPUT error)
9+
10+
if(lto_supported)
11+
message(STATUS "IPO / LTO enabled")
12+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
13+
else()
14+
message(STATUS "IPO / LTO not supported: <${error}>")
15+
endif()
16+
endif()
17+
18+
if(MSVC)
19+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
20+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /GR- /Zc:__cplusplus")
21+
else()
22+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fdiagnostics-color")
23+
endif()
24+
25+
find_program(RE2C re2c)
26+
if(RE2C)
27+
# the depfile parser and ninja lexers are generated using re2c.
28+
function(re2c IN OUT)
29+
add_custom_command(DEPENDS ${IN} OUTPUT ${OUT}
30+
COMMAND ${RE2C} -b -i --no-generation-date -o ${OUT} ${IN}
31+
)
32+
endfunction()
33+
re2c(${CMAKE_SOURCE_DIR}/src/depfile_parser.in.cc ${CMAKE_BINARY_DIR}/depfile_parser.cc)
34+
re2c(${CMAKE_SOURCE_DIR}/src/lexer.in.cc ${CMAKE_BINARY_DIR}/lexer.cc)
35+
add_library(libninja-re2c OBJECT ${CMAKE_BINARY_DIR}/depfile_parser.cc ${CMAKE_BINARY_DIR}/lexer.cc)
36+
else()
37+
message(WARNING "re2c was not found; changes to src/*.in.cc will not affect your build.")
38+
add_library(libninja-re2c OBJECT src/depfile_parser.cc src/lexer.cc)
39+
endif()
40+
target_include_directories(libninja-re2c PRIVATE src)
41+
42+
# Core source files all build into ninja library.
43+
add_library(libninja OBJECT
44+
src/build_log.cc
45+
src/build.cc
46+
src/clean.cc
47+
src/clparser.cc
48+
src/dyndep.cc
49+
src/dyndep_parser.cc
50+
src/debug_flags.cc
51+
src/deps_log.cc
52+
src/disk_interface.cc
53+
src/edit_distance.cc
54+
src/eval_env.cc
55+
src/graph.cc
56+
src/graphviz.cc
57+
src/line_printer.cc
58+
src/manifest_parser.cc
59+
src/metrics.cc
60+
src/parser.cc
61+
src/state.cc
62+
src/string_piece_util.cc
63+
src/util.cc
64+
src/version.cc
65+
)
66+
if(WIN32)
67+
target_sources(libninja PRIVATE
68+
src/subprocess-win32.cc
69+
src/includes_normalize-win32.cc
70+
src/msvc_helper-win32.cc
71+
src/msvc_helper_main-win32.cc
72+
src/getopt.c
73+
)
74+
if(MSVC)
75+
target_sources(libninja PRIVATE src/minidump-win32.cc)
76+
endif()
77+
else()
78+
target_sources(libninja PRIVATE src/subprocess-posix.cc)
79+
endif()
80+
81+
#Fixes GetActiveProcessorCount on MinGW
82+
if(MINGW)
83+
target_compile_definitions(libninja PRIVATE _WIN32_WINNT=0x0601 __USE_MINGW_ANSI_STDIO=1)
84+
endif()
85+
86+
# Main executable is library plus main() function.
87+
add_executable(ninja src/ninja.cc)
88+
target_link_libraries(ninja PRIVATE libninja libninja-re2c)
89+
90+
# Tests all build into ninja_test executable.
91+
add_executable(ninja_test
92+
src/build_log_test.cc
93+
src/build_test.cc
94+
src/clean_test.cc
95+
src/clparser_test.cc
96+
src/depfile_parser_test.cc
97+
src/deps_log_test.cc
98+
src/disk_interface_test.cc
99+
src/dyndep_parser_test.cc
100+
src/edit_distance_test.cc
101+
src/graph_test.cc
102+
src/lexer_test.cc
103+
src/manifest_parser_test.cc
104+
src/ninja_test.cc
105+
src/state_test.cc
106+
src/string_piece_util_test.cc
107+
src/subprocess_test.cc
108+
src/test.cc
109+
src/util_test.cc
110+
)
111+
if(WIN32)
112+
target_sources(ninja_test PRIVATE src/includes_normalize_test.cc src/msvc_helper_test.cc)
113+
endif()
114+
target_link_libraries(ninja_test PRIVATE libninja libninja-re2c)
115+
116+
foreach(perftest
117+
build_log_perftest
118+
canon_perftest
119+
clparser_perftest
120+
depfile_parser_perftest
121+
hash_collision_bench
122+
manifest_parser_perftest
123+
)
124+
add_executable(${perftest} src/${perftest}.cc)
125+
target_link_libraries(${perftest} PRIVATE libninja libninja-re2c)
126+
endforeach()
127+
128+
enable_testing()
129+
add_test(NinjaTest ninja_test)

CONTRIBUTING.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# How to successfully make changes to Ninja
2+
3+
We're very wary of changes that increase the complexity of Ninja (in particular,
4+
new build file syntax or command-line flags) or increase the maintenance burden
5+
of Ninja. Ninja is already successfully used by hundreds of developers for large
6+
projects and it already achieves (most of) the goals we set out for it to do.
7+
It's probably best to discuss new feature ideas on the
8+
[mailing list](https://groups.google.com/forum/#!forum/ninja-build) or in an
9+
issue before creating a PR.
10+
11+
## Coding guidelines
12+
13+
Generally it's the
14+
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) with
15+
a few additions:
16+
17+
* Any code merged into the Ninja codebase which will be part of the main
18+
executable must compile as C++03. You may use C++11 features in a test or an
19+
unimportant tool if you guard your code with `#if __cplusplus >= 201103L`.
20+
* We have used `using namespace std;` a lot in the past. For new contributions,
21+
please try to avoid relying on it and instead whenever possible use `std::`.
22+
However, please do not change existing code simply to add `std::` unless your
23+
contribution already needs to change that line of code anyway.
24+
* All source files should have the Google Inc. license header.
25+
* Use `///` for [Doxygen](http://www.doxygen.nl/) (use `\a` to refer to
26+
arguments).
27+
* It's not necessary to document each argument, especially when they're
28+
relatively self-evident (e.g. in
29+
`CanonicalizePath(string* path, string* err)`, the arguments are hopefully
30+
obvious).
31+
32+
If you're unsure about code formatting, please use
33+
[clang-format](https://clang.llvm.org/docs/ClangFormat.html). However, please do
34+
not format code that is not otherwise part of your contribution.

0 commit comments

Comments
 (0)