• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2023 Huawei Device Co., Ltd. All rights reserved.
2#
3# Redistribution and use in source and binary forms, with or without modification,
4# are permitted provided that the following conditions are met:
5#
6# 1. Redistributions of source code must retain the above copyright notice, this list of
7#    conditions and the following disclaimer.
8#
9# 2. Redistributions in binary form must reproduce the above copyright notice, this list
10#    of conditions and the following disclaimer in the documentation and/or other materials
11#    provided with the distribution.
12#
13# 3. Neither the name of the copyright holder nor the names of its contributors may be used
14#    to endorse or promote products derived from this software without specific prior written
15#    permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29nghttp2_lib_sources = [
30  "nghttp2_alpn.c",
31  "nghttp2_buf.c",
32  "nghttp2_callbacks.c",
33  "nghttp2_debug.c",
34  "nghttp2_extpri.c",
35  "nghttp2_frame.c",
36  "nghttp2_hd.c",
37  "nghttp2_hd_huffman.c",
38  "nghttp2_hd_huffman_data.c",
39  "nghttp2_helper.c",
40  "nghttp2_http.c",
41  "nghttp2_map.c",
42  "nghttp2_mem.c",
43  "nghttp2_option.c",
44  "nghttp2_outbound_item.c",
45  "nghttp2_pq.c",
46  "nghttp2_priority_spec.c",
47  "nghttp2_queue.c",
48  "nghttp2_ratelim.c",
49  "nghttp2_rcbuf.c",
50  "nghttp2_session.c",
51  "nghttp2_stream.c",
52  "nghttp2_submit.c",
53  "nghttp2_time.c",
54  "nghttp2_version.c",
55  "sfparse.c",
56]
57
58llhttp_sources = [
59  "../third-party/llhttp/src/api.c",
60  "../third-party/llhttp/src/http.c",
61  "../third-party/llhttp/src/llhttp.c",
62]
63
64config("nghttp2_lib_config") {
65  include_dirs = [
66    ".",
67    "./includes",
68  ]
69  defines = [ "HAVE_ARPA_INET_H=1" ]
70}
71
72config("llhttp_public_config") {
73  include_dirs = [ "../third-party/llhttp/include" ]
74}
75
76if (defined(ohos_lite)) {
77  import("//build/lite/config/component/lite_component.gni")
78  import("//build/lite/ndk/ndk.gni")
79
80  lite_library("nghttp2_lib_static") {
81    target_type = "static_library"
82    sources = nghttp2_lib_sources
83    public_configs = [ ":nghttp2_lib_config" ]
84    output_name = "nghttp2"
85  }
86
87  lite_library("llhttp_lib_static") {
88    target_type = "static_library"
89    sources = llhttp_sources
90  }
91
92  lite_library("nghttp2_lib_shared") {
93    target_type = "shared_library"
94    sources = nghttp2_lib_sources
95    public_configs = [ ":nghttp2_lib_config" ]
96    output_name = "nghttp2"
97  }
98
99  ndk_lib("nghttp2_lib_ndk") {
100    if (ohos_kernel_type == "liteos_m") {
101      lib_extension = ".a"
102      deps = [ ":nghttp2_lib_static" ]
103    } else {
104      lib_extension = ".so"
105      deps = [ ":nghttp2_lib_shared" ]
106    }
107    head_files = [
108      "//third_party/nghttp2/lib",
109      "//third_party/nghttp2/lib/includes",
110    ]
111  }
112} else {
113  import("//build/config/config.gni")
114  import("//build/ohos.gni")
115
116  ohos_static_library("nghttp2") {
117    include_dirs = [ "includes" ]
118    license_file = "//third_party/nghttp2/COPYING"
119    defines = []
120    if (is_linux || is_mac || is_ohos) {
121      defines += [
122        "HAVE_ARPA_INET_H=1",
123        "HAVE_NETINET_IN_H=1",
124      ]
125    }
126    sources = nghttp2_lib_sources
127  }
128
129  ohos_static_library("libllhttp") {
130    sources = llhttp_sources
131    public_configs = [ ":llhttp_public_config" ]
132  }
133
134  config("libnghttp2_shared_config_public") {
135    include_dirs = [
136      "//third_party/nghttp2/lib/includes",
137      "//third_party/nghttp2/lib/includes/nghttp2",
138    ]
139
140    cflags = [ "-Wno-deprecated-declarations" ]
141  }
142
143  ohos_shared_library("libnghttp2_shared") {
144    include_dirs = [ "includes" ]
145    license_file = "//third_party/nghttp2/COPYING"
146    public_configs = [ ":libnghttp2_shared_config_public" ]
147    defines = [ "HAVE_TIME_H=1" ]
148    if (is_linux || is_mac || is_ohos) {
149      defines += [
150        "HAVE_ARPA_INET_H=1",
151        "HAVE_NETINET_IN_H=1",
152      ]
153    }
154    if (current_os == "ios") {
155      ldflags = [
156        "-Wl",
157        "-install_name",
158        "@rpath/libnghttp2.framework/libnghttp2",
159      ]
160      output_name = "nghttp2"
161    }
162    branch_protector_ret = "pac_ret"
163    sources = nghttp2_lib_sources
164    if (target_os != "ios") {
165      if (product_name != "ohos-sdk") {
166        version_script = "libnghttp2_shared.map"
167      }
168      install_images = [
169        "system",
170        "updater",
171      ]
172    }
173    subsystem_name = "thirdparty"
174    innerapi_tags = [ "platformsdk" ]
175    part_name = "nghttp2"
176  }
177
178  if (current_os == "ios") {
179    ohos_combine_darwin_framework("libnghttp2") {
180      deps = [ ":libnghttp2_shared" ]
181      subsystem_name = "thirdparty"
182      part_name = "nghttp2"
183    }
184  }
185}
186