From e28f17694a2f6a5a4df2f4efaf1da62cbfef1e8d Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 20 Nov 2024 16:01:51 +0100 Subject: [PATCH] add variant sample --- variant_path/.gitignore | 2 ++ variant_path/Tupfile | 1 + variant_path/Tupfile.ini | 0 variant_path/Tuprules.tup | 9 +++++++++ variant_path/footer.txt | 2 ++ variant_path/generate_header.sh | 8 ++++++++ variant_path/src/Tupfile | 3 +++ variant_path/src/a.txt | 1 + variant_path/src/sub/Tupfile | 3 +++ variant_path/src/sub/b.txt | 1 + 10 files changed, 30 insertions(+) create mode 100644 variant_path/.gitignore create mode 100644 variant_path/Tupfile create mode 100644 variant_path/Tupfile.ini create mode 100644 variant_path/Tuprules.tup create mode 100644 variant_path/footer.txt create mode 100755 variant_path/generate_header.sh create mode 100644 variant_path/src/Tupfile create mode 100644 variant_path/src/a.txt create mode 100644 variant_path/src/sub/Tupfile create mode 100644 variant_path/src/sub/b.txt 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 b/variant_path/Tupfile new file mode 100644 index 0000000..ba79860 --- /dev/null +++ b/variant_path/Tupfile @@ -0,0 +1 @@ +: |> ./generate_header.sh > %o |> header.txt ./ 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..58d5215 --- /dev/null +++ b/variant_path/Tuprules.tup @@ -0,0 +1,9 @@ +&root = . + +# This doesn't work, cannot find the generated header.txt +# I want to access the variant path for . but $(TUP_VARIANTDIR) will follow the +# current Tupfile and there is no variant "anchor" like &-variables. +!add_header = | &(root)/ |> cat &(root)/header.txt %f &(root)/footer.txt > %o |> %B.gen.txt + +# This works +#!add_header = | &(root)/ |> cat %f &(root)/footer.txt > %o |> %B.gen.txt diff --git a/variant_path/footer.txt b/variant_path/footer.txt new file mode 100644 index 0000000..b12144a --- /dev/null +++ b/variant_path/footer.txt @@ -0,0 +1,2 @@ +-- +the end diff --git a/variant_path/generate_header.sh b/variant_path/generate_header.sh new file mode 100755 index 0000000..e2b1f4a --- /dev/null +++ b/variant_path/generate_header.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cat << EOF +YEAR $(date +%Y) +==== +EOF diff --git a/variant_path/src/Tupfile b/variant_path/src/Tupfile new file mode 100644 index 0000000..d8f9134 --- /dev/null +++ b/variant_path/src/Tupfile @@ -0,0 +1,3 @@ +include_rules + +: a.txt |> !add_header |> diff --git a/variant_path/src/a.txt b/variant_path/src/a.txt new file mode 100644 index 0000000..c0b6465 --- /dev/null +++ b/variant_path/src/a.txt @@ -0,0 +1 @@ +letter a diff --git a/variant_path/src/sub/Tupfile b/variant_path/src/sub/Tupfile new file mode 100644 index 0000000..3ed03df --- /dev/null +++ b/variant_path/src/sub/Tupfile @@ -0,0 +1,3 @@ +include_rules + +: b.txt |> !add_header |> diff --git a/variant_path/src/sub/b.txt b/variant_path/src/sub/b.txt new file mode 100644 index 0000000..5a55a99 --- /dev/null +++ b/variant_path/src/sub/b.txt @@ -0,0 +1 @@ +letter b