On Wed, Dec 9, 2015 at 9:33 PM, Pat Pannuto <[email protected]> wrote:
>
> I had a little less success with this.
>
> I'm trying to build
> https://github.com/lab11/M-ulator/tree/master/simulator
>
> When I used the explicit-variant branch, the first complaint tup had came
> from this Tupfile:
> https://github.com/lab11/M-ulator/blob/master/simulator/cpu/common/private_peripheral_bus/Tupfile#L3
>
> It said that the ppb.c and ppb.h files were unspecified output files,
> which I fixed by changing the output of that rule to:
>
> : gen_registers.py | exceptions *.conf |> python %f *.conf |>
> $(TUP_VARIANTDIR)/ppb.c $(TUP_VARIANTDIR)/ppb.h
>
> Next it identified that the explicitly name file ppb.h was scheduled to be
> deleted, easy fix, change the next line to:
>
> : ppb.c | $(TUP_VARIANTDIR)/ppb.h |> !cc |> %B.o ../../../<objs>
>
> Next, it had the same complaint about this Tupfile:
> https://github.com/lab11/M-ulator/blob/master/simulator/cpu/Tupfile#L3
>
> That is, that common/private_peripheral_bus/ppb.h was scheduled to be
> deleted. So I changed that rule to
>
> : foreach *.c | $(TUP_VARIANTDIR)/common/private_peripheral_bus/ppb.h |>
> !cc |> %B.o ../<objs>
>
> Unfortunately, that gave:
>
> tup error: Unable to use inputs from a generated directory (1899) that
> isn't written to by this Tupfile.
>
>
> I'm not really sure how to reconcile this?
>
> I thought it was a little bit weird that I had to specify TUP_VARIANTDIR
> on the outputs at all, felt like something that tup should've been able to
> figure out.
>
>
Right, you shouldn't need to use TUP_VARIANTDIR in either the input or
output list. However, the command needs to either use TUP_VARIANTDIR or the
%-flags in some way in order for tup to communicate where the output file
should go. Here's a simple example:
# Tupfile A
: |> touch foo.txt |> foo.txt
# Tupfile B
: |> touch %o |> foo.txt
Tupfile A won't work with the explicit-variants, since all commands run in
the source directory, so 'touch foo.txt' creates foo.txt in the source dir
instead of the variant dir. In Tupfile B, the '%o' flag is expanded to
something like 'build/foo.txt', so the file is written inside the variant.
You could also do:
: |> touch $(TUP_VARIANT)/foo.txt |> foo.txt
But that looks strange IMO. TUP_VARIANTDIR is still needed in some cases,
such as for -I flags:
: |> generate.py %o |> foo.h
: foreach *.c | foo.h |> gcc -c %f -o %o -I$(TUP_VARIANTDIR) |> %B.o
This would add something like '-I../../build/sub/dir' so that it could find
the generated foo.h (without a variant, TUP_VARIANTDIR is like TUP_CWD).
In your case, you'll need to pass something in to gen_registers.py to tell
it where to write the files. I've attached a patch as an example that
should work with explicit variants.
Though now that I'm writing this, maybe it makes sense to have explicit
variants assume that the outputs will be written in the srcdir, and then
just move them to the variant directory? So it'd be something like:
python gen_registers.py *.conf
(writes ppb.h and ppb.c as normal)
mv ppb.c ../../../../build/simulator/cpu/common/private_peripheral_bus/ppb.c
mv ppb.h ../../../../build/simulator/cpu/common/private_peripheral_bus/ppb.h
But that would mean variants couldn't be built in parallel easily on all
platforms.
-Mike
--
--
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.
diff --git a/simulator/Tuprules.tup b/simulator/Tuprules.tup
index d4f8822..4533fe7 100644
--- a/simulator/Tuprules.tup
+++ b/simulator/Tuprules.tup
@@ -31,6 +31,7 @@ CFLAGS += -Wshadow -Wpacked
#-Wmissing-noreturn -- causes too much noise on not implemented paths
CFLAGS += -I$(TUP_CWD)
+CFLAGS += -I$(TUP_VARIANTDIR)
CFLAGS += -pthread -D_GNU_SOURCE
CFLAGS += -D@(CPU_PROFILE)
diff --git a/simulator/cpu/Tupfile b/simulator/cpu/Tupfile
index d889a7b..f11dc0e 100644
--- a/simulator/cpu/Tupfile
+++ b/simulator/cpu/Tupfile
@@ -1,3 +1,9 @@
include_rules
+# core.c includes common/private_peripheral_bus/ppb.h, which is relative to
+# this directory but is a generated file. Alternatively, we could remove this
+# line and use simulator/Tuprules.tup's '-I$(TUP_VARIANTDIR)' if core.c
+# includes cpu/common/private_peripheral_bus/ppb.h instead.
+CFLAGS += -I$(TUP_VARIANTDIR)
+
: foreach *.c | common/private_peripheral_bus/ppb.h |> !cc |> %B.o ../<objs>
diff --git a/simulator/cpu/common/private_peripheral_bus/Tupfile b/simulator/cpu/common/private_peripheral_bus/Tupfile
index 9ae1aff..2c9ef4c 100644
--- a/simulator/cpu/common/private_peripheral_bus/Tupfile
+++ b/simulator/cpu/common/private_peripheral_bus/Tupfile
@@ -1,4 +1,4 @@
include_rules
-: gen_registers.py | exceptions *.conf |> python %f *.conf |> ppb.c ppb.h
+: gen_registers.py | exceptions *.conf |> python %f %o *.conf |> ppb.c ppb.h
: ppb.c | ppb.h |> !cc |> %B.o ../../../<objs>
diff --git a/simulator/cpu/common/private_peripheral_bus/gen_registers.py b/simulator/cpu/common/private_peripheral_bus/gen_registers.py
index a07d097..da53341 100755
--- a/simulator/cpu/common/private_peripheral_bus/gen_registers.py
+++ b/simulator/cpu/common/private_peripheral_bus/gen_registers.py
@@ -74,8 +74,8 @@ except StopIteration:
if not clean:
raise ParseError(e, "Malformed exceptions file")
-h = open("ppb.h", "w")
-c = open("ppb.c", "w")
+c = open(sys.argv[1], "w")
+h = open(sys.argv[2], "w")
preamble = "/* THIS FILE AUTOMATICALLY GENERATED -- DO NOT EDIT */\n\n"
h.write(preamble)
@@ -112,7 +112,7 @@ unpredictable_func = '\
\tWARN("Unpredictable register reset is NOP\\n");\n\
}\n'
-for f in sys.argv[1:]:
+for f in sys.argv[3:]:
# It's a for loop! (ish)
e = EnumerableFile(f)
while True:
diff --git a/simulator/tests/operations/Tuprules.tup b/simulator/tests/operations/Tuprules.tup
index b1db9e3..5e1e09a 100644
--- a/simulator/tests/operations/Tuprules.tup
+++ b/simulator/tests/operations/Tuprules.tup
@@ -12,7 +12,7 @@ ARM_ASFLAGS += -g -mthumb --warn -mcpu=cortex-m3
!arm_as = |> ^c ARM_AS %f^ $(ARM_AS) $(ARM_ASFLAGS) %f -o %o |> %B.o
!arm_cc = |> ^c ARM_CC %f^ $(ARM_CC) $(ARM_CFLAGS) -c %f -o %o |> %B.o
&MEMMAP = memmap
-!arm_ld = | ../vectors.o |> ^c ARM_LD %o^ $(ARM_LD) $(ARM_LDFLAGS) -T &(MEMMAP) ../vectors.o %f -o %o |> %B.elf
+!arm_ld = | ../vectors.o |> ^c ARM_LD %o^ $(ARM_LD) $(ARM_LDFLAGS) -T &(MEMMAP) %1i %f -o %o |> %B.elf
!arm_dump = |> ^c ARM_DUMP %o^ $(ARM_OBJDUMP) -d %f > %o |> %B.dump
!arm_bin = |> ^c ARM_BIN %o^ $(ARM_OBJCOPY) -O binary %f %o |> %B.bin