Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subincludes #28

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .plzconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
[please]
version = >=16.12.1
version = >=17.0.0

[Plugin "python"]
Target = //plugins:python
ModuleDir = third_party.python
WheelRepo = https://get.please.build/third_party/python/py3
WheelNameScheme = {url_base}/{package_name}-{version}-${{OS}}_${{ARCH}}.whl
WheelNameScheme = "{url_base}/{package_name}-{version}.whl"

[parse]
preloadbuilddefs = build_defs/cc.build_defs

[PluginDefinition]
name = cc
Expand All @@ -12,7 +17,7 @@ ConfigKey = Coverage
DefaultValue = true
Type = bool
Inherit = true
Help = Whether to build with coverage
Help = Whether to build with coverage

[PluginConfig "cc_tool"]
ConfigKey = CCTool
Expand Down Expand Up @@ -42,7 +47,7 @@ Hel- = The path or build label for the archiver
ConfigKey = DefaultOptCFlags
DefaultValue = --std=c99 -O3 -pipe -DNDEBUG -Wall -Werror
Inherit = true
Help = The default c compiler flags when compiling for release
Help = The default c compiler flags when compiling for release

[PluginConfig "default_dbg_cflags"]
ConfigKey = DefaultDbgCFlags
Expand All @@ -54,7 +59,7 @@ Help = The default c compiler flags when compiling for debug
ConfigKey = DefaultOptCppFlags
DefaultValue = --std=c++11 -O3 -pipe -DNDEBUG -Wall -Werror
Inherit = true
Help = The default c++ compiler flags when compiling for release
Help = The default c++ compiler flags when compiling for release

[PluginConfig "default_dbg_cppflags"]
ConfigKey = DefaultDbgCppFlags
Expand All @@ -66,19 +71,19 @@ Help = The default c++ compiler flags when compiling for debug
ConfigKey = DefaultLdFlags
DefaultValue = -lpthread -ldl
Inherit = true
Help = The default set of flags to apply when linking
Help = The default set of flags to apply when linking

[PluginConfig "pkg_config_path"]
ConfigKey = PkgConfigPath
DefaultValue =
Inherit = true
Help = A path to the systems package configs
Help = A path to the systems package configs

[PluginConfig "test_main"]
ConfigKey = TestMain
Inherit = true
DefaultValue = //unittest-pp:main
Help = A build label with c/c++ source code to use run tests.
Help = A build label with c/c++ source code to use run tests.

[PluginConfig "dsym_tool"]
ConfigKey = DsymTool
Expand All @@ -90,9 +95,10 @@ Help = Set this to dsymutil or equivalent on MacOS to use this tool to generate
ConfigKey = AsmTool
DefaultValue = nasm
Inherit = true
Help = The tool to use for assembling assembly code
Help = The tool to use for assembling assembly code

[PluginConfig "default_namespace"]
ConfigKey = DefaultNamespace
DefaultValue =
Help = The default namespace to compile c++ code in

4 changes: 2 additions & 2 deletions .plzconfig.gcc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[plugin "cc"]
cctool = gcc-10
cpptool = g++-10
cctool = gcc-11
cpptool = g++-11
ldtool = gold
defaultdbgcppflags = --std=c++1z -g3 -DDEBUG -Wall -Wextra -Werror -Wno-unused-parameter
defaultoptcppflags = --std=c++1z -O2 -DNDEBUG -Wall -Wextra -Werror -Wno-unused-parameter
Expand Down
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 0.3.3
-------------
* Add subincludes so we don't rely on them being globally subincluded to use

Version 0.3.2
-------------
* Fix dsymutil to have no default value (as plz was with its builtin rules)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.2
0.3.3
2 changes: 1 addition & 1 deletion build_defs/c.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ other than using different config settings.
Both C and C++ can be mixed and matched arbitrarily, but of course to do so
you must pay attention to interoperability when needed (e.g. 'extern "C"' and so forth).
"""
subinclude("///cc//build_defs:cc")
subinclude("//build_defs:cc")

def c_library(name:str, srcs:list=[], hdrs:list=[], private_hdrs:list=[], deps:list=[], out:str='', optional_outs:list=[],
visibility:list=None, test_only:bool&testonly=False, compiler_flags:list&cflags&copts=[],
Expand Down
2 changes: 2 additions & 0 deletions compdb/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
subinclude("//build_defs:cc")

cc_binary(
name = "compdb",
srcs = ["compdb.cc"],
Expand Down
14 changes: 0 additions & 14 deletions gtest/BUILD

This file was deleted.

6 changes: 6 additions & 0 deletions plugins/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugin_repo(
name = "python",
revision = "v1.3.0",
plugin = "python-rules",
owner = "please-build",
)
2 changes: 2 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Test the way cc rules depend on one another; ideally we should be able to
# pick up all transitive dependencies correctly but compile the .o files independently.

subinclude("//build_defs:cc")

cc_library(
name = "lib1",
srcs = ["lib1.cc"],
Expand Down
2 changes: 2 additions & 0 deletions test/binary/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
subinclude("//build_defs:cc")

cc_binary(
name = "test_binary",
srcs = ["test_binary.cc"],
Expand Down
2 changes: 2 additions & 0 deletions test/c/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
subinclude("//build_defs:c")

c_test(
name = "c_test",
srcs = ["test.c"],
Expand Down
2 changes: 2 additions & 0 deletions test/deps/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
subinclude("//build_defs:cc")

# Tests that a sequence of dependencies works as expected.
cc_library(
name = "lib1",
Expand Down
2 changes: 1 addition & 1 deletion test/embed/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
subinclude("//build_defs:cc_embed_binary")
subinclude("//build_defs:cc", "//build_defs:cc_embed_binary")

cc_embed_binary(
name = "embedded_file_1",
Expand Down
11 changes: 0 additions & 11 deletions test/gtest/BUILD

This file was deleted.

18 changes: 0 additions & 18 deletions test/gtest/gtest_test.cc

This file was deleted.

2 changes: 2 additions & 0 deletions test/labels/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
subinclude("//build_defs:cc")

cc_library(
name = "lib1",
hdrs = ["lib1/include/lib.hpp"],
Expand Down
2 changes: 2 additions & 0 deletions test/modules/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
subinclude("//build_defs:cc")

# Currently only supported for Clang.
if "clang" in CONFIG.CC.CPP_TOOL:
cc_module(
Expand Down
3 changes: 3 additions & 0 deletions test/so/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
subinclude("//build_defs:cc", "///python//build_defs:python")

# TODO(peterebden): now Python is becoming a plugin, we should choose something else to test with.
cc_shared_object(
name = "so_test",
Expand Down Expand Up @@ -30,5 +32,6 @@ python_test(
zip_safe = False,
deps = [
":so_test",
"//third_party/python:six",
],
)
9 changes: 9 additions & 0 deletions third_party/python/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
subinclude("///python//build_defs:python")

python_wheel(
name = "six",
outs = ["six.py"],
hashes = ["8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"],
version = "1.14.0",
visibility = ["PUBLIC"],
)
18 changes: 16 additions & 2 deletions unittest-pp/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
subinclude("///cc//build_defs:cc")

github_repo(
name = "unittest_cpp",
repo = "unittest-cpp/unittest-cpp",
Expand All @@ -7,9 +9,21 @@ github_repo(
strip_prefix = "unittest-cpp-2.0.0",
)


filegroup(
name = "srcs",
srcs = ["unittest_main.cc", "///unittest-pp/unittest_cpp//:unittest_cpp_srcs"],
)

filegroup(
name = "hdrs",
srcs = ["///unittest-pp/unittest_cpp//:unittest_cpp_hdrs"],
)

cc_library(
name = "main",
srcs = ["unittest_main.cc"],
srcs = [":srcs"],
hdrs = [":hdrs"],
visibility = ["PUBLIC"],
deps = ["///unittest-pp/unittest_cpp//:unittest_cpp"],
includes = ["."],
)
12 changes: 9 additions & 3 deletions unittest-pp/unittest.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

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

cc_library(
name = "unittest_cpp",
filegroup(
name = "unittest_cpp_srcs",
srcs = glob(["UnitTest++/*.cpp", f"UnitTest++/{os}/*.cpp"]),
hdrs = glob(["UnitTest++/*.h", f"UnitTest++/{os}/*.h"]),
visibility = ["PUBLIC"],
)


filegroup(
name = "unittest_cpp_hdrs",
srcs = glob(["UnitTest++/*.h", f"UnitTest++/{os}/*.h"]),
visibility = ["PUBLIC"],
)