aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2020-07-07 22:42:55 -0700
committerDan Willemsen <dwillemsen@google.com>2020-07-07 22:45:22 -0700
commit71bdf56a58b603b8888723734277c78c828f6266 (patch)
tree48dbc616dbb645da754587458797039b9ad44858
parentf94f19e6eca76079dba1c3fe272885f97dfcf5b7 (diff)
parent71b96489325e5e2629464687c60f20d9905ab51c (diff)
downloadninja-71bdf56a58b603b8888723734277c78c828f6266.tar.gz
Merge upstream commit '71b96489' into master
* commit '71b96489325e5e2629464687c60f20d9905ab51c': Remove trailing whitespace from all files make inline.sh more portable Feature/add term env dumb to win32 (#1550) Update link to premake Take CPU set limitations into account when calculating processor count Docs: Make builds reproducible by generating the same IDs from the same inputs Fix Fuchsia typo mark this 1.9.0.git ninja_syntax.py: remove unused has_path argument Remove outdated part about Chrome download, fix #1338 Remove dead Chromium link, fix #1263 Change gyp to gn I don't expect anything here to cause problems, it was only a trivial conflict. This stops right before the upstream dyndeps patch. Test: treehugger Change-Id: Ib968993b8a98e75f0ff3e32be7ac325ac3fc14ad
-rw-r--r--.travis.yml1
-rw-r--r--HACKING.md14
-rw-r--r--doc/docbook.xsl3
-rw-r--r--doc/manual.asciidoc9
-rwxr-xr-xmisc/ci.py41
-rw-r--r--misc/ninja_syntax.py2
-rw-r--r--src/clean_test.cc2
-rw-r--r--src/deps_log.cc4
-rw-r--r--src/getopt.c2
-rwxr-xr-xsrc/inline.sh2
-rw-r--r--src/line_printer.cc14
-rw-r--r--src/util.cc9
-rw-r--r--src/version.cc2
13 files changed, 77 insertions, 28 deletions
diff --git a/.travis.yml b/.travis.yml
index 19a9b28..f76b982 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,7 @@ matrix:
sudo: false
language: cpp
script:
+ - ./misc/ci.py
- ./configure.py --bootstrap
- ./ninja all
- ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots
diff --git a/HACKING.md b/HACKING.md
index 086940b..bd6fec7 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -109,17 +109,9 @@ build "all" before committing to verify the other source still works!
## Testing performance impact of changes
-If you have a Chrome build handy, it's a good test case. Otherwise,
-[the github downoads page](https://github.com/ninja-build/ninja/releases)
-has a copy of the Chrome build files (and depfiles). You can untar
-that, then run
-
- path/to/my/ninja chrome
-
-and compare that against a baseline Ninja.
-
-There's a script at `misc/measure.py` that repeatedly runs a command like
-the above (to address variance) and summarizes its runtime. E.g.
+If you have a Chrome build handy, it's a good test case. There's a
+script at `misc/measure.py` that repeatedly runs a command (to address
+variance) and summarizes its runtime. E.g.
path/to/misc/measure.py path/to/my/ninja chrome
diff --git a/doc/docbook.xsl b/doc/docbook.xsl
index 19cc126..2235be2 100644
--- a/doc/docbook.xsl
+++ b/doc/docbook.xsl
@@ -21,6 +21,9 @@
<!-- Don't put the "Chapter 1." prefix on the "chapters". -->
<xsl:param name="chapter.autolabel">0</xsl:param>
+ <!-- Make builds reproducible by generating the same IDs from the same inputs -->
+ <xsl:param name="generate.consistent.ids">1</xsl:param>
+
<!-- Use <ul> for the table of contents. By default DocBook uses a
<dl>, which makes no semantic sense. I imagine they just did
it because it looks nice? -->
diff --git a/doc/manual.asciidoc b/doc/manual.asciidoc
index 4f8c74f..bd3258d 100644
--- a/doc/manual.asciidoc
+++ b/doc/manual.asciidoc
@@ -155,18 +155,17 @@ design is quite clever.
Ninja's benefit comes from using it in conjunction with a smarter
meta-build system.
-http://code.google.com/p/gyp/[gyp]:: The meta-build system used to
+https://gn.googlesource.com/gn/[gn]:: The meta-build system used to
generate build files for Google Chrome and related projects (v8,
-node.js). gyp can generate Ninja files for all platforms supported by
-Chrome. See the
-https://chromium.googlesource.com/chromium/src/+/master/docs/ninja_build.md[Chromium Ninja documentation for more details].
+node.js), as well as Google Fuchsia. gn can generate Ninja files for
+all platforms supported by Chrome.
https://cmake.org/[CMake]:: A widely used meta-build system that
can generate Ninja files on Linux as of CMake version 2.8.8. Newer versions
of CMake support generating Ninja files on Windows and Mac OS X too.
https://github.com/ninja-build/ninja/wiki/List-of-generators-producing-ninja-build-files[others]:: Ninja ought to fit perfectly into other meta-build software
-like http://industriousone.com/premake[premake]. If you do this work,
+like https://premake.github.io/[premake]. If you do this work,
please let us know!
Running Ninja
diff --git a/misc/ci.py b/misc/ci.py
new file mode 100755
index 0000000..17cbf14
--- /dev/null
+++ b/misc/ci.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import os
+
+ignores = [
+ '.git/',
+ 'misc/afl-fuzz-tokens/',
+ 'ninja_deps',
+ 'src/depfile_parser.cc',
+ 'src/lexer.cc',
+]
+
+error_count = 0
+
+def error(path, msg):
+ global error_count
+ error_count += 1
+ print('\x1b[1;31m{}\x1b[0;31m{}\x1b[0m'.format(path, msg))
+
+for root, directory, filenames in os.walk('.'):
+ for filename in filenames:
+ path = os.path.join(root, filename)[2:]
+ if any([path.startswith(x) for x in ignores]):
+ continue
+ with open(path, 'rb') as file:
+ line_nr = 1
+ try:
+ for line in [x.decode() for x in file.readlines()]:
+ if len(line) == 0 or line[-1] != '\n':
+ error(path, ' missing newline at end of file.')
+ if len(line) > 1:
+ if line[-2] == '\r':
+ error(path, ' has Windows line endings.')
+ break
+ if line[-2] == ' ' or line[-2] == '\t':
+ error(path, ':{} has trailing whitespace.'.format(line_nr))
+ line_nr += 1
+ except UnicodeError:
+ pass # binary file
+
+exit(error_count)
diff --git a/misc/ninja_syntax.py b/misc/ninja_syntax.py
index 051bac1..ebe6490 100644
--- a/misc/ninja_syntax.py
+++ b/misc/ninja_syntax.py
@@ -21,7 +21,7 @@ class Writer(object):
def newline(self):
self.output.write('\n')
- def comment(self, text, has_path=False):
+ def comment(self, text):
for line in textwrap.wrap(text, self.width - 2, break_long_words=False,
break_on_hyphens=False):
self.output.write('# ' + line + '\n')
diff --git a/src/clean_test.cc b/src/clean_test.cc
index 4fdaa96..c652ef6 100644
--- a/src/clean_test.cc
+++ b/src/clean_test.cc
@@ -325,7 +325,7 @@ TEST_F(CleanTest, CleanRsp) {
Cleaner cleaner(&state_, config_, &fs_);
ASSERT_EQ(0, cleaner.cleaned_files_count());
ASSERT_EQ(0, cleaner.CleanTarget("out1"));
- EXPECT_EQ(2, cleaner.cleaned_files_count());
+ EXPECT_EQ(2, cleaner.cleaned_files_count());
ASSERT_EQ(0, cleaner.CleanTarget("in2"));
EXPECT_EQ(2, cleaner.cleaned_files_count());
ASSERT_EQ(0, cleaner.CleanRule("cat_rsp"));
diff --git a/src/deps_log.cc b/src/deps_log.cc
index 807dbd3..f2a3888 100644
--- a/src/deps_log.cc
+++ b/src/deps_log.cc
@@ -55,7 +55,7 @@ bool DepsLog::OpenForWrite(const string& path, const DiskInterface& disk, string
if (!Recompact(path, disk, err))
return false;
}
-
+
file_ = fopen(path.c_str(), "ab");
if (!file_) {
*err = strerror(errno);
@@ -694,7 +694,7 @@ bool DepsLog::Recompact(const string& path, const DiskInterface& disk, string* e
// will refer to the ordering in new_log, not in the current log.
for (vector<Node*>::iterator i = nodes_.begin(); i != nodes_.end(); ++i)
(*i)->set_id(-1);
-
+
// Write out all deps again.
for (int old_id = 0; old_id < (int)deps_.size(); ++old_id) {
Deps* deps = deps_[old_id];
diff --git a/src/getopt.c b/src/getopt.c
index 0c2ef35..861f07f 100644
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -75,7 +75,7 @@ COPYRIGHT NOTICE AND DISCLAIMER:
Copyright (C) 1997 Gregory Pietsch
-This file and the accompanying getopt.h header file are hereby placed in the
+This file and the accompanying getopt.h header file are hereby placed in the
public domain without restrictions. Just give the author credit, don't
claim you wrote it or prevent anyone else from using it.
diff --git a/src/inline.sh b/src/inline.sh
index fa282fa..b64e8ca 100755
--- a/src/inline.sh
+++ b/src/inline.sh
@@ -20,6 +20,6 @@
varname="$1"
echo "const char $varname[] ="
-od -t x1 -A n -v | sed -e 's|[ \t]||g; s|..|\\x&|g; s|^|"|; s|$|"|'
+od -t x1 -A n -v | sed -e 's|^[\t ]\{0,\}$||g; s|[\t ]\{1,\}| |g; s| \{1,\}$||g; s| |\\x|g; s|^|"|; s|$|"|'
echo ";"
diff --git a/src/line_printer.cc b/src/line_printer.cc
index 953982a..55469d9 100644
--- a/src/line_printer.cc
+++ b/src/line_printer.cc
@@ -31,18 +31,22 @@
#include "util.h"
LinePrinter::LinePrinter() : have_blank_line_(true), console_locked_(false) {
-#ifndef _WIN32
const char* term = getenv("TERM");
+#ifndef _WIN32
smart_terminal_ = isatty(1) && term && string(term) != "dumb";
#else
// Disable output buffer. It'd be nice to use line buffering but
// MSDN says: "For some systems, [_IOLBF] provides line
// buffering. However, for Win32, the behavior is the same as _IOFBF
// - Full Buffering."
- setvbuf(stdout, NULL, _IONBF, 0);
- console_ = GetStdHandle(STD_OUTPUT_HANDLE);
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- smart_terminal_ = GetConsoleScreenBufferInfo(console_, &csbi);
+ if (term && string(term) == "dumb") {
+ smart_terminal_ = false;
+ } else {
+ setvbuf(stdout, NULL, _IONBF, 0);
+ console_ = GetStdHandle(STD_OUTPUT_HANDLE);
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ smart_terminal_ = GetConsoleScreenBufferInfo(console_, &csbi);
+ }
#endif
supports_color_ = smart_terminal_;
if (!supports_color_) {
diff --git a/src/util.cc b/src/util.cc
index 46d6f9c..bb91923 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -561,6 +561,15 @@ int GetProcessorCount() {
GetNativeSystemInfo(&info);
return info.dwNumberOfProcessors;
#else
+#ifdef CPU_COUNT
+ // The number of exposed processors might not represent the actual number of
+ // processors threads can run on. This happens when a CPU set limitation is
+ // active, see https://github.com/ninja-build/ninja/issues/1278
+ cpu_set_t set;
+ if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) {
+ return CPU_COUNT(&set);
+ }
+#endif
return sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
diff --git a/src/version.cc b/src/version.cc
index 1b6cfac..1c906ae 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -18,7 +18,7 @@
#include "util.h"
-const char* kNinjaVersion = "1.8.2.git";
+const char* kNinjaVersion = "1.9.0.git";
void ParseVersion(const string& version, int* major, int* minor) {
size_t end = version.find('.');