aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-01-31 12:48:20 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-01-31 13:46:14 +0000
commit3f82cc139f6650e0c201466fa395941ef00c5213 (patch)
tree1266ba6e75367622cad26d655cc68efb257b645b
parent41ab6db797bac30c8e39fc705254fef329b6fdbc (diff)
Bazel can now be built on Windows with MSVC
bazel build //src:bazel --cpu=x64_windows_msvc now succeeds, hooray! This change adds empty implementations for build-runfiles and process-wrapper to make that possible. This means we can now build a bazel binary that doesn't depend on MSYS. The resulting binary is not yet functional because many methods are still to be implemented, and they just write "TODO: implement" or something similar. But still this is great news, because now we can add compile tests to the CI for MSVC! See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 146106178 MOS_MIGRATED_REVID=146106178
-rw-r--r--src/main/tools/BUILD23
-rw-r--r--src/main/tools/build-runfiles-windows.cc27
-rw-r--r--src/main/tools/process-wrapper-windows.cc26
3 files changed, 69 insertions, 7 deletions
diff --git a/src/main/tools/BUILD b/src/main/tools/BUILD
index 2c52acf6db..d7bb93bdcf 100644
--- a/src/main/tools/BUILD
+++ b/src/main/tools/BUILD
@@ -2,18 +2,27 @@ package(default_visibility = ["//src:__subpackages__"])
cc_binary(
name = "process-wrapper",
- srcs = [
- "process-tools.c",
- "process-tools.h",
- "process-wrapper.c",
- ],
- copts = ["-std=c99"],
+ srcs = select({
+ "//src:windows_msvc": ["process-wrapper-windows.cc"],
+ "//conditions:default": [
+ "process-tools.c",
+ "process-tools.h",
+ "process-wrapper.c",
+ ],
+ }),
+ copts = select({
+ "//src:windows_msvc": [],
+ "//conditions:default": ["-std=c99"],
+ }),
linkopts = ["-lm"],
)
cc_binary(
name = "build-runfiles",
- srcs = ["build-runfiles.cc"],
+ srcs = select({
+ "//src:windows_msvc": ["build-runfiles-windows.cc"],
+ "//conditions:default": ["build-runfiles.cc"],
+ }),
)
cc_binary(
diff --git a/src/main/tools/build-runfiles-windows.cc b/src/main/tools/build-runfiles-windows.cc
new file mode 100644
index 0000000000..ea4eed189a
--- /dev/null
+++ b/src/main/tools/build-runfiles-windows.cc
@@ -0,0 +1,27 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <iostream>
+
+int main(int argc, char** argv) {
+ // TODO(bazel-team): decide whether we need build-runfiles at all on Windows.
+ // Implement this program if so; make sure we don't run it on Windows if not.
+ std::cout << "ERROR: build-runfiles is not (yet?) implemented on Windows."
+ << std::endl
+ << "Called with args:" << std::endl;
+ for (int i = 0; i < argc; ++i) {
+ std::cout << "argv[" << i << "]=(" << argv[i] << ")" << std::endl;
+ }
+ return 1;
+}
diff --git a/src/main/tools/process-wrapper-windows.cc b/src/main/tools/process-wrapper-windows.cc
new file mode 100644
index 0000000000..e113968b72
--- /dev/null
+++ b/src/main/tools/process-wrapper-windows.cc
@@ -0,0 +1,26 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <iostream>
+
+int main(int argc, char** argv) {
+ // TODO(bazel-team): implement this program.
+ std::cout << "ERROR: process-wrapper is not yet implemented on Windows."
+ << std::endl
+ << "Called with args:" << std::endl;
+ for (int i = 0; i < argc; ++i) {
+ std::cout << "argv[" << i << "]=(" << argv[i] << ")" << std::endl;
+ }
+ return 1;
+}