This repository was archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
65 lines (54 loc) · 1.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
TAG ?= latest
PLATFORMS ?= linux/amd64,linux/arm/v7,linux/arm64
BUILD_ARGS ?=
REPOSITORY_ROOT := $(shell git rev-parse --show-toplevel)
TARGET_DIR ?= $(REPOSITORY_ROOT)/build/libgit2
BUILD_ROOT_DIR ?= $(REPOSITORY_ROOT)/build/libgit2-src
LIBGIT2_PATH := $(TARGET_DIR)
LIBGIT2_LIB_PATH := $(LIBGIT2_PATH)/lib
LIBGIT2_LIB64_PATH := $(LIBGIT2_PATH)/lib64
LIBGIT2 := $(LIBGIT2_LIB_PATH)/libgit2.a
MUSL-CC =
IMG ?= ghcr.io/fluxcd/golang-with-libgit2-only
DOCKERFILE ?= Dockerfile.libgit2-only
TEST_DOCKERFILE ?= Dockerfile.test-libgit2-only
export CGO_ENABLED=1
export LIBRARY_PATH=$(LIBGIT2_LIB_PATH)
export PKG_CONFIG_PATH=$(LIBGIT2_LIB_PATH)/pkgconfig
export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libgit2)
export CGO_CFLAGS=-I$(LIBGIT2_PATH)/include
GO_STATIC_FLAGS=-tags 'netgo,osusergo,static_build'
.PHONY: build
build:
docker buildx build \
--platform=$(PLATFORMS) \
--tag $(IMG):$(TAG) \
--file $(DOCKERFILE) \
$(BUILD_ARGS) .
.PHONY: test
test:
docker buildx build \
--platform=$(PLATFORMS) \
--tag $(IMG):$(TAG)-test \
--file $(TEST_DOCKERFILE) \
$(BUILD_ARGS) .
.PHONY: builder
builder:
# create local builder
docker buildx create --name local-builder \
--platform $(PLATFORMS) \
--driver-opt network=host \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=1073741274 \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=5000000000000 \
--buildkitd-flags '--allow-insecure-entitlement security.insecure' \
--use
# install qemu emulators
docker run -it --rm --privileged tonistiigi/binfmt --install all
$(LIBGIT2):
TARGET_DIR=$(TARGET_DIR) BUILD_ROOT_DIR=$(BUILD_ROOT_DIR) \
./hack/static.sh build_libgit2_only
# dev-test is a smoke test for development environment
# consuming the libraries generated by this project.
dev-test: $(LIBGIT2)
cd tests/smoketest; go vet $(GO_STATIC_FLAGS) ./...
cd tests/smoketest; go run $(GO_STATIC_FLAGS) main.go