Skip to content

Commit 66aae86

Browse files
committed
Makefile: move NDK_ROOT below ANDROID_HOME detection
If ANDROID_HOME is being detected by the code that finds a valid home with an empty host environment, then NDK_ROOT should be able to use that, but it was out of order in the evaluation. Updates #cleanup Signed-off-by: James Tucker <james@tailscale.com>
1 parent e71641a commit 66aae86

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

Makefile

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,6 @@
1313
DOCKER_IMAGE := tailscale-android-build-amd64-041425-1
1414
export TS_USE_TOOLCHAIN=1
1515

16-
# Auto-select an NDK from ANDROID_HOME (choose highest version available)
17-
NDK_ROOT ?= $(shell ls -1d $(ANDROID_HOME)/ndk/* 2>/dev/null | sort -V | tail -n 1)
18-
19-
HOST_OS := $(shell uname | tr A-Z a-z)
20-
ifeq ($(HOST_OS),linux)
21-
STRIP_TOOL := $(NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
22-
else ifeq ($(HOST_OS),darwin)
23-
STRIP_TOOL := $(NDK_ROOT)/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy
24-
endif
25-
26-
$(info Using NDK_ROOT: $(NDK_ROOT))
27-
$(info Using STRIP_TOOL: $(STRIP_TOOL))
28-
2916
DEBUG_APK := tailscale-debug.apk
3017
RELEASE_AAB := tailscale-release.aab
3118
RELEASE_TV_AAB := tailscale-tv-release.aab
@@ -64,6 +51,21 @@ ifeq ($(ANDROID_SDK_ROOT),)
6451
endif
6552
export ANDROID_HOME ?= $(ANDROID_SDK_ROOT)
6653

54+
# Auto-select an NDK from ANDROID_HOME (choose highest version available)
55+
NDK_ROOT ?= $(shell ls -1d $(ANDROID_HOME)/ndk/* 2>/dev/null | sort -V | tail -n 1)
56+
57+
HOST_OS := $(shell uname | tr A-Z a-z)
58+
ifeq ($(HOST_OS),linux)
59+
STRIP_TOOL := $(NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
60+
else ifeq ($(HOST_OS),darwin)
61+
STRIP_TOOL := $(NDK_ROOT)/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy
62+
endif
63+
64+
$(info Using ANDROID_HOME: $(ANDROID_HOME))
65+
$(info Using NDK_ROOT: $(NDK_ROOT))
66+
$(info Using STRIP_TOOL: $(STRIP_TOOL))
67+
68+
6769
# Attempt to find Android Studio for Linux configuration, which does not have a
6870
# predetermined location.
6971
ANDROID_STUDIO_ROOT ?= $(shell find ~/android-studio /usr/local/android-studio /opt/android-studio /Applications/Android\ Studio.app $(PROGRAMFILES)/Android/Android\ Studio -type d -maxdepth 1 2>/dev/null | head -n 1)
@@ -312,7 +314,7 @@ checkandroidsdk: ## Check that Android SDK is installed
312314
test: gradle-dependencies ## Run the Android tests
313315
(cd android && ./gradlew test)
314316

315-
.PHONY: emulator
317+
.PHONY: emulator
316318
emulator: ## Start an android emulator instance
317319
@echo "Checking installed SDK packages..."
318320
@if ! $(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager --list_installed | grep -q "$(AVD_IMAGE)"; then \
@@ -327,15 +329,15 @@ emulator: ## Start an android emulator instance
327329
@echo "Starting emulator..."
328330
@$(ANDROID_HOME)/emulator/emulator -avd "$(AVD)" -logcat-output /dev/stdout -netdelay none -netspeed full
329331

330-
.PHONY: install
332+
.PHONY: install
331333
install: $(DEBUG_APK) ## Install the debug APK on a connected device
332334
adb install -r $<
333335

334336
.PHONY: run
335337
run: install ## Run the debug APK on a connected device
336338
adb shell am start -n com.tailscale.ipn/com.tailscale.ipn.MainActivity
337339

338-
.PHONY: docker-build-image
340+
.PHONY: docker-build-image
339341
docker-build-image: ## Builds the docker image for the android build environment if it does not exist
340342
@echo "Checking if docker image $(DOCKER_IMAGE) already exists..."
341343
@if ! docker images $(DOCKER_IMAGE) -q | grep -q . ; then \

0 commit comments

Comments
 (0)