• 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_buf.c",
31  "nghttp2_callbacks.c",
32  "nghttp2_debug.c",
33  "nghttp2_extpri.c",
34  "nghttp2_frame.c",
35  "nghttp2_hd.c",
36  "nghttp2_hd_huffman.c",
37  "nghttp2_hd_huffman_data.c",
38  "nghttp2_helper.c",
39  "nghttp2_http.c",
40  "nghttp2_map.c",
41  "nghttp2_mem.c",
42  "nghttp2_npn.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
58config("nghttp2_lib_config") {
59  include_dirs = [
60    ".",
61    "./includes",
62  ]
63  defines = [ "HAVE_ARPA_INET_H=1" ]
64}
65
66if (defined(ohos_lite)) {
67  import("//build/lite/config/component/lite_component.gni")
68  import("//build/lite/ndk/ndk.gni")
69
70  lite_library("nghttp2_lib_static") {
71    target_type = "static_library"
72    sources = nghttp2_lib_sources
73    public_configs = [ ":nghttp2_lib_config" ]
74    output_name = "nghttp2"
75  }
76
77  lite_library("nghttp2_lib_shared") {
78    target_type = "shared_library"
79    sources = nghttp2_lib_sources
80    public_configs = [ ":nghttp2_lib_config" ]
81    output_name = "nghttp2"
82  }
83
84  ndk_lib("nghttp2_lib_ndk") {
85    if (ohos_kernel_type == "liteos_m") {
86      lib_extension = ".a"
87      deps = [ ":nghttp2_lib_static" ]
88    } else {
89      lib_extension = ".so"
90      deps = [ ":nghttp2_lib_shared" ]
91    }
92    head_files = [
93      "//third_party/nghttp2/lib",
94      "//third_party/nghttp2/lib/includes",
95    ]
96  }
97} else {
98  import("//build/config/config.gni")
99  import("//build/ohos.gni")
100
101  ohos_static_library("nghttp2") {
102    include_dirs = [ "includes" ]
103    license_file = "//third_party/nghttp2/COPYING"
104    defines = []
105    if (is_linux || is_mac || is_ohos) {
106      defines += [
107        "HAVE_ARPA_INET_H=1",
108        "HAVE_NETINET_IN_H=1",
109      ]
110    }
111    sources = nghttp2_lib_sources
112  }
113
114  config("libnghttp2_shared_config_public") {
115    include_dirs = [
116      "//third_party/nghttp2/lib/includes",
117      "//third_party/nghttp2/lib/includes/nghttp2",
118    ]
119
120    cflags = [ "-Wno-deprecated-declarations" ]
121  }
122
123  ohos_shared_library("libnghttp2_shared") {
124    include_dirs = [ "includes" ]
125    license_file = "//third_party/nghttp2/COPYING"
126    public_configs = [ ":libnghttp2_shared_config_public" ]
127    defines = [ "HAVE_TIME_H=1" ]
128    if (is_linux || is_mac || is_ohos) {
129      defines += [
130        "HAVE_ARPA_INET_H=1",
131        "HAVE_NETINET_IN_H=1",
132      ]
133    }
134    if (current_os == "ios") {
135      ldflags = [
136        "-Wl",
137        "-install_name",
138        "@rpath/libnghttp2.framework/libnghttp2",
139      ]
140      output_name = "nghttp2"
141    }
142    sources = nghttp2_lib_sources
143    if (target_os != "ios") {
144      if (product_name != "ohos-sdk") {
145        version_script = "libnghttp2_shared.map"
146      }
147      install_images = [
148        "system",
149        "updater",
150      ]
151    }
152    subsystem_name = "thirdparty"
153    innerapi_tags = [ "platformsdk" ]
154    part_name = "nghttp2"
155  }
156
157  if (current_os == "ios") {
158    ohos_combine_darwin_framework("libnghttp2") {
159      deps = [ ":libnghttp2_shared" ]
160      subsystem_name = "thirdparty"
161      part_name = "nghttp2"
162    }
163  }
164}
165