1# Copyright (c) 2021 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/config/clang/clang.gni") 15import("//build/ohos.gni") 16 17use_mingw_win = "${current_os}_${current_cpu}" == "mingw_x86_64" 18objcopy_mingw = "//prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/bin/objcopy" 19objcopy_clang = "$clang_base_path/bin/llvm-objcopy" 20objcopy_x86_64 = "${default_clang_base_path}/bin/llvm-objcopy" 21objcopy_default = "//prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin/objcopy" 22 23if (is_standard_system && !is_arkui_x) { 24 if (host_cpu == "arm64") { 25 objcopy_default = 26 "//prebuilts/clang/ohos/linux-aarch64/llvm/bin/llvm-objcopy" 27 } else { 28 objcopy_default = 29 "//prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-objcopy" 30 } 31} else if (is_arkui_x) { 32 if (host_os == "mac") { 33 objcopy_default = objcopy_clang 34 } else if (defined(aosp_objcopy)) { 35 objcopy_default = aosp_objcopy 36 } 37} 38 39use_mac = "${current_os}_${current_cpu}" == "mac_x64" || 40 "${current_os}_${current_cpu}" == "mac_arm64" 41use_ios = "${current_os}_${current_cpu}" == "ios_x64" || 42 "${current_os}_${current_cpu}" == "ios_arm64" 43use_linux = "${current_os}_${current_cpu}" == "linux_x64" || 44 "${current_os}_${current_cpu}" == "linux_arm64" 45 46template("gen_obj") { 47 name = target_name 48 action("gen_obj_" + name) { 49 visibility = [ ":*" ] # Only targets in this file can depend on this. 50 51 if (use_mingw_win) { 52 objcopy_tool = objcopy_mingw 53 script = 54 "//build/config/components/ace_engine/build_resource_to_bytecode.py" 55 } else if (use_mac || target_os == "ios") { 56 objcopy_tool = objcopy_clang 57 script = 58 "//build/config/components/ace_engine/build_resource_to_bytecode.py" 59 } else if (use_linux) { 60 objcopy_tool = objcopy_x86_64 61 script = 62 "//build/config/components/ace_engine/build_resource_to_bytecode.py" 63 } else if (target_cpu == "x86_64") { 64 objcopy_tool = objcopy_x86_64 65 66 # script = "$ace_root/build/tools/run_objcopy.py" 67 script = "//build/scripts/run_objcopy.py" 68 } else { 69 objcopy_tool = objcopy_default 70 71 # script = "$ace_root/build/tools/run_objcopy.py" 72 script = "//build/scripts/run_objcopy.py" 73 } 74 75 args = [ 76 "--objcopy", 77 rebase_path(objcopy_tool), 78 "--input", 79 rebase_path(invoker.input), 80 "--output", 81 rebase_path(invoker.output), 82 "--arch", 83 current_cpu, 84 ] 85 deps = [] 86 deps += invoker.snapshot_dep 87 88 inputs = [ invoker.input ] 89 outputs = [ invoker.output ] 90 } 91 92 source_set("gen_obj_src_" + name) { 93 sources = [ invoker.output ] 94 deps = [ ":gen_obj_" + name ] 95 } 96} 97