File tree Expand file tree Collapse file tree 6 files changed +34
-12
lines changed Expand file tree Collapse file tree 6 files changed +34
-12
lines changed Original file line number Diff line number Diff line change @@ -519,18 +519,12 @@ cxx_library = prelude_rule(
519
519
cxx_common .exported_post_platform_linker_flags_arg () |
520
520
native_common .link_style () |
521
521
native_common .link_whole (link_whole_type = attrs .option (attrs .bool (), default = None )) |
522
+ native_common .soname () |
522
523
cxx_common .raw_headers_arg () |
523
524
cxx_common .include_directories_arg () |
524
525
cxx_common .public_include_directories_arg () |
525
526
cxx_common .public_system_include_directories_arg () |
526
527
{
527
- "soname" : attrs .option (attrs .string (), default = None , doc = """
528
- Sets the soname ("shared object name") of any shared library produced from this rule.
529
- The default value is based on the full rule name.
530
- The macro `$(ext)` will be replaced with a platform-appropriate extension.
531
- An argument can be provided, which is a library version.
532
- For example `soname = 'libfoo.$(ext 2.3)'` will be `libfoo.2.3.dylib` on Mac and `libfoo.so.2.3` on Linux.
533
- """ ),
534
528
"used_by_wrap_script" : attrs .bool (default = False , doc = """
535
529
When using an exopackage
536
530
Android, if this parameter is set to `True`, then the library is
Original file line number Diff line number Diff line change @@ -46,10 +46,22 @@ def _link_group_public_deps_label():
46
46
""" ),
47
47
}
48
48
49
+ def _soname ():
50
+ return {
51
+ "soname" : attrs .option (attrs .string (), default = None , doc = """
52
+ Sets the soname ("shared object name") of any shared library produced from this rule.
53
+ The default value is based on the full rule name.
54
+ The macro `$(ext)` will be replaced with a platform-appropriate extension.
55
+ An argument can be provided, which is a library version.
56
+ For example `soname = 'libfoo.$(ext 2.3)'` will be `libfoo.2.3.dylib` on Mac and `libfoo.so.2.3` on Linux.
57
+ """ ),
58
+ }
59
+
49
60
native_common = struct (
50
61
link_group_deps = _link_group_deps ,
51
62
link_group_public_deps_label = _link_group_public_deps_label ,
52
63
link_style = _link_style ,
53
64
link_whole = _link_whole ,
54
65
preferred_linkage = _preferred_linkage ,
66
+ soname = _soname ,
55
67
)
Original file line number Diff line number Diff line change @@ -186,6 +186,7 @@ rust_library = prelude_rule(
186
186
rust_common .crate (crate_type = attrs .option (attrs .string (), default = None )) |
187
187
rust_common .crate_root () |
188
188
native_common .preferred_linkage (preferred_linkage_type = attrs .enum (Linkage .values (), default = "any" )) |
189
+ native_common .soname () |
189
190
_rust_common_attributes (is_binary = False ) |
190
191
{
191
192
"crate_dynamic" : attrs .option (attrs .dep (), default = None ),
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ load("@prelude//cxx:debug.bzl", "SplitDebugMode")
24
24
load ("@prelude//cxx:dwp.bzl" , "dwp" , "dwp_available" )
25
25
load (
26
26
"@prelude//cxx:linker.bzl" ,
27
- "get_default_shared_library_name" ,
28
27
"get_shared_library_name_linker_flags" ,
29
28
)
30
29
load (
75
74
"RustLinkInfo" ,
76
75
"attr_crate" ,
77
76
"attr_simple_crate_for_filenames" ,
77
+ "attr_soname" ,
78
78
"get_available_proc_macros" ,
79
79
"inherited_external_debug_info" ,
80
80
"inherited_merged_link_infos" ,
@@ -895,7 +895,7 @@ def _compute_common_args(
895
895
896
896
if crate_type in [CrateType ("cdylib" ), CrateType ("dylib" )] and not is_check :
897
897
linker_info = compile_ctx .cxx_toolchain_info .linker_info
898
- shlib_name = get_default_shared_library_name ( linker_info , ctx . label )
898
+ shlib_name = attr_soname ( ctx )
899
899
dep_args .add (cmd_args (
900
900
get_shared_library_name_linker_flags (linker_info .type , shlib_name ),
901
901
format = "-Clink-arg={}" ,
Original file line number Diff line number Diff line change 16
16
"@prelude//cxx:cxx.bzl" ,
17
17
"get_auto_link_group_specs" ,
18
18
)
19
+ load ("@prelude//cxx:cxx_context.bzl" , "get_cxx_toolchain_info" )
19
20
load (
20
21
"@prelude//cxx:cxx_library_utility.bzl" ,
21
22
"cxx_is_gnu" ,
37
38
"@prelude//cxx:link_groups_types.bzl" ,
38
39
"LinkGroupInfo" , # @unused Used as a type
39
40
)
41
+ load (
42
+ "@prelude//cxx:linker.bzl" ,
43
+ "get_default_shared_library_name" ,
44
+ "get_shared_library_name_for_param" ,
45
+ )
40
46
load (
41
47
"@prelude//linking:link_groups.bzl" ,
42
48
"LinkGroupLib" , # @unused Used as a type
@@ -584,3 +590,12 @@ def attr_crate(ctx: AnalysisContext) -> CrateName:
584
590
simple = normalize_crate (ctx .attrs .crate or ctx .label .name ),
585
591
dynamic = dynamic ,
586
592
)
593
+
594
+ def attr_soname (ctx : AnalysisContext ) -> str :
595
+ """
596
+ Get the shared library name to set for the given rust library.
597
+ """
598
+ linker_info = get_cxx_toolchain_info (ctx ).linker_info
599
+ if ctx .attrs .soname != None :
600
+ return get_shared_library_name_for_param (linker_info , ctx .attrs .soname )
601
+ return get_default_shared_library_name (linker_info , ctx .label )
Original file line number Diff line number Diff line change 18
18
load (
19
19
"@prelude//cxx:linker.bzl" ,
20
20
"PDB_SUB_TARGET" ,
21
- "get_default_shared_library_name" ,
22
21
"get_pdb_providers" ,
23
22
)
24
23
load (
92
91
"RustLinkStrategyInfo" ,
93
92
"RustProcMacroMarker" , # @unused Used as a type
94
93
"attr_crate" ,
94
+ "attr_soname" ,
95
95
"inherited_exported_link_deps" ,
96
96
"inherited_link_group_lib_infos" ,
97
97
"inherited_linkable_graphs" ,
@@ -599,7 +599,7 @@ def _advanced_unstable_link_providers(
599
599
solibs = {}
600
600
601
601
# Add the shared library to the list of shared libs.
602
- shlib_name = get_default_shared_library_name ( linker_info , ctx . label )
602
+ shlib_name = attr_soname ( ctx )
603
603
604
604
shared_lib_params = lang_style_param [(LinkageLang ("native-unbundled" ), LibOutputStyle ("shared_lib" ))]
605
605
shared_lib_output = native_param_artifact [shared_lib_params ].output
@@ -786,7 +786,7 @@ def _native_link_providers(
786
786
solibs = {}
787
787
788
788
# Add the shared library to the list of shared libs.
789
- shlib_name = get_default_shared_library_name ( linker_info , ctx . label )
789
+ shlib_name = attr_soname ( ctx )
790
790
791
791
# Only add a shared library if we generated one.
792
792
# TODO(cjhopman): This is strange. Normally (like in c++) the link_infos passed to create_merged_link_info above would only have
You can’t perform that action at this time.
0 commit comments