From b52e13f37dfb80a47b78ca6f95e06b4b27220767 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Thu, 22 Feb 2018 09:28:49 +0100 Subject: Switch over the version contraints to v0.27 --- git_static.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git_static.go') diff --git a/git_static.go b/git_static.go index b42d49f..6303734 100644 --- a/git_static.go +++ b/git_static.go @@ -9,8 +9,8 @@ package git #cgo !windows pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc #include -#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 26 -# error "Invalid libgit2 version; this git2go supports libgit2 v0.26" +#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 27 +# error "Invalid libgit2 version; this git2go supports libgit2 v0.27" #endif */ -- cgit v1.2.3 From b3256d9058aa93176190cb69f73afb72f0730100 Mon Sep 17 00:00:00 2001 From: Ryan Graham Date: Tue, 8 May 2018 15:47:34 -0700 Subject: static: use pkg-config exclusively when using it When using the static linking option on platforms that use pkg-config, use ONLY pkg-config to get the CFLAGS and LDFLAGS. This prevents pulling in dependencies and flags for any non-vendored version that may be present on the host. The main practical effect of this is that if someone doesn't need/want any sort of remote access support at all they can completely disable libcurl, libssh2, libssl, etc and produce a smaller/simpler binary and greatly simplify their build-time dependencies. When done properly, the generated pkg-config file will tell cgo everything it needs to know. This also prevents confusion if there is a system copy of libgit2 that is being given priority over the vendored build. Signed-off-by: Ryan Graham --- git_static.go | 5 ++--- script/build-libgit2-static.sh | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'git_static.go') diff --git a/git_static.go b/git_static.go index 6303734..243669f 100644 --- a/git_static.go +++ b/git_static.go @@ -3,9 +3,8 @@ package git /* -#cgo CFLAGS: -I${SRCDIR}/vendor/libgit2/include -#cgo LDFLAGS: -L${SRCDIR}/vendor/libgit2/build/ -lgit2 -#cgo windows LDFLAGS: -lwinhttp +#cgo windows CFLAGS: -I${SRCDIR}/vendor/libgit2/include +#cgo windows LDFLAGS: -L${SRCDIR}/vendor/libgit2/build/ -lgit2 -lwinhttp #cgo !windows pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc #include diff --git a/script/build-libgit2-static.sh b/script/build-libgit2-static.sh index 5723721..1568ece 100755 --- a/script/build-libgit2-static.sh +++ b/script/build-libgit2-static.sh @@ -16,4 +16,4 @@ cmake -DTHREADSAFE=ON \ -DCMAKE_INSTALL_PREFIX=../install \ .. && -cmake --build . +cmake --build . --target install -- cgit v1.2.3 From f3c487966d53ad78e25d2e6750414009f5606dbb Mon Sep 17 00:00:00 2001 From: lhchavez Date: Sat, 5 Jan 2019 20:13:01 +0000 Subject: Improve the static build script This change: * Uses the installed version of both the library and the pkgconfig file, which fixes path resolution on Ubuntu Xenial. * Uses quoting liberally so that paths with spaces in them are correctly handled. * Moves the build+install directories to static-build/ in the git2go repository to avoid having a dirty vendor/libgit2 checkout. --- .gitignore | 1 + git_static.go | 6 +++--- script/build-libgit2-static.sh | 15 ++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 .gitignore (limited to 'git_static.go') diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edc18d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/static-build/ diff --git a/git_static.go b/git_static.go index 243669f..547ae8a 100644 --- a/git_static.go +++ b/git_static.go @@ -3,9 +3,9 @@ package git /* -#cgo windows CFLAGS: -I${SRCDIR}/vendor/libgit2/include -#cgo windows LDFLAGS: -L${SRCDIR}/vendor/libgit2/build/ -lgit2 -lwinhttp -#cgo !windows pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc +#cgo windows CFLAGS: -I${SRCDIR}/static-build/install/include/ +#cgo windows LDFLAGS: -L${SRCDIR}/static-build/install/lib/ -lgit2 -lwinhttp +#cgo !windows pkg-config: --static ${SRCDIR}/static-build/install/lib/pkgconfig/libgit2.pc #include #if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 27 diff --git a/script/build-libgit2-static.sh b/script/build-libgit2-static.sh index 1568ece..680dd93 100755 --- a/script/build-libgit2-static.sh +++ b/script/build-libgit2-static.sh @@ -2,18 +2,19 @@ set -ex -VENDORED_PATH=vendor/libgit2 +ROOT="$(cd "$0/../.." && echo "${PWD}")" +BUILD_PATH="${ROOT}/static-build" +VENDORED_PATH="${ROOT}/vendor/libgit2" -cd $VENDORED_PATH && -mkdir -p install/lib && -mkdir -p build && -cd build && +mkdir -p "${BUILD_PATH}/build" "${BUILD_PATH}/install/lib" + +cd "${BUILD_PATH}/build" && cmake -DTHREADSAFE=ON \ -DBUILD_CLAR=OFF \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_C_FLAGS=-fPIC \ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ - -DCMAKE_INSTALL_PREFIX=../install \ - .. && + -DCMAKE_INSTALL_PREFIX="${BUILD_PATH}/install" \ + "${VENDORED_PATH}" && cmake --build . --target install -- cgit v1.2.3 From 5fda6dd90191b1c51a1785ad7cabd2fd5b05e802 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Sat, 12 Jan 2019 21:21:20 +0000 Subject: Uprev vendored libgit2 to v0.28 New version is here! --- git_static.go | 4 ++-- object.go | 16 ++++++++-------- odb.go | 2 +- vendor/libgit2 | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'git_static.go') diff --git a/git_static.go b/git_static.go index 547ae8a..d7c2295 100644 --- a/git_static.go +++ b/git_static.go @@ -8,8 +8,8 @@ package git #cgo !windows pkg-config: --static ${SRCDIR}/static-build/install/lib/pkgconfig/libgit2.pc #include -#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 27 -# error "Invalid libgit2 version; this git2go supports libgit2 v0.27" +#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 28 +# error "Invalid libgit2 version; this git2go supports libgit2 v0.28" #endif */ diff --git a/object.go b/object.go index 40ab2bf..2d75b06 100644 --- a/object.go +++ b/object.go @@ -13,12 +13,12 @@ import ( type ObjectType int const ( - ObjectAny ObjectType = C.GIT_OBJECT_ANY - ObjectBad ObjectType = C.GIT_OBJECT_BAD - ObjectCommit ObjectType = C.GIT_OBJECT_COMMIT - ObjectTree ObjectType = C.GIT_OBJECT_TREE - ObjectBlob ObjectType = C.GIT_OBJECT_BLOB - ObjectTag ObjectType = C.GIT_OBJECT_TAG + ObjectAny ObjectType = C.GIT_OBJECT_ANY + ObjectInvalid ObjectType = C.GIT_OBJECT_INVALID + ObjectCommit ObjectType = C.GIT_OBJECT_COMMIT + ObjectTree ObjectType = C.GIT_OBJECT_TREE + ObjectBlob ObjectType = C.GIT_OBJECT_BLOB + ObjectTag ObjectType = C.GIT_OBJECT_TAG ) type Object struct { @@ -35,8 +35,8 @@ func (t ObjectType) String() string { switch t { case ObjectAny: return "Any" - case ObjectBad: - return "Bad" + case ObjectInvalid: + return "Invalid" case ObjectCommit: return "Commit" case ObjectTree: diff --git a/odb.go b/odb.go index 5768cf4..fec0eb9 100644 --- a/odb.go +++ b/odb.go @@ -66,7 +66,7 @@ func (v *Odb) ReadHeader(oid *Oid) (uint64, ObjectType, error) { ret := C.git_odb_read_header(&sz, &cotype, v.ptr, oid.toC()) runtime.KeepAlive(v) if ret < 0 { - return 0, ObjectBad, MakeGitError(ret) + return 0, ObjectInvalid, MakeGitError(ret) } return uint64(sz), ObjectType(cotype), nil diff --git a/vendor/libgit2 b/vendor/libgit2 index fba70a9..1a107fa 160000 --- a/vendor/libgit2 +++ b/vendor/libgit2 @@ -1 +1 @@ -Subproject commit fba70a9d5f1fa433968a3dfd51e3153c8eebe834 +Subproject commit 1a107fac0fc88a4d74b64ffc9ae2fd178ba631c0 -- cgit v1.2.3