2 # Copyright (C) 2011 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 ifeq ($(PREBUILT_MODULES),)
18 ifeq ($(LOCAL_MODULE),)
19 $(error PREBUILT_MODULES must be specified; LOCAL_PATH=$(LOCAL_PATH))
21 PREBUILT_MODULES := $(LOCAL_MODULE)
24 ifeq ($(PREBUILT_PROJECT),)
25 $(error PREBUILT_PROJECT must be specified; LOCAL_PATH=$(LOCAL_PATH))
28 ifndef prebuilt_create_once
29 prebuilt_create_once := true
31 PREBUILT_OUT_DIR := $(OUT_DIR)/prebuilt
33 define convert_installed_to_relative
34 $(if $(strip $(TARGET_OUT_$(strip $(2)))), \
35 $(subst $(TARGET_OUT_$(strip $(2)))/,,$(1)) \
37 $(subst $(PRODUCT_OUT)/,,$(1)) \
41 define transfer_content
42 $(info prebuilt transfer_content: $(1) => $(2))
43 $(hide) $(ACP) -fp $(1) $(2)
46 define _write_metadata
47 $(eval data := $(strip $(1)))
49 $(shell echo $(data) > $(2)) \
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.
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))
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) \
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)) \
80 $(foreach x,$(PREBUILT-HEADERS-$(3)),\
81 $(call transfer_content,$(PREBUILT-HEADERS-FROM-$(3))/$(x),$(prebuilt_headers_out)) \
83 $(info Headers list for $(3) from $(PREBUILT-HEADERS-FROM-$(3)): $(PREBUILT-HEADERS-$(3)))
87 # create a project android.mk
88 # $(1): path to the Android.mk to create for this project
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))
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
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))
116 prebuilt_base := $(PREBUILT_OUT_DIR)/$(PREBUILT_PROJECT)
118 prebuilt_bin := $(prebuilt_base)/proprietary
119 ifneq ($(PREBUILT_INSTALL_DIR),)
120 prebuilt_bin := $(prebuilt_base)/$(PREBUILT_INSTALL_DIR)
123 prebuilt_hdr := $(prebuilt_base)/include
124 ifneq ($(PREBUILT_INSTALL_HEADERS_DIR),)
125 prebuilt_hdr := $(prebuilt_base)/$(PREBUILT_INSTALL_HEADERS_DIR)
128 $(prebuilt_bin)/Android.mk:
129 $(call install_prebuilt_project,$@)
131 .PHONY: PREBUILT-PROJECT-$(PREBUILT_PROJECT)
133 PREBUILT-PROJECT-$(PREBUILT_PROJECT): $(prebuilt_bin)/Android.mk
135 $(foreach x,$(PREBUILT_MODULES), \
136 $(eval $(call prebuilt_bundle_create_boilerplate,$(prebuilt_bin),$(prebuilt_hdr),$(PREBUILT_PROJECT),$(x))) \
144 PREBUILT_INSTALL_DIR :=