• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved.
2
3import("//build/config/config.gni")
4import("//build/ohos.gni")
5import("//build/ohos/ndk/ndk.gni")
6
7config("zlib_config") {
8  cflags = [
9    "-Wno-incompatible-pointer-types",
10    "-Werror",
11    "-Wno-strict-prototypes",
12    "-Wimplicit-function-declaration",
13  ]
14}
15
16config("zlib_public_config") {
17  include_dirs = [
18    ".",
19    "contrib/minizip",
20  ]
21}
22
23ohos_static_library("libz") {
24  sources = [
25    "adler32.c",
26    "compress.c",
27    "contrib/minizip/ioapi.c",
28    "contrib/minizip/unzip.c",
29    "contrib/minizip/zip.c",
30    "crc32.c",
31    "crc32.h",
32    "deflate.c",
33    "deflate.h",
34    "gzclose.c",
35    "gzguts.h",
36    "gzlib.c",
37    "gzread.c",
38    "gzwrite.c",
39    "infback.c",
40    "inffast.c",
41    "inffast.h",
42    "inffixed.h",
43    "inflate.c",
44    "inflate.h",
45    "inftrees.c",
46    "inftrees.h",
47    "trees.c",
48    "trees.h",
49    "uncompr.c",
50    "zconf.h",
51    "zlib.h",
52    "zutil.c",
53    "zutil.h",
54  ]
55  configs = [ ":zlib_config" ]
56  public_configs = [ ":zlib_public_config" ]
57
58  part_name = "zlib"
59  subsystem_name = "thirdparty"
60}
61
62ohos_shared_library("shared_libz") {
63  branch_protector_ret = "pac_ret"
64  sources = [
65    "adler32.c",
66    "compress.c",
67    "contrib/minizip/ioapi.c",
68    "contrib/minizip/unzip.c",
69    "contrib/minizip/zip.c",
70    "crc32.c",
71    "crc32.h",
72    "deflate.c",
73    "deflate.h",
74    "gzclose.c",
75    "gzguts.h",
76    "gzlib.c",
77    "gzread.c",
78    "gzwrite.c",
79    "infback.c",
80    "inffast.c",
81    "inffast.h",
82    "inffixed.h",
83    "inflate.c",
84    "inflate.h",
85    "inftrees.c",
86    "inftrees.h",
87    "trees.c",
88    "trees.h",
89    "uncompr.c",
90    "zconf.h",
91    "zlib.h",
92    "zutil.c",
93    "zutil.h",
94  ]
95  configs = [ ":zlib_config" ]
96  public_configs = [ ":zlib_public_config" ]
97
98  if (current_os == "ios") {
99    ldflags = [
100      "-Wl",
101      "-install_name",
102      "@rpath/libshared_libz.framework/libshared_libz",
103    ]
104  }
105
106  install_images = [
107    "system",
108    "updater",
109  ]
110
111  symlink_target_name = [ "libz.so" ]
112
113  innerapi_tags = [
114    "chipsetsdk",
115    "platformsdk",
116  ]
117  part_name = "zlib"
118  subsystem_name = "thirdparty"
119}
120
121if (current_os == "ios") {
122  ohos_combine_darwin_framework("libshared_libz") {
123    deps = [ ":shared_libz" ]
124    subsystem_name = "thirdparty"
125    part_name = "zlib"
126  }
127}
128
129if (current_cpu == "arm64") {
130  config("zlib_crc_config") {
131    cflags = [
132      "-Wno-incompatible-pointer-types",
133      "-Werror",
134      "-Wno-strict-prototypes",
135      "-Wimplicit-function-declaration",
136      "-march=armv8-a+crc",
137    ]
138  }
139} else {
140  config("zlib_crc_config") {
141    cflags = [
142      "-Wno-incompatible-pointer-types",
143      "-Werror",
144      "-Wno-strict-prototypes",
145      "-Wimplicit-function-declaration",
146    ]
147  }
148}
149
150ohos_static_library("libz_crc") {
151  sources = [
152    "crc32.c",
153    "crc32.h",
154    "zconf.h",
155  ]
156  configs = [ ":zlib_crc_config" ]
157  public_configs = [ ":zlib_public_config" ]
158
159  part_name = "zlib"
160  subsystem_name = "thirdparty"
161}
162