dumpvar.mk revision 7dfdb843b25b4ef04c47b148e0095f292eceacd4
1 2# List of variables we want to print in the build banner. 3print_build_config_vars := \ 4 PLATFORM_VERSION_CODENAME \ 5 PLATFORM_VERSION \ 6 TARGET_PRODUCT \ 7 TARGET_BUILD_VARIANT \ 8 TARGET_BUILD_TYPE \ 9 TARGET_BUILD_APPS \ 10 TARGET_ARCH \ 11 TARGET_ARCH_VARIANT \ 12 TARGET_CPU_VARIANT \ 13 TARGET_2ND_ARCH \ 14 TARGET_2ND_ARCH_VARIANT \ 15 TARGET_2ND_CPU_VARIANT \ 16 HOST_ARCH \ 17 HOST_2ND_ARCH \ 18 HOST_OS \ 19 HOST_OS_EXTRA \ 20 HOST_CROSS_OS \ 21 HOST_CROSS_ARCH \ 22 HOST_CROSS_2ND_ARCH \ 23 HOST_BUILD_TYPE \ 24 BUILD_ID \ 25 OUT_DIR 26 27ifeq ($(TARGET_BUILD_PDK),true) 28print_build_config_vars += \ 29 TARGET_BUILD_PDK \ 30 PDK_FUSION_PLATFORM_ZIP 31endif 32 33# --------------------------------------------------------------- 34# the setpath shell function in envsetup.sh uses this to figure out 35# what to add to the path given the config we have chosen. 36ifeq ($(CALLED_FROM_SETUP),true) 37 38ifneq ($(filter /%,$(HOST_OUT_EXECUTABLES)),) 39ABP:=$(HOST_OUT_EXECUTABLES) 40else 41ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES) 42endif 43 44ANDROID_BUILD_PATHS := $(ABP) 45ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG) 46ANDROID_GCC_PREBUILTS := prebuilts/gcc/$(HOST_PREBUILT_TAG) 47 48# The "dumpvar" stuff lets you say something like 49# 50# CALLED_FROM_SETUP=true \ 51# make -f config/envsetup.make dumpvar-TARGET_OUT 52# or 53# CALLED_FROM_SETUP=true \ 54# make -f config/envsetup.make dumpvar-abs-HOST_OUT_EXECUTABLES 55# 56# The plain (non-abs) version just dumps the value of the named variable. 57# The "abs" version will treat the variable as a path, and dumps an 58# absolute path to it. 59# 60dumpvar_goals := \ 61 $(strip $(patsubst dumpvar-%,%,$(filter dumpvar-%,$(MAKECMDGOALS)))) 62ifdef dumpvar_goals 63 64 ifneq ($(words $(dumpvar_goals)),1) 65 $(error Only one "dumpvar-" goal allowed. Saw "$(MAKECMDGOALS)") 66 endif 67 68 # If the goal is of the form "dumpvar-abs-VARNAME", then 69 # treat VARNAME as a path and return the absolute path to it. 70 absolute_dumpvar := $(strip $(filter abs-%,$(dumpvar_goals))) 71 ifdef absolute_dumpvar 72 dumpvar_goals := $(patsubst abs-%,%,$(dumpvar_goals)) 73 ifneq ($(filter /%,$($(dumpvar_goals))),) 74 DUMPVAR_VALUE := $($(dumpvar_goals)) 75 else 76 DUMPVAR_VALUE := $(PWD)/$($(dumpvar_goals)) 77 endif 78 dumpvar_target := dumpvar-abs-$(dumpvar_goals) 79 else 80 DUMPVAR_VALUE := $($(dumpvar_goals)) 81 dumpvar_target := dumpvar-$(dumpvar_goals) 82 endif 83 84.PHONY: $(dumpvar_target) 85$(dumpvar_target): 86 @echo $(DUMPVAR_VALUE) 87 88endif # dumpvar_goals 89 90ifneq ($(dumpvar_goals),report_config) 91PRINT_BUILD_CONFIG:= 92endif 93 94ifneq ($(filter report_config,$(DUMP_MANY_VARS)),) 95# Construct the shell commands that print the config banner. 96report_config_sh := echo '============================================'; 97report_config_sh += $(foreach v,$(print_build_config_vars),echo '$v=$($(v))';) 98report_config_sh += echo '============================================'; 99endif 100 101# Dump mulitple variables to "<var>=<value>" pairs, one per line. 102# The output may be executed as bash script. 103# Input variables: 104# DUMP_MANY_VARS: the list of variable names. 105# DUMP_VAR_PREFIX: an optional prefix of the variable name added to the output. 106# DUMP_MANY_ABS_VARS: the list of abs variable names. 107# DUMP_ABS_VAR_PREFIX: an optional prefix of the abs variable name added to the output. 108.PHONY: dump-many-vars 109dump-many-vars : 110 @$(foreach v, $(filter-out report_config, $(DUMP_MANY_VARS)),\ 111 echo "$(DUMP_VAR_PREFIX)$(v)='$($(v))'";) 112ifneq ($(filter report_config, $(DUMP_MANY_VARS)),) 113 @# Construct a special variable for report_config. 114 @# Escape \` to defer the execution of report_config_sh to preserve the line breaks. 115 @echo "$(DUMP_VAR_PREFIX)report_config=\`$(report_config_sh)\`" 116endif 117 @$(foreach v, $(sort $(DUMP_MANY_ABS_VARS)),\ 118 echo "$(DUMP_ABS_VAR_PREFIX)$(v)='$(PWD)/$($(v))'";) 119 120endif # CALLED_FROM_SETUP 121 122ifneq ($(PRINT_BUILD_CONFIG),) 123$(info ============================================) 124$(foreach v, $(print_build_config_vars),\ 125 $(info $v=$($(v)))) 126$(info ============================================) 127endif 128