Skip to content

Commit dd75918

Browse files
Nikita Patskovfacebook-github-bot
authored andcommitted
Allow transformation spec rule to be configured for both cxx binary and test
Summary: With transformation specs being ready for rollout moving arg definition into better place and setting it up for both `cpp_binary` and `cpp_unittest`. Reviewed By: yahayaohinoyi Differential Revision: D83559456 fbshipit-source-id: 1010c201108d6ba61357aa9a2a920c9d373ff7a6
1 parent c099f14 commit dd75918

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

prelude/decls/cxx_rules.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ cxx_binary = prelude_rule(
143143
native_common.link_style() |
144144
native_common.link_group_deps() |
145145
native_common.link_group_public_deps_label() |
146+
native_common.transformation_spec_arg() |
146147
buck.deps_query_arg() |
147148
cxx_common.raw_headers_arg() |
148149
cxx_common.include_directories_arg() |
@@ -969,6 +970,7 @@ cxx_test = prelude_rule(
969970
buck.test_rule_timeout_ms() |
970971
native_common.link_group_deps() |
971972
native_common.link_group_public_deps_label() |
973+
native_common.transformation_spec_arg() |
972974
native_common.link_style() |
973975
{
974976
"additional_coverage_targets": attrs.list(attrs.source(), default = []),

prelude/decls/native_common.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# the generated docs, and so those should be verified to be accurate and
1212
# well-formatted (and then delete this TODO)
1313

14+
load("@prelude//cxx:transformation_spec.bzl", "TransformationResultProvider")
1415
load(":common.bzl", "LinkableDepType")
1516

1617
def _link_style():
@@ -58,11 +59,21 @@ def _soname():
5859
"""),
5960
}
6061

62+
def _transformation_spec_arg():
63+
return {
64+
"transformation_spec": attrs.option(
65+
attrs.dep(providers = [TransformationResultProvider]),
66+
default = None,
67+
doc = "Dependency to a transformation spec that will selectively change parts of dependency graph",
68+
),
69+
}
70+
6171
native_common = struct(
6272
link_group_deps = _link_group_deps,
6373
link_group_public_deps_label = _link_group_public_deps_label,
6474
link_style = _link_style,
6575
link_whole = _link_whole,
6676
preferred_linkage = _preferred_linkage,
6777
soname = _soname,
78+
transformation_spec_arg = _transformation_spec_arg,
6879
)

prelude/rules_impl.bzl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ load("@prelude//cxx:cxx_toolchain_types.bzl", "CxxPlatformInfo", "CxxToolchainIn
3131
load("@prelude//cxx:headers.bzl", "CPrecompiledHeaderInfo", "HeaderMode")
3232
load("@prelude//cxx:link_groups_types.bzl", "LINK_GROUP_MAP_ATTR")
3333
load("@prelude//cxx:prebuilt_cxx_library_group.bzl", "prebuilt_cxx_library_group_impl")
34-
load("@prelude//cxx:transformation_spec.bzl", "TransformationKind", "TransformationResultProvider", "transformation_spec_impl")
34+
load("@prelude//cxx:transformation_spec.bzl", "TransformationKind", "transformation_spec_impl")
3535
load("@prelude//cxx:windows_resource.bzl", "windows_resource_impl")
3636
load("@prelude//decls:android_rules.bzl", "android_rules")
3737
load("@prelude//decls:common.bzl", "IncludeType", "buck")
@@ -325,17 +325,7 @@ cxx_extra_attributes = {
325325
},
326326
"cxx_library": _cxx_extra_library_attrs,
327327
"cxx_precompiled_header": _cxx_extra_library_attrs,
328-
"cxx_test": _merge_dictionaries(
329-
[
330-
re_test_common.test_args(),
331-
{
332-
"transformation_spec": attrs.option(
333-
attrs.dep(providers = [TransformationResultProvider]),
334-
default = None,
335-
),
336-
},
337-
],
338-
),
328+
"cxx_test": re_test_common.test_args(),
339329
"cxx_toolchain": cxx_toolchain_extra_attributes(is_toolchain_rule = False),
340330
"llvm_link_bitcode": {
341331
"_cxx_toolchain": toolchains_common.cxx(),

0 commit comments

Comments
 (0)