# Copyright (c) 2021 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/templates/common/copy.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 ] module_type = "bin" prebuilt = true install_enable = false enable_strip = false if (defined(invoker.enable_strip) && invoker.enable_strip) { enable_strip = true } if (defined(invoker.install_enable)) { install_enable = invoker.install_enable } } } 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 } # auto set auto_relative_install_dir by innerapi_tags if (defined(invoker.innerapi_tags)) { is_chipsetsdk = false is_platformsdk = false is_passthrough = false foreach(tag, filter_include(invoker.innerapi_tags, [ "chipsetsdk*" ])) { is_chipsetsdk = true } foreach(tag, filter_include(invoker.innerapi_tags, [ "platformsdk*" ])) { is_platformsdk = true } foreach(tag, filter_include(invoker.innerapi_tags, [ "passthrough*" ])) { is_passthrough = true } if (is_chipsetsdk && is_platformsdk) { auto_relative_install_dir = "chipset-pub-sdk" } else if (is_chipsetsdk) { auto_relative_install_dir = "chipset-sdk" } else if (is_platformsdk) { auto_relative_install_dir = "platformsdk" } if (is_passthrough) { auto_relative_install_dir = chipset_passthrough_dir } is_ndk = false foreach(tag, filter_include(invoker.innerapi_tags, [ "ndk" ])) { is_ndk = true } if (is_ndk) { auto_relative_install_dir = "ndk" } } 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", "symlink_target_name", "innerapi_tags", # Open source license related "license_file", "license_as_sources", ]) sources = [ invoker.source ] outputs = [ _copy_output ] module_type = "lib" prebuilt = true install_enable = true enable_strip = false if (defined(invoker.enable_strip) && invoker.enable_strip) { enable_strip = true } if (defined(invoker.install_enable)) { install_enable = invoker.install_enable } # update relative_install_dir if auto_relative_install_dir defined if (defined(auto_relative_install_dir)) { relative_install_dir = auto_relative_install_dir } if (defined(invoker.relative_install_dir)) { relative_install_dir = invoker.relative_install_dir } 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 ] bypass_module_info_generation = true 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 ] module_type = "etc" prebuilt = true install_enable = true if (defined(invoker.install_enable)) { install_enable = invoker.install_enable } } }