On 6/9/22 4:47 AM, Mark Maker wrote:
> Hi,
>
> I understand that file system based globs are a no-go for the build system.
> They are also arguably a bad idea, as mistakenly adding a new file (such as
> a quick "Save as" backup copy of another file) happens all-too easy.
>
> But everybody is using a versioning system nowadays, and I wondered, if
> their file index was a possible dependency.
>
> The following is numbered for easy referencing:
>
> 1. git (for instances) has the .git/index file that registers files,
> recursively, including those only staged (see Refs at end).
> 2. Other versioning software, at least those with a well-known file
> based index, should work in a similar way. But let's face it, even just
> covering git would go a long way.
> 3. Assuming Ninja could be told to include a dependency from the .git/index
> file, a globbing *check operation* could be triggered whenever it
> changes.
> 4. Note: with an unchanged index file, this would still be a NOP in any
> rebuild. A *check operation* would* only* be triggered after someone
> checked in or added files (etc.). Most importantly it would never run for
> those that just modify existing files during routine build cycles.
Actually, .git/index changes whenever any git status changes, including
but not limited to modifying existing files.
> 5. But even if the index changes, it does not yet mean a full
> reconfigure. The globbing *check operation* could do
> git ls-files --stage
> which lists all files that are officially added to the repo,
> recursively. The command also seems very fast, compared to recursive file
> system ls[*].
> 6. I assume Meson already has git well integrated for its automatic
> subproject support
> <
https://mesonbuild.com/Release-notes-for-0-40-0.html#automatic-initialization-of-subprojects-that-are-git-submodules>,
> so I guess this should be feasible, technically.
This is only used for one-time source discovery, and has a fallback mode
in that if you're not in a git repo Meson needs you to provide the same
url that would normally be in .gitmodules, inside a wrap file, so that
Meson can clone it into an extracted tarball too.
> 7. The output could be filtered to just look at relevant portions (i.e.
> just the file names), then be hashed, and the hash written into a *glob-trigger
> artifact**, but only if the hash changed!*
> 8. Finally that *glob-trigger artifact* file in turn could be added to
> the Ninja dependencies to* reconfigure the build*, i.e., to finally
> perform any new globbing.
> 9. All this could be made to be "pay as you go", i.e. only generated in
> projects with globs.
> 10. It could be made conditional on whether the .git/index file exists,
> so any external/automated "tarball" building system (no files are ever
> dynamically added or removed) would not incur a dependency from git.
And if you download the project as a tarball, what *does* it do?
Completely fail to generate the build in the first place as it cannot
run git-ls-files during `meson setup`? Do filesystem globs, then fail if
you apply a patch to the extracted tarball?
> 11. Finally, I just wanted to express my opinion, that not having globs
> is kind of like the elephant in the room for Meson, where everything else
> is *declarative* and *auto-discovered* so nicely! It would be so cool to
> have this! :-)
>
> Caveats:
>
> 1. Arguably the build system should be agnostic of the versioning
> system, i.e. just downloading a tarball should work the same way as
> checking out with git. But on the other hand, the same could be said for
> git subprojects etc. where Meson equally engages with the versioning
> system. Plus see point 10.
See my reply to point 6. :)
> 2. One could argue that people git add new files only at the end, builds
> should already work before. That could be a valid point. Frankly I don't
> know what the "universally accepted git workflow" is.
It doesn't need to be a universally accepted git workflow, there are
certainly people doing it. As a random data point, I do it that way.
--
Eli Schwartz