diff options
| author | bors <bors@rust-lang.org> | 2015-09-26 00:14:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-09-26 00:14:39 +0000 |
| commit | 78ce46ffddfed7dee58569b5f30242b00d299dfe (patch) | |
| tree | ae80a901ab56af79be5338bdb61cf2bdffc6a66b /src/test | |
| parent | 69f27c856b3e18e54b9a48412a918c91fe8b08e7 (diff) | |
| parent | abfedb7d16fc536e85e271f945195335ca0ba9e0 (diff) | |
| download | rust-78ce46ffddfed7dee58569b5f30242b00d299dfe.tar.gz rust-78ce46ffddfed7dee58569b5f30242b00d299dfe.zip | |
Auto merge of #28612 - gandro:targetvendor, r=alexcrichton
This adds a new target property, `target_vendor`. It is to be be used as a matcher for conditional compilation. The vendor is part of the [autoconf target triple](http://llvm.org/docs/doxygen/html/classllvm_1_1Triple.html#details): `<arch><sub>-<vendor>-<os>-<env>`. `arch`, `target_os` and `target_env` are already supported by Rust. This change was suggested in PR #28593. It enables conditional compilation based on the vendor. This is needed for the rumprun target, which needs to match against both, target_os and target_vendor. The default value for `target_vendor` is "unknown", "apple" and "pc" are other common values. Matching against the `target_vendor` is introduced behind the feature gate `#![feature(cfg_target_vendor)]`. This is the first time I messed around with rustc internals. I just added the my code where I found the existing `target_*` variables, hopefully I haven't missed anything. Please review with care. :) r? @alexcrichton
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/feature-gate-cfg-target-vendor.rs | 21 | ||||
| -rw-r--r-- | src/test/run-pass/cfg-target-vendor.rs | 19 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/test/compile-fail/feature-gate-cfg-target-vendor.rs b/src/test/compile-fail/feature-gate-cfg-target-vendor.rs new file mode 100644 index 00000000000..e68a84d3553 --- /dev/null +++ b/src/test/compile-fail/feature-gate-cfg-target-vendor.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(target_vendor = "x")] //~ ERROR `cfg(target_vendor)` is experimental +#[cfg_attr(target_vendor = "x", x)] //~ ERROR `cfg(target_vendor)` is experimental +struct Foo(u64, u64); + +#[cfg(not(any(all(target_vendor = "x"))))] //~ ERROR `cfg(target_vendor)` is experimental +fn foo() {} + +fn main() { + cfg!(target_vendor = "x"); + //~^ ERROR `cfg(target_vendor)` is experimental and subject to change +} diff --git a/src/test/run-pass/cfg-target-vendor.rs b/src/test/run-pass/cfg-target-vendor.rs new file mode 100644 index 00000000000..787ae5289dd --- /dev/null +++ b/src/test/run-pass/cfg-target-vendor.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(cfg_target_vendor)] + +#[cfg(target_vendor = "unknown")] +pub fn main() { +} + +#[cfg(not(target_vendor = "unknown"))] +pub fn main() { +} |
