• 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]
56
57config("nghttp2_lib_config") {
58  include_dirs = [
59    ".",
60    "./includes",
61  ]
62  defines = [
63    "HAVE_ARPA_INET_H=1",
64    "HAVE_TIME_H=1",
65  ]
66}
67
68if (defined(ohos_lite)) {
69  import("//build/lite/config/component/lite_component.gni")
70  import("//build/lite/ndk/ndk.gni")
71
72  lite_library("nghttp2_lib_static") {
73    target_type = "static_library"
74    sources = nghttp2_lib_sources
75    public_configs = [ ":nghttp2_lib_config" ]
76    output_name = "nghttp2"
77  }
78
79  lite_library("nghttp2_lib_shared") {
80    target_type = "shared_library"
81    sources = nghttp2_lib_sources
82    public_configs = [ ":nghttp2_lib_config" ]
83    output_name = "nghttp2"
84  }
85
86  ndk_lib("nghttp2_lib_ndk") {
87    if (ohos_kernel_type == "liteos_m") {
88      lib_extension = ".a"
89      deps = [ ":nghttp2_lib_static" ]
90    } else {
91      lib_extension = ".so"
92      deps = [ ":nghttp2_lib_shared" ]
93    }
94    head_files = [
95      "//third_party/nghttp2/lib",
96      "//third_party/nghttp2/lib/includes",
97    ]
98  }
99} else {
100  import("//build/config/config.gni")
101  import("//build/ohos.gni")
102
103  ohos_static_library("nghttp2") {
104    include_dirs = [ "includes" ]
105    license_file = "//third_party/nghttp2/COPYING"
106    defines = []
107    if (is_linux || is_mac || is_ohos) {
108      defines += [
109        "HAVE_ARPA_INET_H=1",
110        "HAVE_NETINET_IN_H=1",
111      ]
112    }
113    sources = nghttp2_lib_sources
114  }
115
116  ohos_shared_library("libnghttp2_shared") {
117    include_dirs = [ "includes" ]
118    license_file = "//third_party/nghttp2/COPYING"
119    defines = [ "HAVE_TIME_H=1" ]
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    if (current_os == "ios") {
127      ldflags = [
128        "-Wl",
129        "-install_name",
130        "@rpath/libnghttp2.framework/libnghttp2",
131      ]
132      output_name = "nghttp2"
133    }
134    sources = nghttp2_lib_sources
135    if (target_os != "ios") {
136      if (product_name != "ohos-sdk") {
137        version_script = "libnghttp2_shared.map"
138      }
139      install_images = [
140        "system",
141        "updater",
142      ]
143    }
144    subsystem_name = "thirdparty"
145    innerapi_tags = [ "platformsdk" ]
146    part_name = "nghttp2"
147  }
148
149  if (current_os == "ios") {
150    ohos_combine_darwin_framework("libnghttp2") {
151      deps = [ ":libnghttp2_shared" ]
152      subsystem_name = "thirdparty"
153      part_name = "nghttp2"
154    }
155  }
156}
157