Skip to content

Commit 6c95eec

Browse files
peterebdenTatskaarichrisnovakovic
authored
Add subincludes (#28)
Means that consuming repos don't have to always globally subinclude the rules in order to use them. Co-authored-by: Jon Poole <[email protected]> Co-authored-by: Chris Novakovic <[email protected]>
1 parent a6fba27 commit 6c95eec

File tree

18 files changed

+65
-54
lines changed

18 files changed

+65
-54
lines changed

Diff for: .plzconfig

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
[please]
2-
version = >=16.12.1
3-
4-
[parse]
5-
preloadbuilddefs = build_defs/cc.build_defs
2+
version = >=17.0.0
3+
4+
[Plugin "python"]
5+
Target = //plugins:python
6+
ModuleDir = third_party.python
7+
WheelRepo = https://get.please.build/third_party/python/py3
8+
WheelNameScheme = {url_base}/{package_name}-{version}-${{OS}}_${{ARCH}}.whl
9+
WheelNameScheme = "{url_base}/{package_name}-{version}.whl"
610

711
[PluginDefinition]
812
name = cc

Diff for: build_defs/c.build_defs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ other than using different config settings.
66
Both C and C++ can be mixed and matched arbitrarily, but of course to do so
77
you must pay attention to interoperability when needed (e.g. 'extern "C"' and so forth).
88
"""
9-
subinclude("///cc//build_defs:cc")
9+
subinclude("//build_defs:cc")
1010

1111
def c_library(name:str, srcs:list=[], hdrs:list=[], private_hdrs:list=[], deps:list=[], out:str='', optional_outs:list=[],
1212
visibility:list=None, test_only:bool&testonly=False, compiler_flags:list&cflags&copts=[],

Diff for: compdb/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
subinclude("//build_defs:cc")
2+
13
cc_binary(
24
name = "compdb",
35
srcs = ["compdb.cc"],

Diff for: gtest/BUILD

-14
This file was deleted.

Diff for: plugins/BUILD

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
plugin_repo(
2+
name = "python",
3+
revision = "v1.12.2",
4+
)

Diff for: test/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Test the way cc rules depend on one another; ideally we should be able to
22
# pick up all transitive dependencies correctly but compile the .o files independently.
33

4+
subinclude("//build_defs:cc")
5+
46
cc_library(
57
name = "lib1",
68
srcs = ["lib1.cc"],

Diff for: test/binary/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
subinclude("//build_defs:cc")
2+
13
cc_binary(
24
name = "test_binary",
35
srcs = ["test_binary.cc"],

Diff for: test/c/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
subinclude("//build_defs:c")
2+
13
c_test(
24
name = "c_test",
35
srcs = ["test.c"],

Diff for: test/deps/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
subinclude("//build_defs:cc")
2+
13
# Tests that a sequence of dependencies works as expected.
24
cc_library(
35
name = "lib1",

Diff for: test/embed/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
subinclude("//build_defs:cc_embed_binary")
1+
subinclude("//build_defs:cc", "//build_defs:cc_embed_binary")
22

33
cc_embed_binary(
44
name = "embedded_file_1",

Diff for: test/gtest/BUILD

-11
This file was deleted.

Diff for: test/gtest/gtest_test.cc

-18
This file was deleted.

Diff for: test/labels/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
subinclude("//build_defs:cc")
2+
13
cc_library(
24
name = "lib1",
35
hdrs = ["lib1/include/lib.hpp"],

Diff for: test/modules/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
subinclude("//build_defs:cc")
2+
13
# Currently only supported for Clang.
24
if "clang" in CONFIG.CC.CPP_TOOL:
35
cc_module(

Diff for: test/so/BUILD

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
subinclude("//build_defs:cc", "///python//build_defs:python")
2+
13
# TODO(peterebden): now Python is becoming a plugin, we should choose something else to test with.
24
cc_shared_object(
35
name = "so_test",
@@ -30,5 +32,6 @@ python_test(
3032
zip_safe = False,
3133
deps = [
3234
":so_test",
35+
"//third_party/python:six",
3336
],
3437
)

Diff for: third_party/python/BUILD

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
subinclude("///python//build_defs:python")
2+
3+
python_wheel(
4+
name = "six",
5+
outs = ["six.py"],
6+
hashes = ["8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"],
7+
version = "1.14.0",
8+
visibility = ["PUBLIC"],
9+
)

Diff for: unittest-pp/BUILD

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
subinclude("///cc//build_defs:cc")
2+
13
github_repo(
24
name = "unittest_cpp",
35
repo = "unittest-cpp/unittest-cpp",
@@ -7,9 +9,21 @@ github_repo(
79
strip_prefix = "unittest-cpp-2.0.0",
810
)
911

12+
13+
filegroup(
14+
name = "srcs",
15+
srcs = ["unittest_main.cc", "///unittest-pp/unittest_cpp//:unittest_cpp_srcs"],
16+
)
17+
18+
filegroup(
19+
name = "hdrs",
20+
srcs = ["///unittest-pp/unittest_cpp//:unittest_cpp_hdrs"],
21+
)
22+
1023
cc_library(
1124
name = "main",
12-
srcs = ["unittest_main.cc"],
25+
srcs = [":srcs"],
26+
hdrs = [":hdrs"],
1327
visibility = ["PUBLIC"],
14-
deps = ["///unittest-pp/unittest_cpp//:unittest_cpp"],
28+
includes = ["."],
1529
)

Diff for: unittest-pp/unittest.build

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22

33
os = "Win32" if CONFIG.OS == "windows" else "Posix"
44

5-
cc_library(
6-
name = "unittest_cpp",
5+
filegroup(
6+
name = "unittest_cpp_srcs",
77
srcs = glob(["UnitTest++/*.cpp", f"UnitTest++/{os}/*.cpp"]),
8-
hdrs = glob(["UnitTest++/*.h", f"UnitTest++/{os}/*.h"]),
98
visibility = ["PUBLIC"],
109
)
10+
11+
12+
filegroup(
13+
name = "unittest_cpp_hdrs",
14+
srcs = glob(["UnitTest++/*.h", f"UnitTest++/{os}/*.h"]),
15+
visibility = ["PUBLIC"],
16+
)

0 commit comments

Comments
 (0)