Android makefile 내 함수 하나만 해석해주세요.
글쓴이: yo-tteum / 작성시간: 화, 2013/02/12 - 6:59오후
제가 envsetup.sh부터 따라왔는데 makefile 메뉴얼을 봐도 실제 응용된 코드는 난해하고 인터넷 예제도 제가 보는 코드와 일치하는 예제를 찾기가 힘드네요.
build/core/product.mk 파일 내의 resolve-short-product-name 함수입니다.
TARGET_DEVICE값을 구하기 위해서 TARGET_PRODUCT값을 받아서 처리를 하는것으로 보여집니다.
만약에 SKT에 출시될 갤럭시S4라고 하면 TARGET_PRODUCT값은 "s3_skt_kr" 이 될텐데 TARGET_DEVICE는 "s3"로만 나오면 되거든요.
그런데 이 함수를 호출하는 build/core/product_config.mk 에는 INTERNAL_PRODUCT값을 먼저 구합니다. 뭐하자는 건지 잘..
line-by-line으로 해석해주시면 가장 좋고 조그만 단서라도 부탁드려요.
200 # Convert a short name like "sooner" into the path to the product 201 # file defining that product. 202 # 203 INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT)) 204 #$(error TARGET_PRODUCT $(TARGET_PRODUCT) --> $(INTERNAL_PRODUCT)) 205 206 # Find the device that this product maps to. 207 TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)
168 # 169 # Returns the product makefile path for the product with the provided name 170 # 171 # $(1): short product name like "generic" 172 # 173 define _resolve-short-product-name 174 $(eval pn := $(strip $(1))) 175 $(eval p := \ 176 $(foreach p,$(PRODUCTS), \ 177 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \ 178 $(p) \ 179 )) \ 180 ) 181 $(eval p := $(sort $(p))) 182 $(if $(filter 1,$(words $(p))), \ 183 $(p), \ 184 $(if $(filter 0,$(words $(p))), \ 185 $(error No matches for product "$(pn)"), \ 186 $(error Product "$(pn)" ambiguous: matches $(p)) \ 187 ) \ 188 ) 189 endef 190 define resolve-short-product-name 191 $(strip $(call _resolve-short-product-name,$(1))) 192 endef
실행할 때 넘겨받는 인자값은 "TARGET_PRODUCT"입니다.
$(eval pn := $(strip $(1)))
위 내용도 pn에 TARGET_PRODUCT를 저장하는것으로 보이는데 eval은 왜 저기 붙어있나요.
그리고 더 어려운게 $(PRODUCTS) 요놈이 도대체 어디서 설정되는지 find로 문자열 검색해도 안나오네요.
Forums:
댓글 달기