@@ -190,27 +190,29 @@ fn compile<'gctx>(
190190 } else {
191191 let force = exec. force_rebuild ( unit) || force_rebuild;
192192 let mut job = fingerprint:: prepare_target ( build_runner, unit, force) ?;
193- job. before ( if job. freshness ( ) . is_dirty ( ) {
194- let work = if unit. mode . is_doc ( ) || unit. mode . is_doc_scrape ( ) {
195- rustdoc ( build_runner, unit) ?
193+ job. before (
194+ if job. freshness ( ) . is_dirty ( ) || env_config_modified ( bcx. gctx ) ? {
195+ let work = if unit. mode . is_doc ( ) || unit. mode . is_doc_scrape ( ) {
196+ rustdoc ( build_runner, unit) ?
197+ } else {
198+ rustc ( build_runner, unit, exec) ?
199+ } ;
200+ work. then ( link_targets ( build_runner, unit, false ) ?)
196201 } else {
197- rustc ( build_runner, unit, exec) ?
198- } ;
199- work. then ( link_targets ( build_runner, unit, false ) ?)
200- } else {
201- // We always replay the output cache,
202- // since it might contain future-incompat-report messages
203- let work = replay_output_cache (
204- unit. pkg . package_id ( ) ,
205- PathBuf :: from ( unit. pkg . manifest_path ( ) ) ,
206- & unit. target ,
207- build_runner. files ( ) . message_cache_path ( unit) ,
208- build_runner. bcx . build_config . message_format ,
209- unit. show_warnings ( bcx. gctx ) ,
210- ) ;
211- // Need to link targets on both the dirty and fresh.
212- work. then ( link_targets ( build_runner, unit, true ) ?)
213- } ) ;
202+ // We always replay the output cache,
203+ // since it might contain future-incompat-report messages
204+ let work = replay_output_cache (
205+ unit. pkg . package_id ( ) ,
206+ PathBuf :: from ( unit. pkg . manifest_path ( ) ) ,
207+ & unit. target ,
208+ build_runner. files ( ) . message_cache_path ( unit) ,
209+ build_runner. bcx . build_config . message_format ,
210+ unit. show_warnings ( bcx. gctx ) ,
211+ ) ;
212+ // Need to link targets on both the dirty and fresh.
213+ work. then ( link_targets ( build_runner, unit, true ) ?)
214+ } ,
215+ ) ;
214216
215217 job
216218 } ;
@@ -1926,6 +1928,21 @@ fn should_include_scrape_units(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool
19261928 unit. mode . is_doc ( ) && bcx. scrape_units . len ( ) > 0 && bcx. ws . unit_needs_doc_scrape ( unit)
19271929}
19281930
1931+ /// Detects if environment variables from config `[env]` is newly modified.
1932+ fn env_config_modified ( gctx : & crate :: GlobalContext ) -> CargoResult < bool > {
1933+ for ( key, value) in gctx. env_config ( ) ?. iter ( ) {
1934+ if !gctx. env ( ) . any ( |( k, _) | k == key) {
1935+ continue ;
1936+ }
1937+
1938+ if !value. is_force ( ) && gctx. env ( ) . find ( |( k, _) | k == key) . is_some ( ) {
1939+ return Ok ( true ) ;
1940+ }
1941+ }
1942+
1943+ Ok ( false )
1944+ }
1945+
19291946/// Gets the file path of function call information output from `rustdoc`.
19301947fn scrape_output_path ( build_runner : & BuildRunner < ' _ , ' _ > , unit : & Unit ) -> CargoResult < PathBuf > {
19311948 assert ! ( unit. mode. is_doc( ) || unit. mode. is_doc_scrape( ) ) ;
0 commit comments