OSDN Git Service

Do not stash BOARD_SYSTEMIMAGE_PARTITION_SIZE
[android-x86/build.git] / core / prebuilt_bundle_create.mk
1 #
2 # Copyright (C) 2011 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 #      http://www.apache.org/licenses/LICENSE-2.0
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 ifeq ($(PREBUILT_MODULES),)
18 ifeq ($(LOCAL_MODULE),)
19 $(error PREBUILT_MODULES must be specified; LOCAL_PATH=$(LOCAL_PATH))
20 endif
21 PREBUILT_MODULES := $(LOCAL_MODULE)
22 endif
23
24 ifeq ($(PREBUILT_PROJECT),)
25 $(error PREBUILT_PROJECT must be specified; LOCAL_PATH=$(LOCAL_PATH))
26 endif
27
28 ifndef prebuilt_create_once
29 prebuilt_create_once := true
30
31 PREBUILT_OUT_DIR := $(OUT_DIR)/prebuilt
32
33 define convert_installed_to_relative
34   $(if $(strip $(TARGET_OUT_$(strip $(2)))), \
35     $(subst $(TARGET_OUT_$(strip $(2)))/,,$(1)) \
36    , \
37     $(subst $(PRODUCT_OUT)/,,$(1)) \
38   )
39 endef
40
41 define transfer_content
42   $(info prebuilt transfer_content: $(1) => $(2))
43   $(hide) $(ACP) -fp $(1) $(2)
44 endef
45
46 define _write_metadata
47   $(eval data := $(strip $(1)))
48   $(if $(data),\
49     $(shell echo $(data) > $(2)) \
50   )
51 endef
52
53 #
54 # translate ABS module data into a prebuilt bundle.
55 # $(1): pathway to the binary base
56 # $(2): pathway to the headers base
57 # $(3): module to translate.
58 #
59 define install_prebuilt
60   $(eval prebuilt_out := $(1)/$(TARGET_BOARD_PLATFORM)/$(3))
61   $(eval prebuilt_headers_out := $(2)/$(TARGET_BOARD_PLATFORM)/$(PREBUILT-HEADERS-TO-$(3)))
62   $(shell mkdir -p $(prebuilt_out))
63   $(if $(word 1,$(PREBUILT-HEADERS-$(3))),
64     $(shell mkdir -p $(prebuilt_headers_out))
65   )
66   $(info creating prebuilt: $(3))
67   $(call _write_metadata,$(ALL_MODULES.$(3).CLASS),$(prebuilt_out)/class)
68   $(call _write_metadata,$(ALL_MODULES.$(3).TAGS),$(prebuilt_out)/tags)
69   $(call _write_metadata,$(ALL_MODULES.$(3).REQUIRED),$(prebuilt_out)/required)
70   $(eval files = $(call module-installed-files,$(3)))
71   $(if $(word 2,$(files)), \
72     $(error installing $(3), multiple files encountered- we cannot handle that) \
73   )
74
75   $(eval suf := $(suffix $(files)))
76   $(call _write_metadata,$(suf),$(prebuilt_out)/suffix)
77   $(foreach x,$(files),\
78     $(call transfer_content,$(x),$(prebuilt_out)/payload$(suf)) \
79   )
80   $(foreach x,$(PREBUILT-HEADERS-$(3)),\
81     $(call transfer_content,$(PREBUILT-HEADERS-FROM-$(3))/$(x),$(prebuilt_headers_out)) \
82   )
83   $(info Headers list for $(3) from $(PREBUILT-HEADERS-FROM-$(3)): $(PREBUILT-HEADERS-$(3)))
84 endef
85
86 #
87 # create a project android.mk
88 # $(1): path to the Android.mk to create for this project
89 #
90 define install_prebuilt_project
91   $(shell mkdir -p $(dir $(1)))
92   $(shell echo # autogenerated template for prebuilts > $(1))
93   $(shell echo 'ifneq ($$(TARGET_BOARD_PLATFORM),)' >> $(1))
94   $(shell echo LOCAL_PATH := $$\(call my-dir\)/$$\(TARGET_BOARD_PLATFORM\) >> $(1))
95   $(shell echo include $$\(BUILD_PREBUILT_BUNDLE\) >> $(1))
96   $(shell echo endif >> $(1))
97 endef
98
99 #
100 # create a module bundle
101 # $(1): directory to create the prebuilt projects bundles in.
102 # $(2): directory to create the prebuilt headers bundles in.
103 # $(3): project/grouping for the module bundling.
104 # $(4): module to translate
105 #
106 define prebuilt_bundle_create_boilerplate
107   $(eval PREBUILT-HEADERS-FROM-$(4) := $(LOCAL_PATH))
108   $(eval PREBUILT-HEADERS-TO-$(4) := $(LOCAL_COPY_HEADERS_TO))
109   $(eval PREBUILT-HEADERS-$(4) := $(LOCAL_COPY_HEADERS))
110   $(eval .PHONY: PREBUILT-$(4))
111   $(eval PREBUILT-$(4): $(1)/Android.mk $(4) ; $$(call install_prebuilt,$(1),$(2),$(4)))
112   $(eval PREBUILT-PROJECT-$(3): PREBUILT-$(4))
113 endef
114 endif
115
116 prebuilt_base := $(PREBUILT_OUT_DIR)/$(PREBUILT_PROJECT)
117
118 prebuilt_bin := $(prebuilt_base)/proprietary
119 ifneq ($(PREBUILT_INSTALL_DIR),)
120 prebuilt_bin := $(prebuilt_base)/$(PREBUILT_INSTALL_DIR)
121 endif
122
123 prebuilt_hdr := $(prebuilt_base)/include
124 ifneq ($(PREBUILT_INSTALL_HEADERS_DIR),)
125 prebuilt_hdr := $(prebuilt_base)/$(PREBUILT_INSTALL_HEADERS_DIR)
126 endif
127
128 $(prebuilt_bin)/Android.mk:
129         $(call install_prebuilt_project,$@)
130
131 .PHONY: PREBUILT-PROJECT-$(PREBUILT_PROJECT)
132
133 PREBUILT-PROJECT-$(PREBUILT_PROJECT): $(prebuilt_bin)/Android.mk
134
135 $(foreach x,$(PREBUILT_MODULES), \
136   $(eval $(call prebuilt_bundle_create_boilerplate,$(prebuilt_bin),$(prebuilt_hdr),$(PREBUILT_PROJECT),$(x))) \
137 )
138
139 prebuilt_base :=
140 prebuilt_bin :=
141 prebuilt_hdr :=
142 PREBUILT_MODULES :=
143 PREBUILT_PROJECT :=
144 PREBUILT_INSTALL_DIR :=