• 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
18if (defined(ohos_lite)) {
19  import("//build/lite/config/component/lite_component.gni")
20  import("//build/lite/ndk/ndk.gni")
21
22  config("mbedtls_config") {
23    include_dirs = MBEDTLS_INLCUDE_DIRS
24    if (ohos_kernel_type == "liteos_m") {
25      defines += [
26        "__unix__",
27        "MBEDTLS_CONFIG_FILE=<../port/config/config_liteos_m.h>",
28      ]
29    }
30    if (ohos_kernel_type == "liteos_a") {
31      defines += [
32        "__unix__",
33        "MBEDTLS_CONFIG_FILE=<../port/config/config_liteos_a.h>",
34      ]
35    }
36  }
37
38  lite_library("mbedtls_shared") {
39    target_type = "shared_library"
40    public_configs = [ ":mbedtls_config" ]
41    output_name = "mbedtls"
42    sources = MBEDTLS_SOURCES
43  }
44
45  lite_library("mbedtls_static") {
46    target_type = "static_library"
47    public_configs = [ ":mbedtls_config" ]
48    output_name = "mbedtls"
49    sources = MBEDTLS_SOURCES
50  }
51
52  group("mbedtls") {
53    if (ohos_kernel_type == "liteos_m") {
54      if (ohos_security_huks_mbedtls_porting_path != "") {
55        public_deps = [ ohos_security_huks_mbedtls_porting_path ]
56      } else {
57        public_deps = [ ":mbedtls_static" ]
58      }
59    } else {
60      public_deps = [ ":mbedtls_shared" ]
61    }
62  }
63
64  ndk_lib("mbedtls_ndk") {
65    if (ohos_kernel_type == "liteos_m") {
66      lib_extension = ".a"
67    } else {
68      lib_extension = ".so"
69    }
70    deps = [ ":mbedtls" ]
71    head_files = [ "include" ]
72  }
73
74  # for test: test profile
75  if (ohos_build_type == "debug" && ohos_kernel_type != "liteos_m") {
76    config("mbedtls_profile_test") {
77      include_dirs = [
78        "./include",
79        "./configs",  # The directory where the custom configuration file is
80                      # located
81      ]
82      defines = [
83        "MBEDTLS_CONFIG_FILE=<config_rsa_aes_cbc.h>",
84        "__unix__",
85      ]
86      ldflags = [
87        "-s",
88        "-w",
89      ]
90    }
91
92    MBEDTLS_SOURCES += [
93      "library/debug.c",
94      "library/pkcs11.c",
95      "library/ssl_cache.c",
96      "library/ssl_cookie.c",
97      "library/ssl_srv.c",
98      "library/ssl_ticket.c",
99      "library/x509_create.c",
100      "library/x509_csr.c",
101      "library/x509write_crt.c",
102      "library/x509write_csr.c",
103    ]
104
105    static_library("mbedtls_gt") {
106      sources = MBEDTLS_SOURCES
107      output_name = "mbedtls_gt"
108      public_configs = [ ":mbedtls_profile_test" ]
109    }
110  }
111} else {
112  import("//build/ohos.gni")
113  config("mbedtls_config") {
114    include_dirs = MBEDTLS_INLCUDE_DIRS
115  }
116
117  ohos_shared_library("mbedtls_shared") {
118    public_configs = [ ":mbedtls_config" ]
119    output_name = "mbedtls"
120    subsystem_name = "common"
121    part_name = "dsoftbus_standard"
122    sources = MBEDTLS_SOURCES
123  }
124
125  group("mbedtls") {
126    public_deps = [ ":mbedtls_shared" ]
127  }
128}
129