Output dictionary
Example from website ends as a code builded in same directory:
.
|-- build
| \-- newmath
|-- hello
|-- hello.c
|-- hello.o
|-- newmath
| |-- libnewmath.a
| |-- square.c
| |-- square.h
| |-- square.o
| \-- Tupfile
|-- Tupfile
\-- Tuprules.tup
However I've seen many time that results from other tools are in some directory like: "target", "build" etc. Is there simple a way to do that in tup?
What I'm looking for:
.
|-- build
| |-- hello
| |-- hello.o
| `-- newmath
| |-- libnewmath.a
| `-- square.o
|-- hello.c
|-- newmath
| |-- square.c
| |-- square.h
| `-- Tupfile
|-- Tupfile
`-- Tuprules.tup
I've tried to add, build directory to the file names: Tupfile:
include_rules
CFLAGS += -Inewmath
: foreach *.c |> !cc |> build/%B.o
: *.o build/newmath/libnewmath.a |> gcc %f -o %o |> build/hello
newmath/Tupfile:
include_rules
: foreach *.c |> !cc |> ../build/newmath/%B.o
: *.o |> !ar |> ../build/newmath/libnewmath.a
Tuprules.tup:
CFLAGS += -Wall
CFLAGS += -O2
!cc = |> gcc $(CFLAGS) -c %f -o %o |>
!ar = |> ar crs %o %f |>
But this config is not working, as I expected, and I'm not sure how to understand following error:
tup error: Explicitly named file 'build/newmath/libnewmath.a' can't be listed as an input because it was generated from external directory 'newmath' - try placing the file in a group instead and using the group as an input.
tup error: Error parsing Tupfile line 4
Line was: ': *.o build/newmath/libnewmath.a |> gcc %f -o %o |> build/hello'
[ ] 100%
*** tup: 1 job failed.
But I'm interested, if there is no simpler way of changing output directory?
Thanks for help.
This can be done, but if you use files generated that way as inputs in other commands, you - unfortunately - have to use them via "groups" (<...>), not by explicit naming.
In my project I've implemented something like this with tup and lua parser - https://github.com/DISTORTEC/distortos
You can get this behavior by using variants.
Yeah, but this seams to be workaround. I think that such functionality should be standard one in such tool.
Attempting to do anything nontrivial in tup involves repeatedly running into quirks, deficiencies, leaky abstractions and inconsistencies until you drop from exhaustion.