2023-10-16 21:14:54 +03:30
|
|
|
PRODUCT_NAME=libcore
|
|
|
|
|
BASENAME=hiddify-$(PRODUCT_NAME)
|
2023-08-16 15:16:02 +03:30
|
|
|
BINDIR=bin
|
|
|
|
|
|
2023-09-11 15:20:19 +03:30
|
|
|
BRANCH=$(shell git branch --show-current)
|
|
|
|
|
VERSION=$(shell git describe --tags || echo "unknown version")
|
2023-09-11 21:09:34 +03:30
|
|
|
NAME=$(BASENAME)-$@
|
2023-09-11 15:20:19 +03:30
|
|
|
|
2023-10-27 17:44:18 +03:30
|
|
|
TAGS=with_gvisor,with_quic,with_wireguard,with_ech,with_utls,with_clash_api,with_grpc
|
2023-09-11 21:09:34 +03:30
|
|
|
IOS_TAGS=with_dhcp,with_low_memory,with_conntrack
|
2023-08-16 15:16:02 +03:30
|
|
|
GOBUILD=CGO_ENABLED=1 go build -trimpath -tags $(TAGS) -ldflags="-w -s" -buildmode=c-shared
|
|
|
|
|
|
|
|
|
|
lib_install:
|
2023-12-21 11:10:14 +03:30
|
|
|
go install -v github.com/sagernet/gomobile/cmd/gomobile@v0.1.1
|
|
|
|
|
go install -v github.com/sagernet/gomobile/cmd/gobind@v0.1.1
|
2023-08-16 15:16:02 +03:30
|
|
|
|
2023-08-19 14:10:13 +03:30
|
|
|
headers:
|
2023-09-11 15:20:19 +03:30
|
|
|
go build -buildmode=c-archive -o $(BINDIR)/$(NAME).h ./custom
|
2023-08-19 14:10:13 +03:30
|
|
|
|
2023-08-22 20:06:38 +00:00
|
|
|
android: lib_install
|
2023-10-17 19:49:21 +03:30
|
|
|
gomobile bind -v -androidapi=21 -javapkg=io.nekohasekai -libname=box -tags=$(TAGS) -trimpath -target=android -o $(BINDIR)/$(NAME).aar github.com/sagernet/sing-box/experimental/libbox ./mobile
|
2023-08-16 15:16:02 +03:30
|
|
|
|
2023-08-22 20:06:38 +00:00
|
|
|
ios-full: lib_install
|
2024-01-03 16:23:11 +00:00
|
|
|
gomobile bind -v -target ios,iossimulator,tvos,tvossimulator,macos -libname=box -tags=$(TAGS),with_dhcp,with_low_memory,with_conntrack -trimpath -ldflags="-w -s" -o $(BINDIR)/$(PRODUCT_NAME).xcframework github.com/sagernet/sing-box/experimental/libbox ./mobile &&\
|
|
|
|
|
mv $(BINDIR)/$(PRODUCT_NAME).xcframework $(BINDIR)/$(NAME).xcframework &&\
|
|
|
|
|
cp Libcore.podspec $(BINDIR)/$(NAME).xcframework/
|
|
|
|
|
|
2023-08-22 20:06:38 +00:00
|
|
|
ios: lib_install
|
2023-10-24 06:47:32 +00:00
|
|
|
gomobile bind -v -target ios -libname=box -tags=$(TAGS),with_dhcp,with_low_memory,with_conntrack -trimpath -ldflags="-w -s" -o $(BINDIR)/$(PRODUCT_NAME).xcframework github.com/sagernet/sing-box/experimental/libbox ./mobile &&\
|
2024-01-03 16:23:11 +00:00
|
|
|
mv $(BINDIR)/$(PRODUCT_NAME).xcframework $(BINDIR)/$(NAME).xcframework &&\
|
|
|
|
|
cp Libcore.podspec $(BINDIR)/$(NAME).xcframework/
|
2023-10-24 06:47:32 +00:00
|
|
|
|
2023-08-20 12:39:55 +00:00
|
|
|
|
2023-08-16 15:16:02 +03:30
|
|
|
windows-amd64:
|
2023-09-11 15:20:19 +03:30
|
|
|
env GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc $(GOBUILD) -o $(BINDIR)/$(NAME).dll ./custom
|
2023-08-16 15:16:02 +03:30
|
|
|
|
2023-08-19 14:10:13 +03:30
|
|
|
linux-amd64:
|
2023-09-11 15:20:19 +03:30
|
|
|
env GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINDIR)/$(NAME).so ./custom
|
2023-08-19 14:10:13 +03:30
|
|
|
|
2023-08-20 08:21:08 +00:00
|
|
|
macos-amd64:
|
2023-09-11 21:09:34 +03:30
|
|
|
env GOOS=darwin GOARCH=amd64 CGO_CFLAGS="-mmacosx-version-min=10.11" CGO_LDFLAGS="-mmacosx-version-min=10.11" CGO_ENABLED=1 go build -trimpath -tags $(TAGS),$(IOS_TAGS) -buildmode=c-shared -o $(BINDIR)/$(NAME).dylib ./custom
|
2023-08-20 08:21:08 +00:00
|
|
|
macos-arm64:
|
2023-09-11 21:09:34 +03:30
|
|
|
env GOOS=darwin GOARCH=arm64 CGO_CFLAGS="-mmacosx-version-min=10.11" CGO_LDFLAGS="-mmacosx-version-min=10.11" CGO_ENABLED=1 go build -trimpath -tags $(TAGS),$(IOS_TAGS) -buildmode=c-shared -o $(BINDIR)/$(NAME).dylib ./custom
|
2023-08-20 08:28:11 +00:00
|
|
|
macos-universal: macos-amd64 macos-arm64
|
2023-09-11 21:09:34 +03:30
|
|
|
lipo -create $(BINDIR)/$(BASENAME)-macos-amd64.dylib $(BINDIR)/$(BASENAME)-macos-arm64.dylib -output $(BINDIR)/$(NAME).dylib
|
2023-08-20 08:21:08 +00:00
|
|
|
|
2023-08-16 15:16:02 +03:30
|
|
|
clean:
|
2023-10-16 21:14:54 +03:30
|
|
|
rm $(BINDIR)/*
|
2024-01-03 16:23:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
release: # Create a new tag for release.
|
|
|
|
|
@echo "previous version was $$(git describe --tags $$(git rev-list --tags --max-count=1))"
|
|
|
|
|
@echo "WARNING: This operation will creates version tag and push to github"
|
|
|
|
|
@bash -c '\
|
|
|
|
|
read -p "Version? (provide the next x.y.z semver) : " TAG && \
|
|
|
|
|
echo $$TAG &&\
|
|
|
|
|
[[ "$$TAG" =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(\.dev)?$$ ]] || { echo "Incorrect tag. e.g., 1.2.3 or 1.2.3.dev"; exit 1; } && \
|
|
|
|
|
IFS="." read -r -a VERSION_ARRAY <<< "$$TAG" && \
|
|
|
|
|
VERSION_STR="$${VERSION_ARRAY[0]}.$${VERSION_ARRAY[1]}.$${VERSION_ARRAY[2]}" && \
|
|
|
|
|
BUILD_NUMBER=$$(( $${VERSION_ARRAY[0]} * 10000 + $${VERSION_ARRAY[1]} * 100 + $${VERSION_ARRAY[2]} )) && \
|
|
|
|
|
echo "version: $${VERSION_STR}+$${BUILD_NUMBER}" && \
|
|
|
|
|
sed -i "s/^s.version: .*/s.version = '$${VERSION_STR}'/g" Libcore.podspec && \
|
|
|
|
|
git tag $${TAG} > /dev/null && \
|
|
|
|
|
git tag -d $${TAG} > /dev/null && \
|
|
|
|
|
git add Libcore.podspec && \
|
|
|
|
|
git commit -m "release: version $${TAG}" && \
|
|
|
|
|
echo "creating git tag : v$${TAG}" && \
|
|
|
|
|
git tag v$${TAG} && \
|
|
|
|
|
git push -u origin HEAD --tags && \
|
|
|
|
|
echo "Github Actions will detect the new tag and release the new version."'
|