diff options
author | Evan Martin <martine@danga.com> | 2011-03-22 21:29:48 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-03-22 21:29:48 (GMT) |
commit | 9d5fd61c00b34511fd16bce1a3233743c7e4448f (patch) | |
tree | 53222e97f616b8d79cacfae06e73884905204f8f | |
parent | b909f149b3fee2ec9a8c0339185b3640a393b056 (diff) | |
parent | 52925ea07e4bfd98e6b3febbc0594f5da634f5d3 (diff) | |
download | Ninja-9d5fd61c00b34511fd16bce1a3233743c7e4448f.zip Ninja-9d5fd61c00b34511fd16bce1a3233743c7e4448f.tar.gz Ninja-9d5fd61c00b34511fd16bce1a3233743c7e4448f.tar.bz2 |
Merge branch 'errors-reporting' of https://github.com/polrop/ninja
-rw-r--r-- | src/build_log.h | 5 | ||||
-rw-r--r-- | src/hash_map.h | 5 | ||||
-rw-r--r-- | src/ninja.cc | 19 | ||||
-rw-r--r-- | src/subprocess.h | 5 | ||||
-rw-r--r-- | src/test.h | 5 | ||||
-rw-r--r-- | src/util.cc | 11 | ||||
-rw-r--r-- | src/util.h | 8 |
7 files changed, 48 insertions, 10 deletions
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/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_ @@ -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 1968702..a2e080f 100644 --- a/src/util.cc +++ b/src/util.cc @@ -20,10 +20,19 @@ 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); fprintf(stderr, "\n"); 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"); +} @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef NINJA_UTIL_H_ +#define NINJA_UTIL_H_ + // Dump a backtrace to stderr. // |skip_frames| is how many frames to skip; // DumpBacktrace implicitly skips itself already. @@ -19,3 +22,8 @@ void DumpBacktrace(int skip_frames); // Log a fatal message, dump a backtrace, and exit. void Fatal(const char* msg, ...); + +// Log an error message. +void Error(const char* msg, ...); + +#endif // NINJA_UTIL_H_ |