1# Copyright (c) 2024 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") 16import("//build/test.gni") 17 18enable_dump_drawcmd = false 19is_ohos_standard_system = is_standard_system && !is_arkui_x 20use_mingw_win = "${current_os}_${current_cpu}" == "mingw_x86_64" 21use_mac = "${current_os}_${current_cpu}" == "mac_x64" || 22 "${current_os}_${current_cpu}" == "mac_arm64" 23use_ios = "${current_os}_${current_cpu}" == "ios_x64" || 24 "${current_os}_${current_cpu}" == "ios_arm64" 25use_linux = "${current_os}_${current_cpu}" == "linux_x64" 26 27# Config toolchain 28windows_buildtool = "//build/toolchain/mingw:mingw_x86_64" 29objcopy_default = "//prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin/objcopy" 30objcopy_mingw = "//prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/bin/objcopy" 31objcopy_x86_64 = "${default_clang_base_path}/bin/llvm-objcopy" 32if ("${current_os}_${current_cpu}" == "mac_arm64") { 33 mac_buildtool = "//build/toolchain/mac:clang_arm64" 34} else if ("${current_os}_${current_cpu}" == "mac_x64") { 35 mac_buildtool = "//build/toolchain/mac:clang_x64" 36} 37 38objcopy_clang = "$clang_base_path/bin/llvm-objcopy" 39 40if (is_ohos_standard_system) { 41 objcopy_default = "//prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-objcopy" 42} else if (is_arkui_x) { 43 if (host_os == "mac") { 44 objcopy_default = objcopy_clang 45 } 46} 47 48use_hilog = is_mingw || is_mac || is_linux || is_ohos || is_ohos_standard_system 49 50# Config gen_obj 51template("gen_obj") { 52 name = target_name 53 action("gen_obj_" + name) { 54 visibility = [ ":*" ] # Only targets in this file can depend on this. 55 56 if (use_mingw_win) { 57 objcopy_tool = objcopy_mingw 58 script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" 59 } else if (use_mac || target_os == "ios") { 60 objcopy_tool = objcopy_clang 61 script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" 62 } else if (use_linux) { 63 objcopy_tool = objcopy_x86_64 64 script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" 65 } else if (target_cpu == "x86_64") { 66 objcopy_tool = objcopy_x86_64 67 script = "//foundation/arkui/ace_engine/build/tools/run_objcopy.py" 68 } else { 69 objcopy_tool = objcopy_default 70 script = "//foundation/arkui/ace_engine/build/tools/run_objcopy.py" 71 } 72 73 args = [ 74 "--objcopy", 75 rebase_path(objcopy_tool), 76 "--input", 77 rebase_path(invoker.input), 78 "--output", 79 rebase_path(invoker.output), 80 "--arch", 81 current_cpu, 82 ] 83 84 deps = [] 85 deps += invoker.snapshot_dep 86 87 inputs = [ invoker.input ] 88 outputs = [ invoker.output ] 89 } 90 91 source_set("gen_obj_src_" + name) { 92 sources = [ invoker.output ] 93 deps = [ ":gen_obj_" + name ] 94 } 95} 96