Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Aug 18, 2020
2 parents ed7f670 + 9ddd3c9 commit 5c2cde2
Show file tree
Hide file tree
Showing 31 changed files with 322 additions and 156 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ AllowShortLoopsOnASingleLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: false
IndentCaseLabels: false
DerivePointerBinding: false
22 changes: 13 additions & 9 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@ jobs:
container:
image: centos:7
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Install dependencies
run: |
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2-Linux-x86_64.sh
chmod +x cmake-3.16.2-Linux-x86_64.sh
./cmake-3.16.2-Linux-x86_64.sh --skip-license --prefix=/usr/local
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.sh
chmod +x cmake-3.16.4-Linux-x86_64.sh
./cmake-3.16.4-Linux-x86_64.sh --skip-license --prefix=/usr/local
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
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
rpm -U --quiet p7zip-16.02-10.el7.x86_64.rpm
rpm -U --quiet p7zip-plugins-16.02-10.el7.x86_64.rpm
yum install -y make gcc-c++
- name: Build ninja
shell: bash
run: |
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallel --config Release
ctest -vv
strip ninja
cmake -DCMAKE_BUILD_TYPE=Release -B build
cmake --build build --parallel --config Release
strip build/ninja
- name: Test ninja
run: ./ninja_test
working-directory: build

- name: Create ninja archive
run: |
mkdir artifact
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ jobs:
runs-on: macOS-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Install dependencies
run: brew install re2c p7zip cmake

- name: Build ninja
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: 10.12
run: |
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallel --config Release
ctest -vv
cmake -DCMAKE_BUILD_TYPE=Release -B build
cmake --build build --parallel --config Release
- name: Test ninja
run: ctest -vv
working-directory: build

- name: Create ninja archive
shell: bash
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Install dependencies
run: choco install re2c

- name: Build ninja
shell: bash
run: |
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallel --config Release
ctest -vv
cmake -DCMAKE_BUILD_TYPE=Release -B build
cmake --build build --parallel --config Release
- name: Test ninja
run: .\ninja_test.exe
working-directory: build/Release

- name: Create ninja archive
shell: bash
Expand Down
25 changes: 18 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
project(ninja)

# --- optional link-time optimization
if(CMAKE_BUILD_TYPE MATCHES "Release")
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT error)

Expand All @@ -15,13 +14,23 @@ if(CMAKE_BUILD_TYPE MATCHES "Release")
endif()
endif()

# --- compiler flags
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /GR- /Zc:__cplusplus")
string(APPEND CMAKE_CXX_FLAGS " /W4 /GR- /Zc:__cplusplus")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fdiagnostics-color")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Wno-deprecated flag_no_deprecated)
if(flag_no_deprecated)
string(APPEND CMAKE_CXX_FLAGS " -Wno-deprecated")
endif()
check_cxx_compiler_flag(-fdiagnostics-color flag_color_diag)
if(flag_color_diag)
string(APPEND CMAKE_CXX_FLAGS " -fdiagnostics-color")
endif()
endif()

# --- optional re2c
find_program(RE2C re2c)
if(RE2C)
# the depfile parser and ninja lexers are generated using re2c.
Expand All @@ -30,9 +39,9 @@ if(RE2C)
COMMAND ${RE2C} -b -i --no-generation-date -o ${OUT} ${IN}
)
endfunction()
re2c(${CMAKE_SOURCE_DIR}/src/depfile_parser.in.cc ${CMAKE_BINARY_DIR}/depfile_parser.cc)
re2c(${CMAKE_SOURCE_DIR}/src/lexer.in.cc ${CMAKE_BINARY_DIR}/lexer.cc)
add_library(libninja-re2c OBJECT ${CMAKE_BINARY_DIR}/depfile_parser.cc ${CMAKE_BINARY_DIR}/lexer.cc)
re2c(${PROJECT_SOURCE_DIR}/src/depfile_parser.in.cc ${PROJECT_BINARY_DIR}/depfile_parser.cc)
re2c(${PROJECT_SOURCE_DIR}/src/lexer.in.cc ${PROJECT_BINARY_DIR}/lexer.cc)
add_library(libninja-re2c OBJECT ${PROJECT_BINARY_DIR}/depfile_parser.cc ${PROJECT_BINARY_DIR}/lexer.cc)
else()
message(WARNING "re2c was not found; changes to src/*.in.cc will not affect your build.")
add_library(libninja-re2c OBJECT src/depfile_parser.cc src/lexer.cc)
Expand Down Expand Up @@ -127,3 +136,5 @@ endforeach()

enable_testing()
add_test(NinjaTest ninja_test)

install(TARGETS ninja DESTINATION bin)
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ resulting ninja binary. However, to enable features like Bash
completion and Emacs and Vim editing modes, some files in misc/ must be
copied to appropriate locations.

If you're interested in making changes to Ninja, read CONTRIBUTING.md first.
If you're interested in making changes to Ninja, read
[CONTRIBUTING.md](CONTRIBUTING.md) first.

## Building Ninja itself

Expand All @@ -31,7 +32,7 @@ via CMake. For more details see
```

This will generate the `ninja` binary and a `build.ninja` file you can now use
to built Ninja with itself.
to build Ninja with itself.

### CMake

Expand Down
23 changes: 0 additions & 23 deletions bootstrap.py

This file was deleted.

2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def has_re2c():
command='$doxygen_mainpage_generator $in > $out',
description='DOXYGEN_MAINPAGE $out')
mainpage = n.build(built('doxygen_mainpage'), 'doxygen_mainpage',
['README', 'COPYING'],
['README.md', 'COPYING'],
implicit=['$doxygen_mainpage_generator'])
n.build('doxygen', 'doxygen', doc('doxygen.config'),
implicit=mainpage)
Expand Down
6 changes: 3 additions & 3 deletions doc/manual.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ tool takes in account the +-v+ and the +-n+ options (note that +-n+
implies +-v+).
`cleandead`:: remove files produced by previous builds that are no longer in the
manifest. _Available since Ninja 1.10._
build file. _Available since Ninja 1.10._
`compdb`:: given a list of rules, each of which is expected to be a
C family language compiler rule whose first input is the name of the
Expand Down Expand Up @@ -900,7 +900,7 @@ set environment variables.
On Windows, commands are strings, so Ninja passes the `command` string
directly to `CreateProcess`. (In the common case of simply executing
a compiler this means there is less overhead.) Consequently the
quoting rules are deterimined by the called program, which on Windows
quoting rules are determined by the called program, which on Windows
are usually provided by the C library. If you need shell
interpretation of the command (such as the use of `&&` to chain
multiple commands), make the command execute the Windows shell by
Expand Down Expand Up @@ -936,7 +936,7 @@ There are three types of build dependencies which are subtly different.

1. _Explicit dependencies_, as listed in a build line. These are
available as the `$in` variable in the rule. Changes in these files
cause the output to be rebuilt; if these file are missing and
cause the output to be rebuilt; if these files are missing and
Ninja doesn't know how to build them, the build is aborted.
+
This is the standard form of dependency to be used e.g. for the
Expand Down
14 changes: 14 additions & 0 deletions misc/ninja_syntax.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/usr/bin/python

# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Python module for generating .ninja files.
Note that this is emphatically not a required piece of Ninja; it's
Expand Down
4 changes: 4 additions & 0 deletions misc/output_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def run(build_ninja, flags='', pipe=False, env=default_env):
final_output += line.replace('\r', '')
return final_output

@unittest.skipIf(platform.system() == 'Windows', 'These test methods do not work on Windows')
class Output(unittest.TestCase):
def test_issue_1418(self):
self.assertEqual(run(
Expand Down Expand Up @@ -107,5 +108,8 @@ def test_pr_1685(self):
self.assertEqual(run('', flags='-t recompact'), '')
self.assertEqual(run('', flags='-t restat'), '')

def test_status(self):
self.assertEqual(run(''), 'ninja: no work to do.\n')

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion misc/packaging/ninja.spec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cp -p ninja %{buildroot}%{_bindir}/

%files
%defattr(-, root, root)
%doc COPYING README doc/manual.html
%doc COPYING README.md doc/manual.html
%{_bindir}/*

%clean
Expand Down
7 changes: 5 additions & 2 deletions src/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
import BaseHTTPServer as httpserver
import SocketServer as socketserver
import argparse
import cgi
import os
import socket
import subprocess
import sys
import webbrowser
if sys.version_info >= (3, 2):
from html import escape
else:
from cgi import escape
try:
from urllib.request import unquote
except ImportError:
Expand Down Expand Up @@ -62,7 +65,7 @@ def match_strip(line, prefix):
return (True, line[len(prefix):])

def html_escape(text):
return cgi.escape(text, quote=True)
return escape(text, quote=True)

def parse(text):
lines = iter(text.split('\n'))
Expand Down
4 changes: 2 additions & 2 deletions src/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void BuildStatus::BuildLoadDyndeps() {
// it considers a portion of the graph to be out of date. Normally
// this is done before the build starts, but our caller is about to
// load a dyndep file during the build. Doing so may generate more
// exlanation lines (via fprintf directly to stderr), but in an
// explanation lines (via fprintf directly to stderr), but in an
// interactive console the cursor is currently at the end of a status
// line. Start a new line so that the first explanation does not
// append to the status line. After the explanations are done a
Expand Down Expand Up @@ -1033,7 +1033,7 @@ bool Builder::FinishCommand(CommandRunner::Result* result, string* err) {
}

if (!deps_type.empty() && !config_.dry_run) {
assert(edge->outputs_.size() >= 1 && "should have been rejected by parser");
assert(!edge->outputs_.empty() && "should have been rejected by parser");
for (std::vector<Node*>::const_iterator o = edge->outputs_.begin();
o != edge->outputs_.end(); ++o) {
TimeStamp deps_mtime = disk_interface_->Stat((*o)->path(), err);
Expand Down
Loading

0 comments on commit 5c2cde2

Please sign in to comment.