summaryrefslogtreecommitdiffstats
path: root/src/executor.rs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-09-29 01:07:56 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-10-02 12:58:35 +0200
commitf0653ccdb084ad7bb389ad6859474c117893e5a9 (patch)
tree764d6b1367c6ffd470482b6dc7ac4b8244b6cd6c /src/executor.rs
parente9d557fc2923d5c130b252f935479bc2f74734d6 (diff)
downloadrebel-f0653ccdb084ad7bb389ad6859474c117893e5a9.tar
rebel-f0653ccdb084ad7bb389ad6859474c117893e5a9.zip
executor: add various toolchain-related variables to the environment by default
Diffstat (limited to 'src/executor.rs')
-rw-r--r--src/executor.rs77
1 files changed, 75 insertions, 2 deletions
diff --git a/src/executor.rs b/src/executor.rs
index 69e869d..06b3610 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -1,5 +1,6 @@
use std::collections::{HashMap, HashSet};
+use indoc::indoc;
use serde::{Deserialize, Serialize};
use crate::{
@@ -155,6 +156,75 @@ impl<'ctx> Executor<'ctx> {
.collect())
}
+ fn task_setup(&self, task_ref: &TaskRef<'ctx>) -> Vec<&'static str> {
+ let mut ret = Vec::new();
+
+ ret.push(indoc! {"
+ export AR_FOR_BUILD=ar
+ export AS_FOR_BUILD=as
+ export DLLTOOL_FOR_BUILD=dlltool
+ export CC_FOR_BUILD=gcc
+ export CXX_FOR_BUILD=g++
+ export GCC_FOR_BUILD=gcc
+ export GFORTRAN_FOR_BUILD=gfortran
+ export GOC_FOR_BUILD=goc
+ export LD_FOR_BUILD=ld
+ export LIPO_FOR_BUILD=lipo
+ export NM_FOR_BUILD=nm
+ export OBJCOPY_FOR_BUILD=objcopy
+ export OBJDUMP_FOR_BUILD=objdump
+ export RANLIB_FOR_BUILD=ranlib
+ export STRIP_FOR_BUILD=strip
+ export WINDRES_FOR_BUILD=windres
+ export WINDMC_FOR_BUILD=windmc
+ "});
+
+ if task_ref.args.contains_key("build_to_host") {
+ ret.push(indoc! {"
+ export AR={{build_to_host.cross_compile}}ar
+ export AS={{build_to_host.cross_compile}}as
+ export DLLTOOL={{build_to_host.cross_compile}}dlltool
+ export CC={{build_to_host.cross_compile}}gcc
+ export CXX={{build_to_host.cross_compile}}g++
+ export GCC={{build_to_host.cross_compile}}gcc
+ export GFORTRAN={{build_to_host.cross_compile}}gfortran
+ export GOC={{build_to_host.cross_compile}}goc
+ export LD={{build_to_host.cross_compile}}ld
+ export LIPO={{build_to_host.cross_compile}}lipo
+ export NM={{build_to_host.cross_compile}}nm
+ export OBJCOPY={{build_to_host.cross_compile}}objcopy
+ export OBJDUMP={{build_to_host.cross_compile}}objdump
+ export RANLIB={{build_to_host.cross_compile}}ranlib
+ export STRIP={{build_to_host.cross_compile}}strip
+ export WINDRES={{build_to_host.cross_compile}}windres
+ export WINDMC={{build_to_host.cross_compile}}windmc
+ "});
+ }
+
+ if task_ref.args.contains_key("build_to_target") {
+ ret.push(indoc! {"
+ export AR_FOR_TARGET={{build_to_target.cross_compile}}ar
+ export AS_FOR_TARGET={{build_to_target.cross_compile}}as
+ export DLLTOOL_FOR_TARGET={{build_to_target.cross_compile}}dlltool
+ export CC_FOR_TARGET={{build_to_target.cross_compile}}gcc
+ export CXX_FOR_TARGET={{build_to_target.cross_compile}}g++
+ export GCC_FOR_TARGET={{build_to_target.cross_compile}}gcc
+ export GFORTRAN_FOR_TARGET={{build_to_target.cross_compile}}gfortran
+ export GOC_FOR_TARGET={{build_to_target.cross_compile}}goc
+ export LD_FOR_TARGET={{build_to_target.cross_compile}}ld
+ export LIPO_FOR_TARGET={{build_to_target.cross_compile}}lipo
+ export NM_FOR_TARGET={{build_to_target.cross_compile}}nm
+ export OBJCOPY_FOR_TARGET={{build_to_target.cross_compile}}objcopy
+ export OBJDUMP_FOR_TARGET={{build_to_target.cross_compile}}objdump
+ export RANLIB_FOR_TARGET={{build_to_target.cross_compile}}ranlib
+ export STRIP_FOR_TARGET={{build_to_target.cross_compile}}strip
+ export WINDRES_FOR_TARGET={{build_to_target.cross_compile}}windres
+ export WINDMC_FOR_TARGET={{build_to_target.cross_compile}}windmc
+ "});
+ }
+ ret
+ }
+
fn run_one(&self, task_ref: &TaskRef<'ctx>, runner: &impl runner::Runner) -> Result<TaskMeta> {
let task_def = &self.ctx[task_ref.id];
let task_deps = self.task_deps(task_ref)?;
@@ -179,9 +249,12 @@ impl<'ctx> Executor<'ctx> {
})
.unwrap_or_default();
+ let mut run = self.task_setup(task_ref);
+ run.push(&task_def.action.run);
+
let command = self
.tpl
- .eval(&task_def.action.run, &task_ref.args)
+ .eval(&run.concat(), &task_ref.args)
.with_context(|| {
format!("Failed to evaluate command template for task {}", task_ref)
})?;
@@ -207,7 +280,7 @@ impl<'ctx> Executor<'ctx> {
fs::mkdir(&state_dir)?;
let task = runner::Task {
- label: format!("{:#}", task_ref,),
+ label: format!("{:#}", task_ref),
input,
input_hash,
};