From 20a55cdf92f4ad6af4110861811a7076056cdf36 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Sun, 21 Jun 2020 15:40:52 -0700 Subject: 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. --- git_system_dynamic.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 git_system_dynamic.go (limited to 'git_system_dynamic.go') diff --git a/git_system_dynamic.go b/git_system_dynamic.go new file mode 100644 index 0000000..daed8ff --- /dev/null +++ b/git_system_dynamic.go @@ -0,0 +1,14 @@ +// +build !static + +package git + +/* +#cgo pkg-config: libgit2 +#cgo CFLAGS: -DLIBGIT2_DYNAMIC +#include + +#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR != 0 +# error "Invalid libgit2 version; this git2go supports libgit2 v1.0" +#endif +*/ +import "C" -- cgit v1.2.3