diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-19 04:50:00 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-19 04:50:00 +0000 |
commit | 684d45b2feac114a0152cf4458846fbeca61b5d9 (patch) | |
tree | 781a604308f2866d6b321d6cfbe238c2732cc469 /src/google/protobuf/compiler/subprocess.h | |
parent | bdbb863099c7ef3e1ecdeefa732798e095b85fb8 (diff) |
Fix build on MinGW/Win32 (including implementing Subprocess using CreateProcess()).
Diffstat (limited to 'src/google/protobuf/compiler/subprocess.h')
-rw-r--r-- | src/google/protobuf/compiler/subprocess.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/google/protobuf/compiler/subprocess.h b/src/google/protobuf/compiler/subprocess.h index d7e6ed58..f9e8ae8d 100644 --- a/src/google/protobuf/compiler/subprocess.h +++ b/src/google/protobuf/compiler/subprocess.h @@ -33,12 +33,16 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__ #define GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__ -#include <vector> -#include <string> +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN // right... +#include <windows.h> +#else // _WIN32 #include <sys/types.h> #include <unistd.h> -#include <google/protobuf/stubs/common.h> +#endif // !_WIN32 +#include <string> +#include <google/protobuf/stubs/common.h> namespace google { namespace protobuf { @@ -69,13 +73,31 @@ class Subprocess { // *error to a description of the problem. bool Communicate(const Message& input, Message* output, string* error); +#ifdef _WIN32 + // Given an error code, returns a human-readable error message. This is + // defined here so that CommandLineInterface can share it. + static string Subprocess::Win32ErrorMessage(DWORD error_code); +#endif + private: +#ifdef _WIN32 + DWORD process_start_error_; + HANDLE child_handle_; + + // The file handles for our end of the child's pipes. We close each and + // set it to NULL when no longer needed. + HANDLE child_stdin_; + HANDLE child_stdout_; + +#else // _WIN32 pid_t child_pid_; // The file descriptors for our end of the child's pipes. We close each and // set it to -1 when no longer needed. int child_stdin_; int child_stdout_; + +#endif // !_WIN32 }; } // namespace compiler |