Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
	configure.py
  • Loading branch information
ClausKlein committed Jul 21, 2012
2 parents 69e055c + 8a37bff commit 3b1ac8e
Show file tree
Hide file tree
Showing 16 changed files with 113 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ TAGS
.*.swp
.*~
*~
/gtest-1.6.0
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ help: ninja
./ninja -t targets

clean: build.ninja
-$(RM) build/*.o ###XXX build.ninja
-$(RM) build/*.o build.ninja

distclean: ###XXX clean
find . \( -name '*~' -o -name '.*~' -o -name '*.pyc' \) -delete
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def shell_escape(str):
options.with_python,
generator=True)
n.build('build.ninja', 'configure',
implicit=['configure.py', 'misc/ninja_syntax.py'])
implicit=['configure.py', os.path.normpath('misc/ninja_syntax.py')])
n.newline()

n.comment('Build only the main binary by default.')
Expand Down
6 changes: 3 additions & 3 deletions doc/manual.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ built for them.
If used like +ninja -t clean -r _rules_+ it removes all files built using
the given rules.
+
depfiles are not removed. Files created but not referenced in the
graph are not removed. This tool takes in account the +-v+ and the
+-n+ options (note that +-n+ implies +-v+).
Files created but not referenced in the graph are not removed. This
tool takes in account the +-v+ and the +-n+ options (note that +-n+
implies +-v+).
Expand Down
12 changes: 6 additions & 6 deletions misc/ninja_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import textwrap
import re

def escape_spaces(word):
return word.replace('$ ','$$ ').replace(' ','$ ')
def escape_path(word):
return word.replace('$ ','$$ ').replace(' ','$ ').replace(':', '$:')

class Writer(object):
def __init__(self, output, width=78):
Expand Down Expand Up @@ -53,15 +53,15 @@ def build(self, outputs, rule, inputs=None, implicit=None, order_only=None,
variables=None):
outputs = self._as_list(outputs)
all_inputs = self._as_list(inputs)[:]
out_outputs = list(map(escape_spaces, outputs))
all_inputs = list(map(escape_spaces, all_inputs))
out_outputs = list(map(escape_path, outputs))
all_inputs = list(map(escape_path, all_inputs))

if implicit:
implicit = map(escape_spaces, self._as_list(implicit))
implicit = map(escape_path, self._as_list(implicit))
all_inputs.append('|')
all_inputs.extend(implicit)
if order_only:
order_only = map(escape_spaces, self._as_list(order_only))
order_only = map(escape_path, self._as_list(order_only))
all_inputs.append('||')
all_inputs.extend(order_only)

Expand Down
1 change: 1 addition & 0 deletions src/build_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ bool BuildLog::Load(const string& path, string* err) {
if (log_version < kOldestSupportedVersion) {
*err = "unable to extract version from build log, perhaps due to "
"being too old; you must clobber your build output and rebuild";
fclose(file);
return false;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/clean.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#ifndef NINJA_CLEAN_H_
#define NINJA_CLEAN_H_
#pragma once

#include <set>
#include <string>
Expand Down
11 changes: 7 additions & 4 deletions src/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ bool Edge::RecomputeOutputDirty(BuildLog* build_log,
if (rule_->restat() && build_log &&
(entry = build_log->LookupByOutput(output->path()))) {
if (entry->restat_mtime < most_recent_input) {
EXPLAIN("restat of output %s older than inputs", output->path().c_str());
EXPLAIN("restat of output %s older than most recent input %s (0x%016" PRIx64 " vs 0x%016" PRIx64 ")",
output->path().c_str(),
most_recent_node ? most_recent_node->path().c_str() : "",
entry->restat_mtime, most_recent_input);
return true;
}
} else {
EXPLAIN("output %s older than most recent input %s (%016" PRIx64 " vs %016" PRIx64 ")",
EXPLAIN("output %s older than most recent input %s (0x%016" PRIx64 " vs 0x%016" PRIx64 ")",
output->path().c_str(),
most_recent_node ? most_recent_node->path().c_str() : "",
output->mtime(), most_recent_input);
Expand All @@ -171,7 +174,7 @@ bool Edge::RecomputeOutputDirty(BuildLog* build_log,
// FIXME: The FS time may not have ns resolution, so round to sec! ck
if (((entry->restat_mtime / 10000000LL)) != ((most_recent_node->mtime()
/ 10000000LL))) {
EXPLAIN("generator: mtime %"PRIx64" != %"PRIx64" of file %s changed",
EXPLAIN("generator: mtime 0x%016"PRIx64" != 0x%016"PRIx64" of file %s changed",
entry->restat_mtime, most_recent_node->mtime(),
most_recent_node->path().c_str());
return true;
Expand Down Expand Up @@ -355,7 +358,7 @@ bool Edge::is_phony() const {
}

void Node::Dump(const char* prefix) const {
printf("%s <%s 0x%p> mtime: %" PRIx64 "%s, (:%s), ",
printf("%s <%s 0x%p> mtime: 0x%016" PRIx64 "%s, (:%s), ",
prefix, path().c_str(), this,
mtime(), mtime()?"":" (:missing)",
dirty()?" dirty":" clean");
Expand Down
110 changes: 59 additions & 51 deletions src/lexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Lexer::Token Lexer::ReadToken() {
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 64, 64, 64, 64, 64, 64, 64,
64, 64, 0, 64, 64, 64, 64, 64,
64, 64, 0, 64, 64, 0, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
192, 64, 64, 64, 64, 64, 64, 64,
Expand Down Expand Up @@ -216,7 +216,8 @@ Lexer::Token Lexer::ReadToken() {
yy4:
yyaccept = 1;
yych = *(q = ++p);
if (yych >= 0x01) goto yy60;
if (yych <= 0x00) goto yy5;
if (yych != '\r') goto yy60;
yy5:
{ token = ERROR; break; }
yy6:
Expand Down Expand Up @@ -354,7 +355,9 @@ Lexer::Token Lexer::ReadToken() {
if (yybm[0+yych] & 64) {
goto yy59;
}
if (yych >= 0x01) goto yy62;
if (yych <= 0x00) goto yy61;
if (yych <= '\f') goto yy62;
yy61:
p = q;
if (yyaccept <= 0) {
goto yy3;
Expand Down Expand Up @@ -576,7 +579,7 @@ bool Lexer::ReadEvalString(EvalString* eval, bool path, string* err) {
unsigned char yych;
static const unsigned char yybm[] = {
0, 128, 128, 128, 128, 128, 128, 128,
128, 128, 0, 128, 128, 128, 128, 128,
128, 128, 0, 128, 128, 0, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
16, 128, 128, 128, 0, 128, 128, 128,
Expand Down Expand Up @@ -609,24 +612,25 @@ bool Lexer::ReadEvalString(EvalString* eval, bool path, string* err) {
128, 128, 128, 128, 128, 128, 128, 128,
};
yych = *p;
if (yych <= '#') {
if (yych <= ' ') {
if (yych <= '\n') {
if (yych <= 0x00) goto yy96;
if (yych >= '\n') goto yy92;
} else {
if (yych == ' ') goto yy92;
if (yych == '\r') goto yy98;
if (yych >= ' ') goto yy92;
}
} else {
if (yych <= ':') {
if (yych <= '$') goto yy94;
if (yych >= ':') goto yy92;
if (yych <= '9') {
if (yych == '$') goto yy94;
} else {
if (yych <= ':') goto yy92;
if (yych == '|') goto yy92;
}
}
++p;
yych = *p;
goto yy120;
goto yy121;
yy91:
{
eval->AddText(StringPiece(start, p - start));
Expand All @@ -649,39 +653,40 @@ bool Lexer::ReadEvalString(EvalString* eval, bool path, string* err) {
++p;
if ((yych = *p) <= '/') {
if (yych <= ' ') {
if (yych == '\n') goto yy109;
if (yych <= 0x1F) goto yy98;
goto yy100;
if (yych == '\n') goto yy110;
if (yych <= 0x1F) goto yy99;
goto yy101;
} else {
if (yych <= '$') {
if (yych <= '#') goto yy98;
goto yy102;
if (yych <= '#') goto yy99;
goto yy103;
} else {
if (yych == '-') goto yy104;
goto yy98;
if (yych == '-') goto yy105;
goto yy99;
}
}
} else {
if (yych <= '^') {
if (yych <= ':') {
if (yych <= '9') goto yy104;
goto yy106;
if (yych <= '9') goto yy105;
goto yy107;
} else {
if (yych <= '@') goto yy98;
if (yych <= 'Z') goto yy104;
goto yy98;
if (yych <= '@') goto yy99;
if (yych <= 'Z') goto yy105;
goto yy99;
}
} else {
if (yych <= '`') {
if (yych <= '_') goto yy104;
goto yy98;
if (yych <= '_') goto yy105;
goto yy99;
} else {
if (yych <= 'z') goto yy104;
if (yych <= '{') goto yy108;
goto yy98;
if (yych <= 'z') goto yy105;
if (yych <= '{') goto yy109;
goto yy99;
}
}
}
yy95:
{
last_token_ = start;
return Error("lexing error", err);
Expand All @@ -693,83 +698,86 @@ bool Lexer::ReadEvalString(EvalString* eval, bool path, string* err) {
return Error("unexpected EOF", err);
}
yy98:
++p;
yych = *++p;
goto yy95;
yy99:
++p;
yy100:
{
last_token_ = start;
return Error("bad $-escape (literal $ must be written as $$)", err);
}
yy100:
yy101:
++p;
{
eval->AddText(StringPiece(" ", 1));
continue;
}
yy102:
yy103:
++p;
{
eval->AddText(StringPiece("$", 1));
continue;
}
yy104:
yy105:
++p;
yych = *p;
goto yy118;
yy105:
goto yy119;
yy106:
{
eval->AddSpecial(StringPiece(start + 1, p - start - 1));
continue;
}
yy106:
yy107:
++p;
{
eval->AddText(StringPiece(":", 1));
continue;
}
yy108:
yy109:
yych = *(q = ++p);
if (yybm[0+yych] & 32) {
goto yy112;
goto yy113;
}
goto yy99;
yy109:
goto yy100;
yy110:
++p;
yych = *p;
if (yybm[0+yych] & 16) {
goto yy109;
goto yy110;
}
{
continue;
}
yy112:
yy113:
++p;
yych = *p;
if (yybm[0+yych] & 32) {
goto yy112;
goto yy113;
}
if (yych == '}') goto yy115;
if (yych == '}') goto yy116;
p = q;
goto yy99;
yy115:
goto yy100;
yy116:
++p;
{
eval->AddSpecial(StringPiece(start + 2, p - start - 3));
continue;
}
yy117:
yy118:
++p;
yych = *p;
yy118:
yy119:
if (yybm[0+yych] & 64) {
goto yy117;
goto yy118;
}
goto yy105;
yy119:
goto yy106;
yy120:
++p;
yych = *p;
yy120:
yy121:
if (yybm[0+yych] & 128) {
goto yy119;
goto yy120;
}
goto yy91;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lexer.in.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Lexer::Token Lexer::ReadToken() {
simple_varname = [a-zA-Z0-9_-]+;
varname = [a-zA-Z0-9_.-]+;
[ ]*"#"[^\000\n]*"\n" { continue; }
[ ]*"#"[^\000\r\n]*"\n" { continue; }
[ ]*[\n] { token = NEWLINE; break; }
[ ]+ { token = INDENT; break; }
"build" { token = BUILD; break; }
Expand Down Expand Up @@ -200,7 +200,7 @@ bool Lexer::ReadEvalString(EvalString* eval, bool path, string* err) {
for (;;) {
start = p;
/*!re2c
[^$ :\n|\000]+ {
[^$ :\r\n|\000]+ {
eval->AddText(StringPiece(start, p - start));
continue;
}
Expand Down
20 changes: 20 additions & 0 deletions src/manifest_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,23 @@ TEST_F(ParserTest, UTF8) {
" command = true\n"
" description = compilaci\xC3\xB3\n"));
}

// We might want to eventually allow CRLF to be nice to Windows developers,
// but for now just verify we error out with a nice message.
TEST_F(ParserTest, CRLF) {
State state;
ManifestParser parser(&state, NULL);
string err;

EXPECT_FALSE(parser.ParseTest("# comment with crlf\r\n",
&err));
EXPECT_EQ("input:1: lexing error\n",
err);

EXPECT_FALSE(parser.ParseTest("foo = foo\nbar = bar\r\n",
&err));
EXPECT_EQ("input:2: lexing error\n"
"bar = bar\r\n"
" ^ near here",
err);
}
Loading

0 comments on commit 3b1ac8e

Please sign in to comment.