File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66## [ Unreleased]
77
88- #722 - boolean environment variables are evaluated as truthy or falsey.
9+ - #721 - add support for running doctests on nightly if ` CROSS_UNSTABLE_ENABLE_DOCTESTS=true ` .
910- #718 - remove deb subcommand.
1011- #714 - use host target directory when falling back to host cargo.
1112- #713 - convert relative target directories to absolute paths.
Original file line number Diff line number Diff line change @@ -207,6 +207,15 @@ passthrough = [
207207]
208208```
209209
210+ ### Unstable Features
211+
212+ Certain unstable features can enable additional functionality useful to
213+ cross-compiling. Note that these are unstable, and may be removed at any
214+ time (particularly if the feature is stabilized or removed), and will
215+ only be used on a nightly channel.
216+
217+ - ` CROSS_UNSTABLE_ENABLE_DOCTESTS=true ` : also run doctests.
218+
210219### Mounting volumes into the build environment
211220
212221In addition to passing environment variables, you can also specify environment
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ pub struct Args {
1414 pub target : Option < Target > ,
1515 pub target_dir : Option < PathBuf > ,
1616 pub docker_in_docker : bool ,
17+ pub enable_doctests : bool ,
1718}
1819
1920// Fix for issue #581. target_dir must be absolute.
@@ -85,6 +86,9 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
8586 let docker_in_docker = env:: var ( "CROSS_DOCKER_IN_DOCKER" )
8687 . map ( |s| bool_from_envvar ( & s) )
8788 . unwrap_or_default ( ) ;
89+ let enable_doctests = env:: var ( "CROSS_UNSTABLE_ENABLE_DOCTESTS" )
90+ . map ( |s| bool:: from_str ( & s) . unwrap_or_default ( ) )
91+ . unwrap_or_default ( ) ;
8892
8993 Ok ( Args {
9094 all,
@@ -93,5 +97,6 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
9397 target,
9498 target_dir,
9599 docker_in_docker,
100+ enable_doctests,
96101 } )
97102}
Original file line number Diff line number Diff line change @@ -279,6 +279,7 @@ fn run() -> Result<ExitStatus> {
279279
280280 let host_version_meta =
281281 rustc_version:: version_meta ( ) . wrap_err ( "couldn't fetch the `rustc` version" ) ?;
282+ let is_nightly = rustc:: is_nightly ( & args. channel , & host_version_meta) ;
282283 if let Some ( root) = cargo:: root ( ) ? {
283284 let host = host_version_meta. host ( ) ;
284285 let toml = toml ( & root) ?;
@@ -358,7 +359,7 @@ fn run() -> Result<ExitStatus> {
358359 . map ( |sc| sc. needs_interpreter ( ) )
359360 . unwrap_or ( false ) ;
360361
361- let filtered_args = if args
362+ let mut filtered_args = if args
362363 . subcommand
363364 . map_or ( false , |s| !s. needs_target_in_command ( ) )
364365 {
@@ -384,6 +385,14 @@ fn run() -> Result<ExitStatus> {
384385 args. all . clone ( )
385386 } ;
386387
388+ let is_test = args
389+ . subcommand
390+ . map ( |sc| sc == Subcommand :: Test )
391+ . unwrap_or ( false ) ;
392+ if is_test && args. enable_doctests && is_nightly {
393+ filtered_args. push ( "-Zdoctest-xcompile" . to_string ( ) ) ;
394+ }
395+
387396 if target. needs_docker ( ) && args. subcommand . map ( |sc| sc. needs_docker ( ) ) . unwrap_or ( false )
388397 {
389398 if host_version_meta. needs_interpreter ( )
Original file line number Diff line number Diff line change 11use std:: path:: PathBuf ;
22use std:: process:: Command ;
33
4- use rustc_version:: { Version , VersionMeta } ;
4+ use rustc_version:: { Channel , Version , VersionMeta } ;
55
66use crate :: errors:: * ;
77use crate :: extensions:: CommandExt ;
@@ -33,6 +33,14 @@ impl VersionMetaExt for VersionMeta {
3333 }
3434}
3535
36+ pub fn is_nightly ( channel : & Option < String > , host_version_meta : & VersionMeta ) -> bool {
37+ if let Some ( channel) = channel {
38+ channel. contains ( "nightly" )
39+ } else {
40+ host_version_meta. channel == Channel :: Nightly
41+ }
42+ }
43+
3644pub fn target_list ( verbose : bool ) -> Result < TargetList > {
3745 Command :: new ( "rustc" )
3846 . args ( & [ "--print" , "target-list" ] )
You can’t perform that action at this time.
0 commit comments