Files
d2r-mobile/dm/host/Makefile.android
T
shenleiandClaude Opus 5.5 4d91f80bae Android port (Adreno): Vulkan backend, GameActivity app, touch HUD, lifecycle, minimap quest goals
- host/android: Vulkan replay backend (nvn_vk.c) with pipeline/descriptor caching, ADPF,
  AChoreographer present link; Linux compat layer; Makefile.android (headless dmhost + APK lib)
- android/app: GameActivity shell without Gradle (build_apk.sh), AAudio output, touch HUD port
  (touch_app.c + TouchOverlay.java, three layers: body / joystick / minimap goals),
  lifecycle save-on-background like iOS, art_from_ipa.py for touch / HUD / mapgoal art
- touch: shared touch controls moved from ios/Sources to dm/touch
- patch_nso.py Android ruleset, dmsh_vk.py shader pack, DM_TOUCH_PRODUCT defaults
- hle_audio: AAudio resume waits through STARTING and reopens once on failure
- .gitignore: local resources/ (original game data) never committed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 14:55:05 +09:00

65 lines
4.4 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Android(arm64,仅 Adreno 机型)无头宿主:adb shell 直接跑,用来先把引导链跑通;图形 / 音频 / 前端后续接入
# Android (arm64, Adreno devices only) headless host: run directly from adb shell to get the boot chain working first; graphics / audio / front end come later
NDK ?= $(or $(ANDROID_NDK_HOME),$(lastword $(sort $(wildcard $(HOME)/Library/Android/sdk/ndk/*))))
API ?= 33
CC := $(wildcard $(NDK)/toolchains/llvm/prebuilt/*/bin)/aarch64-linux-android$(API)-clang
OUT ?= build-android
# 表头:没有游戏文件时可用 DM_GENH_DIR 指向现成的表头目录 | generated headers: without game files, DM_GENH_DIR can point at a directory of ready-made headers
GENH_DIR ?= $(or $(DM_GENH_DIR),.)
# -ffixed-x18:x18 是客体的平台寄存器,宿主代码不许碰;16K 页对齐(Android 15+ 16K 页设备);保留 __start_/__stop_ 段登记表
# -ffixed-x18: x18 is the guest's platform register, host code must not touch it; 16K page alignment (Android 15+ 16K-page devices); keep the __start_/__stop_ section registration tables
CFLAGS = -O1 -g -Wall -Wno-unused-function -Wno-format -ffixed-x18 -fPIE \
-include compat/linux/compat_linux.h -Icompat/linux/include -I. -I$(GENH_DIR) -I../gfx/nvn/include -I../gfx/nvn
LDFLAGS = -pie -Wl,-z,max-page-size=16384 -Wl,-z,nostart-stop-gc -Wl,--export-dynamic
# APP=1:同一份源编成 libd2r.so 给 GameActivity 加载(android/app/),前端换成 front_app.c;APK 由 android/app/build_apk.sh 打
# APP=1: build the same sources into libd2r.so for GameActivity to load (android/app/), with front_app.c as the front end; the APK is packed by android/app/build_apk.sh
ifeq ($(APP),1)
OUT := build-android/app
CFLAGS := $(subst -fPIE,-fPIC,$(CFLAGS))
LDFLAGS := -shared -Wl,-soname,libd2r.so -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-z,max-page-size=16384 -Wl,-z,nostart-stop-gc
endif
LIBS = -llog -lm -ldl -lz -landroid -laaudio
# 与 Makefile 同一份源单,去掉 macOS 专属(.m、touch_mac.c、front_mac.m、memstat.m)
# Same source list as Makefile, minus the macOS-only ones (.m, touch_mac.c, front_mac.m, memstat.m)
# Makefile 的 SRC 是续行写的(一行一个),读到第一条不带续行符的行为止 | Makefile's SRC uses continuation lines (one per line); read up to the first line without a continuation
SRC_MAC := $(filter %.c,$(shell awk '/^SRC=/{f=1} f{l=$$0; sub(/^SRC=/,"",l); c=(l ~ /[\\\\]$$/); sub(/[\\\\]$$/,"",l); print l; if(!c) exit}' Makefile))
SRC := $(filter-out touch_mac.c,$(SRC_MAC)) $(sort $(wildcard hle_*.c)) $(wildcard compat/linux/*.c) $(wildcard android/*.c)
ifeq ($(APP),1)
SRC := $(filter-out android/front_headless.c,$(SRC)) android/app/front_app.c android/app/touch_app.c \
../touch/dm_touch_game_bridge.c ../touch/dm_touch_game_state.c ../touch/dm_touch_game_identity.c ../touch/dm_touch_native_art.c
endif
GFX := $(sort $(wildcard ../gfx/*.c ../gfx/nvn/*.c ../gfx/tex/*.c))
LIBDEFLATE := $(shell sed -n 's/^LIBDEFLATE=//p' Makefile)
ASM := entry.S ../gfx/nvn/nvn_entry.S ../gfx/nvn/nvn_thunks.S
OBJ := $(patsubst %.c,$(OUT)/obj/%.o,$(subst ../,up/,$(SRC) $(GFX) $(LIBDEFLATE))) \
$(patsubst %.S,$(OUT)/obj/%.o,$(subst ../,up/,$(ASM)))
$(OUT)/dmhost: $(OBJ)
$(CC) $(LDFLAGS) -Wl,--error-limit=0 -o $@ $^ $(LIBS)
$(OUT)/libd2r.so: $(OBJ)
$(CC) $(LDFLAGS) -Wl,--error-limit=0 -o $@ $^ $(LIBS)
# 图形回放(gfx/、android/)是逐绘制热路径,用 -O2;其余宿主代码保持 -O1,与 Mac 构建一致
# Graphics replay (gfx/, android/) is the per-draw hot path, built at -O2; the rest of the host stays at -O1 like the Mac build
$(OUT)/obj/up/gfx/%.o $(OUT)/obj/android/%.o: CFLAGS += -O2
$(OUT)/obj/up/%.o: ../%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(OUT)/obj/%.o: %.c dm.h hle.h compat/linux/compat_linux.h
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
# Mach-O 汇编转 ELF:去符号前导 _、@PAGE/@PAGEOFF 换 ELF 写法、.cstring 换 .rodata
# Mach-O assembly to ELF: strip the leading _ of symbols, @PAGE/@PAGEOFF to the ELF forms, .cstring to .rodata
ASM2ELF = perl -pe 's/(?<![\w.])_([A-Za-z])/$$1/g; s/(\w+)\@PAGEOFF/:lo12:$$1/g; s/(\w+)\@PAGE\b/$$1/g; s/^\s*\.cstring\b/\t.section .rodata/'
$(OUT)/obj/up/%.o: ../%.S
@mkdir -p $(dir $@)
$(ASM2ELF) $< > $(@:.o=.elf.S) && $(CC) -c $(@:.o=.elf.S) -o $@
$(OUT)/obj/%.o: %.S
@mkdir -p $(dir $@)
$(ASM2ELF) $< > $(@:.o=.elf.S) && $(CC) -c $(@:.o=.elf.S) -o $@
clean:
rm -rf $(OUT)
.PHONY: clean