Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to make a rule always run?

10 views
Skip to first unread message

Ivan Morén

unread,
Oct 14, 2024, 3:10:50 PM10/14/24
to tup-...@googlegroups.com
Hi! :-)

I am generating a file based on the output of `git log`, so it changes when the repo changes, not when the files change. Is it possible to "force re-run" it every time (I would then use the ^o flag to stop everything else from recompiling when nothing changed)

Does anyone know of a way to instruct tup to always re-run a rule?

Best regards!
Ivan

PS. I'm making a small blog using tup and pandoc and having a blast! The lua scripting of tup is really flexible! <3

Guillaume @layus Maudoux

unread,
Oct 14, 2024, 4:56:21 PM10/14/24
to tup-...@googlegroups.com, Ivan Morén
I wonder if you could unignore .git folder and depend on whatever file there that represents the last pull status.

Otherwise you could maybe have a wrapper that dumps git logs to a file before every run.

That to say that I do not think tup supports that as a proper feature, being quite strongly trying to avoid unnecessary rebuilds.

I may be wrong though.

Guillaume (@layus) Maudoux

unread,
Oct 15, 2024, 1:12:42 AM10/15/24
to tup-...@googlegroups.com, Ivan Morén

I actually found a way, with a workaround.

The .git folder is explicitly ignore by tup (why ?) here: https://github.com/gittup/tup/blob/master/src/tup/pel_group.c#L32

But you can fool it using a gitfile (https://git-scm.com/docs/gitrepository-layout#_description):

$ mv .git .git_folder
$ echo "gitdir: .git_folder" > .git
$ echo ": |> git log -n 3 > %o |> logfile" >> Tupfile
$ tup # updates
$ tup # no update
$ git switch - (or any other operation that changes git state really)
$ tup # re-runs
$ tup # no update, all updated.

This is very elegant and powerful. I think .git and other .<vcs> systems where ignored for performance reasons, and because they where deemed irrelevant for a build system. Maybe make a PR to unignore these files (behind a flag). Or just patch your version of Tup really. Not a big project, and has a fantastic build system ;-).

Hope it helps,

-- Guillaume.

--
--
tup-users mailing list
email: tup-...@googlegroups.com
unsubscribe: tup-users+...@googlegroups.com
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 tup-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tup-users/CAORM-N%2B8e7W%2BLkqYhuyWOjiqMrd426_Z7hO%3D_uLx3KXOZ2F31Q%40mail.gmail.com.

Ivan Morén

unread,
Oct 15, 2024, 7:16:04 AM10/15/24
to Guillaume (@layus) Maudoux, tup-...@googlegroups.com
Hi!

> I wonder if you could unignore .git folder and depend on whatever file there that represents the last pull status.
>
> Otherwise you could maybe have a wrapper that dumps git logs to a file before every run.

Excellent workaround ideas! For now I solved it by

1. hard linking ./.git/logs/HEAD to ./gitlog
2. using ./gitlog as input and copying it to ./gitlog_dummy in rule
that depends on the output of `git log`

which is not a very exact solution, and also requires setting up the hard link.

> But you can fool it using a gitfile (https://git-scm.com/docs/gitrepository-layout#_description):
>
> $ mv .git .git_folder
> $ echo "gitdir: .git_folder" > .git

This did work (tup started including the .git_folder), but not in my
specific use case (I think because of the "immutable" nature of git
and what i was logging?)

> Does anyone know of a way to instruct tup to always re-run a rule?

Still of interest to me!! If it is not possible then I'll see, maybe
I'll poke around the tup source and see if I can just add a ^v
"volatile" flag or something. Trying to avoid sidetracking too heavily
though (always my problem hahh).

Best regards!
/Ivan
Reply all
Reply to author
Forward
0 new messages