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

Runfiles not bundled with macos_application #2477

Closed
gkoreman opened this issue Jun 26, 2024 · 0 comments · Fixed by #2479
Closed

Runfiles not bundled with macos_application #2477

gkoreman opened this issue Jun 26, 2024 · 0 comments · Fixed by #2479

Comments

@gkoreman
Copy link
Contributor

Building a macos_application with a cc_library does not include runfiles.

cc_library(
    name = "libapp",
    srcs = ["main.cpp",],
    data = [":data.txt"],
)

macos_application(
    name = "app_macos",
    deps = [":libapp"],
)

data.txt is not packaged in the macos_application.

brentleyjones pushed a commit that referenced this issue Aug 7, 2024
#2479)

Fixes #2477

Include all data from cc_libraries as runfiles or resources, depending
on aspect_hints.
Provide aspect_hints for resource collection for all resource targets
(eg, swift_library, cc_library, etc)

By default all data is now included from cc_libraries as runfiles and
follows the expected runfiles folder structure, with files retaining
their nested folders and being placed in
/external/pkg_name/some/file.txt when included from a http_archive or
local_repository.

The default behavior for other resource collecting targets like
swift_library has not changed, and will continue to collect and process
data as resources.

To allow modification of this default behavior, users may add
aspect_hints to the target cc_library/swift_library/etc. There are three
supported aspect_hints:
@build_bazel_rules_apple//apple:use_runfiles
@build_bazel_rules_apple//apple:use_resources
@build_bazel_rules_apple//apple:suppress_resources

##### Example
Here is an example of modifying the default behavior to bundle data.txt
as a resource instead of a runfile.
```
cc_library(
    name = "libapp",
    srcs = ["main.cpp",],
    data = [":data.txt"],
    aspect_hints = ["@build_bazel_rules_apple//apple:use_runfiles"],
)

macos_application(
    name = "app_macos",
    deps = [":libapp"],
)
```
data.txt is bundled in Contents/Resources/data.txt

#### Note
Hints apply only to the target and do not affect transitive deps,
however if a target includes runfiles then all runfiles are bundled
(including transitive runfiles) regardless of the hints applied to
transitive targets.

---------

Co-authored-by: Luis Padron <heyluispadron@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant