summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-09-13 18:07:45 (GMT)
committerEvan Martin <martine@danga.com>2012-09-13 18:11:47 (GMT)
commitc57f8a4258998a185f961ce12fd7c905a3e86180 (patch)
tree8651047b7ac8387f50348b6c37d8c5d6dd8addd4 /src
parentce825d2f6e2bb8a0fa0bb97fe961d5f194f8f6f8 (diff)
downloadNinja-c57f8a4258998a185f961ce12fd7c905a3e86180.zip
Ninja-c57f8a4258998a185f961ce12fd7c905a3e86180.tar.gz
Ninja-c57f8a4258998a185f961ce12fd7c905a3e86180.tar.bz2
windows: merge msvc-helper into ninja.exe itself
Now "ninja -t msvc ..." passes the "..." to the msvc helper main. This drastically simplifies bootstrap and makes ninja a single binary again.
Diffstat (limited to 'src')
-rw-r--r--src/msvc_helper_main-win32.cc10
-rw-r--r--src/ninja.cc17
2 files changed, 22 insertions, 5 deletions
diff --git a/src/msvc_helper_main-win32.cc b/src/msvc_helper_main-win32.cc
index f265010..0c8db37 100644
--- a/src/msvc_helper_main-win32.cc
+++ b/src/msvc_helper_main-win32.cc
@@ -24,9 +24,7 @@ namespace {
void Usage() {
printf(
-"ninja-msvc-helper: adjust msvc command-line tools for use by ninja.\n"
-"\n"
-"usage: ninja-mvsc-helper [options] -- command args\n"
+"usage: ninja -t msvc [options] -- cl.exe /showIncludes /otherArgs\n"
"options:\n"
" -e ENVFILE load environment block from ENVFILE as environment\n"
" -r BASE normalize paths and make relative to BASE before output\n"
@@ -48,7 +46,7 @@ void PushPathIntoEnvironment(const string& env_block) {
} // anonymous namespace
-int main(int argc, char** argv) {
+int MSVCHelperMain(int argc, char** argv) {
const char* output_filename = NULL;
const char* relative_to = NULL;
const char* envfile = NULL;
@@ -76,8 +74,10 @@ int main(int argc, char** argv) {
}
}
- if (!output_filename)
+ if (!output_filename) {
+ Usage();
Fatal("-o required");
+ }
string env;
if (envfile) {
diff --git a/src/ninja.cc b/src/ninja.cc
index fb273be..089dbc1 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -42,6 +42,9 @@
#include "state.h"
#include "util.h"
+// Defined in msvc_helper_main-win32.cc.
+int MSVCHelperMain(int argc, char** argv);
+
namespace {
/// The version number of the current Ninja release. This will always
@@ -289,6 +292,16 @@ int ToolBrowse(Globals* globals, int argc, char* argv[]) {
}
#endif // _WIN32
+#if defined(WIN32)
+int ToolMSVC(Globals* globals, int argc, char* argv[]) {
+ // Reset getopt: push one argument onto the front of argv, reset optind.
+ argc++;
+ argv--;
+ optind = 0;
+ return MSVCHelperMain(argc, argv);
+}
+#endif
+
int ToolTargetsList(const vector<Node*>& nodes, int depth, int indent) {
for (vector<Node*>::const_iterator n = nodes.begin();
n != nodes.end();
@@ -524,6 +537,10 @@ int ChooseTool(const string& tool_name, const Tool** tool_out) {
{ "browse", "browse dependency graph in a web browser",
Tool::RUN_AFTER_LOAD, ToolBrowse },
#endif
+#if defined(WIN32)
+ { "msvc", "build helper for MSVC cl.exe",
+ Tool::RUN_AFTER_FLAGS, ToolMSVC },
+#endif
{ "clean", "clean built files",
Tool::RUN_AFTER_LOAD, ToolClean },
{ "commands", "list all commands required to rebuild given targets",