summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml64
-rw-r--r--.gitignore1
-rw-r--r--.travis.yml16
-rw-r--r--Makefile47
-rwxr-xr-xscript/build-libgit2-dynamic.sh5
-rwxr-xr-xscript/build-libgit2-static.sh20
-rwxr-xr-xscript/build-libgit2.sh46
7 files changed, 166 insertions, 33 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d058ec6..931cc09 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -4,15 +4,16 @@ on:
push:
branches:
- master
+ - release-*
- v*
jobs:
- build:
+ build-legacy:
strategy:
fail-fast: false
matrix:
- go: [ '1.9', '1.10', '1.11', '1.12' , '1.13']
+ go: [ '1.9', '1.10' ]
name: Go ${{ matrix.go }}
runs-on: ubuntu-18.04
@@ -23,9 +24,66 @@ jobs:
with:
go-version: ${{ matrix.go }}
id: go
+ - name: Check out code into the GOPATH
+ uses: actions/checkout@v1
+ with:
+ fetch-depth: 1
+ path: src/github.com/${{ github.repository }}
+ - name: Build
+ env:
+ GOPATH: /home/runner/work/git2go
+ run: |
+ git submodule update --init
+ make build-libgit2-static
+ go get --tags "static" github.com/${{ github.repository }}/...
+ go build --tags "static" github.com/${{ github.repository }}/...
+ - name: Test
+ env:
+ GOPATH: /home/runner/work/git2go
+ run: make test-static
+
+ build-static:
+ strategy:
+ fail-fast: false
+ matrix:
+ go: [ '1.11', '1.12', '1.13' ]
+ name: Go ${{ matrix.go }}
+
+ runs-on: ubuntu-18.04
+
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v1
+ with:
+ go-version: ${{ matrix.go }}
+ id: go
+ - name: Check out code into the Go module directory
+ uses: actions/checkout@v1
+ - name: Build
+ run: |
+ git submodule update --init
+ make build-libgit2-static
+ - name: Test
+ run: make test-static
+
+ build-dynamic:
+ strategy:
+ fail-fast: false
+ name: Go (dynamic)
+
+ runs-on: ubuntu-18.04
+
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v1
+ with:
+ go-version: '1.13'
+ id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Build
run: |
git submodule update --init
- make test-static
+ make build-libgit2-dynamic
+ - name: Test
+ run: make test-dynamic
diff --git a/.gitignore b/.gitignore
index edc18d5..713781b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/static-build/
+/dynamic-build/
diff --git a/.travis.yml b/.travis.yml
index 7d53122..b25a052 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,25 +1,29 @@
language: go
go:
+ - "1.9"
+ - "1.10"
- "1.11"
- "1.12"
- "1.13"
- tip
-script: make test-static
+install:
+ - make build-libgit2-static
+ - go get --tags "static" ./...
+
+script:
+ - make test-static
matrix:
allow_failures:
- go: tip
git:
- submodules: false
-
-before_install:
- - git submodule update --init
+ submodules: true
branches:
only:
- master
- /v\d+/
- - next
+ - /release-.*/
diff --git a/Makefile b/Makefile
index 4dffce0..182c53e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,53 @@
default: test
-test: build-libgit2
+# System library
+# ==============
+# This uses whatever version of libgit2 can be found in the system.
+test:
go run script/check-MakeGitError-thread-lock.go
go test --count=1 ./...
-install: build-libgit2
+install:
go install ./...
-build-libgit2:
+# Bundled dynamic library
+# =======================
+# In order to avoid having to manipulate `git_dynamic.go`, which would prevent
+# the system-wide libgit2.so from being used in a sort of ergonomic way, this
+# instead moves the complexity of overriding the paths so that the built
+# libraries can be found by the build and tests.
+.PHONY: build-libgit2-dynamic
+build-libgit2-dynamic:
+ ./script/build-libgit2-dynamic.sh
+
+dynamic-build/install/lib/libgit2.so:
+ ./script/build-libgit2-dynamic.sh
+
+test-dynamic: dynamic-build/install/lib/libgit2.so
+ PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
+ go run script/check-MakeGitError-thread-lock.go
+ PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
+ LD_LIBRARY_PATH=dynamic-build/install/lib \
+ go test --count=1 ./...
+
+install-dynamic: dynamic-build/install/lib/libgit2.so
+ PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
+ go install ./...
+
+# Bundled static library
+# ======================
+# This is mostly used in tests, but can also be used to provide a
+# statically-linked library with the bundled version of libgit2.
+.PHONY: build-libgit2-static
+build-libgit2-static:
./script/build-libgit2-static.sh
-install-static: build-libgit2
- go install --tags "static" ./...
+static-build/install/lib/libgit2.a:
+ ./script/build-libgit2-static.sh
-test-static: build-libgit2
+test-static: static-build/install/lib/libgit2.a
go run script/check-MakeGitError-thread-lock.go
go test --count=1 --tags "static" ./...
+
+install-static: static-build/install/lib/libgit2.a
+ go install --tags "static" ./...
diff --git a/script/build-libgit2-dynamic.sh b/script/build-libgit2-dynamic.sh
new file mode 100755
index 0000000..af037f3
--- /dev/null
+++ b/script/build-libgit2-dynamic.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+exec "$(dirname "$0")/build-libgit2.sh" --dynamic
diff --git a/script/build-libgit2-static.sh b/script/build-libgit2-static.sh
index 26efc8e..1d28898 100755
--- a/script/build-libgit2-static.sh
+++ b/script/build-libgit2-static.sh
@@ -1,21 +1,5 @@
#!/bin/sh
-set -ex
+set -e
-ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")"
-BUILD_PATH="${ROOT}/static-build"
-VENDORED_PATH="${ROOT}/vendor/libgit2"
-
-mkdir -p "${BUILD_PATH}/build" "${BUILD_PATH}/install/lib"
-
-cd "${BUILD_PATH}/build" &&
-cmake -DTHREADSAFE=ON \
- -DBUILD_CLAR=OFF \
- -DBUILD_SHARED_LIBS=OFF \
- -DREGEX_BACKEND=builtin \
- -DCMAKE_C_FLAGS=-fPIC \
- -DCMAKE_BUILD_TYPE="RelWithDebInfo" \
- -DCMAKE_INSTALL_PREFIX="${BUILD_PATH}/install" \
- "${VENDORED_PATH}" &&
-
-cmake --build . --target install
+exec "$(dirname "$0")/build-libgit2.sh" --static
diff --git a/script/build-libgit2.sh b/script/build-libgit2.sh
new file mode 100755
index 0000000..acbc84a
--- /dev/null
+++ b/script/build-libgit2.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Since CMake cannot build the static and dynamic libraries in the same
+# directory, this script helps build both static and dynamic versions of it and
+# have the common flags in one place instead of split between two places.
+
+set -e
+
+if [ "$#" -eq "0" ]; then
+ echo "Usage: $0 <--dynamic|--static>">&2
+ exit 1
+fi
+
+ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")"
+VENDORED_PATH="${ROOT}/vendor/libgit2"
+
+case "$1" in
+ --static)
+ BUILD_PATH="${ROOT}/static-build"
+ BUILD_SHARED_LIBS=OFF
+ ;;
+
+ --dynamic)
+ BUILD_PATH="${ROOT}/dynamic-build"
+ BUILD_SHARED_LIBS=ON
+ ;;
+
+ *)
+ echo "Usage: $0 <--dynamic|--static>">&2
+ exit 1
+ ;;
+esac
+
+mkdir -p "${BUILD_PATH}/build" "${BUILD_PATH}/install/lib"
+
+cd "${BUILD_PATH}/build" &&
+cmake -DTHREADSAFE=ON \
+ -DBUILD_CLAR=OFF \
+ -DBUILD_SHARED_LIBS"=${BUILD_SHARED_LIBS}" \
+ -DREGEX_BACKEND=builtin \
+ -DCMAKE_C_FLAGS=-fPIC \
+ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \
+ -DCMAKE_INSTALL_PREFIX="${BUILD_PATH}/install" \
+ "${VENDORED_PATH}" &&
+
+exec cmake --build . --target install