154aa6d63Sopenharmony_ci# Copyright (c) 2024-2024 Huawei Device Co., Ltd.
254aa6d63Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
354aa6d63Sopenharmony_ci# you may not use this file except in compliance with the License.
454aa6d63Sopenharmony_ci# You may obtain a copy of the License at
554aa6d63Sopenharmony_ci#
654aa6d63Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
754aa6d63Sopenharmony_ci#
854aa6d63Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
954aa6d63Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1054aa6d63Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1154aa6d63Sopenharmony_ci# See the License for the specific language governing permissions and
1254aa6d63Sopenharmony_ci# limitations under the License.
1354aa6d63Sopenharmony_ci
1454aa6d63Sopenharmony_ciimport("cmd/signature_tools_cmd.gni")
1554aa6d63Sopenharmony_ciimport("codesigning/signature_tools_codesigning.gni")
1654aa6d63Sopenharmony_ciimport("common/signature_tools_common.gni")
1754aa6d63Sopenharmony_ciimport("hap/signature_tools_hap.gni")
1854aa6d63Sopenharmony_ciimport("profile/signature_tools_profile.gni")
1954aa6d63Sopenharmony_ciimport("signature_tools.gni")
2054aa6d63Sopenharmony_ciimport("utils/signature_tools_utils.gni")
2154aa6d63Sopenharmony_ciimport("zip/signature_tools_zip.gni")
2254aa6d63Sopenharmony_ci
2354aa6d63Sopenharmony_ciimport("//build/ohos.gni")
2454aa6d63Sopenharmony_ci
2554aa6d63Sopenharmony_ciohos_copy("copy_signature_tools_resource") {
2654aa6d63Sopenharmony_ci  sources = [
2754aa6d63Sopenharmony_ci    "../dist/OpenHarmony.p12",
2854aa6d63Sopenharmony_ci    "../dist/OpenHarmonyApplication.pem",
2954aa6d63Sopenharmony_ci    "../dist/OpenHarmonyProfileDebug.pem",
3054aa6d63Sopenharmony_ci    "../dist/OpenHarmonyProfileRelease.pem",
3154aa6d63Sopenharmony_ci    "../dist/SgnedReleaseProfileTemplate.p7b",
3254aa6d63Sopenharmony_ci    "../dist/UnsgnedDebugProfileTemplate.json",
3354aa6d63Sopenharmony_ci    "../dist/UnsgnedReleasedProfileTemplate.json",
3454aa6d63Sopenharmony_ci  ]
3554aa6d63Sopenharmony_ci  outputs =
3654aa6d63Sopenharmony_ci      [ "${target_out_dir}/toolchains/hapsigntool_pc/{{source_file_part}}" ]
3754aa6d63Sopenharmony_ci  module_source_dir = target_out_dir + "/toolchains/hapsigntool_pc"
3854aa6d63Sopenharmony_ci  module_install_name = ""
3954aa6d63Sopenharmony_ci  part_name = "hapsigner"
4054aa6d63Sopenharmony_ci  subsystem_name = "developtools"
4154aa6d63Sopenharmony_ci}
4254aa6d63Sopenharmony_ci
4354aa6d63Sopenharmony_cisignature_tools_main_include = [
4454aa6d63Sopenharmony_ci  "${signature_tools_api}/include",
4554aa6d63Sopenharmony_ci  "${signature_tools_signer}/include",
4654aa6d63Sopenharmony_ci  "//third_party/openssl/include",
4754aa6d63Sopenharmony_ci  "//third_party/openssl/crypto/pkcs12",
4854aa6d63Sopenharmony_ci]
4954aa6d63Sopenharmony_ci
5054aa6d63Sopenharmony_cisignature_tools_main_src = [
5154aa6d63Sopenharmony_ci  "main.cpp",
5254aa6d63Sopenharmony_ci  "${signature_tools_api}/src/sign_tool_service_impl.cpp",
5354aa6d63Sopenharmony_ci  "${signature_tools_api}/src/cert_tools.cpp",
5454aa6d63Sopenharmony_ci  "${signature_tools_signer}/src/signer_factory.cpp",
5554aa6d63Sopenharmony_ci  "${signature_tools_signer}/src/local_signer.cpp",
5654aa6d63Sopenharmony_ci]
5754aa6d63Sopenharmony_ci
5854aa6d63Sopenharmony_ciohos_executable("hap-sign-tool") {
5954aa6d63Sopenharmony_ci  signature_tools_main_include += signature_tools_utils_include
6054aa6d63Sopenharmony_ci  signature_tools_main_include += signature_tools_zip_include
6154aa6d63Sopenharmony_ci
6254aa6d63Sopenharmony_ci  # signature_tools_main_include += signature_tools_entity_include
6354aa6d63Sopenharmony_ci  signature_tools_main_include += signature_tools_codesigning_include
6454aa6d63Sopenharmony_ci  signature_tools_main_include += signature_tools_common_include
6554aa6d63Sopenharmony_ci  signature_tools_main_include += signature_tools_hap_include
6654aa6d63Sopenharmony_ci  signature_tools_main_include += signature_tools_profile_include
6754aa6d63Sopenharmony_ci  signature_tools_main_include += signature_tools_cmd_include
6854aa6d63Sopenharmony_ci
6954aa6d63Sopenharmony_ci  # 在 //developtools/signaturetools/services/utils 模块里面定义编译脚本 signature_tools_utils.gni
7054aa6d63Sopenharmony_ci  signature_tools_main_src += signature_tools_utils_src
7154aa6d63Sopenharmony_ci
7254aa6d63Sopenharmony_ci  # 在 //developtools/signaturetools/services/zip 模块里面定义编译脚本 signature_tools_zip.gni
7354aa6d63Sopenharmony_ci  signature_tools_main_src += signature_tools_zip_src
7454aa6d63Sopenharmony_ci
7554aa6d63Sopenharmony_ci  # signature_tools_main_src += signature_tools_entity_src
7654aa6d63Sopenharmony_ci  signature_tools_main_src += signature_tools_codesigning_src
7754aa6d63Sopenharmony_ci  signature_tools_main_src += signature_tools_common_src
7854aa6d63Sopenharmony_ci  signature_tools_main_src += signature_tools_hap_src
7954aa6d63Sopenharmony_ci  signature_tools_main_src += signature_tools_profile_src
8054aa6d63Sopenharmony_ci  signature_tools_main_src += signature_tools_cmd_src
8154aa6d63Sopenharmony_ci
8254aa6d63Sopenharmony_ci  include_dirs = signature_tools_main_include
8354aa6d63Sopenharmony_ci  sources = signature_tools_main_src
8454aa6d63Sopenharmony_ci
8554aa6d63Sopenharmony_ci  deps = [
8654aa6d63Sopenharmony_ci    "//third_party/bzip2:libbz2",
8754aa6d63Sopenharmony_ci    "//third_party/openssl:libcrypto_shared",
8854aa6d63Sopenharmony_ci    "//third_party/openssl:libssl_shared",
8954aa6d63Sopenharmony_ci    "//third_party/zlib:shared_libz",
9054aa6d63Sopenharmony_ci  ]
9154aa6d63Sopenharmony_ci
9254aa6d63Sopenharmony_ci  external_deps = [
9354aa6d63Sopenharmony_ci    "c_utils:utils",
9454aa6d63Sopenharmony_ci    "json:nlohmann_json_static",
9554aa6d63Sopenharmony_ci  ]
9654aa6d63Sopenharmony_ci
9754aa6d63Sopenharmony_ci  cflags_cc = [
9854aa6d63Sopenharmony_ci    "-std=c++17",
9954aa6d63Sopenharmony_ci    "-fno-rtti",
10054aa6d63Sopenharmony_ci  ]
10154aa6d63Sopenharmony_ci
10254aa6d63Sopenharmony_ci  cflags = [
10354aa6d63Sopenharmony_ci    "-fno-rtti",
10454aa6d63Sopenharmony_ci    "-Wno-c++20-extensions",
10554aa6d63Sopenharmony_ci  ]
10654aa6d63Sopenharmony_ci
10754aa6d63Sopenharmony_ci  install_images = [ "system" ]
10854aa6d63Sopenharmony_ci  install_enable = false
10954aa6d63Sopenharmony_ci  part_name = "hapsigner"
11054aa6d63Sopenharmony_ci  subsystem_name = "developtools"
11154aa6d63Sopenharmony_ci}
112