4 ms·
> Provide an ad-hoc in-tree script to download the dependency > Yes, really, git submodule is worse than ad-hoc Makefile runes Please don't. Submodules are mu
by soraminazuki 4y ago
> Provide an ad-hoc in-tree script to download the dependency
> Yes, really, git submodule is worse than ad-hoc Makefile runes
Please don't. Submodules are much better.
Projects using submodules and standard build tools are easy to build. They're easier to customize. They can be packaged downstream with few or no patching. On the contrary, projects using ad-hoc scripts are often hard to build, have no convenient methods of customization, and resists downstream packaging.
That's because with the former approach, build descriptions are standardized and (often) declarative. Standardized build descriptions are easier to build and customize because they're predictable and provide uniform methods to configure builds. Declarative build descriptions are easier to customize because they only specify the end state. It doesn't matter what changes you make to the build process as long as it doesn't create conflicts with the described end state.
When building a project, submodules can be viewed as declarative way of specifying dependencies because it only specifies a Git URL, a commit hash, and a target subdirectory. It doesn't really matter how you fetch them. This is convenient for things like package managers because it allows them to fetch dependencies beforehand. With ad-hoc scripts, dependencies are specified imperatively. Or as the article puts it, the script is "in precise control of when/whether the download occurs." If package managers want to prefetch dependencies, it would have to patch that part of the script out.
- mmis1000 4y agoThe concept is not the problem. The submodule's problem is it has the most suck ui ever. The default 'git clone' don't ever setup the submodule. The checkout, rebase... etc works half of time. And some left submodule intact unless you add some weird parameters. It's pain in the ass even you are not the one writing submodule but just the one using it. In practice, a lot of repo add shell scripts just to… setup and update the submodule. This should be git's own task to do. But it really isn't done well. It will be much better if git just treat submodule as a readonly subdirectory and force sync everything unless I tell it I want to edit it. Package managers on the other end don't give you such pain. A 'npm install' will just correct every dependency to proper state without bother you about anything.