Skip to content

Commit

Permalink
Make Bazel build with MSVC-default-toolchain Bazel
Browse files Browse the repository at this point in the history
After this change, a msys bazel can be built with
a MSVC-default Bazel by adding --cpu=x64_windows_msys --host=x64_windows_msys

See bazelbuild#2627

--
Change-Id: Iaa82bf4dd911c5740b98d3b2739dfccca6203f79
Reviewed-on: https://cr.bazel.build/9293
PiperOrigin-RevId: 149532274
MOS_MIGRATED_REVID=149532274
  • Loading branch information
meteorcloudy authored and vladmos committed Mar 8, 2017
1 parent c77eac9 commit cb8a5e2
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 1 deletion.
6 changes: 6 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ if [[ $PLATFORM == "darwin" ]] && \
xcodebuild -showsdks 2> /dev/null | grep -q '\-sdk iphonesimulator'; then
EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS-} --define IPHONE_SDK=1"
fi

case "${PLATFORM}" in
msys*|mingw*)
EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS-} --cpu=x64_windows_msys --host_cpu=x64_windows_msys"
esac

source scripts/bootstrap/bootstrap.sh

if [ $DO_COMPILE ]; then
Expand Down
7 changes: 7 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ filegroup(
":darwin": ["//src/main/native:libunix.dylib"],
":darwin_x86_64": ["//src/main/native:libunix.dylib"],
":windows": ["//src/main/native:windows_jni.dll"],
":windows_msys": ["//src/main/native:windows_jni.dll"],
":windows_msvc": ["//src/main/native:windows_jni.dll"],
"//conditions:default": ["//src/main/native:libunix.so"],
}),
Expand Down Expand Up @@ -279,6 +280,12 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "windows_msys",
values = {"cpu": "x64_windows_msys"},
visibility = ["//visibility:public"],
)

filegroup(
name = "srcs",
srcs = glob(["**"]) + [
Expand Down
4 changes: 4 additions & 0 deletions src/main/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ cc_library(
"//src:windows": [
"blaze_util_windows.cc",
],
"//src:windows_msys": [
"blaze_util_windows.cc",
],
"//src:windows_msvc": [
"blaze_util_windows.cc",
],
Expand Down Expand Up @@ -60,6 +63,7 @@ cc_library(
"//src/main/cpp/util:blaze_exit_code",
] + select({
"//src:windows": ["//src/main/native:windows_jni_lib"],
"//src:windows_msys": ["//src/main/native:windows_jni_lib"],
"//src:windows_msvc": ["//src/main/native:windows_jni_lib"],
"//conditions:default": [],
}),
Expand Down
5 changes: 5 additions & 0 deletions src/main/cpp/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ cc_library(
"//src:windows": [
"file_windows.cc",
],
"//src:windows_msys": [
"file_windows.cc",
],
"//src:windows_msvc": [
"file_windows.cc",
],
Expand All @@ -57,6 +60,7 @@ cc_library(
":strings",
] + select({
"//src:windows": ["//src/main/native:windows_jni_lib"],
"//src:windows_msys": ["//src/main/native:windows_jni_lib"],
"//src:windows_msvc": ["//src/main/native:windows_jni_lib"],
"//conditions:default": [],
}),
Expand All @@ -66,6 +70,7 @@ cc_library(
name = "errors",
srcs = ["errors.cc"] + select({
"//src:windows": ["errors_windows.cc"],
"//src:windows_msys": ["errors_windows.cc"],
"//src:windows_msvc": ["errors_windows.cc"],
"//conditions:default": ["errors_posix.cc"],
}),
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ java_library(
resources = select({
# todo(dslomov): Get rid of this whole library on Windows.
"//src:windows": [],
"//src:windows_msys": [],
"//src:windows_msvc": [],
"//conditions:default": ["//src/main/native:libunix.so"],
}),
Expand Down
1 change: 1 addition & 0 deletions src/main/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ cc_binary(
"//src:darwin_x86_64": ["dummy-sandbox.c"],
"//src:freebsd": ["dummy-sandbox.c"],
"//src:windows": ["dummy-sandbox.c"],
"//src:windows_msys": ["dummy-sandbox.c"],
"//src:windows_msvc": ["dummy-sandbox.c"],
"//conditions:default": [
"linux-sandbox.cc",
Expand Down
4 changes: 4 additions & 0 deletions src/test/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ cc_test(
"blaze_util_test.cc",
"blaze_util_windows_test.cc",
],
"//src:windows_msys": [
"blaze_util_test.cc",
"blaze_util_windows_test.cc",
],
"//src:windows_msvc": [
"blaze_util_windows_test.cc",
],
Expand Down
15 changes: 14 additions & 1 deletion src/test/cpp/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ cc_test(
size = "small",
srcs = ["file_test.cc"] + select({
"//src:windows": [
"file_posix_test.cc",
"file_windows_test.cc",
],
"//src:windows_msys": [
"file_windows_test.cc",
],
"//src:windows_msvc": [
Expand All @@ -43,6 +45,10 @@ cc_test(
":windows_test_util",
"//src/main/native:windows_jni_lib",
],
"//src:windows_msys": [
":windows_test_util",
"//src/main/native:windows_jni_lib",
],
"//src:windows_msvc": [
":windows_test_util",
"//src/main/native:windows_jni_lib",
Expand Down Expand Up @@ -86,11 +92,13 @@ cc_library(
testonly = 1,
srcs = select({
"//src:windows": ["windows_test_util.cc"],
"//src:windows_msys": ["windows_test_util.cc"],
"//src:windows_msvc": ["windows_test_util.cc"],
"//conditions:default": [],
}),
hdrs = select({
"//src:windows": ["windows_test_util.h"],
"//src:windows_msys": ["windows_test_util.h"],
"//src:windows_msvc": ["windows_test_util.h"],
"//conditions:default": [],
}),
Expand All @@ -105,6 +113,7 @@ cc_test(
size = "small",
srcs = select({
"//src:windows": ["windows_test_util_test.cc"],
"//src:windows_msys": ["windows_test_util_test.cc"],
"//src:windows_msvc": ["windows_test_util_test.cc"],
"//conditions:default": ["dummy_test.cc"],
}),
Expand All @@ -113,6 +122,10 @@ cc_test(
":windows_test_util",
"//third_party:gtest",
],
"//src:windows_msys": [
":windows_test_util",
"//third_party:gtest",
],
"//src:windows_msvc": [
":windows_test_util",
"//third_party:gtest",
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/google/devtools/build/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ALL_WINDOWS_TESTS = CROSS_PLATFORM_WINDOWS_TESTS + WINDOWS_ON_WINDOWS_TESTS

JNI_LIB = select({
"//src:windows": ["//src/main/native:windows_jni.dll"],
"//src:windows_msys": ["//src/main/native:windows_jni.dll"],
"//src:windows_msvc": ["//src/main/native:windows_jni.dll"],
"//conditions:default": [
"//src/main/native:libunix.dylib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ java_test(
name = "RepositoryTests",
srcs = select({
"//src:windows": [":RepositoryTests_windows_srcs"],
"//src:windows_msys": [":RepositoryTests_windows_srcs"],
"//src:windows_msvc": [":RepositoryTests_windows_srcs"],
"//conditions:default": glob(["*.java"]),
}),
Expand Down
9 changes: 9 additions & 0 deletions src/test/native/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ cc_test(
"windows_util_test.cc",
"windows_file_operations_test.cc",
],
"//src:windows_msys": [
"windows_util_test.cc",
"windows_file_operations_test.cc",
],
"//src:windows_msvc": [
"windows_util_test.cc",
"windows_file_operations_test.cc",
Expand All @@ -28,6 +32,11 @@ cc_test(
"//src/test/cpp/util:windows_test_util",
"//third_party:gtest",
],
"//src:windows_msys": [
"//src/main/native:windows_jni_lib",
"//src/test/cpp/util:windows_test_util",
"//third_party:gtest",
],
"//src:windows_msvc": [
"//src/main/native:windows_jni_lib",
"//src/test/cpp/util:windows_test_util",
Expand Down
1 change: 1 addition & 0 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ sh_test(
"//src:darwin": [],
"//src:darwin_x86_64": [],
"//src:windows": [],
"//src:windows_msys": [],
"//src:windows_msvc": [],
"//conditions:default": ["//src/test/shell/bazel/testdata:bazel_toolchain_test_project_pkg"],
}),
Expand Down

0 comments on commit cb8a5e2

Please sign in to comment.