• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (c) 2020 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16import("//third_party/mbedtls/mbedtls.gni")
17
18MBEDTLS_SOURCES += [
19  "library/debug.c",
20  "library/ssl_cache.c",
21  "library/ssl_cookie.c",
22  "library/ssl_srv.c",
23  "library/ssl_ticket.c",
24  "library/x509_create.c",
25  "library/x509_csr.c",
26  "library/x509write_crt.c",
27  "library/x509write_csr.c",
28]
29
30if (defined(ohos_lite)) {
31  import("//build/lite/config/component/lite_component.gni")
32  import("//build/lite/ndk/ndk.gni")
33
34  config("mbedtls_config") {
35    include_dirs = MBEDTLS_INLCUDE_DIRS
36    if (ohos_kernel_type == "liteos_m") {
37      defines += [
38        "__unix__",
39        "MBEDTLS_CONFIG_FILE=<../port/config/config_liteos_m.h>",
40      ]
41    }
42    if (ohos_kernel_type == "liteos_a") {
43      defines += [
44        "__unix__",
45        "MBEDTLS_CONFIG_FILE=<../port/config/config_liteos_a.h>",
46      ]
47    }
48  }
49
50  lite_library("mbedtls_shared") {
51    target_type = "shared_library"
52    public_configs = [ ":mbedtls_config" ]
53    output_name = "mbedtls"
54    sources = MBEDTLS_SOURCES
55  }
56
57  lite_library("mbedtls_static") {
58    target_type = "static_library"
59    public_configs = [ ":mbedtls_config" ]
60    output_name = "mbedtls"
61    sources = MBEDTLS_SOURCES
62  }
63
64  group("mbedtls") {
65    if (ohos_kernel_type == "liteos_m") {
66      if (ohos_security_huks_mbedtls_porting_path != "") {
67        public_deps = [ ohos_security_huks_mbedtls_porting_path ]
68      } else {
69        public_deps = [ ":mbedtls_static" ]
70      }
71    } else {
72      public_deps = [ ":mbedtls_shared" ]
73    }
74  }
75
76  ndk_lib("mbedtls_ndk") {
77    if (ohos_kernel_type == "liteos_m") {
78      lib_extension = ".a"
79    } else {
80      lib_extension = ".so"
81    }
82    deps = [ ":mbedtls" ]
83    head_files = [ "include" ]
84  }
85
86  # for test: test profile
87  if (ohos_build_type == "debug" && ohos_kernel_type != "liteos_m") {
88    config("mbedtls_profile_test") {
89      include_dirs = [
90        "./include",
91        "./configs",  # The directory where the custom configuration file is
92                      # located
93      ]
94      defines = [
95        "MBEDTLS_CONFIG_FILE=<config_rsa_aes_cbc.h>",
96        "__unix__",
97      ]
98      ldflags = [
99        "-s",
100        "-w",
101      ]
102    }
103
104    static_library("mbedtls_gt") {
105      sources = MBEDTLS_SOURCES
106      output_name = "mbedtls_gt"
107      public_configs = [ ":mbedtls_profile_test" ]
108    }
109  }
110} else {
111  import("//build/ohos.gni")
112  config("mbedtls_config") {
113    include_dirs = MBEDTLS_INLCUDE_DIRS
114  }
115
116  ohos_shared_library("mbedtls_shared") {
117    public_configs = [ ":mbedtls_config" ]
118    output_name = "mbedtls"
119    subsystem_name = "common"
120    part_name = "dsoftbus"
121    sources = MBEDTLS_SOURCES
122    install_images = [
123      "system",
124      "updater",
125    ]
126  }
127
128  group("mbedtls") {
129    public_deps = [ ":mbedtls_shared" ]
130  }
131}
132