Hello!

I have just converted a C project to using TUP and I'm very happy with it 
so far. It is very satisfying to not have to worry about stale files and 
having to run some "clean" command!

When I wrote my Tupfiles I tried to avoid manually curated lists of files. 
I managed to use glob rules with a directory structure so that in each 
directory, all .c files are handled exactly the same way. I managed to do 
this in all cases except for one, so this is where I would like to ask for 
advice.

I have a directory of unit test test suite files that use the Unity 
framework. Unity comes with a generator script that takes a test suite and 
generates a "runner" .c file that contains a main() that runs all the test 
cases. Then, for each test suite I want to link a test binary from the test 
suite, test runner and code under test object files. Today I have this:

# Directory contains cpu_test.c and integration_test.c

!compile  = |> gcc $(CFLAGS) -c %f -o %o |>
!link     = |> gcc $(CFLAGS) %f -o %o |>
!generate = |> ruby unity/auto/generate_test_runner.rb %f %o |>

: unity/src/unity.c   |> !compile             |> unity.o
: foreach *.c         |> !generate            |> runners/%B.c
: foreach runners/*.c |> !compile $(INCLUDES) |> runners/%B.o
: foreach *.c         |> !compile $(INCLUDES) |> %B.o

# Here I would like to use a foreach to avoid needing to add a new line 
manually when adding a test suite.
: cpu_test.o         runners/cpu_test.o         unity.o $(LIBS) |> !link |> 
cpu_test.elf
: integration_test.o runners/integration_test.o unity.o $(LIBS) |> !link |> 
integration_test.elf

I almost managed to generalize the last two rules by using a combination of 
foreach and order only dependencies:

: foreach *.o | runners/%B.o unity.o $(LIBS) |> !link runners/%B.o unity.o 
$(LIBS) |> %B.elf

This would work except for the fact that TUP does not recognize the "%B" 
syntax in order only dependencies. If I remove that dependency the link 
command itself succeeds, but of course TUP (rightfully) complains that it 
read a file not declared as an input.

Can this be done in any other way? What do you think?

Best regards,
Rasmus Bondesson

-- 
-- 
tup-users mailing list
email: [email protected]
unsubscribe: [email protected]
options: http://groups.google.com/group/tup-users?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"tup-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to