forked from bazelbuild/rules_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide
.dSYM
package in OutputGroupInfo
for cdylib and lib on da…
…rwin rustc emits symbols when the `split-debuginfo=packed` codegen option is set (currently the default). Also reorganized the tests a bit so that the logic between `pdb_file` and `dsym_folder` is shared. Note that while the cc rules use `pdb_file` in the `OutputGroupInfo` I wasn't able to find anything similar for macos. So I opted for adding some extra docs to `rust_shared_library` and `rust_binary` so that it's easier to find.
- Loading branch information
Showing
7 changed files
with
145 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
load(":debug_info_analysis_test.bzl", "debug_info_analysis_test_suite") | ||
|
||
############################ UNIT TESTS ############################# | ||
debug_info_analysis_test_suite(name = "debug_info_analysis_test_suite") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
"""Analysis tests for debug info in cdylib and bin targets.""" | ||
|
||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("@rules_cc//cc:defs.bzl", "cc_binary") | ||
load("//rust:defs.bzl", "rust_binary", "rust_shared_library") | ||
|
||
def _pdb_file_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
target = analysistest.target_under_test(env) | ||
|
||
files = target[DefaultInfo].files.to_list() | ||
asserts.equals(env, len(files), 1) | ||
file = files[0] | ||
asserts.equals(env, file.extension, "pdb") | ||
|
||
return analysistest.end(env) | ||
|
||
pdb_file_test = analysistest.make(_pdb_file_test_impl) | ||
|
||
def _dsym_folder_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
target = analysistest.target_under_test(env) | ||
|
||
files = target[DefaultInfo].files.to_list() | ||
asserts.equals(env, len(files), 1) | ||
file = files[0] | ||
asserts.equals(env, file.extension, "dSYM") | ||
|
||
return analysistest.end(env) | ||
|
||
dsym_folder_test = analysistest.make(_dsym_folder_test_impl) | ||
|
||
def debug_info_analysis_test_suite(name): | ||
"""Analysis tests for debug info in cdylib and bin targets. | ||
Args: | ||
name: the test suite name | ||
""" | ||
rust_shared_library( | ||
name = "mylib", | ||
srcs = ["lib.rs"], | ||
) | ||
|
||
native.filegroup( | ||
name = "mylib.pdb", | ||
srcs = [":mylib"], | ||
output_group = "pdb_file", | ||
) | ||
|
||
pdb_file_test( | ||
name = "lib_pdb_test", | ||
target_under_test = ":mylib.pdb", | ||
target_compatible_with = ["@platforms//os:windows"], | ||
) | ||
|
||
native.filegroup( | ||
name = "mylib.dSYM", | ||
srcs = [":mylib"], | ||
output_group = "dsym_folder", | ||
) | ||
|
||
dsym_folder_test( | ||
name = "lib_dsym_test", | ||
target_under_test = ":mylib.dSYM", | ||
target_compatible_with = ["@platforms//os:macos"], | ||
) | ||
|
||
rust_binary( | ||
name = "myrustbin", | ||
srcs = ["main.rs"], | ||
) | ||
|
||
native.filegroup( | ||
name = "mybin.pdb", | ||
srcs = [":myrustbin"], | ||
output_group = "pdb_file", | ||
) | ||
|
||
pdb_file_test( | ||
name = "bin_pdb_test", | ||
target_under_test = ":mybin.pdb", | ||
target_compatible_with = ["@platforms//os:windows"], | ||
) | ||
|
||
native.filegroup( | ||
name = "mybin.dSYM", | ||
srcs = [":myrustbin"], | ||
output_group = "dsym_folder", | ||
) | ||
|
||
dsym_folder_test( | ||
name = "bin_dsym_test", | ||
target_under_test = ":mybin.dSYM", | ||
target_compatible_with = ["@platforms//os:macos"], | ||
) | ||
|
||
native.test_suite( | ||
name = name, | ||
tests = [ | ||
":lib_pdb_test", | ||
":lib_dsym_test", | ||
":bin_pdb_test", | ||
":bin_dsym_test", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[no_mangle] | ||
pub extern "C" fn hello() { | ||
println!("Hello"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn main() { | ||
println!("Hello"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters