xref: /aosp_15_r20/build/make/core/tasks/with-license.mk (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1# Copyright (C) 2019 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
16.PHONY: with-license
17
18name := $(TARGET_PRODUCT)
19ifeq ($(TARGET_BUILD_TYPE),debug)
20	name := $(name)_debug
21endif
22
23dist_name := $(name)-flashable-FILE_NAME_TAG_PLACEHOLDER-with-license
24name := $(name)-flashable-with-license
25
26with_license_intermediates := \
27	$(call intermediates-dir-for,PACKAGING,with_license)
28
29# Create a with-license artifact target
30license_image_input_zip := $(with_license_intermediates)/$(name).zip
31$(license_image_input_zip) : $(BUILT_TARGET_FILES_PACKAGE) $(ZIP2ZIP)
32# DO NOT PROCEED without a license file.
33ifndef VENDOR_BLOBS_LICENSE
34	@echo "with-license requires VENDOR_BLOBS_LICENSE to be set."
35	exit 1
36else
37	$(ZIP2ZIP) -i $(BUILT_TARGET_FILES_PACKAGE) -o $@ \
38		RADIO/bootloader.img:bootloader.img RADIO/radio.img:radio.img \
39		IMAGES/*.img:. OTA/android-info.txt:android-info.txt
40endif
41
42$(call declare-1p-container,$(license_image_input_zip),build)
43$(call declare-container-deps,$(license_image_input_zip),$(BUILT_TARGET_FILES_PACKAGE))
44
45with_license_zip := $(PRODUCT_OUT)/$(name).sh
46dist_name := $(dist_name).sh
47$(with_license_zip): PRIVATE_NAME := $(name)
48$(with_license_zip): PRIVATE_INPUT_ZIP := $(license_image_input_zip)
49$(with_license_zip): PRIVATE_VENDOR_BLOBS_LICENSE := $(VENDOR_BLOBS_LICENSE)
50$(with_license_zip): $(license_image_input_zip) $(VENDOR_BLOBS_LICENSE)
51$(with_license_zip): $(HOST_OUT_EXECUTABLES)/generate-self-extracting-archive
52	# Args: <output> <input archive> <comment> <license file>
53	$(HOST_OUT_EXECUTABLES)/generate-self-extracting-archive $@ \
54		$(PRIVATE_INPUT_ZIP) $(PRIVATE_NAME) $(PRIVATE_VENDOR_BLOBS_LICENSE)
55with-license : $(with_license_zip)
56$(call dist-for-goals, with-license, $(with_license_zip):$(dist_name))
57
58$(call declare-1p-container,$(with_license_zip),)
59$(call declare-container-license-deps,$(with_license_zip),$(license_image_input_zip),$(with_license_zip):)
60
61