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 48declare_args() { 49 advanced_ui_component_feature_pc = false 50} 51 52use_hilog = is_mingw || is_mac || is_linux || is_ohos || is_ohos_standard_system 53 54# Config gen_obj 55template("gen_obj") { 56 name = target_name 57 action("gen_obj_" + name) { 58 visibility = [ ":*" ] # Only targets in this file can depend on this. 59 60 if (use_mingw_win) { 61 objcopy_tool = objcopy_mingw 62 script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" 63 } else if (use_mac || target_os == "ios") { 64 objcopy_tool = objcopy_clang 65 script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" 66 } else if (use_linux) { 67 objcopy_tool = objcopy_x86_64 68 script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" 69 } else if (target_cpu == "x86_64") { 70 objcopy_tool = objcopy_x86_64 71 script = "//foundation/arkui/ace_engine/build/tools/run_objcopy.py" 72 } else { 73 objcopy_tool = objcopy_default 74 script = "//foundation/arkui/ace_engine/build/tools/run_objcopy.py" 75 } 76 77 args = [ 78 "--objcopy", 79 rebase_path(objcopy_tool), 80 "--input", 81 rebase_path(invoker.input), 82 "--output", 83 rebase_path(invoker.output), 84 "--arch", 85 current_cpu, 86 ] 87 88 deps = [] 89 deps += invoker.snapshot_dep 90 91 inputs = [ invoker.input ] 92 outputs = [ invoker.output ] 93 } 94 95 source_set("gen_obj_src_" + name) { 96 sources = [ invoker.output ] 97 deps = [ ":gen_obj_" + name ] 98 } 99} 100