Skip to content

Commit

Permalink
Change experimental build to use pl_exp_ variants
Browse files Browse the repository at this point in the history
Summary:
This allows us to mark targets as manual build and not bazel ignore them.

We need to add a linter to make sure we follow this rule.

Test Plan: bazel test //...

Reviewers: oazizi, michelle, #engineering

Reviewed By: oazizi, #engineering

Differential Revision: https://phab.corp.pixielabs.ai/D1122
  • Loading branch information
zasgar committed Jul 8, 2019
1 parent 3f69237 commit f47fd0d
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 38 deletions.
4 changes: 0 additions & 4 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# If you want to work on experimental you need to delete the following line.
# Sadly bazel does not seem to provide an easy way to this automatically.
experimental/

src/ui/node_modules
vendor
third_party/bpftrace/build
5 changes: 5 additions & 0 deletions bazel/cc_resource.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ def pl_cc_resource_impl(

# Create a cc_library with the .o files.
native.cc_library(name = name, srcs = object_files, tags = tags, linkstatic = 1, **kwargs)

def pl_exp_cc_resource(**kwargs):
tags = kwargs.get("tags", [])
kwargs["tags"] = tags + ["manual"]
pl_cc_resource(**kwargs)
24 changes: 23 additions & 1 deletion bazel/pl_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def pl_cc_test(
args = [],
coverage = True,
local = False):
test_lib_tags = []
test_lib_tags = list(tags)
if coverage:
test_lib_tags.append("coverage_test_lib")
pl_cc_test_library(
Expand All @@ -180,6 +180,7 @@ def pl_cc_test(
repository = repository,
tags = test_lib_tags,
)

native.cc_test(
name = name,
copts = pl_copts(repository, test = True),
Expand Down Expand Up @@ -254,3 +255,24 @@ def pl_go_library(**kwargs):
kwargs["clinkopts"] = pl_linkopts()
kwargs["toolchains"] = ["@bazel_tools//tools/cpp:current_cc_toolchain"]
go_library(**kwargs)

def append_manual_tag(kwargs):
tags = kwargs.get("tags", [])
kwargs["tags"] = tags + ["manual"]
return kwargs

def pl_exp_cc_binary(**kwargs):
kwargs = append_manual_tag(kwargs)
pl_cc_binary(**kwargs)

def pl_exp_cc_library(**kwargs):
kwargs = append_manual_tag(kwargs)
pl_cc_library(**kwargs)

def pl_exp_cc_test(**kwargs):
kwargs = append_manual_tag(kwargs)
pl_cc_test(**kwargs)

def pl_exp_cc_test_library(**kwargs):
kwargs = append_manual_tag(kwargs)
pl_cc_test_library(**kwargs)
5 changes: 5 additions & 0 deletions bazel/proto_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ def pl_go_proto_library(name, proto, importpath, deps = [], **kwargs):
deps = deps,
**kwargs
)

def pl_exp_cc_proto_library(**kwargs):
tags = kwargs.get("tags", [])
kwargs["tags"] = tags + ["manual"]
pl_cc_proto_library(**kwargs)
15 changes: 9 additions & 6 deletions experimental/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package(default_visibility = ["//experimental:__pkg__"], default_testonly = True)
package(
default_testonly = True,
default_visibility = ["//experimental:__pkg__"],
)

load("//bazel:cc_resource.bzl", "pl_cc_resource")
load("//bazel:pl_build_system.bzl", "pl_cc_binary", "pl_cc_library", "pl_cc_test")
load("//bazel:cc_resource.bzl", "pl_exp_cc_resource")
load("//bazel:pl_build_system.bzl", "pl_exp_cc_binary", "pl_exp_cc_library", "pl_exp_cc_test")

pl_cc_library(
pl_exp_cc_library(
name = "natsc",
srcs = glob(
[
Expand All @@ -15,15 +18,15 @@ pl_cc_library(
],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "natsc_binary",
deps = [
":natsc",
"//third_party/foreign_cc:natsc",
],
)

pl_cc_library(
pl_exp_cc_library(
name = "concurrentqueue",
srcs = glob(
[
Expand Down
18 changes: 9 additions & 9 deletions experimental/bpf/http_trace/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//bazel:cc_resource.bzl", "pl_cc_resource")
load("//bazel:pl_build_system.bzl", "pl_cc_binary", "pl_cc_library", "pl_cc_test")
load("//bazel:cc_resource.bzl", "pl_exp_cc_resource")
load("//bazel:pl_build_system.bzl", "pl_exp_cc_binary", "pl_exp_cc_library", "pl_exp_cc_test")

pl_cc_resource(
pl_exp_cc_resource(
name = "bcc_bpf_files",
srcs = [
"golang_http_response_event.h",
Expand All @@ -10,7 +10,7 @@ pl_cc_resource(
],
)

pl_cc_library(
pl_exp_cc_library(
name = "probe_deployment_lib",
srcs = ["probe_deployment.cc"],
hdrs = ["probe_deployment.h"],
Expand All @@ -22,7 +22,7 @@ pl_cc_library(
],
)

pl_cc_library(
pl_exp_cc_library(
name = "golang_http_response_prober_lib",
srcs = [
"golang_http_response_event.h",
Expand All @@ -37,7 +37,7 @@ pl_cc_library(
],
)

pl_cc_library(
pl_exp_cc_library(
name = "syscall_write_prober_lib",
srcs = [
"syscall_write_event.h",
Expand All @@ -53,23 +53,23 @@ pl_cc_library(
],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "golang_http_response_prober",
tags = ["linux_only"],
deps = [
":golang_http_response_prober_lib",
],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "syscall_write_prober",
tags = ["linux_only"],
deps = [
":syscall_write_prober_lib",
],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "stirling_http_prober",
srcs = ["stirling_http_prober.cc"],
tags = ["linux_only"],
Expand Down
10 changes: 5 additions & 5 deletions experimental/bpf/maps_ring_buffer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package(default_visibility = ["//visibility:public"])

load("//bazel:cc_resource.bzl", "pl_cc_resource")
load("//bazel:pl_build_system.bzl", "pl_cc_binary", "pl_cc_library", "pl_cc_test")
load("//bazel:cc_resource.bzl", "pl_exp_cc_resource")
load("//bazel:pl_build_system.bzl", "pl_exp_cc_binary", "pl_exp_cc_library", "pl_exp_cc_test")

pl_cc_resource(
pl_exp_cc_resource(
name = "bpf_files",
srcs = [
"perf_cycles_bpf_map.c",
"perf_cycles_bpf_ring_buffer.c",
],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "perf_cycles_bpf_map",
srcs = ["perf_cycles_bpf_map.cc"],
tags = ["linux_only"],
Expand All @@ -23,7 +23,7 @@ pl_cc_binary(
],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "perf_cycles_bpf_ring_buffer",
srcs = ["perf_cycles_bpf_ring_buffer.cc"],
tags = ["linux_only"],
Expand Down
8 changes: 4 additions & 4 deletions experimental/stirling/codegen_data_model/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//bazel:pl_build_system.bzl", "pl_cc_binary", "pl_cc_library", "pl_cc_test")
load("//bazel:pl_build_system.bzl", "pl_exp_cc_binary", "pl_exp_cc_library", "pl_exp_cc_test")

pl_cc_library(
pl_exp_cc_library(
name = "cc_library",
srcs = glob(
["*.cc"],
Expand All @@ -12,7 +12,7 @@ pl_cc_library(
hdrs = glob(["*.h"]),
)

pl_cc_test(
pl_exp_cc_test(
name = "generator_test",
srcs = ["generator_test.cc"],
deps = [
Expand All @@ -21,7 +21,7 @@ pl_cc_test(
],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "main",
srcs = ["main.cc"],
deps = [":cc_library"],
Expand Down
6 changes: 3 additions & 3 deletions experimental/stirling/proto_data_model/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//bazel:pl_build_system.bzl", "pl_cc_binary", "pl_cc_library", "pl_cc_test")
load("//bazel:pl_build_system.bzl", "pl_exp_cc_binary", "pl_exp_cc_library", "pl_exp_cc_test")

pl_cc_library(
pl_exp_cc_library(
name = "http_record",
srcs = ["http_record.cc"],
hdrs = ["http_record.h"],
Expand All @@ -10,7 +10,7 @@ pl_cc_library(
],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "data_copy_benchmark",
srcs = ["data_copy_benchmark.cc"],
deps = [
Expand Down
4 changes: 2 additions & 2 deletions experimental/stirling/proto_data_model/proto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# gazelle:ignore
load("//bazel:proto_compile.bzl", "pl_cc_proto_library", "pl_go_proto_library", "pl_proto_library")
load("//bazel:proto_compile.bzl", "pl_exp_cc_proto_library", "pl_go_proto_library", "pl_proto_library")

package(default_visibility = ["//experimental/stirling/proto_data_model:__pkg__"])

Expand All @@ -14,7 +14,7 @@ pl_go_proto_library(
proto = ":http_record_pl_proto",
)

pl_cc_proto_library(
pl_exp_cc_proto_library(
name = "http_record_pl_cc_proto",
proto = ":http_record_pl_proto",
)
8 changes: 4 additions & 4 deletions experimental/utils/threader/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package(default_visibility = ["//visibility:public"])

load("//bazel:pl_build_system.bzl", "pl_cc_binary", "pl_cc_library", "pl_cc_test")
load("//bazel:pl_build_system.bzl", "pl_exp_cc_binary", "pl_exp_cc_library", "pl_exp_cc_test")

pl_cc_binary(
pl_exp_cc_binary(
name = "threader",
srcs = ["threader.cc"],
deps = [],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "threader_time",
srcs = ["threader_time.cc"],
tags = ["linux_only"],
deps = [],
)

pl_cc_binary(
pl_exp_cc_binary(
name = "forker",
srcs = ["forker.cc"],
tags = ["linux_only"],
Expand Down

0 comments on commit f47fd0d

Please sign in to comment.