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>
pull/684/head
James Tucker 4 months ago committed by James Tucker
parent e71641a422
commit 66aae86d40

@ -13,19 +13,6 @@
DOCKER_IMAGE := tailscale-android-build-amd64-041425-1 DOCKER_IMAGE := tailscale-android-build-amd64-041425-1
export TS_USE_TOOLCHAIN=1 export TS_USE_TOOLCHAIN=1
# Auto-select an NDK from ANDROID_HOME (choose highest version available)
NDK_ROOT ?= $(shell ls -1d $(ANDROID_HOME)/ndk/* 2>/dev/null | sort -V | tail -n 1)
HOST_OS := $(shell uname | tr A-Z a-z)
ifeq ($(HOST_OS),linux)
STRIP_TOOL := $(NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
else ifeq ($(HOST_OS),darwin)
STRIP_TOOL := $(NDK_ROOT)/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy
endif
$(info Using NDK_ROOT: $(NDK_ROOT))
$(info Using STRIP_TOOL: $(STRIP_TOOL))
DEBUG_APK := tailscale-debug.apk DEBUG_APK := tailscale-debug.apk
RELEASE_AAB := tailscale-release.aab RELEASE_AAB := tailscale-release.aab
RELEASE_TV_AAB := tailscale-tv-release.aab RELEASE_TV_AAB := tailscale-tv-release.aab
@ -64,6 +51,21 @@ ifeq ($(ANDROID_SDK_ROOT),)
endif endif
export ANDROID_HOME ?= $(ANDROID_SDK_ROOT) export ANDROID_HOME ?= $(ANDROID_SDK_ROOT)
# Auto-select an NDK from ANDROID_HOME (choose highest version available)
NDK_ROOT ?= $(shell ls -1d $(ANDROID_HOME)/ndk/* 2>/dev/null | sort -V | tail -n 1)
HOST_OS := $(shell uname | tr A-Z a-z)
ifeq ($(HOST_OS),linux)
STRIP_TOOL := $(NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
else ifeq ($(HOST_OS),darwin)
STRIP_TOOL := $(NDK_ROOT)/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy
endif
$(info Using ANDROID_HOME: $(ANDROID_HOME))
$(info Using NDK_ROOT: $(NDK_ROOT))
$(info Using STRIP_TOOL: $(STRIP_TOOL))
# Attempt to find Android Studio for Linux configuration, which does not have a # Attempt to find Android Studio for Linux configuration, which does not have a
# predetermined location. # predetermined location.
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) 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
test: gradle-dependencies ## Run the Android tests test: gradle-dependencies ## Run the Android tests
(cd android && ./gradlew test) (cd android && ./gradlew test)
.PHONY: emulator .PHONY: emulator
emulator: ## Start an android emulator instance emulator: ## Start an android emulator instance
@echo "Checking installed SDK packages..." @echo "Checking installed SDK packages..."
@if ! $(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager --list_installed | grep -q "$(AVD_IMAGE)"; then \ @if ! $(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager --list_installed | grep -q "$(AVD_IMAGE)"; then \
@ -327,7 +329,7 @@ emulator: ## Start an android emulator instance
@echo "Starting emulator..." @echo "Starting emulator..."
@$(ANDROID_HOME)/emulator/emulator -avd "$(AVD)" -logcat-output /dev/stdout -netdelay none -netspeed full @$(ANDROID_HOME)/emulator/emulator -avd "$(AVD)" -logcat-output /dev/stdout -netdelay none -netspeed full
.PHONY: install .PHONY: install
install: $(DEBUG_APK) ## Install the debug APK on a connected device install: $(DEBUG_APK) ## Install the debug APK on a connected device
adb install -r $< adb install -r $<
@ -335,7 +337,7 @@ install: $(DEBUG_APK) ## Install the debug APK on a connected device
run: install ## Run the debug APK on a connected device run: install ## Run the debug APK on a connected device
adb shell am start -n com.tailscale.ipn/com.tailscale.ipn.MainActivity adb shell am start -n com.tailscale.ipn/com.tailscale.ipn.MainActivity
.PHONY: docker-build-image .PHONY: docker-build-image
docker-build-image: ## Builds the docker image for the android build environment if it does not exist docker-build-image: ## Builds the docker image for the android build environment if it does not exist
@echo "Checking if docker image $(DOCKER_IMAGE) already exists..." @echo "Checking if docker image $(DOCKER_IMAGE) already exists..."
@if ! docker images $(DOCKER_IMAGE) -q | grep -q . ; then \ @if ! docker images $(DOCKER_IMAGE) -q | grep -q . ; then \

Loading…
Cancel
Save