From bb0494637fb1225487f53c91545ef514d02b6db7 Mon Sep 17 00:00:00 2001 From: Denton Gentry Date: Sun, 25 Jul 2021 20:52:20 -0700 Subject: [PATCH 1/2] Makefile: download Tailscale's Go toolchain Tailscale maintains a patched Go toolchain, pulling in fixes early. Download the toolchain and use it to build. Fixes https://github.com/tailscale/tailscale/issues/2450 in a better way. Signed-off-by: Denton Gentry --- Makefile | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7cc6b45..5ee903f 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,13 @@ TAILSCALE_COMMIT=$(shell echo $(TAILSCALE_VERSION) | cut -d - -f 2 | cut -d t -f VERSIONCODE=$(lastword $(shell grep versionCode android/build.gradle)) VERSIONCODE_PLUSONE=$(shell expr $(VERSIONCODE) + 1) +# When you update TOOLCHAINREV, also update TOOLCHAINWANT +TOOLCHAINREV=6fa85e8201f1f75fb7323eb48a0b24274a6e33b2 +TOOLCHAINDIR=${HOME}/.cache/tailscale-android-go-$(TOOLCHAINREV) +TOOLCHAINSUM=$(shell find $(TOOLCHAINDIR) -type f -print0 | sort -z | xargs -0 sha1sum | sha1sum | cut -d" " -f1) +TOOLCHAINWANT=e336267ea2a637426c0302945d0c1f8fa2f2f627 +export PATH := $(TOOLCHAINDIR)/go/bin:$(PATH) + all: $(APK) tag_release: @@ -30,13 +37,26 @@ tag_release: git commit -sm "android: bump version code" android/build.gradle git tag -a "$(VERSION_LONG)" -$(DEBUG_APK): +toolchain: +ifneq ($(TOOLCHAINWANT),$(TOOLCHAINSUM)) + @echo want: $(TOOLCHAINWANT) + @echo got: $(TOOLCHAINSUM) + rm -rf ${HOME}/.cache/tailscale-android-go-* + $(eval tmpfile=$(shell mktemp --suffix=.tgz)) + wget https://github.com/tailscale/go/releases/download/build-$(TOOLCHAINREV)/linux.tar.gz -O "$(tmpfile)" + mkdir -p $(TOOLCHAINDIR) + tar xzf $(tmpfile) -C $(TOOLCHAINDIR) + rm $(tmpfile) +endif + +$(DEBUG_APK): toolchain mkdir -p android/libs go run gioui.org/cmd/gogio -buildmode archive -target android -appid $(APPID) -o $(AAR) github.com/tailscale/tailscale-android/cmd/tailscale (cd android && ./gradlew assemblePlayDebug) mv android/build/outputs/apk/play/debug/android-play-debug.apk $@ # This target is also used by the F-Droid builder. +release_aar: toolchain release_aar: mkdir -p android/libs go run gioui.org/cmd/gogio -ldflags "-X tailscale.com/version.Long=$(VERSIONNAME) -X tailscale.com/version.Short=$(VERSIONNAME_SHORT) -X tailscale.com/version.GitCommit=$(TAILSCALE_COMMIT) -X tailscale.com/version.ExtraGitCommit=$(OUR_VERSION)" -tags xversion -buildmode archive -target android -appid $(APPID) -o $(AAR) github.com/tailscale/tailscale-android/cmd/tailscale From 078eee6b3900ba485bdf6fc8230f1186df469b93 Mon Sep 17 00:00:00 2001 From: Denton Gentry Date: Tue, 27 Jul 2021 15:37:14 -0700 Subject: [PATCH 2/2] Dockerfile: use Go 1.16.5 Going to use the Tailscale fork of the Go toolchain instead. --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d33767e..1c104ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,9 +32,9 @@ RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager 'build-tools;28.0.3' # Get Go stable release WORKDIR $HOME -ARG GO_VERSION=1.17rc1 +ARG GO_VERSION=1.16.5 RUN curl -O https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz -RUN echo "bfbd3881a01ca3826777b1c40f241acacd45b14730d373259cd673d74e15e534 go${GO_VERSION}.linux-amd64.tar.gz" | sha256sum -c +RUN echo "b12c23023b68de22f74c0524f10b753e7b08b1504cb7e417eccebdd3fae49061 go${GO_VERSION}.linux-amd64.tar.gz" | sha256sum -c RUN tar -xzf go${GO_VERSION}.linux-amd64.tar.gz && mv go goroot ENV GOROOT $HOME/goroot ENV PATH $PATH:$GOROOT/bin:$HOME/bin:$ANDROID_HOME/platform-tools