-
Notifications
You must be signed in to change notification settings - Fork 483
Add support for passing a custom target specification. #836
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e017f7c
Add support for passing a custom target specification.
davidskidmore a6a0e93
Pass the target spec ias a dependency.
davidskidmore c5d4099
Created a target_flag_value toolchain info field to avoid recalculati…
davidskidmore 13b9372
Merge branch 'main' into main
davidskidmore a8d8034
Prevent passing both target_triple and target_json simultaneously.
davidskidmore 3127957
Streamline checks for None.
davidskidmore 77a8d33
Merge branch 'main' into main
davidskidmore 7ec841e
Added unit tests for rust_toolchain rules.
davidskidmore f2d8509
Rename test target spec to avoid collisions with the builtin.
davidskidmore 2eda8df
Regenerate documentation
davidskidmore 22b3eb7
Merge branch 'main' into main
UebelAndre 9752717
Rename the triple used in unit tests.
davidskidmore 6fd74a5
Merge branch 'main' into main
hlopko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
load(":toolchain_test.bzl", "toolchain_test_suite") | ||
|
||
toolchain_test_suite(name = "toolchain_test_suite") |
This file contains hidden or 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,34 @@ | ||
{ | ||
"arch": "x86_64", | ||
"cpu": "x86-64", | ||
"crt-static-respected": true, | ||
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", | ||
"dynamic-linking": true, | ||
"env": "gnu", | ||
"executables": true, | ||
"has-elf-tls": true, | ||
"has-rpath": true, | ||
"llvm-target": "x86_64-unknown-linux-gnu", | ||
"max-atomic-width": 64, | ||
"os": "linux", | ||
"position-independent-executables": true, | ||
"pre-link-args": { | ||
"gcc": [ | ||
"-m64" | ||
] | ||
}, | ||
"relro-level": "full", | ||
"stack-probes": { | ||
"kind": "call" | ||
}, | ||
"supported-sanitizers": [ | ||
"address", | ||
"leak", | ||
"memory", | ||
"thread" | ||
], | ||
"target-family": [ | ||
"unix" | ||
], | ||
"target-pointer-width": "64" | ||
} |
This file contains hidden or 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,80 @@ | ||
"""Unit tests for rust toolchains.""" | ||
|
||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("//rust:toolchain.bzl", "rust_stdlib_filegroup", "rust_toolchain") | ||
|
||
def _toolchain_specifies_target_triple_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
toolchain_info = analysistest.target_under_test(env)[platform_common.ToolchainInfo] | ||
|
||
asserts.equals(env, None, toolchain_info.target_json) | ||
asserts.equals(env, "toolchain-test-triple", toolchain_info.target_flag_value) | ||
asserts.equals(env, "toolchain-test-triple", toolchain_info.target_triple) | ||
|
||
return analysistest.end(env) | ||
|
||
def _toolchain_specifies_target_json_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
toolchain_info = analysistest.target_under_test(env)[platform_common.ToolchainInfo] | ||
|
||
asserts.equals(env, "toolchain-test-triple.json", toolchain_info.target_json.basename) | ||
asserts.equals(env, "test/unit/toolchain/toolchain-test-triple.json", toolchain_info.target_flag_value) | ||
asserts.equals(env, "", toolchain_info.target_triple) | ||
|
||
return analysistest.end(env) | ||
|
||
toolchain_specifies_target_triple_test = analysistest.make(_toolchain_specifies_target_triple_test_impl) | ||
toolchain_specifies_target_json_test = analysistest.make(_toolchain_specifies_target_json_test_impl) | ||
|
||
def _toolchain_test(): | ||
rust_stdlib_filegroup( | ||
name = "std_libs", | ||
srcs = [], | ||
) | ||
|
||
native.filegroup( | ||
name = "target_json", | ||
srcs = ["toolchain-test-triple.json"], | ||
) | ||
|
||
rust_toolchain( | ||
name = "rust_triple_toolchain", | ||
binary_ext = "", | ||
dylib_ext = ".so", | ||
os = "linux", | ||
rust_lib = ":std_libs", | ||
staticlib_ext = ".a", | ||
stdlib_linkflags = [], | ||
target_triple = "toolchain-test-triple", | ||
) | ||
|
||
rust_toolchain( | ||
name = "rust_json_toolchain", | ||
binary_ext = "", | ||
dylib_ext = ".so", | ||
os = "linux", | ||
rust_lib = ":std_libs", | ||
staticlib_ext = ".a", | ||
stdlib_linkflags = [], | ||
target_json = ":target_json", | ||
) | ||
|
||
toolchain_specifies_target_triple_test( | ||
name = "toolchain_specifies_target_triple_test", | ||
target_under_test = ":rust_triple_toolchain", | ||
) | ||
toolchain_specifies_target_json_test( | ||
name = "toolchain_specifies_target_json_test", | ||
target_under_test = ":rust_json_toolchain", | ||
) | ||
|
||
def toolchain_test_suite(name): | ||
_toolchain_test() | ||
|
||
native.test_suite( | ||
name = name, | ||
tests = [ | ||
":toolchain_specifies_target_triple_test", | ||
":toolchain_specifies_target_json_test", | ||
], | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.