Skip to content

Commit

Permalink
v1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
evmar committed Jun 4, 2013
2 parents 22f60e9 + 0f53fd3 commit 045d008
Show file tree
Hide file tree
Showing 18 changed files with 389 additions and 228 deletions.
2 changes: 1 addition & 1 deletion HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ googletest (gtest) library.
* On newer Ubuntus it's only distributed as source

apt-get install libgtest-dev
./configure --with-gtest=/usr/src/gtest
./configure.py --with-gtest=/usr/src/gtest

* Otherwise you need to download it, unpack it, and pass
`--with-gtest` to `configure.py`. Get it from [its downloads
Expand Down
2 changes: 2 additions & 0 deletions RELEASING
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Notes to myself on all the steps to make for a Ninja release.
6. commit, tag, push (don't forget to push --tags)
7. construct release notes from prior notes
credits: git shortlog -s --no-merges REV..
8. update home page mention of latest version.

6 changes: 6 additions & 0 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
parser.add_option('--platform',
help='target platform (' + '/'.join(platform_helper.platforms()) + ')',
choices=platform_helper.platforms())
parser.add_option('--force-pselect', action='store_true',
help="ppoll() is used by default on Linux and OpenBSD, but older versions might need to use pselect instead",)
(options, conf_args) = parser.parse_args()


Expand Down Expand Up @@ -107,6 +109,10 @@ def run(*args, **kwargs):
cflags.append('-D_WIN32_WINNT=0x0501')
if options.x64:
cflags.append('-m64')
if (platform.is_linux() or platform.is_openbsd()) and not options.force_pselect:
cflags.append('-DUSE_PPOLL')
if options.force_pselect:
conf_args.append("--force-pselect")
args.extend(cflags)
args.extend(ldflags)
binary = 'ninja.bootstrap'
Expand Down
5 changes: 5 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
parser.add_option('--with-python', metavar='EXE',
help='use EXE as the Python interpreter',
default=os.path.basename(sys.executable))
parser.add_option('--force-pselect', action='store_true',
help="ppoll() is used by default on Linux and OpenBSD, but older versions might need to use pselect instead",)
(options, args) = parser.parse_args()
if args:
print('ERROR: extra unparsed command-line arguments:', args)
Expand Down Expand Up @@ -163,6 +165,9 @@ def binary(name):
cflags.append('-fno-omit-frame-pointer')
libs.extend(['-Wl,--no-as-needed', '-lprofiler'])

if (platform.is_linux() or platform.is_openbsd()) and not options.force_pselect:
cflags.append('-DUSE_PPOLL')

def shell_escape(str):
"""Escape str such that it's interpreted as a single argument by
the shell."""
Expand Down
4 changes: 3 additions & 1 deletion platform_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def platforms():
return ['linux', 'darwin', 'freebsd', 'openbsd', 'solaris', 'sunos5',
'mingw', 'msvc']
'mingw', 'msvc', 'gnukfreebsd8']

class Platform( object ):
def __init__( self, platform):
Expand All @@ -31,6 +31,8 @@ def __init__( self, platform):
self._platform = 'linux'
elif self._platform.startswith('freebsd'):
self._platform = 'freebsd'
elif self._platform.startswith('gnukfreebsd8'):
self._platform = 'freebsd'
elif self._platform.startswith('openbsd'):
self._platform = 'openbsd'
elif self._platform.startswith('solaris'):
Expand Down
8 changes: 6 additions & 2 deletions src/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import http.server as httpserver
except ImportError:
import BaseHTTPServer as httpserver
import os
import socket
import subprocess
import sys
import webbrowser
Expand Down Expand Up @@ -183,8 +185,10 @@ def log_message(self, format, *args):
port = 8000
httpd = httpserver.HTTPServer(('',port), RequestHandler)
try:
print('Web server running on port %d, ctl-C to abort...' % port)
webbrowser.open_new('http://localhost:%s' % port)
hostname = socket.gethostname()
print('Web server running on %s:%d, ctl-C to abort...' % (hostname,port) )
print('Web server pid %d' % os.getpid(), file=sys.stderr )
webbrowser.open_new('http://%s:%s' % (hostname, port) )
httpd.serve_forever()
except KeyboardInterrupt:
print()
Expand Down
64 changes: 64 additions & 0 deletions src/build_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1602,3 +1602,67 @@ TEST_F(BuildWithDepsLogTest, DepsIgnoredInDryRun) {

builder.command_runner_.release();
}

/// Check that a restat rule generating a header cancels compilations correctly.
TEST_F(BuildWithDepsLogTest, RestatDepfileDependency) {
string err;
// Note: in1 was created by the superclass SetUp().
const char* manifest =
"rule true\n"
" command = true\n" // Would be "write if out-of-date" in reality.
" restat = 1\n"
"build header.h: true header.in\n"
"build out: cat in1\n"
" deps = gcc\n"
" depfile = in1.d\n";
{
State state;
ASSERT_NO_FATAL_FAILURE(AddCatRule(&state));
ASSERT_NO_FATAL_FAILURE(AssertParse(&state, manifest));

// Run the build once, everything should be ok.
DepsLog deps_log;
ASSERT_TRUE(deps_log.OpenForWrite("ninja_deps", &err));
ASSERT_EQ("", err);

Builder builder(&state, config_, NULL, &deps_log, &fs_);
builder.command_runner_.reset(&command_runner_);
EXPECT_TRUE(builder.AddTarget("out", &err));
ASSERT_EQ("", err);
fs_.Create("in1.d", "out: header.h");
EXPECT_TRUE(builder.Build(&err));
EXPECT_EQ("", err);

deps_log.Close();
builder.command_runner_.release();
}

{
State state;
ASSERT_NO_FATAL_FAILURE(AddCatRule(&state));
ASSERT_NO_FATAL_FAILURE(AssertParse(&state, manifest));

// Touch the input of the restat rule.
fs_.Tick();
fs_.Create("header.in", "");

// Run the build again.
DepsLog deps_log;
ASSERT_TRUE(deps_log.Load("ninja_deps", &state, &err));
ASSERT_TRUE(deps_log.OpenForWrite("ninja_deps", &err));

Builder builder(&state, config_, NULL, &deps_log, &fs_);
builder.command_runner_.reset(&command_runner_);
command_runner_.commands_ran_.clear();
EXPECT_TRUE(builder.AddTarget("out", &err));
ASSERT_EQ("", err);
EXPECT_TRUE(builder.Build(&err));
EXPECT_EQ("", err);

// Rule "true" should have run again, but the build of "out" should have
// been cancelled due to restat propagating through the depfile header.
EXPECT_EQ(1u, command_runner_.commands_ran_.size());

builder.command_runner_.release();
}
}
1 change: 1 addition & 0 deletions src/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ bool ImplicitDepLoader::LoadDepsFromLog(Edge* edge, TimeStamp* deps_mtime,
PreallocateSpace(edge, deps->node_count);
for (int i = 0; i < deps->node_count; ++i, ++implicit_dep) {
*implicit_dep = deps->nodes[i];
deps->nodes[i]->AddOutEdge(edge);
CreatePhonyInEdge(*implicit_dep);
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/includes_normalize-win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ string IncludesNormalize::Normalize(const string& input,
}
StringPiece partially_fixed(copy, len);
if (!SameDrive(partially_fixed, relative_to))
return ToLower(partially_fixed.AsString());
return ToLower(Relativize(partially_fixed, relative_to));
return partially_fixed.AsString();
return Relativize(partially_fixed, relative_to);
}
20 changes: 10 additions & 10 deletions src/includes_normalize_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ TEST(IncludesNormalize, WithRelative) {

TEST(IncludesNormalize, Case) {
EXPECT_EQ("b", IncludesNormalize::Normalize("Abc\\..\\b", NULL));
EXPECT_EQ("bdef", IncludesNormalize::Normalize("Abc\\..\\BdEf", NULL));
EXPECT_EQ("a\\b", IncludesNormalize::Normalize("A\\.\\b", NULL));
EXPECT_EQ("a\\b", IncludesNormalize::Normalize("A\\./b", NULL));
EXPECT_EQ("a\\b", IncludesNormalize::Normalize("A\\.\\B", NULL));
EXPECT_EQ("a\\b", IncludesNormalize::Normalize("A\\./B", NULL));
EXPECT_EQ("BdEf", IncludesNormalize::Normalize("Abc\\..\\BdEf", NULL));
EXPECT_EQ("A\\b", IncludesNormalize::Normalize("A\\.\\b", NULL));
EXPECT_EQ("a\\b", IncludesNormalize::Normalize("a\\./b", NULL));
EXPECT_EQ("A\\B", IncludesNormalize::Normalize("A\\.\\B", NULL));
EXPECT_EQ("A\\B", IncludesNormalize::Normalize("A\\./B", NULL));
}

TEST(IncludesNormalize, Join) {
Expand Down Expand Up @@ -91,12 +91,12 @@ TEST(IncludesNormalize, DifferentDrive) {
EXPECT_EQ("stuff.h",
IncludesNormalize::Normalize("p:\\vs08\\stuff.h", "p:\\vs08"));
EXPECT_EQ("stuff.h",
IncludesNormalize::Normalize("P:\\vs08\\stuff.h", "p:\\vs08"));
EXPECT_EQ("p:\\vs08\\stuff.h",
IncludesNormalize::Normalize("P:\\vs08\\stuff.h", "c:\\vs08"));
EXPECT_EQ("p:\\vs08\\stuff.h",
IncludesNormalize::Normalize("P:\\vs08\\stuff.h", "D:\\stuff/things"));
IncludesNormalize::Normalize("P:\\Vs08\\stuff.h", "p:\\vs08"));
EXPECT_EQ("p:\\vs08\\stuff.h",
IncludesNormalize::Normalize("p:\\vs08\\stuff.h", "c:\\vs08"));
EXPECT_EQ("P:\\vs08\\stufF.h",
IncludesNormalize::Normalize("P:\\vs08\\stufF.h", "D:\\stuff/things"));
EXPECT_EQ("P:\\vs08\\stuff.h",
IncludesNormalize::Normalize("P:/vs08\\stuff.h", "D:\\stuff/things"));
// TODO: this fails; fix it.
//EXPECT_EQ("P:\\wee\\stuff.h",
Expand Down
7 changes: 5 additions & 2 deletions src/msvc_helper-win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "msvc_helper.h"

#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <windows.h>
Expand Down Expand Up @@ -63,14 +64,16 @@ string CLParser::FilterShowIncludes(const string& line) {
}

// static
bool CLParser::IsSystemInclude(const string& path) {
bool CLParser::IsSystemInclude(string path) {
transform(path.begin(), path.end(), path.begin(), ::tolower);
// TODO: this is a heuristic, perhaps there's a better way?
return (path.find("program files") != string::npos ||
path.find("microsoft visual studio") != string::npos);
}

// static
bool CLParser::FilterInputFilename(const string& line) {
bool CLParser::FilterInputFilename(string line) {
transform(line.begin(), line.end(), line.begin(), ::tolower);
// TODO: other extensions, like .asm?
return EndsWith(line, ".c") ||
EndsWith(line, ".cc") ||
Expand Down
5 changes: 2 additions & 3 deletions src/msvc_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ struct CLParser {
static string FilterShowIncludes(const string& line);

/// Return true if a mentioned include file is a system path.
/// Expects the path to already by normalized (including lower case).
/// Filtering these out reduces dependency information considerably.
static bool IsSystemInclude(const string& path);
static bool IsSystemInclude(string path);

/// Parse a line of cl.exe output and return true if it looks like
/// it's printing an input filename. This is a heuristic but it appears
/// to be the best we can do.
/// Exposed for testing.
static bool FilterInputFilename(const string& line);
static bool FilterInputFilename(string line);

/// Parse the full output of cl, returning the output (if any) that
/// should printed.
Expand Down
1 change: 1 addition & 0 deletions src/msvc_helper_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ TEST(CLParserTest, FilterInputFilename) {
ASSERT_TRUE(CLParser::FilterInputFilename("foobar.cc"));
ASSERT_TRUE(CLParser::FilterInputFilename("foo bar.cc"));
ASSERT_TRUE(CLParser::FilterInputFilename("baz.c"));
ASSERT_TRUE(CLParser::FilterInputFilename("FOOBAR.CC"));

ASSERT_FALSE(CLParser::FilterInputFilename(
"src\\cl_helper.cc(166) : fatal error C1075: end "
Expand Down
Loading

0 comments on commit 045d008

Please sign in to comment.