Another option you could look into is variants. If you create a
dest/tup.config file, then all the outputs will be created in a mirrored
directory hierarchy under dest automatically. Then you'd have Tupfiles like:

src/Tupfile:
: foreach *.input |> dothing %f %o |> %B.output

And the output files would end up under dest/src/*.output. Using a
Tupdefault file would help if you want to do the same thing in every
directory.

-Mike

On Thu, Mar 15, 2018 at 4:09 PM, Erik Brinkman <[email protected]>
wrote:
> tup in general isn't really designed to separate source from build. This
> isn't really necessary with tup since you never have to do a clean build.
If
> you're okay with putting build files in source, then you could look into
> Tupdefault. It allows you to specify a default tupfile for every directory
> without an existing tupfule. Thus, you could just have:
>
> cat Tupdefault
> : foreach *.input |> dothing %f %o |> %B.output
>
> If you really need to put the outputs in dest, then maybe you could do
> something with Tupdefault.lua, but I'm not really sure how to get the
> relative path to RUNNING rather than the relative path from running.
>
> On Wed, Mar 14, 2018, 20:27 'Ben Golightly' via tup-users
> <[email protected]> wrote:
>>
>> One problem with this approach is if I add a new file to a subfolder, tup
>> doesn't see it and know to automatically re-run the shell script :-( Any
>> ideas how I could fix that?
>>
>>
>> On Wednesday, March 14, 2018 at 10:20:06 PM UTC, Ben Golightly wrote:
>>>
>>>
>>> Hi, apologies if this has been asked before. I searched but didn't find
>>> anything.
>>>
>>> I have a rule that I want to apply to everything in a directory, and
>>> again in all subdirectories (possibly again, recursively, in all
>>> subdirectories of that), with the output destination mirroring this.
>>>
>>> For example, my first attempt might look like this:
>>>
>>> : foreach src/*.input         |> dothing %f %o |> dest/%B.output
>>> : foreach src/foo/*.input     |> dothing %f %o |> dest/foo/%B.output
>>> : foreach src/foo/bar/*.input |> dothing %f %o |> dest/foo/bar/%B.output
>>> : foreach src/bar/*.input     |> dothing %f %o |> dest/bar/%B.output
>>>
>>> The commands "run ./script args" and "preload directory" described in
the
>>> manual let me do this with a separate shell script.
>>>
>>> Here's what I came up with:
>>>
>>> Tupfile:
>>> preload src/pages
>>> run ./mkpage.inc.sh
>>>
>>> mkpage.inc.sh
>>> #! /bin/sh -e
>>>
>>> cmd ()
>>> {
>>>     echo ": foreach src/$1*.input |> dothing %f %o |> dest/$1%B.output"
>>> }
>>>
>>> cd "src"
>>> dirs="."/*
>>>
>>> cmd
>>>
>>> for entry in $dirs
>>> do
>>>     if [ -d "$entry" ];then
>>>         cmd $entry
>>>     fi
>>> done
>>> cd "../"
>>>
>>>
>>> This works for me (with a bit of work I could make it recursive).
>>>
>>> I hope someone else might find it useful.
>>>
>>> But I was also wondering if there was a better way to do this natively
>>> with tup?
>>>
>>> Thanks
>>>
>>> Ben
>>>
>>>
>> --
>> --
>> 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.
>
> --
> --
> 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.

-- 
-- 
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