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/config/python.gni") 16import("//build/templates/common/copy.gni") 17 18template("js_declaration") { 19 group(target_name) { 20 not_needed(invoker, "*") 21 } 22} 23 24template("gen_js_obj") { 25 name = target_name 26 action("gen_js_obj_" + name) { 27 visibility = [ ":*" ] 28 29 objcopy_tool = "${clang_base_path}/bin/llvm-objcopy" 30 platform = "${current_os}_${current_cpu}" 31 if (platform == "mingw_x86_64") { 32 script = 33 "//third_party/flutter/engine/flutter/sky/tools/objcopy_pc_mac.py" 34 } else if (platform == "mac_x64") { 35 script = 36 "//third_party/flutter/engine/flutter/sky/tools/objcopy_pc_mac.py" 37 } else if (target_cpu == "x86_64") { 38 script = "//third_party/flutter/engine/flutter/sky/tools/objcopy.py" 39 } else if (target_cpu == "arm" || target_cpu == "arm64") { 40 script = "//third_party/flutter/engine/flutter/sky/tools/objcopy.py" 41 } 42 43 args = [ 44 "--objcopy", 45 rebase_path(objcopy_tool), 46 "--input", 47 rebase_path(invoker.input), 48 "--output", 49 rebase_path(invoker.output), 50 "--arch", 51 current_cpu, 52 ] 53 54 deps = [] 55 if (defined(invoker.dep)) { 56 deps += [ invoker.dep ] 57 } 58 59 inputs = [ invoker.input ] 60 outputs = [ invoker.output ] 61 } 62 63 source_set(name) { 64 sources = [ invoker.output ] 65 deps = [ ":gen_js_obj_" + name ] 66 } 67} 68