From 2a9204cab666d47770bf3809d95a689088019121 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 27 May 2020 15:27:57 +0200 Subject: Various minor fixes and cleanups --- libbuild2/build/script/script.cxx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'libbuild2/build/script/script.cxx') diff --git a/libbuild2/build/script/script.cxx b/libbuild2/build/script/script.cxx index e344b59..3485f54 100644 --- a/libbuild2/build/script/script.cxx +++ b/libbuild2/build/script/script.cxx @@ -22,7 +22,7 @@ namespace build2 static const optional wd_name ("current directory"); environment:: - environment (action a, const target_type& t) + environment (action a, const target_type& t, bool temp) : build2::script::environment ( t.ctx, cast (t.ctx.global_scope["build.host"]), @@ -34,9 +34,7 @@ namespace build2 target (t), vars (context, false /* global */) { - // Set special variables. Note that the $~ variable is set later and - // only if the temporary directory is required for the script - // execution (see create_temp_dir() for details). + // Set special variables. // { // $> @@ -65,6 +63,14 @@ namespace build2 assign (var_pool.insert ("<")) = move (ns); } + + // Set the $~ special variable. + // + if (temp) + { + create_temp_dir (); + assign (var_pool.insert ("~")) = temp_dir.path; + } } void environment:: @@ -118,11 +124,6 @@ namespace build2 << e; } - // Set the $~ special variable. - // - value& v (assign (var_pool.insert ("~"))); - v = td; - if (verb >= 3) text << "mkdir " << td; } -- cgit v1.1