From: Evan Martin Date: Sun, 6 Feb 2011 17:12:39 +0000 (-0800) Subject: create builddir on start; fixes bootstrap X-Git-Tag: release-120715~483^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6a3ed4c7f7e1295de185dccdd0df22d3a90af12;p=platform%2Fupstream%2Fninja.git create builddir on start; fixes bootstrap --- diff --git a/src/ninja.cc b/src/ninja.cc index 39cbfed..41ee1ff 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -1,9 +1,12 @@ #include "ninja.h" +#include #include #include #include #include +#include +#include #include "build.h" #include "build_log.h" @@ -206,7 +209,16 @@ int main(int argc, char** argv) { const string build_dir = state.bindings_.LookupVariable("builddir"); const char* kLogPath = ".ninja_log"; - string log_path = build_dir.empty() ? kLogPath : build_dir + "/" + kLogPath; + 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)); + 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());