summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-04-15 19:26:45 (GMT)
committerEvan Martin <martine@danga.com>2011-04-15 19:26:45 (GMT)
commite5891f73fea0879851312fbaec8f32490fa4638c (patch)
tree73345c0ee79d2d92c0c2f718557d7785e8c00905
parentece2d63323bde9fd89956193167e09708802d73c (diff)
parent9d5fd61c00b34511fd16bce1a3233743c7e4448f (diff)
downloadNinja-e5891f73fea0879851312fbaec8f32490fa4638c.zip
Ninja-e5891f73fea0879851312fbaec8f32490fa4638c.tar.gz
Ninja-e5891f73fea0879851312fbaec8f32490fa4638c.tar.bz2
Merge branch 'master' of github.com:martine/ninja
Conflicts: src/util.cc src/util.h
-rw-r--r--README3
-rw-r--r--src/build_log.h5
-rw-r--r--src/hash_map.h5
-rwxr-xr-xsrc/inline.sh2
-rw-r--r--src/ninja.cc19
-rw-r--r--src/subprocess.h5
-rw-r--r--src/test.h5
-rw-r--r--src/util.cc11
-rw-r--r--src/util.h3
9 files changed, 47 insertions, 11 deletions
diff --git a/README b/README
index be46134..b7ec4cd 100644
--- a/README
+++ b/README
@@ -6,3 +6,6 @@ including motivation and build instructions.
Though the code is copyright Google, don't take that as an
endorsement; I wrote this in my spare time for fun.
+
+Discussions about Ninja should take place on the mailing list:
+http://groups.google.com/group/ninja-build
diff --git a/src/build_log.h b/src/build_log.h
index be12d85..a671467 100644
--- a/src/build_log.h
+++ b/src/build_log.h
@@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#ifndef NINJA_BUILD_LOG_H_
+#define NINJA_BUILD_LOG_H_
+
#include <map>
#include <string>
using namespace std;
@@ -61,3 +64,5 @@ struct BuildLog {
BuildConfig* config_;
bool needs_recompaction_;
};
+
+#endif // NINJA_BUILD_LOG_H_
diff --git a/src/hash_map.h b/src/hash_map.h
index 45a83a9..dd63c01 100644
--- a/src/hash_map.h
+++ b/src/hash_map.h
@@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#ifndef NINJA_MAP_H_
+#define NINJA_MAP_H_
+
#include <ext/hash_map>
using __gnu_cxx::hash_map;
@@ -24,3 +27,5 @@ struct hash<std::string> {
}
};
}
+
+#endif // NINJA_MAP_H_
diff --git a/src/inline.sh b/src/inline.sh
index 5ea082d..5acc17b 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| |\\x|g; s|^|"|; s|$|"|'
+od -t x1 -A n -v | sed -e 's| ||g; s|..|\\x&|g; s|^|"|; s|$|"|'
echo ";"
diff --git a/src/ninja.cc b/src/ninja.cc
index c113bfb..35d25e0 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -34,6 +34,7 @@
#include "graph.h"
#include "graphviz.h"
#include "parsers.h"
+#include "util.h"
option options[] = {
{ "help", no_argument, NULL, 'h' },
@@ -164,7 +165,7 @@ int main(int argc, char** argv) {
}
}
if (optind >= argc) {
- fprintf(stderr, "expected target to build\n");
+ Error("expected target to build");
usage(config);
return 1;
}
@@ -182,7 +183,7 @@ int main(int argc, char** argv) {
ManifestParser parser(&state, &file_reader);
string err;
if (!parser.Load(input_file, &err)) {
- fprintf(stderr, "error loading '%s': %s\n", input_file, err.c_str());
+ Error("loading '%s': %s", input_file, err.c_str());
return 1;
}
@@ -193,7 +194,7 @@ int main(int argc, char** argv) {
return CmdQuery(&state, argc, argv);
if (tool == "browse")
return CmdBrowse(&state, argc, argv);
- fprintf(stderr, "unknown tool '%s'\n", tool.c_str());
+ Error("unknown tool '%s'", tool.c_str());
}
BuildLog build_log;
@@ -205,21 +206,21 @@ int main(int argc, char** argv) {
string log_path = kLogPath;
if (!build_dir.empty()) {
if (mkdir(build_dir.c_str(), 0777) < 0 && errno != EEXIST) {
- fprintf(stderr, "Error creating build directory %s: %s\n",
- build_dir.c_str(), strerror(errno));
+ Error("creating build directory %s: %s",
+ build_dir.c_str(), strerror(errno));
return 1;
}
log_path = build_dir + "/" + kLogPath;
}
if (!build_log.Load(log_path.c_str(), &err)) {
- fprintf(stderr, "error loading build log %s: %s\n",
- log_path.c_str(), err.c_str());
+ Error("loading build log %s: %s",
+ log_path.c_str(), err.c_str());
return 1;
}
if (!build_log.OpenForWrite(log_path.c_str(), &err)) {
- fprintf(stderr, "error opening build log: %s\n", err.c_str());
+ Error("opening build log: %s", err.c_str());
return 1;
}
@@ -227,7 +228,7 @@ int main(int argc, char** argv) {
for (int i = 0; i < argc; ++i) {
if (!builder.AddTarget(argv[i], &err)) {
if (!err.empty()) {
- fprintf(stderr, "%s\n", err.c_str());
+ Error("%s", err.c_str());
return 1;
} else {
// Added a target that is already up-to-date; not really
diff --git a/src/subprocess.h b/src/subprocess.h
index 35b7914..acdb625 100644
--- a/src/subprocess.h
+++ b/src/subprocess.h
@@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#ifndef NINJA_SUBPROCESS_H_
+#define NINJA_SUBPROCESS_H_
+
#include <string>
#include <vector>
#include <queue>
@@ -54,3 +57,5 @@ struct SubprocessSet {
vector<Subprocess*> running_;
queue<Subprocess*> finished_;
};
+
+#endif // NINJA_SUBPROCESS_H_
diff --git a/src/test.h b/src/test.h
index 74ee430..988617f 100644
--- a/src/test.h
+++ b/src/test.h
@@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#ifndef NINJA_TEST_H_
+#define NINJA_TEST_H_
+
#include <gtest/gtest.h>
#include "ninja.h"
@@ -53,3 +56,5 @@ struct VirtualFileSystem : public DiskInterface {
typedef map<string, Entry> FileMap;
FileMap files_;
};
+
+#endif // NINJA_TEST_H_
diff --git a/src/util.cc b/src/util.cc
index d0236bc..b68227b 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -22,7 +22,7 @@
void Fatal(const char* msg, ...) {
va_list ap;
- fprintf(stderr, "FATAL: ");
+ fprintf(stderr, "ninja: FATAL: ");
va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
@@ -30,6 +30,15 @@ void Fatal(const char* msg, ...) {
exit(1);
}
+void Error(const char* msg, ...) {
+ va_list ap;
+ fprintf(stderr, "ninja: error: ");
+ va_start(ap, msg);
+ vfprintf(stderr, msg, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+
bool CanonicalizePath(std::string* path, std::string* err) {
// Try to fast-path out the common case.
if (path->find("/.") == std::string::npos &&
diff --git a/src/util.h b/src/util.h
index efbb88b..dc3e40f 100644
--- a/src/util.h
+++ b/src/util.h
@@ -21,6 +21,9 @@
// Log a fatal message, dump a backtrace, and exit.
void Fatal(const char* msg, ...);
+// Log an error message.
+void Error(const char* msg, ...);
+
// Canonicalize a path like "foo/../bar.h" into just "bar.h".
bool CanonicalizePath(std::string* path, std::string* err);