# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/config/clang/clang.gni")
import("//build/config/python.gni")
import("//build/templates/common/copy.gni")
template("js_declaration") {
group(target_name) {
not_needed(invoker, "*")
}
}
template("gen_js_obj") {
name = target_name
action("gen_js_obj_" + name) {
visibility = [ ":*" ]
objcopy_tool = "${clang_base_path}/bin/llvm-objcopy"
platform = "${current_os}_${current_cpu}"
if (platform == "mingw_x86_64") {
script = "//build/scripts/run_objcopy_pc_mac.py"
} else if (platform == "mac_x64") {
script = "//build/scripts/run_objcopy_pc_mac.py"
} else if (platform == "linux_x64") {
script = "//build/scripts/run_objcopy_pc_mac.py"
} else if (target_cpu == "x86_64") {
script = "//build/scripts/run_objcopy.py"
} else if (target_cpu == "arm" || target_cpu == "arm64" ||
target_cpu == "riscv64" || target_cpu == "loongarch64") {
script = "//build/scripts/run_objcopy.py"
}
args = [
"--objcopy",
rebase_path(objcopy_tool),
"--input",
rebase_path(invoker.input),
"--output",
rebase_path(invoker.output),
"--arch",
current_cpu,
]
deps = []
if (defined(invoker.dep)) {
deps += [ invoker.dep ]
}
inputs = [ invoker.input ]
outputs = [ invoker.output ]
}
source_set(name) {
sources = [ invoker.output ]
deps = [ ":gen_js_obj_" + name ]
}
}