Skip to content

Commit

Permalink
support dsymutil_extra_flags
Browse files Browse the repository at this point in the history
Summary: ditto

Reviewed By: chatura-atapattu

Differential Revision: D51426025

fbshipit-source-id: 842816a72ed0a79e4b2c1bccd5ae6f66e3b3b0cd
  • Loading branch information
blackm00n authored and facebook-github-bot committed Dec 15, 2023
1 parent 31a7f3f commit aba7277
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
3 changes: 1 addition & 2 deletions prelude/apple/apple_dsym.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ def get_apple_dsym(ctx: AnalysisContext, executable: Artifact, debug_info: list[
return get_apple_dsym_ext(ctx, executable, debug_info, action_identifier, output_path)

# TODO(T110672942): Things which are still unsupported:
# - pass in dsymutil_extra_flags
# - oso_prefix
# - dsym_verification
def get_apple_dsym_ext(ctx: AnalysisContext, executable: [ArgLike, Artifact], debug_info: list[ArgLike], action_identifier: str, output_path: str) -> Artifact:
dsymutil = ctx.attrs._apple_toolchain[AppleToolchainInfo].dsymutil
output = ctx.actions.declare_output(output_path, dir = True)

cmd = cmd_args([dsymutil, "-o", output.as_output()])
cmd = cmd_args([dsymutil] + ctx.attrs._dsymutil_extra_flags + ["-o", output.as_output()])
cmd.add(executable)

# Mach-O executables don't contain DWARF data.
Expand Down
13 changes: 13 additions & 0 deletions prelude/apple/apple_dsym_config.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under both the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree and the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.

load("@prelude//utils:buckconfig.bzl", "read_list")

def apple_dsym_config() -> dict[str, typing.Any]:
return {
"_dsymutil_extra_flags": read_list("apple", "dsymutil_extra_flags", delimiter = " ", default = [], root_cell = True),
}
8 changes: 8 additions & 0 deletions prelude/apple/apple_macro_layer.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# of this source tree.

load(":apple_bundle_config.bzl", "apple_bundle_config")
load(":apple_dsym_config.bzl", "apple_dsym_config")
load(":apple_genrule_deps.bzl", "get_apple_build_genrule_deps_default_kwargs")
load(":apple_info_plist_substitutions_parsing.bzl", "parse_codesign_entitlements")
load(":apple_package_config.bzl", "apple_package_config")
Expand Down Expand Up @@ -73,6 +74,7 @@ def apple_macro_layer_set_bool_override_attrs_from_config(overrides: list[AppleB

def apple_test_macro_impl(apple_test_rule, apple_resource_bundle_rule, **kwargs):
kwargs.update(apple_bundle_config())
kwargs.update(apple_dsym_config())
kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config(_APPLE_TEST_LOCAL_EXECUTION_OVERRIDES))
kwargs.update(get_apple_build_genrule_deps_default_kwargs())

Expand All @@ -86,6 +88,7 @@ def apple_test_macro_impl(apple_test_rule, apple_resource_bundle_rule, **kwargs)
def apple_bundle_macro_impl(apple_bundle_rule, apple_resource_bundle_rule, **kwargs):
info_plist_substitutions = kwargs.get("info_plist_substitutions")
kwargs.update(apple_bundle_config())
kwargs.update(apple_dsym_config())
kwargs.update(get_apple_build_genrule_deps_default_kwargs())
apple_bundle_rule(
_codesign_entitlements = parse_codesign_entitlements(info_plist_substitutions),
Expand All @@ -94,12 +97,15 @@ def apple_bundle_macro_impl(apple_bundle_rule, apple_resource_bundle_rule, **kwa
)

def apple_library_macro_impl(apple_library_rule = None, **kwargs):
kwargs.update(apple_dsym_config())
kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config(_APPLE_LIBRARY_LOCAL_EXECUTION_OVERRIDES))
kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config([APPLE_STRIPPED_DEFAULT]))
kwargs.update(get_apple_build_genrule_deps_default_kwargs())
apple_library_rule(**kwargs)

def apple_binary_macro_impl(apple_binary_rule = None, apple_universal_executable = None, **kwargs):
dsym_args = apple_dsym_config()
kwargs.update(dsym_args)
kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config(_APPLE_BINARY_LOCAL_EXECUTION_OVERRIDES))
kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config([APPLE_STRIPPED_DEFAULT]))
kwargs.update(get_apple_build_genrule_deps_default_kwargs())
Expand All @@ -115,6 +121,7 @@ def apple_binary_macro_impl(apple_binary_rule = None, apple_universal_executable
labels = kwargs.get("labels"),
visibility = kwargs.get("visibility"),
default_target_platform = kwargs.get("default_target_platform"),
**dsym_args
)
else:
binary_name = original_binary_name
Expand All @@ -128,6 +135,7 @@ def apple_package_macro_impl(apple_package_rule = None, **kwargs):
)

def apple_universal_executable_macro_impl(apple_universal_executable_rule = None, **kwargs):
kwargs.update(apple_dsym_config())
apple_universal_executable_rule(
**kwargs
)
13 changes: 10 additions & 3 deletions prelude/apple/apple_rules_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ load(
":apple_rules_impl_utility.bzl",
"APPLE_ARCHIVE_OBJECTS_LOCALLY_OVERRIDE_ATTR_NAME",
"apple_bundle_extra_attrs",
"apple_dsymutil_attrs",
"apple_test_extra_attrs",
"get_apple_bundle_toolchain_attr",
"get_apple_toolchain_attr",
Expand Down Expand Up @@ -78,7 +79,7 @@ ApplePackageExtension = enum(
)

def _apple_binary_extra_attrs():
return {
attribs = {
"binary_linker_flags": attrs.list(attrs.arg(), default = []),
"enable_distributed_thinlto": attrs.bool(default = False),
"extra_xcode_sources": attrs.list(attrs.source(allow_directory = True), default = []),
Expand All @@ -99,9 +100,11 @@ def _apple_binary_extra_attrs():
APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE,
BUCK2_COMPATIBILITY_ATTRIB_NAME: BUCK2_COMPATIBILITY_ATTRIB_TYPE,
}
attribs.update(apple_dsymutil_attrs())
return attribs

def _apple_library_extra_attrs():
return {
attribs = {
"extra_xcode_sources": attrs.list(attrs.source(allow_directory = True), default = []),
"header_mode": attrs.option(attrs.enum(HeaderMode.values()), default = None),
"link_execution_preference": link_execution_preference_attr(),
Expand All @@ -125,9 +128,11 @@ def _apple_library_extra_attrs():
APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE,
BUCK2_COMPATIBILITY_ATTRIB_NAME: BUCK2_COMPATIBILITY_ATTRIB_TYPE,
}
attribs.update(apple_dsymutil_attrs())
return attribs

def _apple_universal_executable_extra_attrs():
return {
attribs = {
"executable": attrs.split_transition_dep(cfg = cpu_split_transition),
"executable_name": attrs.option(attrs.string(), default = None),
"labels": attrs.list(attrs.string()),
Expand All @@ -136,6 +141,8 @@ def _apple_universal_executable_extra_attrs():
"_apple_toolchain": _APPLE_TOOLCHAIN_ATTR,
"_apple_tools": attrs.exec_dep(default = "prelude//apple/tools:apple-tools", providers = [AppleToolsInfo]),
}
attribs.update(apple_dsymutil_attrs())
return attribs

extra_attributes = {
"apple_asset_catalog": {
Expand Down
6 changes: 6 additions & 0 deletions prelude/apple/apple_rules_impl_utility.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ APPLE_ARCHIVE_OBJECTS_LOCALLY_OVERRIDE_ATTR_NAME = "_archive_objects_locally_ove
APPLE_USE_ENTITLEMENTS_WHEN_ADHOC_CODE_SIGNING_CONFIG_OVERRIDE_ATTR_NAME = "_use_entitlements_when_adhoc_code_signing"
APPLE_USE_ENTITLEMENTS_WHEN_ADHOC_CODE_SIGNING_ATTR_NAME = "use_entitlements_when_adhoc_code_signing"

def apple_dsymutil_attrs():
return {
"_dsymutil_extra_flags": attrs.list(attrs.string()),
}

def _apple_bundle_like_common_attrs():
# `apple_bundle()` and `apple_test()` share a common set of extra attrs
attribs = {
Expand All @@ -72,6 +77,7 @@ def _apple_bundle_like_common_attrs():
BUCK2_COMPATIBILITY_ATTRIB_NAME: BUCK2_COMPATIBILITY_ATTRIB_TYPE,
}
attribs.update(get_apple_info_plist_build_system_identification_attrs())
attribs.update(apple_dsymutil_attrs())
return attribs

def apple_test_extra_attrs():
Expand Down

0 comments on commit aba7277

Please sign in to comment.