Skip to content

Commit

Permalink
bazel: Fix resource paths as external repo (see #3757)
Browse files Browse the repository at this point in the history
- Headers that are included by .rc files need to be supplied to
  `declare_exe` via the `resources_deps` attribute (passed as the `deps
  attribute to `compile_rc`). The headers must be part of a cc_library
  target via either the `hdrs` or `srcs` attribute.
- File paths for CEF resources are prefixed with "external/<repo>"
  when CEF is loaded as an external repo. Update `copy_filegroups` to
  work with these paths.
  • Loading branch information
magreenblatt committed Aug 2, 2024
1 parent e71a509 commit 35f74cc
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
8 changes: 6 additions & 2 deletions bazel/copy_filegroups.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ def _copy_filegroups_impl(ctx):
outputs = []
for f in inputs:
relative_path = f.path
if relative_path.startswith("external/"):
# Remove the "external/<repo>" component, if any.
relative_path = "/".join(relative_path.split("/")[2:])

for prefix in remove_prefixes:
# Add trailing forward slash if necessary.
if prefix[-1] != "/":
prefix += "/"
if len(prefix) > 0 and f.path.startswith(prefix):
relative_path = f.path[len(prefix):]
if len(prefix) > 0 and relative_path.startswith(prefix):
relative_path = relative_path[len(prefix):]
break

if len(add_prefix) > 0:
Expand Down
6 changes: 3 additions & 3 deletions tools/distrib/bazel/tests-cefclient-BUILD.bazel.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ objc_library(
# Windows targets.
#

# Allow access from the declare_exe target.
filegroup(
# Allow access to resource.h from the declare_exe target.
cc_library(
name = "ResourceH",
srcs = [
hdrs = [
"browser/resource.h"
]
)
Expand Down
4 changes: 3 additions & 1 deletion tools/distrib/bazel/tests-cefclient-win-BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ declare_exe(
"{}.exe.manifest".format(PRODUCT_NAME),
],
resources_srcs = [
"{}:ResourceH".format(PKG_NAME),
"{}:Resources".format(PKG_NAME),
"{}.ico".format(PRODUCT_NAME),
"small.ico",
"//tests/shared:Resources",
],
resources_deps = [
"{}:ResourceH".format(PKG_NAME),
],
linkopts = [
"/SUBSYSTEM:WINDOWS",
] + [
Expand Down
6 changes: 3 additions & 3 deletions tools/distrib/bazel/tests-cefsimple-BUILD.bazel.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ cc_library(
# Windows targets.
#

# Allow access from the declare_exe target.
filegroup(
# Allow access to resource.h from the declare_exe target.
cc_library(
name = "ResourceH",
srcs = [
hdrs = [
"resource.h"
]
)
Expand Down
4 changes: 3 additions & 1 deletion tools/distrib/bazel/tests-cefsimple-win-BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ declare_exe(
"{}.exe.manifest".format(PRODUCT_NAME),
],
resources_srcs = [
"{}:ResourceH".format(PKG_NAME),
"{}.ico".format(PRODUCT_NAME),
"small.ico",
],
resources_deps = [
"{}:ResourceH".format(PKG_NAME),
],
linkopts = [
"/SUBSYSTEM:WINDOWS",
],
Expand Down
6 changes: 3 additions & 3 deletions tools/distrib/bazel/tests-ceftests-BUILD.bazel.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ objc_library(
# Windows targets.
#

# Allow access from the declare_exe target.
filegroup(
# Allow access to resource.h from the declare_exe target.
cc_library(
name = "ResourceH",
srcs = [
hdrs = [
"resource.h"
]
)
Expand Down
4 changes: 3 additions & 1 deletion tools/distrib/bazel/tests-ceftests-win-BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ declare_exe(
"{}.exe.manifest".format(PRODUCT_NAME),
],
resources_srcs = [
"{}:ResourceH".format(PKG_NAME),
"{}.ico".format(PRODUCT_NAME),
"small.ico",
"//tests/shared:Resources",
],
resources_deps = [
"{}:ResourceH".format(PKG_NAME),
],
linkopts = [
"/SUBSYSTEM:CONSOLE",
],
Expand Down

0 comments on commit 35f74cc

Please sign in to comment.