Chinaunix首页 | 论坛 | 博客
  • 博客访问: 18766
  • 博文数量: 6
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 90
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-10 10:40
文章分类

全部博文(6)

文章存档

2013年(6)

我的朋友

分类: Android平台

2013-09-17 12:09:11

config.mk:

点击(此处)折叠或打开

  1. -include $(TOPDIR)buildspec.mk

  2. # ---------------------------------------------------------------
  3. # Define most of the global variables. These are the ones that
  4. # are specific to the user's build configuration.
  5. include $(BUILD_SYSTEM)/envsetup.mk
envsetup.mk:

点击(此处)折叠或打开

  1. include $(BUILD_SYSTEM)/product_config.mk

product_config.mk:

点击(此处)折叠或打开

  1. include $(BUILD_SYSTEM)/node_fns.mk
  2. include $(BUILD_SYSTEM)/product.mk
  3. include $(BUILD_SYSTEM)/device.mk

  4. ifneq ($(strip $(TARGET_BUILD_APPS)),)
  5. # An unbundled app build needs only the core product makefiles.
  6. $(call import-products,$(call get-product-makefiles,\
  7. $(SRC_TARGET_DIR)/product/AndroidProducts.mk))
  8. else
  9. # Read in all of the product definitions specified by the AndroidProducts.mk
  10. # files in the tree.
  11. #
  12. #TODO: when we start allowing direct pointers to product files,
  13. # guarantee that they're in this list.
  14. $(call import-products, $(get-all-product-makefiles))
  15. endif # TARGET_BUILD_APPS
  16. $(check-all-products)
product.mk:

点击(此处)折叠或打开

  1. #
  2. # $(1): product makefile list
  3. #
  4. #TODO: check to make sure that products have all the necessary vars defined
  5. define import-products
  6. $(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
  7. endef


  8. #
  9. # Does various consistency checks on all of the known products.
  10. # Takes no parameters, so $(call ) is not necessary.
  11. #
  12. define check-all-products
  13. $(if ,, \
  14. $(eval _cap_names :=) \
  15. $(foreach p,$(PRODUCTS), \
  16. $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
  17. $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
  18. $(if $(filter $(pn),$(_cap_names)), \
  19. $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
  20. $(foreach \
  21. pp,$(PRODUCTS),
  22. $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
  23. $(pp) \
  24. ))) \
  25. ) \
  26. ) \
  27. $(eval _cap_names += $(pn)) \
  28. $(if $(call is-c-identifier,$(pn)),, \
  29. $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
  30. ) \
  31. $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
  32. $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
  33. $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
  34. $(if $(filter 2,$(words $(subst :,$(space),$(cf)))),, \
  35. $(error $(p): malformed COPY_FILE "$(cf)") \
  36. ) \
  37. ) \
  38. ) \
  39. )
  40. endef


  41. #
  42. # Returns the product makefile path for the product with the provided name
  43. #
  44. # $(1): short product name like "generic"
  45. #
  46. define _resolve-short-product-name
  47. $(eval pn := $(strip $(1)))
  48. $(eval p := \
  49. $(foreach p,$(PRODUCTS), \
  50. $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
  51. $(p) \
  52. )) \
  53. )
  54. $(eval p := $(sort $(p)))
  55. $(if $(filter 1,$(words $(p))), \
  56. $(p), \
  57. $(if $(filter 0,$(words $(p))), \
  58. $(error No matches for product "$(pn)"), \
  59. $(error Product "$(pn)" ambiguous: matches $(p)) \
  60. ) \
  61. )
  62. endef
  63. define resolve-short-product-name
  64. $(strip $(call _resolve-short-product-name,$(1)))
  65. endef
node_fns.mk:

点击(此处)折叠或打开

  1. #
  2. # Copyright (C) 2007 The Android Open Source Project
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. #
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. #
  17. # Clears a list of variables using ":=".
  18. #
  19. # E.g.,
  20. # $(call clear-var-list,A B C)
  21. # would be the same as:
  22. # A :=
  23. # B :=
  24. # C :=
  25. #
  26. # $(1): list of variable names to clear
  27. #
  28. define clear-var-list
  29. $(foreach v,$(1),$(eval $(v):=))
  30. endef
  31. #
  32. # Copies a list of variables into another list of variables.
  33. # The target list is the same as the source list, but has
  34. # a dotted prefix affixed to it.
  35. #
  36. # E.g.,
  37. # $(call copy-var-list, PREFIX, A B)
  38. # would be the same as:
  39. # PREFIX.A := $(A)
  40. # PREFIX.B := $(B)
  41. #
  42. # $(1): destination prefix
  43. # $(2): list of variable names to copy
  44. #
  45. define copy-var-list
  46. $(foreach v,$(2),$(eval $(strip $(1)).$(v):=$($(v))))
  47. endef
  48. #
  49. # Moves a list of variables into another list of variables.
  50. # The variable names differ by a prefix. After moving, the
  51. # source variable is cleared.
  52. #
  53. # NOTE: Spaces are not allowed around the prefixes.
  54. #
  55. # E.g.,
  56. # $(call move-var-list,SRC,DST,A B)
  57. # would be the same as:
  58. # DST.A := $(SRC.A)
  59. # SRC.A :=
  60. # DST.B := $(SRC.B)
  61. # SRC.B :=
  62. #
  63. # $(1): source prefix
  64. # $(2): destination prefix
  65. # $(3): list of variable names to move
  66. #
  67. define move-var-list
  68. $(foreach v,$(3), \
  69. $(eval $(2).$(v) := $($(1).$(v))) \
  70. $(eval $(1).$(v) :=) \
  71. )
  72. endef
  73. #
  74. # $(1): haystack
  75. # $(2): needle
  76. #
  77. # Guarantees that needle appears at most once in haystack,
  78. # without changing the order of other elements in haystack.
  79. # If needle appears multiple times, only the first occurrance
  80. # will survive.
  81. #
  82. # How it works:
  83. #
  84. # - Stick everything in haystack into a single word,
  85. # with "|||" separating the words.
  86. # - Replace occurrances of "|||$(needle)|||" with "||| |||",
  87. # breaking haystack back into multiple words, with spaces
  88. # where needle appeared.
  89. # - Add needle between the first and second words of haystack.
  90. # - Replace "|||" with spaces, breaking haystack back into
  91. # individual words.
  92. #
  93. empty :=
  94. space := $(empty) $(empty)
  95. define uniq-word
  96. $(strip \
  97. $(if $(filter $(2),$(1)), \
  98. $(eval h := |||$(subst $(space),|||,$(strip $(1)))|||) \
  99. $(eval h := $(subst |||$(strip $(2))|||,|||$(space)|||,$(h))) \
  100. $(eval h := $(word 1,$(h)) $(2) $(wordlist 2,9999,$(h))) \
  101. $(subst |||,$(space),$(h)) \
  102. , \
  103. $(1) \
  104. ))
  105. endef
  106. INHERIT_TAG := @inherit:
  107. #
  108. # Walks through the list of variables, each qualified by the prefix,
  109. # and finds instances of words beginning with INHERIT_TAG. Scrape
  110. # off INHERIT_TAG from each matching word, and return the sorted,
  111. # unique set of those words.
  112. #
  113. # E.g., given
  114. # PREFIX.A := A $(INHERIT_TAG)aaa B C
  115. # PREFIX.B := B $(INHERIT_TAG)aaa C $(INHERIT_TAG)bbb D E
  116. # Then
  117. # $(call get-inherited-nodes,PREFIX,A B)
  118. # returns
  119. # aaa bbb
  120. #
  121. # $(1): variable prefix
  122. # $(2): list of variables to check
  123. #
  124. define get-inherited-nodes
  125. $(sort \
  126. $(subst $(INHERIT_TAG),, \
  127. $(filter $(INHERIT_TAG)%, \
  128. $(foreach v,$(2),$($(1).$(v))) \
  129. )))
  130. endef
  131. #
  132. # for each variable ( (prefix + name) * vars ):
  133. # get list of inherited words; if not empty:
  134. # for each inherit:
  135. # replace the first occurrence with (prefix + inherited + var)
  136. # clear the source var so we can't inherit the value twice
  137. #
  138. # $(1): context prefix
  139. # $(2): name of this node
  140. # $(3): list of variable names
  141. #
  142. define _expand-inherited-values
  143. $(foreach v,$(3), \
  144. $(eval ### "Shorthand for the name of the target variable") \
  145. $(eval _eiv_tv := $(1).$(2).$(v)) \
  146. $(eval ### "Get the list of nodes that this variable inherits") \
  147. $(eval _eiv_i := \
  148. $(sort \
  149. $(patsubst $(INHERIT_TAG)%,%, \
  150. $(filter $(INHERIT_TAG)%, $($(_eiv_tv)) \
  151. )))) \
  152. $(foreach i,$(_eiv_i), \
  153. $(eval ### "Make sure that this inherit appears only once") \
  154. $(eval $(_eiv_tv) := \
  155. $(call uniq-word,$($(_eiv_tv)),$(INHERIT_TAG)$(i))) \
  156. $(eval ### "Expand the inherit tag") \
  157. $(eval $(_eiv_tv) := \
  158. $(strip \
  159. $(patsubst $(INHERIT_TAG)$(i),$($(1).$(i).$(v)), \
  160. $($(_eiv_tv))))) \
  161. $(eval ### "Clear the child so DAGs don't create duplicate entries" ) \
  162. $(eval $(1).$(i).$(v) :=) \
  163. $(eval ### "If we just inherited ourselves, it's a cycle.") \
  164. $(if $(filter $(INHERIT_TAG)$(2),$($(_eiv_tv))), \
  165. $(warning Cycle detected between "$(2)" and "$(i)" for context "$(1)") \
  166. $(error import of "$(2)" failed) \
  167. ) \
  168. ) \
  169. ) \
  170. $(eval _eiv_tv :=) \
  171. $(eval _eiv_i :=)
  172. endef
  173. #
  174. # $(1): context prefix
  175. # $(2): makefile representing this node
  176. # $(3): list of node variable names
  177. #
  178. # _include_stack contains the list of included files, with the most recent files first.
  179. define _import-node
  180. $(eval _include_stack := $(2) $$(_include_stack))
  181. $(call clear-var-list, $(3))
  182. $(eval LOCAL_PATH := $(patsubst %/,%,$(dir $(2))))
  183. $(eval MAKEFILE_LIST :=)
  184. $(eval include $(2))
  185. $(eval _included := $(filter-out $(2),$(MAKEFILE_LIST)))
  186. $(eval MAKEFILE_LIST :=)
  187. $(eval LOCAL_PATH :=)
  188. $(call copy-var-list, $(1).$(2), $(3))
  189. $(call clear-var-list, $(3))
  190. $(eval $(1).$(2).inherited := \
  191. $(call get-inherited-nodes,$(1).$(2),$(3)))
  192. $(call _import-nodes-inner,$(1),$($(1).$(2).inherited),$(3))
  193. $(call _expand-inherited-values,$(1),$(2),$(3))
  194. $(eval $(1).$(2).inherited :=)
  195. $(eval _include_stack := $(wordlist 2,9999,$$(_include_stack)))
  196. endef
  197. #
  198. # This will generate a warning for _included above
  199. # $(if $(_included), \
  200. # $(eval $(warning product spec file: $(2)))\
  201. # $(foreach _inc,$(_included),$(eval $(warning $(space)$(space)$(space)includes: $(_inc)))),)
  202. #
  203. #
  204. # $(1): context prefix
  205. # $(2): list of makefiles representing nodes to import
  206. # $(3): list of node variable names
  207. #
  208. #TODO: Make the "does not exist" message more helpful;
  209. # should print out the name of the file trying to include it.
  210. define _import-nodes-inner
  211. $(foreach _in,$(2), \
  212. $(if $(wildcard $(_in)), \
  213. $(if $($(1).$(_in).seen), \
  214. $(eval ### "skipping already-imported $(_in)") \
  215. , \
  216. $(eval $(1).$(_in).seen := true) \
  217. $(call _import-node,$(1),$(strip $(_in)),$(3)) \
  218. ) \
  219. , \
  220. $(error $(1): "$(_in)" does not exist) \
  221. ) \
  222. )
  223. endef
  224. #
  225. # $(1): output list variable name, like "PRODUCTS" or "DEVICES"
  226. # $(2): list of makefiles representing nodes to import
  227. # $(3): list of node variable names
  228. #
  229. define import-nodes
  230. $(if \
  231. $(foreach _in,$(2), \
  232. $(eval _node_import_context := _nic.$(1).[[$(_in)]]) \
  233. $(if $(_include_stack),$(eval $(error ASSERTION FAILED: _include_stack \
  234. should be empty here: $(_include_stack))),) \
  235. $(eval _include_stack := ) \
  236. $(call _import-nodes-inner,$(_node_import_context),$(_in),$(3)) \
  237. $(call move-var-list,$(_node_import_context).$(_in),$(1).$(_in),$(3)) \
  238. $(eval _node_import_context :=) \
  239. $(eval $(1) := $($(1)) $(_in)) \
  240. $(if $(_include_stack),$(eval $(error ASSERTION FAILED: _include_stack \
  241. should be empty here: $(_include_stack))),) \
  242. ) \
  243. ,)
  244. endef

其实整个全局变量建立过程就是一句话:$(call import-products, $(get-all-product-makefiles))


阅读(2250) | 评论(0) | 转发(0) |
0

上一篇:火狐插件--IE TAB 2

下一篇:没有了

给主人留下些什么吧!~~