On Fri, Jul 9, 2021 at 3:25 PM 'Peter Moore' via tup-users <
[email protected]> wrote:

>
> Hi folks,
>
> Is there an idiomatic way to implement a source formatting step in tup?
> I'm aware that the following type of construction is illegal since a file
> cannot be both a generated node and a normal file:
>
> : foreach *.s |> asm-format %f |> %f
>
> I see that I could have a wrapper script that moves files before or after
> tup is called, but that feels suboptimal, so I was wondering if there is a
> better approach.
>

Hi Pete,

I don't think this workflow will work well in tup. I think it would also be
fairly confusing even if it did work -- consider if there was an
un-formatted file checked into your repo, and someone checks it out and
does a build. They would then find files modified in 'git diff' and the
like, even though they didn't change anything themselves.

One thing you can do in the build system is to use it as a linter, so it's
more of a format-checker rather than a format-rewriter. So you could do
something like this:

: foreach *.s |> asm-format --check %f |>

(Assuming asm-format accepts a --check argument and exits with 0 for
success and 1 for bad formatting). Note that you don't actually need an
output file for this; the command will re-run if any of the inputs change.

The actual re-formatting is likely much better suited for one or both of
your editor and/or a version control hook (so all files could be formatted
on commit or something).

Hope that helps,
-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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tup-users/CA%2B6x0LVHPi8YM4caVPx3Ste7dXL7HUyqsUn2aDTd0iPCOtMAOg%40mail.gmail.com.

Reply via email to