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',
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:
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()
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:
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):
#ifdef _WIN32
#include <windows.h>
#else
+#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/termios.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "build.h"
#include "graph.h"
/// 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_;
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");
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
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);
// 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();
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) {
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());
#include <windows.h>
#else
#include <getopt.h>
+#include <unistd.h>
#endif
#include "browse.h"
#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_);
#ifdef _WIN32
#include <windows.h>
+#include <io.h>
#endif
#include <errno.h>