Suppose you use GIT for your source control and would like to include SQLite as a third-party component via `git submodule` or `git subtree`. How does one go about getting access to the SQLite amalgamation as a GIT repo? When I tried this I found one on github.com, but it wasn’t being maintained any longer. It occurred to me that I didn’t need to depend on anyone else — I could do this myself. These steps use the bash command line shell. I’ve tried it on Mac OS, but should also work on Linux or using a bash shell on Windows. SQLite source is kept in a source control management tool called Fossil (http://fossil-scm.org). (It’s written by the authors of SQLite and uses SQLite internally, naturally.) The authors courteously tag each major of release in Fossil. So it’s simply a matter of cloning the SQLite source, checking out each tag, running the makefile to produce the amalgamation and checking in the amalgamated code into a new git repo.
Setup:
- Install Fossil from http://www.fossil-scm.org/download.html
- Install dev tools necessary for building fossil’s amalgamation (make, etc..)
- Install git
- Clone the SQLite source repo using fossil:
mkdir sqlite-fossil
cd sqlite-fossil
fossil clone http://www.sqlite.org/cgi/src sqlite.fossil
fossil open sqlite.fossil
cd ..
- Create a new git repo to hold the amalgamation:
mkdir sqlite-amalgamation
cd sqlite-amalgamation
git init
- Optional: Create a README.md file with a copy of these instructions or a link to this page and commit it.
In the future you won’t need to clone from fossil fresh, nor create a new repo — you’ll still have them. To add new SQLite releases to your repo you will use `fossil update` and `git pull` to update the two repos.
Adding one release:
- Perform these steps, replacing $1 with the release name — OR just copy this into a file called build-sqlite.sh next to your two repos, make it executable using `chmod +x build-sqlite.sh` and invoke it with the name of the release.
cd sqlite-fossil
fossil update $1
rm -rf ../sqlite_build
mkdir ../sqlite-build
cd ../sqlite-build/
../sqlite-fossil/configure
make sqlite3.c
cd ../sqlite-amalgamation/
mv ../sqlite-build/sqlite3.c .
mv ../sqlite-fossil/src/shell.c .
mv ../sqlite-build/sqlite3.h .
mv ../sqlite-fossil/src/sqlite3ext.h .
git commit -a -m $1
cd ..
For example:
./build-sqlite.sh version-3.8.11.1
Not sure what all the tags are? Use `fossil tags` to display all the tags. Search for the ones that start with 3. as the major releases. Warning: The releases do not sort in alphabetical order (e.g. 3.8.11 sorts before 3.8.9 but is a later release) so use care when picking which tags to build, otherwise your git repo could end up with the commits not in the correct order.