@@ -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 : 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 : 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,13 @@ 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 $(wildcard .git/HEAD)
131+ $(shell ./tool/go run tailscale.com/cmd/mkversion > tailscale.version)
132+
133+ .PHONY : version
134+ version : tailscale.version # # print the current version information
135+ cat tailscale.version
136+
144137#
145138# Go Builds:
146139#
@@ -154,10 +147,10 @@ $(GOBIN)/gomobile: $(GOBIN)/gobind go.mod go.sum
154147$(GOBIN ) /gobind : go.mod go.sum
155148 ./tool/go install golang.org/x/mobile/cmd/gobind
156149
157- $(LIBTAILSCALE ) : Makefile android/libs $(shell find libtailscale -name * .go) go.mod go.sum $(GOBIN ) /gomobile
150+ $(LIBTAILSCALE ) : Makefile android/libs $(shell find libtailscale -name * .go) go.mod go.sum $(GOBIN ) /gomobile tailscale.version
158151 $(GOBIN ) /gomobile bind -target android -androidapi 26 \
159152 -tags " $$ (./build-tags.sh)" \
160- -ldflags " $( FULL_LDFLAGS ) " \
153+ -ldflags " -w $$ (./version-ldflags.sh )" \
161154 -o $@ ./libtailscale
162155
163156.PHONY : libtailscale
@@ -202,29 +195,25 @@ androidpath:
202195 @echo ' export PATH=$(ANDROID_HOME)/cmdline-tools/latest/bin:$(ANDROID_HOME)/platform-tools:$$PATH'
203196
204197.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} "
198+ tag_release : tailscale.version # # Tag the current commit with the current version
199+ source tailscale.version && git tag -a " $$ { VERSION_LONG} " -m " OSS and Version updated to $ $ {VERSION_LONG}"
207200
208201
209202.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} "
203+ bumposs : update-oss tailscale. version
204+ 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
205+ source tailscale.version && git tag -a " $$ { VERSION_LONG} " -m " OSS and Version updated to $ $ {VERSION_LONG}"
213206
214207.PHONY : bump_version_code
215208bump_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
209+ 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
221210
222211.PHONY : update-oss
223- update-oss : # # Update the tailscale.com go module and update the version in build.gradle
212+ update-oss : # # Update the tailscale.com go module
224213 GOPROXY=direct ./tool/go get tailscale.com@main
214+ ./tool/go mod tidy -compat=1.23
225215 ./tool/go run tailscale.com/cmd/printdep --go > go.toolchain.rev.new
226216 mv go.toolchain.rev.new go.toolchain.rev
227- ./tool/go mod tidy -compat=1.23
228217
229218# Get the commandline tools package, this provides (among other things) the sdkmanager binary.
230219$(ANDROID_HOME ) /cmdline-tools/latest/bin/sdkmanager :
@@ -310,13 +299,13 @@ docker-remove-shell-image: ## Removes all docker shell image
310299 docker rmi --force tailscale-android-shell-amd64
311300
312301.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.
302+ clean : clean-tailscale.version # # Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that.
315303 @echo " Cleaning up old build artifacts"
316304 -rm -rf android/build $(DEBUG_APK ) $(RELEASE_AAB ) $(RELEASE_TV_AAB ) $(LIBTAILSCALE ) android/libs * .apk * .aab
317305 @echo " Cleaning cached toolchain"
318306 -rm -rf $(HOME ) /.cache/tailscale-go{,.extracted}
319307 -pkill -f gradle
308+ -rm tailscale.version
320309
321310.PHONY : help
322311help : # # Show this help
0 commit comments