Skip to content

Commit c5edbe6

Browse files
committed
Add env var TARGET_IS_CUSTOM for build-scripts giving them to know how to use env TARGET (part of rust-lang#14208)
1 parent e98f702 commit c5edbe6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cargo/core/compiler/custom_build.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
//! [instructions]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script
3333
3434
use super::{fingerprint, BuildRunner, Job, Unit, Work};
35-
use crate::core::compiler::artifact;
3635
use crate::core::compiler::build_runner::Metadata;
3736
use crate::core::compiler::fingerprint::DirtyReason;
3837
use crate::core::compiler::job_queue::JobState;
38+
use crate::core::compiler::{artifact, CompileKind};
3939
use crate::core::{profiles::ProfileRoot, PackageId, Target};
4040
use crate::util::errors::CargoResult;
4141
use crate::util::internal;
@@ -277,10 +277,17 @@ fn build_work(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResul
277277
let to_exec = to_exec.into_os_string();
278278
let mut cmd = build_runner.compilation.host_process(to_exec, &unit.pkg)?;
279279
let debug = unit.profile.debuginfo.is_turned_on();
280+
let target_is_json = // TODO: fix it after #14197 merged, use `unit.kind.has_json_ext_ignore_case`
281+
matches!(unit.kind, CompileKind::Target(ct) if ct.rustc_target().ends_with(".json"));
282+
280283
cmd.env("OUT_DIR", &script_out_dir)
281284
.env("CARGO_MANIFEST_DIR", unit.pkg.root())
282285
.env("NUM_JOBS", &bcx.jobs().to_string())
283286
.env("TARGET", bcx.target_data.short_name(&unit.kind))
287+
.env(
288+
"TARGET_IS_CUSTOM",
289+
target_is_json.then_some("1").unwrap_or_default(),
290+
)
284291
.env("DEBUG", debug.to_string())
285292
.env("OPT_LEVEL", &unit.profile.opt_level)
286293
.env(

0 commit comments

Comments
 (0)