1#
2# Copyright (C) 2020 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# $(1): List of target native files to copy.
18# $(2): Copy destination directory.
19# Evaluates to a list of ":"-separated pairs src:dst.
20define target-native-copy-pairs
21$(foreach m,$(1),\
22  $(eval _built_files := $(strip $(ALL_MODULES.$(m).BUILT_INSTALLED)\
23  $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT_INSTALLED)))\
24  $(foreach i, $(_built_files),\
25    $(eval bui_ins := $(subst :,$(space),$(i)))\
26    $(eval ins := $(word 2,$(bui_ins)))\
27    $(if $(filter $(TARGET_OUT_ROOT)/%,$(ins)),\
28      $(eval bui := $(word 1,$(bui_ins)))\
29      $(eval my_copy_dest := $(patsubst data/%,DATA/%,\
30                               $(patsubst system/%,DATA/%,\
31                                   $(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\
32      $(bui):$(2)/$(my_copy_dest))))
33endef
34