blob: 4f571c2f825f39727588421953d914a920b6cbd1 [file] [log] [blame]
oquenchil96068872019-07-08 07:01:39 -07001"""
2Copyright 2017 The Bazel Authors. All rights reserved.
Yun Peng211d2f22017-11-20 06:12:42 -08003
oquenchil96068872019-07-08 07:01:39 -07004Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15
16This is a quick and dirty rule to make Bazel compile itself. It
17only supports Java.
18"""
19
20load("@rules_cc//cc:defs.bzl", macro_cc_bin = "cc_binary", macro_cc_lib = "cc_library", macro_cc_test = "cc_test")
Yun Peng211d2f22017-11-20 06:12:42 -080021
Laszlo Csomorc60675a2019-07-15 06:06:48 -070022def win_cc_library(srcs = [], deps = [], hdrs = [], **kwargs):
vladmos20a042f2018-06-01 04:51:21 -070023 """Replace srcs and hdrs with a dummy.cc on non-Windows platforms."""
oquenchil96068872019-07-08 07:01:39 -070024 macro_cc_lib(
vladmos20a042f2018-06-01 04:51:21 -070025 srcs = select({
Yun Peng211d2f22017-11-20 06:12:42 -080026 "//conditions:default": ["dummy.cc"],
tomlu1a483d42017-11-30 15:08:40 -080027 "//src/conditions:windows": srcs,
vladmos20a042f2018-06-01 04:51:21 -070028 }),
29 hdrs = select({
Yun Peng211d2f22017-11-20 06:12:42 -080030 "//conditions:default": [],
tomlu1a483d42017-11-30 15:08:40 -080031 "//src/conditions:windows": hdrs,
vladmos20a042f2018-06-01 04:51:21 -070032 }),
Laszlo Csomorc60675a2019-07-15 06:06:48 -070033 deps = select({
34 "//conditions:default": [],
35 "//src/conditions:windows": deps,
36 }),
vladmos20a042f2018-06-01 04:51:21 -070037 **kwargs
38 )
Yun Peng211d2f22017-11-20 06:12:42 -080039
Laszlo Csomorc60675a2019-07-15 06:06:48 -070040def win_cc_binary(srcs = [], deps = [], **kwargs):
vladmos20a042f2018-06-01 04:51:21 -070041 """Replace srcs with a dummy.cc on non-Windows platforms."""
oquenchil96068872019-07-08 07:01:39 -070042 macro_cc_bin(
vladmos20a042f2018-06-01 04:51:21 -070043 srcs = select({
Yun Peng211d2f22017-11-20 06:12:42 -080044 "//conditions:default": ["dummy.cc"],
tomlu1a483d42017-11-30 15:08:40 -080045 "//src/conditions:windows": srcs,
vladmos20a042f2018-06-01 04:51:21 -070046 }),
Laszlo Csomorc60675a2019-07-15 06:06:48 -070047 deps = select({
48 "//conditions:default": [],
49 "//src/conditions:windows": deps,
50 }),
vladmos20a042f2018-06-01 04:51:21 -070051 **kwargs
52 )
Yun Peng211d2f22017-11-20 06:12:42 -080053
Laszlo Csomorc60675a2019-07-15 06:06:48 -070054def win_cc_test(srcs = [], deps = [], **kwargs):
vladmos20a042f2018-06-01 04:51:21 -070055 """Replace srcs with a dummy.cc on non-Windows platforms."""
oquenchil96068872019-07-08 07:01:39 -070056 macro_cc_test(
vladmos20a042f2018-06-01 04:51:21 -070057 srcs = select({
Yun Peng211d2f22017-11-20 06:12:42 -080058 "//conditions:default": ["dummy.cc"],
tomlu1a483d42017-11-30 15:08:40 -080059 "//src/conditions:windows": srcs,
vladmos20a042f2018-06-01 04:51:21 -070060 }),
Laszlo Csomorc60675a2019-07-15 06:06:48 -070061 deps = select({
62 "//conditions:default": [],
63 "//src/conditions:windows": deps,
64 }),
vladmos20a042f2018-06-01 04:51:21 -070065 **kwargs
66 )