# Copyright (C) 2021-2023 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_root/templates/cxx/cxx.gni") template("ohos_prebuilt_executable") { assert(defined(invoker.source), "source must be defined for ${target_name}.") if (defined(invoker.output)) { _copy_output = "${target_out_dir}/${invoker.output}" } else { _copy_output = "${target_out_dir}/${invoker.source}" } if (!defined(invoker.deps)) { invoker.deps = [] } if (!defined(invoker.stable)) { invoker.stable = false } deps_info = [] foreach(dep, invoker.deps) { info = { } info = { target_out_dir = rebase_path(get_label_info(dep, "target_out_dir"), root_build_dir) target_name = get_label_info(dep, "name") } deps_info += [ info ] } module_label = get_label_info(":${target_name}", "label_with_toolchain") target_deps_data = { label = module_label module_deps_info = deps_info type = "executable" prebuilt = true stable = invoker.stable toolchain = get_label_info(":${target_name}", "toolchain") source_path = rebase_path(invoker.source, root_build_dir) output_path = rebase_path(_copy_output, root_build_dir) } write_file("${target_out_dir}/${target_name}_deps_data.json", target_deps_data, "json") ohos_copy(target_name) { forward_variables_from(invoker, [ "testonly", "visibility", "deps", "public_configs", "subsystem_name", "part_name", # For generate_module_info "install_images", "module_install_dir", "relative_install_dir", "symlink_target_name", # Open source license related "license_file", "license_as_sources", ]) sources = [ invoker.source ] outputs = [ _copy_output ] } } template("ohos_prebuilt_shared_library") { assert(defined(invoker.source), "source must be defined for ${target_name}.") if (defined(invoker.output)) { _copy_output = "${target_out_dir}/${invoker.output}" } else { _copy_output = "${target_out_dir}/${invoker.source}" } config("${target_name}__config") { libs = [ _copy_output ] } if (!defined(invoker.deps)) { invoker.deps = [] } if (!defined(invoker.stable)) { invoker.stable = false } deps_info = [] foreach(dep, invoker.deps) { info = { } info = { target_out_dir = rebase_path(get_label_info(dep, "target_out_dir"), root_build_dir) target_name = get_label_info(dep, "name") } deps_info += [ info ] } module_label = get_label_info(":${target_name}", "label_with_toolchain") target_deps_data = { label = module_label module_deps_info = deps_info type = "shared_library" prebuilt = true stable = invoker.stable toolchain = get_label_info(":${target_name}", "toolchain") source_path = rebase_path(invoker.source, root_build_dir) output_path = rebase_path(_copy_output, root_build_dir) } write_file("${target_out_dir}/${target_name}_deps_data.json", target_deps_data, "json") ohos_copy(target_name) { forward_variables_from(invoker, [ "testonly", "visibility", "deps", "public_configs", "subsystem_name", "part_name", # For generate_module_info "install_images", "module_install_dir", "relative_install_dir", "symlink_target_name", # Open source license related "license_file", "license_as_sources", ]) sources = [ invoker.source ] outputs = [ _copy_output ] if (!defined(public_configs)) { public_configs = [] } public_configs += [ ":${target_name}__config" ] } } template("ohos_prebuilt_static_library") { assert(defined(invoker.source), "source must be defined for ${target_name}.") if (defined(invoker.output)) { _copy_output = "${target_out_dir}/${invoker.output}" } else { _copy_output = "${target_out_dir}/${invoker.source}" } config("${target_name}__config") { libs = [ _copy_output ] } ohos_copy(target_name) { forward_variables_from(invoker, [ "testonly", "visibility", "deps", "public_configs", "subsystem_name", "part_name", # Open source license related "license_file", "license_as_sources", ]) sources = [ invoker.source ] outputs = [ _copy_output ] if (!defined(public_configs)) { public_configs = [] } public_configs += [ ":${target_name}__config" ] } } template("ohos_prebuilt_etc") { assert(defined(invoker.source), "source must be defined for ${target_name}.") if (defined(invoker.output)) { _copy_output = "${target_out_dir}/${invoker.output}" } else { _copy_output = "${target_out_dir}/${invoker.source}" } module_label = get_label_info(":${target_name}", "label_with_toolchain") target_deps_data = { label = module_label type = "etc" prebuilt = true source_path = rebase_path(invoker.source, root_build_dir) output_path = rebase_path(_copy_output, root_build_dir) } write_file("${target_out_dir}/${target_name}_deps_data.json", target_deps_data, "json") ohos_copy(target_name) { forward_variables_from(invoker, [ "testonly", "visibility", "deps", "public_configs", "subsystem_name", "part_name", # For generate_module_info "install_images", "module_install_dir", "relative_install_dir", "symlink_target_name", # Open source license related "license_file", "license_as_sources", ]) sources = [ invoker.source ] outputs = [ _copy_output ] } }