xref: /aosp_15_r20/external/tflite-support/third_party/libzip.BUILD (revision b16991f985baa50654c05c5adbb3c8bbcfb40082)
1*b16991f9SAndroid Build Coastguard Workerpackage(
2*b16991f9SAndroid Build Coastguard Worker    default_visibility = ["//visibility:public"],
3*b16991f9SAndroid Build Coastguard Worker)
4*b16991f9SAndroid Build Coastguard Worker
5*b16991f9SAndroid Build Coastguard Workerload("@org_tensorflow_lite_support//tensorflow_lite_support/tools:build_rules/expand_template.bzl", "cmake_substitutions", "expand_template")
6*b16991f9SAndroid Build Coastguard Worker
7*b16991f9SAndroid Build Coastguard Worker_CMAKE_VARIABLES = {
8*b16991f9SAndroid Build Coastguard Worker    "INT16_T_LIBZIP": 2,
9*b16991f9SAndroid Build Coastguard Worker    "INT32_T_LIBZIP": 4,
10*b16991f9SAndroid Build Coastguard Worker    "INT64_T_LIBZIP": 8,
11*b16991f9SAndroid Build Coastguard Worker    "INT8_T_LIBZIP": 1,
12*b16991f9SAndroid Build Coastguard Worker    "INT_LIBZIP": 4,
13*b16991f9SAndroid Build Coastguard Worker    "LIBZIP_TYPES_INCLUDE": "#include <stdint.h>",
14*b16991f9SAndroid Build Coastguard Worker    "LONG_LIBZIP": 8,
15*b16991f9SAndroid Build Coastguard Worker    "LONG_LONG_LIBZIP": 8,
16*b16991f9SAndroid Build Coastguard Worker    "PACKAGE_VERSION": "1.5.1",
17*b16991f9SAndroid Build Coastguard Worker    "PACKAGE_VERSION_MAJOR": "1",
18*b16991f9SAndroid Build Coastguard Worker    "PACKAGE_VERSION_MICRO": "1",
19*b16991f9SAndroid Build Coastguard Worker    "PACKAGE_VERSION_MINOR": "5",
20*b16991f9SAndroid Build Coastguard Worker    "SHORT_LIBZIP": 2,
21*b16991f9SAndroid Build Coastguard Worker    "SIZEOF_OFF_T": 8,
22*b16991f9SAndroid Build Coastguard Worker    "SIZE_T_LIBZIP": 8,
23*b16991f9SAndroid Build Coastguard Worker    "SSIZE_T_LIBZIP": 8,
24*b16991f9SAndroid Build Coastguard Worker    "UINT16_T_LIBZIP": 2,
25*b16991f9SAndroid Build Coastguard Worker    "UINT32_T_LIBZIP": 4,
26*b16991f9SAndroid Build Coastguard Worker    "UINT64_T_LIBZIP": 8,
27*b16991f9SAndroid Build Coastguard Worker    "UINT8_T_LIBZIP": 1,
28*b16991f9SAndroid Build Coastguard Worker    "__INT16_LIBZIP": None,
29*b16991f9SAndroid Build Coastguard Worker    "__INT32_LIBZIP": None,
30*b16991f9SAndroid Build Coastguard Worker    "__INT64_LIBZIP": None,
31*b16991f9SAndroid Build Coastguard Worker    "__INT8_LIBZIP": None,
32*b16991f9SAndroid Build Coastguard Worker}
33*b16991f9SAndroid Build Coastguard Worker
34*b16991f9SAndroid Build Coastguard Worker_CMAKE_VARIABLES.update(dict([
35*b16991f9SAndroid Build Coastguard Worker    (
36*b16991f9SAndroid Build Coastguard Worker        "ZIP_{sign}INT{size}_T".format(
37*b16991f9SAndroid Build Coastguard Worker            sign = sign.upper(),
38*b16991f9SAndroid Build Coastguard Worker            size = size,
39*b16991f9SAndroid Build Coastguard Worker        ),
40*b16991f9SAndroid Build Coastguard Worker        "{sign}int{size}_t".format(
41*b16991f9SAndroid Build Coastguard Worker            sign = sign.lower(),
42*b16991f9SAndroid Build Coastguard Worker            size = size,
43*b16991f9SAndroid Build Coastguard Worker        ),
44*b16991f9SAndroid Build Coastguard Worker    )
45*b16991f9SAndroid Build Coastguard Worker    for sign in ("U", "")
46*b16991f9SAndroid Build Coastguard Worker    for size in (8, 16, 32, 64)
47*b16991f9SAndroid Build Coastguard Worker]))
48*b16991f9SAndroid Build Coastguard Worker
49*b16991f9SAndroid Build Coastguard Worker_SUBSTITUTIONS = {
50*b16991f9SAndroid Build Coastguard Worker    "@PACKAGE@": "libzip",
51*b16991f9SAndroid Build Coastguard Worker    "@VERSION@": "1.5.1",  # Keep in sync with actual package!
52*b16991f9SAndroid Build Coastguard Worker}
53*b16991f9SAndroid Build Coastguard Worker
54*b16991f9SAndroid Build Coastguard Worker_DEFINES = {
55*b16991f9SAndroid Build Coastguard Worker    "HAVE_CLONEFILE": False,
56*b16991f9SAndroid Build Coastguard Worker    "HAVE_COMMONCRYPTO": False,
57*b16991f9SAndroid Build Coastguard Worker    "HAVE_CRYPTO": False,
58*b16991f9SAndroid Build Coastguard Worker    "HAVE_DIRENT_H": False,
59*b16991f9SAndroid Build Coastguard Worker    "HAVE_FICLONERANGE": False,
60*b16991f9SAndroid Build Coastguard Worker    "HAVE_FILENO": True,
61*b16991f9SAndroid Build Coastguard Worker    "HAVE_FSEEK": True,
62*b16991f9SAndroid Build Coastguard Worker    "HAVE_FSEEKO": True,
63*b16991f9SAndroid Build Coastguard Worker    "HAVE_FTELLO": True,
64*b16991f9SAndroid Build Coastguard Worker    "HAVE_FTS_H": True,
65*b16991f9SAndroid Build Coastguard Worker    "HAVE_GETPROGNAME": False,
66*b16991f9SAndroid Build Coastguard Worker    "HAVE_GNUTLS": False,
67*b16991f9SAndroid Build Coastguard Worker    "HAVE_LIBBZ2": False,
68*b16991f9SAndroid Build Coastguard Worker    "HAVE_MKSTEMP": True,
69*b16991f9SAndroid Build Coastguard Worker    "HAVE_NDIR_H": False,
70*b16991f9SAndroid Build Coastguard Worker    "HAVE_OPEN": True,
71*b16991f9SAndroid Build Coastguard Worker    "HAVE_OPENSSL": False,
72*b16991f9SAndroid Build Coastguard Worker    "HAVE_SETMODE": False,
73*b16991f9SAndroid Build Coastguard Worker    "HAVE_SHARED": True,
74*b16991f9SAndroid Build Coastguard Worker    "HAVE_SNPRINTF": True,
75*b16991f9SAndroid Build Coastguard Worker    "HAVE_SSIZE_T_LIBZIP": True,
76*b16991f9SAndroid Build Coastguard Worker    "HAVE_STDBOOL_H": True,
77*b16991f9SAndroid Build Coastguard Worker    "HAVE_STRCASECMP": True,
78*b16991f9SAndroid Build Coastguard Worker    "HAVE_STRDUP": True,
79*b16991f9SAndroid Build Coastguard Worker    "HAVE_STRICMP": False,
80*b16991f9SAndroid Build Coastguard Worker    "HAVE_STRINGS_H": True,
81*b16991f9SAndroid Build Coastguard Worker    "HAVE_STRTOLL": True,
82*b16991f9SAndroid Build Coastguard Worker    "HAVE_STRTOULL": True,
83*b16991f9SAndroid Build Coastguard Worker    "HAVE_STRUCT_TM_TM_ZONE": False,
84*b16991f9SAndroid Build Coastguard Worker    "HAVE_SYS_DIR_H": False,
85*b16991f9SAndroid Build Coastguard Worker    "HAVE_SYS_NDIR_H": False,
86*b16991f9SAndroid Build Coastguard Worker    "HAVE_UNISTD_H": True,
87*b16991f9SAndroid Build Coastguard Worker    "HAVE__CHMOD": False,
88*b16991f9SAndroid Build Coastguard Worker    "HAVE__CLOSE": False,
89*b16991f9SAndroid Build Coastguard Worker    "HAVE__DUP": False,
90*b16991f9SAndroid Build Coastguard Worker    "HAVE__FDOPEN": False,
91*b16991f9SAndroid Build Coastguard Worker    "HAVE__FILENO": False,
92*b16991f9SAndroid Build Coastguard Worker    "HAVE__OPEN": False,
93*b16991f9SAndroid Build Coastguard Worker    "HAVE__SETMODE": False,
94*b16991f9SAndroid Build Coastguard Worker    "HAVE__SNPRINTF": False,
95*b16991f9SAndroid Build Coastguard Worker    "HAVE__STRDUP": False,
96*b16991f9SAndroid Build Coastguard Worker    "HAVE__STRICMP": False,
97*b16991f9SAndroid Build Coastguard Worker    "HAVE__STRTOI64": False,
98*b16991f9SAndroid Build Coastguard Worker    "HAVE__STRTOUI64": False,
99*b16991f9SAndroid Build Coastguard Worker    "HAVE__UMASK": False,
100*b16991f9SAndroid Build Coastguard Worker    "HAVE__UNLINK": False,
101*b16991f9SAndroid Build Coastguard Worker    "HAVE___PROGNAME": False,
102*b16991f9SAndroid Build Coastguard Worker    "WORDS_BIGENDIAN": False,
103*b16991f9SAndroid Build Coastguard Worker}
104*b16991f9SAndroid Build Coastguard Worker
105*b16991f9SAndroid Build Coastguard Worker_DEFINES.update(dict([(
106*b16991f9SAndroid Build Coastguard Worker    key,
107*b16991f9SAndroid Build Coastguard Worker    value != None,
108*b16991f9SAndroid Build Coastguard Worker) for key, value in _CMAKE_VARIABLES.items()]))
109*b16991f9SAndroid Build Coastguard Worker
110*b16991f9SAndroid Build Coastguard Worker_SUBSTITUTIONS.update(cmake_substitutions(
111*b16991f9SAndroid Build Coastguard Worker    defines = _DEFINES,
112*b16991f9SAndroid Build Coastguard Worker    vars = _CMAKE_VARIABLES,
113*b16991f9SAndroid Build Coastguard Worker))
114*b16991f9SAndroid Build Coastguard Worker
115*b16991f9SAndroid Build Coastguard Workerexpand_template(
116*b16991f9SAndroid Build Coastguard Worker    name = "config_h",
117*b16991f9SAndroid Build Coastguard Worker    out = "config.h",
118*b16991f9SAndroid Build Coastguard Worker    substitutions = _SUBSTITUTIONS,
119*b16991f9SAndroid Build Coastguard Worker    template = "cmake-config.h.in",
120*b16991f9SAndroid Build Coastguard Worker)
121*b16991f9SAndroid Build Coastguard Worker
122*b16991f9SAndroid Build Coastguard Worker_VARS = {
123*b16991f9SAndroid Build Coastguard Worker    "LIBZIP_TYPES_INCLUDE": "#include <stdint.h>",
124*b16991f9SAndroid Build Coastguard Worker    "PACKAGE_VERSION": "1.5.1",
125*b16991f9SAndroid Build Coastguard Worker    "PACKAGE_VERSION_MAJOR": "1",
126*b16991f9SAndroid Build Coastguard Worker    "PACKAGE_VERSION_MICRO": "1",
127*b16991f9SAndroid Build Coastguard Worker    "PACKAGE_VERSION_MINOR": "5",
128*b16991f9SAndroid Build Coastguard Worker}
129*b16991f9SAndroid Build Coastguard Worker
130*b16991f9SAndroid Build Coastguard Worker_VARS.update(dict([
131*b16991f9SAndroid Build Coastguard Worker    (
132*b16991f9SAndroid Build Coastguard Worker        "ZIP_{sign}INT{size}_T".format(
133*b16991f9SAndroid Build Coastguard Worker            sign = sign.upper(),
134*b16991f9SAndroid Build Coastguard Worker            size = size,
135*b16991f9SAndroid Build Coastguard Worker        ),
136*b16991f9SAndroid Build Coastguard Worker        "{sign}int{size}_t".format(
137*b16991f9SAndroid Build Coastguard Worker            sign = sign.lower(),
138*b16991f9SAndroid Build Coastguard Worker            size = size,
139*b16991f9SAndroid Build Coastguard Worker        ),
140*b16991f9SAndroid Build Coastguard Worker    )
141*b16991f9SAndroid Build Coastguard Worker    for sign in ("U", "")
142*b16991f9SAndroid Build Coastguard Worker    for size in (8, 16, 32, 64)
143*b16991f9SAndroid Build Coastguard Worker]))
144*b16991f9SAndroid Build Coastguard Worker
145*b16991f9SAndroid Build Coastguard Workerexpand_template(
146*b16991f9SAndroid Build Coastguard Worker    name = "zipconf_h",
147*b16991f9SAndroid Build Coastguard Worker    out = "lib/zipconf.h",
148*b16991f9SAndroid Build Coastguard Worker    substitutions = cmake_substitutions(
149*b16991f9SAndroid Build Coastguard Worker        defines = {
150*b16991f9SAndroid Build Coastguard Worker            "LIBZIP_VERSION": True,
151*b16991f9SAndroid Build Coastguard Worker            "LIBZIP_VERSION_MAJOR": True,
152*b16991f9SAndroid Build Coastguard Worker            "LIBZIP_VERSION_MICRO": True,
153*b16991f9SAndroid Build Coastguard Worker            "LIBZIP_VERSION_MINOR": True,
154*b16991f9SAndroid Build Coastguard Worker            "ZIP_STATIC": False,
155*b16991f9SAndroid Build Coastguard Worker        },
156*b16991f9SAndroid Build Coastguard Worker        vars = _VARS,
157*b16991f9SAndroid Build Coastguard Worker    ),
158*b16991f9SAndroid Build Coastguard Worker    template = "cmake-zipconf.h.in",
159*b16991f9SAndroid Build Coastguard Worker)
160*b16991f9SAndroid Build Coastguard Worker
161*b16991f9SAndroid Build Coastguard Workercc_library(
162*b16991f9SAndroid Build Coastguard Worker    name = "zip",
163*b16991f9SAndroid Build Coastguard Worker    srcs = glob(
164*b16991f9SAndroid Build Coastguard Worker        [
165*b16991f9SAndroid Build Coastguard Worker            "lib/*.c",
166*b16991f9SAndroid Build Coastguard Worker            "lib/*.h",
167*b16991f9SAndroid Build Coastguard Worker        ],
168*b16991f9SAndroid Build Coastguard Worker        exclude = [
169*b16991f9SAndroid Build Coastguard Worker            "lib/*win32*",
170*b16991f9SAndroid Build Coastguard Worker            "lib/zip_random_uwp.c",
171*b16991f9SAndroid Build Coastguard Worker            "lib/*crypto*",
172*b16991f9SAndroid Build Coastguard Worker            "lib/*aes*",
173*b16991f9SAndroid Build Coastguard Worker            "lib/*bzip2*",
174*b16991f9SAndroid Build Coastguard Worker        ],
175*b16991f9SAndroid Build Coastguard Worker    ) + [
176*b16991f9SAndroid Build Coastguard Worker        "config.h",
177*b16991f9SAndroid Build Coastguard Worker    ],
178*b16991f9SAndroid Build Coastguard Worker    hdrs = [
179*b16991f9SAndroid Build Coastguard Worker        "lib/zip.h",
180*b16991f9SAndroid Build Coastguard Worker        "lib/zipconf.h",
181*b16991f9SAndroid Build Coastguard Worker    ],
182*b16991f9SAndroid Build Coastguard Worker    copts = [
183*b16991f9SAndroid Build Coastguard Worker        "-DHAVE_CONFIG_H",
184*b16991f9SAndroid Build Coastguard Worker    ],
185*b16991f9SAndroid Build Coastguard Worker    includes = ["lib"],
186*b16991f9SAndroid Build Coastguard Worker    deps = [
187*b16991f9SAndroid Build Coastguard Worker        "@zlib",
188*b16991f9SAndroid Build Coastguard Worker    ],
189*b16991f9SAndroid Build Coastguard Worker)
190