summaryrefslogtreecommitdiff
path: root/git_system_static.go
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-06-21 15:40:52 -0700
committerGitHub <[email protected]>2020-06-21 15:40:52 -0700
commit20a55cdf92f4ad6af4110861811a7076056cdf36 (patch)
tree1698d1f915b1065eaf17a1b56abdf4259f323f40 /git_system_static.go
parentc78ae57de63857d53f05ed088f308699622360fe (diff)
Revamp the ways in which the library can be built (#621)
This change allows to link the system version of libgit2 statically. Since `-tags static` is already used for the bundled version of the library and to avoid breaking old workflows, `-tags static,system_libgit2` is now used to select that. This means that the valid combinations are: | Flag | Effect | |-------------------------------|-----------------------------------------------| | _No flags_ | Dynamically-linked against the system libgit2 | | `-tags static,system_libgit2` | Statically-linked against the system libgit2 | | `-tags static` | Statically-linked against the bundled libgit2 | Note that there is no way to express dynamically linking against the bundled libgit2 because that makes very little sense, since the binaries wouldn't be able to be distributed. If that's still desired, the `PKG_CONFIG_PATH` environment variable can set before building the code. [`Makefile`](https://github.com/libgit2/git2go/blob/master/Makefile) has an example of how it is used in the CI.
Diffstat (limited to 'git_system_static.go')
-rw-r--r--git_system_static.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/git_system_static.go b/git_system_static.go
new file mode 100644
index 0000000..d30676a
--- /dev/null
+++ b/git_system_static.go
@@ -0,0 +1,14 @@
+// +build static,system_libgit2
+
+package git
+
+/*
+#cgo pkg-config: libgit2 --static
+#cgo CFLAGS: -DLIBGIT2_STATIC
+#include <git2.h>
+
+#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR != 0
+# error "Invalid libgit2 version; this git2go supports libgit2 v1.0"
+#endif
+*/
+import "C"