diff options
-rwxr-xr-x | bootstrap.py | 20 | ||||
-rwxr-xr-x | configure.py | 4 | ||||
-rw-r--r-- | misc/ninja_syntax.py | 6 | ||||
-rw-r--r-- | src/build.cc | 1 | ||||
-rw-r--r-- | src/build_log.cc | 1 | ||||
-rw-r--r-- | src/build_log.h | 5 | ||||
-rw-r--r-- | src/build_log_test.cc | 4 | ||||
-rw-r--r-- | src/build_test.cc | 16 | ||||
-rw-r--r-- | src/depfile_parser.cc | 16 | ||||
-rw-r--r-- | src/depfile_parser.in.cc | 2 | ||||
-rw-r--r-- | src/depfile_parser_test.cc | 15 | ||||
-rw-r--r-- | src/ninja.cc | 1 | ||||
-rw-r--r-- | src/subprocess.cc | 2 | ||||
-rw-r--r-- | src/util.cc | 1 |
14 files changed, 64 insertions, 30 deletions
diff --git a/bootstrap.py b/bootstrap.py index ca47b19..1df423d 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from optparse import OptionParser import sys import os import glob @@ -20,6 +21,11 @@ import errno import shlex import subprocess +parser = OptionParser() +parser.add_option('--verbose', action='store_true', + help='enable verbose build',) +(options, conf_args) = parser.parse_args() + def run(*args, **kwargs): try: subprocess.check_call(*args, **kwargs) @@ -65,7 +71,7 @@ if sys.platform.startswith('win32'): vcdir = os.environ.get('VCINSTALLDIR') if vcdir: - args = [os.path.join(vcdir, 'bin', 'cl.exe'), '/nologo', '/EHsc'] + args = [os.path.join(vcdir, 'bin', 'cl.exe'), '/nologo', '/EHsc', '/DNOMINMAX'] else: args = shlex.split(os.environ.get('CXX', 'g++')) args.extend(['-Wno-deprecated', @@ -81,11 +87,19 @@ if vcdir: args.extend(['/link', '/out:' + binary]) else: args.extend(['-o', binary]) + +if options.verbose: + print ' '.join(args) + run(args) +verbose = [] +if options.verbose: + verbose = ['-v'] + print 'Building ninja using itself...' -run([sys.executable, 'configure.py'] + sys.argv[1:]) -run(['./' + binary]) +run([sys.executable, 'configure.py'] + conf_args) +run(['./' + binary] + verbose) os.unlink(binary) print 'Done!' diff --git a/configure.py b/configure.py index 9c9d108..0637de6 100755 --- a/configure.py +++ b/configure.py @@ -104,7 +104,7 @@ else: if platform == 'windows': cflags = ['/nologo', '/Zi', '/W4', '/WX', '/wd4530', '/wd4100', '/wd4706', '/wd4512', '/wd4800', '/wd4702', '/wd4819', - '/D_CRT_SECURE_NO_WARNINGS', + '/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS', "/DNINJA_PYTHON=\"%s\"" % (options.with_python,)] ldflags = ['/DEBUG', '/libpath:$builddir'] if not options.debug: @@ -154,7 +154,7 @@ if platform == 'windows': description='CXX $out') else: n.rule('cxx', - command='$cxx -MMD -MF $out.d $cflags -c $in -o $out', + command='$cxx -MMD -MT $out -MF $out.d $cflags -c $in -o $out', depfile='$out.d', description='CXX $out') n.newline() diff --git a/misc/ninja_syntax.py b/misc/ninja_syntax.py index ccb38a8..97bd82b 100644 --- a/misc/ninja_syntax.py +++ b/misc/ninja_syntax.py @@ -33,7 +33,7 @@ class Writer(object): self._line('%s = %s' % (key, value), indent) def rule(self, name, command, description=None, depfile=None, - generator=False, restat=False): + generator=False, restat=False, rspfile=None, rspfile_content=None): self._line('rule %s' % name) self.variable('command', command, indent=1) if description: @@ -44,6 +44,10 @@ class Writer(object): self.variable('generator', '1', indent=1) if restat: self.variable('restat', '1', indent=1) + if rspfile: + self.variable('rspfile', rspfile, indent=1) + if rspfile_content: + self.variable('rspfile_content', rspfile_content, indent=1) def build(self, outputs, rule, inputs=None, implicit=None, order_only=None, variables=None): diff --git a/src/build.cc b/src/build.cc index 44c1df6..a2e4f64 100644 --- a/src/build.cc +++ b/src/build.cc @@ -20,6 +20,7 @@ #ifdef _WIN32 #include <windows.h> #else +#include <unistd.h> #include <sys/ioctl.h> #include <sys/time.h> #include <sys/termios.h> diff --git a/src/build_log.cc b/src/build_log.cc index fd93ea8..0cecd70 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -17,6 +17,7 @@ #include <errno.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include "build.h" #include "graph.h" diff --git a/src/build_log.h b/src/build_log.h index 040609d..da8e726 100644 --- a/src/build_log.h +++ b/src/build_log.h @@ -71,10 +71,11 @@ struct BuildLog { /// Rewrite the known log entries, throwing away old data. bool Recompact(const string& path, string* err); - // TODO: make these private. typedef ExternalStringHashMap<LogEntry*>::Type Log; + const Log& log() const { return log_; } + + private: Log log_; -private: FILE* log_file_; BuildConfig* config_; bool needs_recompaction_; diff --git a/src/build_log_test.cc b/src/build_log_test.cc index c6d6bc3..9b729c7 100644 --- a/src/build_log_test.cc +++ b/src/build_log_test.cc @@ -54,8 +54,8 @@ TEST_F(BuildLogTest, WriteRead) { EXPECT_TRUE(log2.Load(kTestFilename, &err)); ASSERT_EQ("", err); - ASSERT_EQ(2u, log1.log_.size()); - ASSERT_EQ(2u, log2.log_.size()); + ASSERT_EQ(2u, log1.log().size()); + ASSERT_EQ(2u, log2.log().size()); BuildLog::LogEntry* e1 = log1.LookupByOutput("out"); ASSERT_TRUE(e1); BuildLog::LogEntry* e2 = log2.LookupByOutput("out"); diff --git a/src/build_test.cc b/src/build_test.cc index 5b35513..c015bc9 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -868,15 +868,15 @@ TEST_F(BuildTest, RspFileSuccess) size_t files_removed = fs_.files_removed_.size(); EXPECT_TRUE(builder_.Build(&err)); - ASSERT_EQ(2, commands_ran_.size()); // cat + cat_rsp + ASSERT_EQ(2u, commands_ran_.size()); // cat + cat_rsp // The RSP file was created ASSERT_EQ(files_created + 1, fs_.files_created_.size()); - ASSERT_EQ(1, fs_.files_created_.count("out2.rsp")); + ASSERT_EQ(1u, fs_.files_created_.count("out2.rsp")); // The RSP file was removed ASSERT_EQ(files_removed + 1, fs_.files_removed_.size()); - ASSERT_EQ(1, fs_.files_removed_.count("out2.rsp")); + ASSERT_EQ(1u, fs_.files_removed_.count("out2.rsp")); } // Test that RSP file is created but not removed for commands, which fail @@ -903,15 +903,15 @@ TEST_F(BuildTest, RspFileFailure) { EXPECT_FALSE(builder_.Build(&err)); ASSERT_EQ("subcommand failed", err); - ASSERT_EQ(1, commands_ran_.size()); + ASSERT_EQ(1u, commands_ran_.size()); // The RSP file was created ASSERT_EQ(files_created + 1, fs_.files_created_.size()); - ASSERT_EQ(1, fs_.files_created_.count("out.rsp")); + ASSERT_EQ(1u, fs_.files_created_.count("out.rsp")); // The RSP file was NOT removed ASSERT_EQ(files_removed, fs_.files_removed_.size()); - ASSERT_EQ(0, fs_.files_removed_.count("out.rsp")); + ASSERT_EQ(0u, fs_.files_removed_.count("out.rsp")); // The RSP file contains what it should ASSERT_EQ("Another very long command", fs_.files_["out.rsp"].contents); @@ -939,7 +939,7 @@ TEST_F(BuildWithLogTest, RspFileCmdLineChange) { // 1. Build for the 1st time (-> populate log) EXPECT_TRUE(builder_.Build(&err)); - ASSERT_EQ(1, commands_ran_.size()); + ASSERT_EQ(1u, commands_ran_.size()); // 2. Build again (no change) commands_ran_.clear(); @@ -960,7 +960,7 @@ TEST_F(BuildWithLogTest, RspFileCmdLineChange) { EXPECT_TRUE(builder_.AddTarget("out", &err)); EXPECT_EQ("", err); EXPECT_TRUE(builder_.Build(&err)); - EXPECT_EQ(1, commands_ran_.size()); + EXPECT_EQ(1u, commands_ran_.size()); } TEST_F(BuildTest, InterruptCleanup) { diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc index 7219eb0..261893f 100644 --- a/src/depfile_parser.cc +++ b/src/depfile_parser.cc @@ -64,7 +64,7 @@ bool DepfileParser::Parse(string* content, string* err) { 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 0, 0, 0, 0, 0, + 128, 128, 128, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -84,7 +84,7 @@ bool DepfileParser::Parse(string* content, string* err) { }; yych = *in; - if (yych <= '[') { + if (yych <= '\\') { if (yych <= ':') { if (yych <= 0x00) goto yy6; if (yych <= '*') goto yy8; @@ -92,20 +92,18 @@ bool DepfileParser::Parse(string* content, string* err) { } else { if (yych <= '@') goto yy8; if (yych <= 'Z') goto yy4; - goto yy8; + if (yych <= '[') goto yy8; } } else { - if (yych <= '_') { - if (yych <= '\\') goto yy2; - if (yych <= '^') goto yy8; - goto yy4; + if (yych <= '`') { + if (yych == '_') goto yy4; + goto yy8; } else { - if (yych <= '`') goto yy8; if (yych <= 'z') goto yy4; + if (yych == '~') goto yy4; goto yy8; } } -yy2: ++in; if ((yych = *in) <= '$') { if (yych <= '\n') { diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc index 419ed8d..5e073df 100644 --- a/src/depfile_parser.in.cc +++ b/src/depfile_parser.in.cc @@ -68,7 +68,7 @@ bool DepfileParser::Parse(string* content, string* err) { *out++ = yych; continue; } - [a-zA-Z0-9+,/_:.-]+ { + [a-zA-Z0-9+,/_:.~-]+ { // Got a span of plain text. int len = in - start; // Need to shift it over if we're overwriting backslashes. diff --git a/src/depfile_parser_test.cc b/src/depfile_parser_test.cc index 883926a..9094283 100644 --- a/src/depfile_parser_test.cc +++ b/src/depfile_parser_test.cc @@ -108,7 +108,7 @@ TEST_F(DepfileParserTest, UnifyMultupleOutputs) { string err; EXPECT_TRUE(Parse("foo foo: x y z", &err)); ASSERT_EQ(parser_.out_.AsString(), "foo"); - ASSERT_EQ(parser_.ins_.size(), 3); + ASSERT_EQ(parser_.ins_.size(), 3u); EXPECT_EQ("x", parser_.ins_[0].AsString()); EXPECT_EQ("y", parser_.ins_[1].AsString()); EXPECT_EQ("z", parser_.ins_[2].AsString()); @@ -119,3 +119,16 @@ TEST_F(DepfileParserTest, RejectMultipleDifferentOutputs) { string err; EXPECT_FALSE(Parse("foo bar: x y z", &err)); } + +TEST_F(DepfileParserTest, Tilde) { + string err; + EXPECT_TRUE(Parse( +"foo~.o: foo~.c", + &err)); + ASSERT_EQ("", err); + EXPECT_EQ("foo~.o", + parser_.out_.AsString()); + ASSERT_EQ(1u, parser_.ins_.size()); + EXPECT_EQ("foo~.c", + parser_.ins_[0].AsString()); +} diff --git a/src/ninja.cc b/src/ninja.cc index 04cd771..7d020db 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -31,6 +31,7 @@ #include <windows.h> #else #include <getopt.h> +#include <unistd.h> #endif #include "browse.h" diff --git a/src/subprocess.cc b/src/subprocess.cc index 99de93f..25b1bda 100644 --- a/src/subprocess.cc +++ b/src/subprocess.cc @@ -45,7 +45,7 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) { #if !defined(linux) // On linux we use ppoll in DoWork(); elsewhere we use pselect and so must // avoid overly-large FDs. - if (fd_ >= FD_SETSIZE) + if (fd_ >= static_cast<int>(FD_SETSIZE)) Fatal("pipe: %s", strerror(EMFILE)); #endif // !linux SetCloseOnExec(fd_); diff --git a/src/util.cc b/src/util.cc index 4d9adf3..c88dc4e 100644 --- a/src/util.cc +++ b/src/util.cc @@ -16,6 +16,7 @@ #ifdef _WIN32 #include <windows.h> +#include <io.h> #endif #include <errno.h> |