diff options
author | Jan Niklas Hasse <jhasse@bixense.com> | 2018-11-16 11:46:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-16 11:46:56 (GMT) |
commit | 845213a9cd882394d011cb22a0c6cffa39361526 (patch) | |
tree | bc7b1183a39b1e374433d7190db4bacdbb3f4600 | |
parent | 516f637504da31ddecba3cb29d3e3d7e7ba61227 (diff) | |
parent | 1463fdc0f73136aca4869be9ad577d08528b19c4 (diff) | |
download | Ninja-845213a9cd882394d011cb22a0c6cffa39361526.zip Ninja-845213a9cd882394d011cb22a0c6cffa39361526.tar.gz Ninja-845213a9cd882394d011cb22a0c6cffa39361526.tar.bz2 |
Merge pull request #1474 from mathstuf/win32-invalid-parameter-help
Win32 invalid parameter help
-rw-r--r-- | doc/manual.asciidoc | 3 | ||||
-rw-r--r-- | src/subprocess-win32.cc | 4 | ||||
-rw-r--r-- | src/util.cc | 8 | ||||
-rw-r--r-- | src/util.h | 2 |
4 files changed, 13 insertions, 4 deletions
diff --git a/doc/manual.asciidoc b/doc/manual.asciidoc index 86d9aaa..7b1c3ba 100644 --- a/doc/manual.asciidoc +++ b/doc/manual.asciidoc @@ -880,7 +880,8 @@ quoting rules are deterimined by the called program, which on Windows are usually provided by the C library. If you need shell interpretation of the command (such as the use of `&&` to chain multiple commands), make the command execute the Windows shell by -prefixing the command with `cmd /c`. +prefixing the command with `cmd /c`. Ninja may error with "invalid parameter" +which usually indicates that the command line length has been exceeded. [[ref_outputs]] Build outputs diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc index 5982b06..a4a7669 100644 --- a/src/subprocess-win32.cc +++ b/src/subprocess-win32.cc @@ -124,6 +124,10 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) { buf_ = "CreateProcess failed: The system cannot find the file " "specified.\n"; return true; + } else if (error == ERROR_INVALID_PARAMETER) { + // This generally means that the command line was too long. Give extra + // context for this case. + Win32Fatal("CreateProcess", "is the command line too long?"); } else { Win32Fatal("CreateProcess"); // pass all other errors to Win32Fatal } diff --git a/src/util.cc b/src/util.cc index e793a92..47a5de2 100644 --- a/src/util.cc +++ b/src/util.cc @@ -442,8 +442,12 @@ string GetLastErrorString() { return msg; } -void Win32Fatal(const char* function) { - Fatal("%s: %s", function, GetLastErrorString().c_str()); +void Win32Fatal(const char* function, const char* hint) { + if (hint) { + Fatal("%s: %s (%s)", function, GetLastErrorString().c_str(), hint); + } else { + Fatal("%s: %s", function, GetLastErrorString().c_str()); + } } #endif @@ -119,7 +119,7 @@ bool Truncate(const string& path, size_t size, string* err); string GetLastErrorString(); /// Calls Fatal() with a function name and GetLastErrorString. -NORETURN void Win32Fatal(const char* function); +NORETURN void Win32Fatal(const char* function, const char* hint = NULL); #endif #endif // NINJA_UTIL_H_ |