diff --git a/variant_path/.gitignore b/variant_path/.gitignore new file mode 100644 index 0000000..6533779 --- /dev/null +++ b/variant_path/.gitignore @@ -0,0 +1,2 @@ +/build-default +!/build-default/tup.config diff --git a/variant_path/Tupfile.ini b/variant_path/Tupfile.ini new file mode 100644 index 0000000..e69de29 diff --git a/variant_path/Tuprules.tup b/variant_path/Tuprules.tup new file mode 100644 index 0000000..bad3673 --- /dev/null +++ b/variant_path/Tuprules.tup @@ -0,0 +1,9 @@ +&templates_dir = ./templates + +# This doesn't work, cannot find the generated header.txt +# I want to access the variant path for templates/ but $(TUP_VARIANTDIR) will +# follow the current Tupfile and there is no variant "anchor" like &-variables. +!add_header = | &(templates_dir)/ |> cat &(templates_dir)/header.txt %f &(templates_dir)/footer.txt > %o |> %B.gen.txt + +# This works +#!add_header = | &(templates_dir)/ |> cat %f &(templates_dir)/footer.txt > %o |> %B.gen.txt diff --git a/variant_path/nested/a/Tupfile b/variant_path/nested/a/Tupfile new file mode 100644 index 0000000..d8f9134 --- /dev/null +++ b/variant_path/nested/a/Tupfile @@ -0,0 +1,3 @@ +include_rules + +: a.txt |> !add_header |> diff --git a/variant_path/nested/a/a.txt b/variant_path/nested/a/a.txt new file mode 100644 index 0000000..c0b6465 --- /dev/null +++ b/variant_path/nested/a/a.txt @@ -0,0 +1 @@ +letter a diff --git a/variant_path/nested/a/b/Tupfile b/variant_path/nested/a/b/Tupfile new file mode 100644 index 0000000..3ed03df --- /dev/null +++ b/variant_path/nested/a/b/Tupfile @@ -0,0 +1,3 @@ +include_rules + +: b.txt |> !add_header |> diff --git a/variant_path/nested/a/b/b.txt b/variant_path/nested/a/b/b.txt new file mode 100644 index 0000000..5a55a99 --- /dev/null +++ b/variant_path/nested/a/b/b.txt @@ -0,0 +1 @@ +letter b diff --git a/variant_path/nested/a/b/c/Tupfile b/variant_path/nested/a/b/c/Tupfile new file mode 100644 index 0000000..ea8a043 --- /dev/null +++ b/variant_path/nested/a/b/c/Tupfile @@ -0,0 +1,3 @@ +include_rules + +: c.txt |> !add_header |> diff --git a/variant_path/nested/a/b/c/c.txt b/variant_path/nested/a/b/c/c.txt new file mode 100644 index 0000000..0630cc4 --- /dev/null +++ b/variant_path/nested/a/b/c/c.txt @@ -0,0 +1 @@ +letter c diff --git a/variant_path/templates/Tupfile b/variant_path/templates/Tupfile new file mode 100644 index 0000000..ba79860 --- /dev/null +++ b/variant_path/templates/Tupfile @@ -0,0 +1 @@ +: |> ./generate_header.sh > %o |> header.txt ./ diff --git a/variant_path/templates/footer.txt b/variant_path/templates/footer.txt new file mode 100644 index 0000000..b12144a --- /dev/null +++ b/variant_path/templates/footer.txt @@ -0,0 +1,2 @@ +-- +the end diff --git a/variant_path/templates/generate_header.sh b/variant_path/templates/generate_header.sh new file mode 100755 index 0000000..e2b1f4a --- /dev/null +++ b/variant_path/templates/generate_header.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cat << EOF +YEAR $(date +%Y) +==== +EOF