SFML, in this case, has a Git repo and a download page. Until now I have always downloaded from the download page, which came (at least for the compiler I use) with .a
and .hpp
files and could easily be used with MinGW with -l
and -i
tags.
When I wanted to use this on Github, though, a couple of problems arised.
When copying it into the repo on the first commit, the Github graph would show 22k changes on the first commit and only a couple hundred on the following commits. I got around this by putting the download into a private repo and using it as a submodule. This isn't very elegant and still has the problem of being OS/compiler-specific.
Using the official Github repo as a submodule. But how do you use external raw
cpp
andhpp
files? Do you put the necessarycpp
files into the Makefile? If so, what are the downloads on the download page for?
2 Answers 2
Adding a library in your git repo would make you a maintainer of another version of the library. You want to avoid that as much as possible.
Depending on the library and the target OS, the most reasonable approach is to have it listed as a dependency in the README, along with good documentation on how to install it on all target operating systems, or links to resources that describe how to install it. Maybe, if possible, provide an automated script, but it's not really necessary and not really helpful since building from source should be reserved to developers and power users.
For "normal" users, you should provide binaries that integrate with the operating system's dependency manager (preferably) or just contain a copy of the library.
-
2This is also very dependant on the programming language - in any widely used programming language there's likely one or more typical dependency management tools that people use. Instead of committing a copy of a third party library to your repo you commit config for that tool. E.g Maven & Gradle in Java, NPM in Javascript, Composer in PHP, PIP in Python, Cargo in Rust etc etc.bdsl– bdsl2023年03月22日 14:57:20 +00:00Commented Mar 22, 2023 at 14:57
If you need full control over the external lib, one option would be:
- Fork your own repo from the original one.
- Add your own custom build scripts for each OS you need (this usually means wraping your own scripts around existing build scripts - usually not much work).
- Build the binaries you need, per OS, keep them, Git tag them, and use with your original project.
./bins/windows/lib.dll
./bins/linux/lib.so
./bins/arm/lib.a
- When the binaries get too old, sync your forked repo with original one, update build scripts, and build again. Tag a new version, use it, repeat...
Explore related questions
See similar questions with these tags.
.gitignore
or to.git/info/exclude
, though?