tup icon indicating copy to clipboard operation
tup copied to clipboard

Variables passed when invoking tup?

Open tehKaiN opened this issue 7 years ago • 1 comments

Since there are = and := for makefile kinda-compatibility I think it could be added too.

I have a makefile which requires specifying some args like: make ARG1=VAL1 ARG2=VAL2 ARG3=VAL3, where one of args was switching debug/release build type, and other ones were doing as little as setting proper defines for CC args. I've seen variants but I think it only supports single variant at once.

One of such makefiles is in AmigaPorts/ACE (I really suck at making makefiles) - arg ACE_CC determines GCC / VBCC compiler, while TARGET determines debug/release build.

I'd like to also integrate it with VSCode, which only allows running a build command with args, so doing such stuff using env vars won't make me happy here. Also having config with those variables set won't be a best resolution to me, since I tend to juggle with those settings very much. Now that I think of it, having it working as variants wouldn't be a best approach too, since someone may want to build my project only with one compiler installed, whereas I as a maintainer have to test all the options.

EDIT: Now after reading docs a bit more I'd say that args passed in cmd line could be treated as at-vars, essentially, calling tup ARG1=VAL1 ARG2=VAL2 could transform into cat tup.config.original > tup.config; echo CONFIG_ARG1=VAL1 >> tup.config; echo CONFIG_ARG2=VAL2 >> tup.config; tup or something like that.

tehKaiN avatar Jul 07 '18 18:07 tehKaiN

Depending on your use case, it might be feasible to use the export directive:

$  cat Tupfile
export FOO
: |> echo "${FOO}" > %o |> output.txt
$  FOO=bar tup

However, this approach doesn't support conditionals, since the variables are merely exported to the commands executed by tup and not imported into tup itself.

See the manual, export VARIABLE.

Regarding variants, they are indeed not supported on Windows (yet). That being said, making use of variants doesn't imply checking your different configurations in your VCS. With some creativity, you might even be able to set up an union mount (with OverlayFS or similar) to keep sources and artifacts separate.

kalrish avatar Jul 09 '18 05:07 kalrish