Skip to content

Commit

Permalink
Merge pull request #329 from johnor/external-bazel
Browse files Browse the repository at this point in the history
Remove copts from bazel build files
  • Loading branch information
johnor authored Dec 5, 2020
2 parents 6fe4768 + bb58927 commit 79079ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion core/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load(":defs.bzl", "private_include_copts")

cc_library(
name = "core",
srcs = glob([
Expand All @@ -6,7 +8,7 @@ cc_library(
hdrs = glob([
"include/**/*.h",
]),
copts = ["-Icore/src"],
copts = private_include_copts(["src/"]),
strip_include_prefix = "include/",
visibility = ["//visibility:public"],
)
Expand Down
18 changes: 18 additions & 0 deletions core/defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# From: https://github.com/bazelbuild/bazel/issues/2670
def private_include_copts(includes):
copts = []
prefix = ''

# convert "@" to "external/" unless in the main workspace
repo_name = native.repository_name()
package_name = native.package_name()
if repo_name != '@':
prefix = 'external/{}/'.format(repo_name[1:])

for inc in includes:
copts.append("-I{}{}/{}".format(prefix, package_name, inc))
copts.append("-I$(GENDIR)/{}{}/{}".format(prefix, package_name, inc))

return copts

1 change: 0 additions & 1 deletion disassembler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ cc_library(
hdrs = glob([
"include/**/*.h",
]),
copts = ["-Idisassembler/src"],
strip_include_prefix = "include/",
visibility = ["//visibility:public"],
deps = [
Expand Down

0 comments on commit 79079ec

Please sign in to comment.