@@ -17,21 +17,7 @@ DEBUG_APK=tailscale-debug.apk
1717RELEASE_AAB =tailscale-release.aab
1818RELEASE_TV_AAB =tailscale-tv-release.aab
1919LIBTAILSCALE =android/libs/libtailscale.aar
20- TAILSCALE_VERSION =$(shell ./version/tailscale-version.sh 200)
21- OUR_VERSION =$(shell git describe --dirty --exclude "* " --always --abbrev=200)
22- TAILSCALE_VERSION_ABBREV =$(shell ./version/tailscale-version.sh 11)
23- OUR_VERSION_ABBREV =$(shell git describe --exclude "* " --always --abbrev=11)
24- VERSION_LONG =$(TAILSCALE_VERSION_ABBREV ) -g$(OUR_VERSION_ABBREV )
25- # Extract the long version build.gradle's versionName and strip quotes.
26- VERSIONNAME =$(patsubst "% ",% ,$(lastword $(shell grep versionName android/build.gradle) ) )
27- # Extract the x.y.z part for the short version.
28- VERSIONNAME_SHORT =$(shell echo $(VERSIONNAME ) | cut -d - -f 1)
29- TAILSCALE_COMMIT =$(shell echo $(TAILSCALE_VERSION ) | cut -d - -f 2 | cut -d t -f 2)
3020# Extract the version code from build.gradle.
31- VERSIONCODE =$(lastword $(shell grep versionCode android/build.gradle) )
32- VERSIONCODE_PLUSONE =$(shell expr $(VERSIONCODE ) + 1)
33- VERSION_LDFLAGS =-X tailscale.com/version.longStamp=$(VERSIONNAME ) -X tailscale.com/version.shortStamp=$(VERSIONNAME_SHORT ) -X tailscale.com/version.gitCommitStamp=$(TAILSCALE_COMMIT ) -X tailscale.com/version.extraGitCommitStamp=$(OUR_VERSION )
34- FULL_LDFLAGS =$(VERSION_LDFLAGS ) -w
3521ifeq ($(shell uname) ,Linux)
3622 ANDROID_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip"
3723 ANDROID_TOOLS_SUM="bd1aa17c7ef10066949c88dc6c9c8d536be27f992a1f3b5a584f9bd2ba5646a0 commandlinetools-linux-9477386_latest.zip"
@@ -111,17 +97,17 @@ tailscale-debug: $(DEBUG_APK) ## Build the debug APK
11197
11298# Builds the release AAB and signs it (phone/tablet/chromeOS variant)
11399.PHONY : release
114- release : update- version jarsign-env $(RELEASE_AAB ) # # Build the release AAB
100+ release : clean-tailscale. version jarsign-env $(RELEASE_AAB ) # # Build the release AAB
115101 @jarsigner -sigalg SHA256withRSA -digestalg SHA-256 -keystore $(JKS_PATH ) -storepass $(JKS_PASSWORD ) $(RELEASE_AAB ) tailscale
116102
117103# Builds the release AAB and signs it (androidTV variant)
118104.PHONY : release-tv
119- release-tv : update- version jarsign-env $(RELEASE_TV_AAB ) # # Build the release AAB
105+ release-tv : clean-tailscale. version jarsign-env $(RELEASE_TV_AAB ) # # Build the release AAB
120106 @jarsigner -sigalg SHA256withRSA -digestalg SHA-256 -keystore $(JKS_PATH ) -storepass $(JKS_PASSWORD ) $(RELEASE_TV_AAB ) tailscale
121107
122108# gradle-dependencies groups together the android sources and libtailscale needed to assemble tests/debug/release builds.
123109.PHONY : gradle-dependencies
124- gradle-dependencies : $(shell find android -type f -not -path "android/build/* " -not -path '* /.* ') $(LIBTAILSCALE )
110+ gradle-dependencies : $(shell find android -type f -not -path "android/build/* " -not -path '* /.* ') $(LIBTAILSCALE ) tailscale.version
125111
126112$(DEBUG_APK ) : gradle-dependencies
127113 (cd android && ./gradlew test assembleDebug)
@@ -141,6 +127,12 @@ tailscale-test.apk: gradle-dependencies
141127 (cd android && ./gradlew assembleApplicationTestAndroidTest)
142128 install -C ./android/build/outputs/apk/androidTest/applicationTest/android-applicationTest-androidTest.apk $@
143129
130+ tailscale.version : go.mod go.sum .git/HEAD
131+ $(shell ./tool/go run tailscale.com/cmd/mkversion > tailscale.version)
132+
133+ version : tailscale.version # # print the current version information
134+ cat tailscale.version
135+
144136#
145137# Go Builds:
146138#
@@ -154,10 +146,10 @@ $(GOBIN)/gomobile: $(GOBIN)/gobind go.mod go.sum
154146$(GOBIN ) /gobind : go.mod go.sum
155147 ./tool/go install golang.org/x/mobile/cmd/gobind
156148
157- $(LIBTAILSCALE ) : Makefile android/libs $(shell find libtailscale -name * .go) go.mod go.sum $(GOBIN ) /gomobile
149+ $(LIBTAILSCALE ) : Makefile android/libs $(shell find libtailscale -name * .go) go.mod go.sum $(GOBIN ) /gomobile tailscale.version
158150 $(GOBIN ) /gomobile bind -target android -androidapi 26 \
159151 -tags " $$ (./build-tags.sh)" \
160- -ldflags " $( FULL_LDFLAGS ) " \
152+ -ldflags " -w $$ (./version-ldflags.sh )" \
161153 -o $@ ./libtailscale
162154
163155.PHONY : libtailscale
@@ -202,29 +194,25 @@ androidpath:
202194 @echo ' export PATH=$(ANDROID_HOME)/cmdline-tools/latest/bin:$(ANDROID_HOME)/platform-tools:$$PATH'
203195
204196.PHONY : tag_release
205- tag_release : # # Tag the current commit with the current version
206- git tag -a " $( VERSION_LONG) " -m " OSS and Version updated to ${VERSION_LONG} "
197+ tag_release : tailscale.version # # Tag the current commit with the current version
198+ source tailscale.version && git tag -a " $$ { VERSION_LONG} " -m " OSS and Version updated to $ $ {VERSION_LONG}"
207199
208200
209201.PHONY : bumposs # # Bump to the latest oss and update the versions.
210- bumposs : update-oss update- version
211- git commit -sm " android: bump OSS" -m " OSS and Version updated to ${VERSION_LONG} " go.toolchain.rev android/build.gradle go.mod go.sum
212- git tag -a " $( VERSION_LONG) " -m " OSS and Version updated to ${VERSION_LONG} "
202+ bumposs : update-oss tailscale. version
203+ source tailscale.version && git commit -sm " android: bump OSS" -m " OSS and Version updated to $ $ {VERSION_LONG}" go.toolchain.rev android/build.gradle go.mod go.sum
204+ source tailscale.version && git tag -a " $$ { VERSION_LONG} " -m " OSS and Version updated to $ $ {VERSION_LONG}"
213205
214206.PHONY : bump_version_code
215207bump_version_code : # # Bump the version code in build.gradle
216- sed -i' .bak' ' s/versionCode .*/versionCode $(VERSIONCODE_PLUSONE)/' android/build.gradle && rm android/build.gradle.bak
217-
218- .PHONY : update-version
219- update-version : # # Update the version in build.gradle
220- sed -i' .bak' ' s/versionName .*/versionName "$(VERSION_LONG)"/' android/build.gradle && rm android/build.gradle.bak
208+ sed -i' .bak' " s/versionCode .*/versionCode $$ (expr $$ (awk '/versionCode ([0-9]+)/{print $$ 2}' android/build.gradle) + 1)/" android/build.gradle && rm android/build.gradle.bak
221209
222210.PHONY : update-oss
223- update-oss : # # Update the tailscale.com go module and update the version in build.gradle
211+ update-oss : # # Update the tailscale.com go module
224212 GOPROXY=direct ./tool/go get tailscale.com@main
213+ ./tool/go mod tidy -compat=1.23
225214 ./tool/go run tailscale.com/cmd/printdep --go > go.toolchain.rev.new
226215 mv go.toolchain.rev.new go.toolchain.rev
227- ./tool/go mod tidy -compat=1.23
228216
229217# Get the commandline tools package, this provides (among other things) the sdkmanager binary.
230218$(ANDROID_HOME ) /cmdline-tools/latest/bin/sdkmanager :
@@ -309,9 +297,12 @@ docker-shell: ## Builds a docker image with the android build env and opens a sh
309297docker-remove-shell-image : # # Removes all docker shell image
310298 docker rmi --force tailscale-android-shell-amd64
311299
300+ .PHONY : clean-taislcale.version
301+ clean-tailscale.version : # # Remove the tailscale.version file
302+ rm tailscale.version
303+
312304.PHONY : clean
313- clean : # # Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that.
314- clean : # # Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that.
305+ clean : clean-tailscale.version # # Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that.
315306 @echo " Cleaning up old build artifacts"
316307 -rm -rf android/build $(DEBUG_APK ) $(RELEASE_AAB ) $(RELEASE_TV_AAB ) $(LIBTAILSCALE ) android/libs * .apk * .aab
317308 @echo " Cleaning cached toolchain"
0 commit comments