AOSP 13中PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD变量失效问题求助
解决AOSP eng版本中PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD不生效问题
问题场景
出于性能优化需求,需要在AOSP的eng构建版本中使用com.android.art包而非com.android.art.debug包。查看runtime_libart.mk中的逻辑:
art_target_include_debug_build := $(PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD) ifneq (false,$(art_target_include_debug_build)) ifneq (,$(filter eng,$(TARGET_BUILD_VARIANT))) art_target_include_debug_build := true endif endif ifeq (true,$(art_target_include_debug_build)) PRODUCT_PACKAGES += com.android.art.debug apex_test_module := art-check-debug-apex-gen-fakebin else PRODUCT_PACKAGES += com.android.art apex_test_module := art-check-release-apex-gen-fakebin endif
在设备对应的mk文件中添加PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD := false后未生效,调试输出显示PRODUCT前缀变量均为@inherit:build/make/target/product/default_art_config.mk的异常值。
问题根源
AOSP的PRODUCT变量加载存在固定顺序:runtime_libart.mk属于全局product配置,会在设备专属mk文件之前被解析。此时设备mk中设置的PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD还未生效,代码读取到的是默认的继承占位符,后续的eng版本强制赋值逻辑会直接覆盖设备设置。
可行解决方案
1. 修改runtime_libart.mk的逻辑判断
调整原有的eng版本强制赋值逻辑,让设备设置的变量优先生效:
art_target_include_debug_build := $(PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD) ifneq (false,$(art_target_include_debug_build)) ifneq (,$(filter eng,$(TARGET_BUILD_VARIANT))) # 仅当设备未强制关闭时,才启用debug build ifneq (false,$(PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD)) art_target_include_debug_build := true endif endif endif ifeq (true,$(art_target_include_debug_build)) PRODUCT_PACKAGES += com.android.art.debug apex_test_module := art-check-debug-apex-gen-fakebin else PRODUCT_PACKAGES += com.android.art apex_test_module := art-check-release-apex-gen-fakebin endif
2. 构建时通过环境变量强制覆盖
不需要修改mk文件,在构建命令中直接传入变量:
m PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD=false
这种方式的变量优先级高于所有mk文件中的设置,直接绕过继承顺序问题。
3. 调整设备mk的加载顺序
将PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD := false添加到设备的product.mk中(而非device.mk),确保该文件在runtime_libart.mk之前被加载。部分设备的配置结构中,product.mk会被更早纳入product配置链。
内容的提问来源于stack exchange,提问作者satur9nine
相关产品推荐
相关产品推荐

