Skip to content

Commit d9c4085

Browse files
Alon Blayer-GatSgrA*
authored andcommitted
chore: improve build
1 parent 2fec12a commit d9c4085

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

MOBILECONFIG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Here's an example .mobileconfig with the above fields filled in:
3737
<key>PayloadVersion</key>
3838
<integer>1</integer>
3939
<key>PayloadIdentifier</key>
40-
<string>com.your-org.wireguard.FCC9BF80-C540-44C1-B243-521FDD1B2905</string>
40+
<string>com.safehousetech.wireguard.FCC9BF80-C540-44C1-B243-521FDD1B2905</string>
4141
<key>PayloadUUID</key>
4242
<string>F346AAF4-53A2-4FA1-ACA3-EEE74DBED029</string>
4343
<key>PayloadContent</key>

Sources/WireGuardKitGo/Makefile

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: MIT
22
#
3-
# Copyright (C) 2018-2019 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
3+
# Copyright (C) 2018-2020 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
44

55
# These are generally passed to us by xcode, but we set working defaults for standalone compilation too.
66
ARCHS ?= x86_64 arm64
@@ -21,40 +21,56 @@ GOARCH_x86_64 := amd64
2121
GOOS_macosx := darwin
2222
GOOS_iphoneos := ios
2323

24+
GO_VERSION := 1.17.13
25+
GO_PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]')-$(GOARCH_$(shell uname -m))
26+
GO_TARBALL := go$(GO_VERSION).$(GO_PLATFORM).tar.gz
27+
GO_HASH_darwin-amd64 := 0fea4e2498067dcf199c71be78bb940f7861efd8ae03c672992d2d65d31f9fc8
28+
GO_HASH_darwin-arm64 := e4ccc9c082d91eaa0b866078b591fc97d24b91495f12deb3dd2d8eda4e55a6ea
29+
2430
build: $(DESTDIR)/libwg-go.a
2531
version-header: $(DESTDIR)/wireguard-go-version.h
2632

27-
REAL_GOROOT := $(shell go env GOROOT 2>/dev/null)
28-
export GOROOT := $(BUILDDIR)/goroot
29-
$(GOROOT)/.prepared:
30-
[ -n "$(REAL_GOROOT)" ]
31-
mkdir -p "$(GOROOT)"
32-
rsync -a --delete --exclude=pkg/obj/go-build "$(REAL_GOROOT)/" "$(GOROOT)/"
33-
cat goruntime-*.diff | patch -p1 -f -N -r- -d "$(GOROOT)"
34-
touch "$@"
33+
$(BUILDDIR)/$(GO_TARBALL):
34+
mkdir -p "$(@D)"
35+
flock "$@.lock" -c ' \
36+
[ -f "$@" ] && exit 0; \
37+
curl -o "$@.tmp" "https://dl.google.com/go/$(GO_TARBALL)" && \
38+
echo "$(GO_HASH_$(GO_PLATFORM)) $@.tmp" | sha256sum -c && \
39+
mv "$@.tmp" "$@"'
40+
41+
$(BUILDDIR)/go-$(GO_VERSION)/.prepared: $(BUILDDIR)/$(GO_TARBALL)
42+
mkdir -p "$(@D)"
43+
flock "$@.lock" -c ' \
44+
[ -f "$@" ] && exit 0; \
45+
tar -C "$(@D)" --strip-components=1 -xzf "$^" && \
46+
patch -p1 -f -N -r- -d "$(@D)" < goruntime-boottime-over-monotonic.diff && \
47+
touch "$@"'
3548

3649
define libwg-go-a
3750
$(BUILDDIR)/libwg-go-$(1).a: export CGO_ENABLED := 1
3851
$(BUILDDIR)/libwg-go-$(1).a: export CGO_CFLAGS := $(CFLAGS_PREFIX) $(ARCH)
3952
$(BUILDDIR)/libwg-go-$(1).a: export CGO_LDFLAGS := $(CFLAGS_PREFIX) $(ARCH)
4053
$(BUILDDIR)/libwg-go-$(1).a: export GOOS := $(GOOS_$(PLATFORM_NAME))
4154
$(BUILDDIR)/libwg-go-$(1).a: export GOARCH := $(GOARCH_$(1))
42-
$(BUILDDIR)/libwg-go-$(1).a: $(GOROOT)/.prepared go.mod
55+
$(BUILDDIR)/libwg-go-$(1).a: $(BUILDDIR)/go-$(GO_VERSION)/.prepared go.mod
4356
go build -ldflags=-w -trimpath -v -o "$(BUILDDIR)/libwg-go-$(1).a" -buildmode c-archive
44-
rm -f "$(BUILDDIR)/libwg-go-$(1).h"
57+
$(RM) "$(BUILDDIR)/libwg-go-$(1).h"
4558
endef
4659
$(foreach ARCH,$(ARCHS),$(eval $(call libwg-go-a,$(ARCH))))
4760

48-
$(DESTDIR)/wireguard-go-version.h: go.mod $(GOROOT)/.prepared
61+
$(DESTDIR)/wireguard-go-version.h: $(BUILDDIR)/go-$(GO_VERSION)/.prepared go.mod
4962
sed -E -n 's/.*golang\.zx2c4\.com\/wireguard +v[0-9.]+-[0-9]+-([0-9a-f]{8})[0-9a-f]{4}.*/#define WIREGUARD_GO_VERSION "\1"/p' "$<" > "$@"
5063

64+
$(DESTDIR)/llibwg-go.a: export PATH := $(BUILDDIR)/go-$(GO_VERSION)/bin/:$(PATH)
5165
$(DESTDIR)/libwg-go.a: $(foreach ARCH,$(ARCHS),$(BUILDDIR)/libwg-go-$(ARCH).a)
5266
@mkdir -vp "$(DESTDIR)"
5367
$(LIPO) -create -output "$@" $^
5468

5569
clean:
56-
rm -rf "$(BUILDDIR)" "$(DESTDIR)/libwg-go.a" "$(DESTDIR)/wireguard-go-version.h"
70+
$(RM) -r "$(BUILDDIR)" "$(DESTDIR)/libwg-go.a" "$(DESTDIR)/wireguard-go-version.h"
5771

5872
install: build
5973

60-
.PHONY: clean build version-header install
74+
.PHONY: clean build version-header install prepared gotarball
75+
76+
.DELETE_ON_ERROR:

0 commit comments

Comments
 (0)