Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2013 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | cc_defaults { |
| 17 | name: "libziparchive_flags", |
| 18 | cflags: [ |
| 19 | // ZLIB_CONST turns on const for input buffers, which is pretty standard. |
| 20 | "-DZLIB_CONST", |
| 21 | "-Werror", |
| 22 | "-Wall", |
Christian Poetzsch | 3081c5e | 2016-12-20 16:13:41 +0000 | [diff] [blame] | 23 | "-D_FILE_OFFSET_BITS=64", |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 24 | ], |
| 25 | cppflags: [ |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 26 | // Incorrectly warns when C++11 empty brace {} initializer is used. |
| 27 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489 |
| 28 | "-Wno-missing-field-initializers", |
Andreas Gampe | 964b95c | 2019-04-05 13:48:02 -0700 | [diff] [blame] | 29 | "-Wconversion", |
| 30 | "-Wno-sign-conversion", |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 31 | ], |
Pirama Arumuga Nainar | 53f5945 | 2018-09-18 14:58:17 -0700 | [diff] [blame] | 32 | |
| 33 | // Enable -Wold-style-cast only for non-Windows targets. _islower_l, |
| 34 | // _isupper_l etc. in MinGW locale_win32.h (included from |
| 35 | // libcxx/include/__locale) has an old-style-cast. |
| 36 | target: { |
| 37 | not_windows: { |
| 38 | cppflags: [ |
| 39 | "-Wold-style-cast", |
| 40 | ], |
| 41 | }, |
| 42 | }, |
Nick Kralevich | 30dec07 | 2019-03-20 13:04:02 -0700 | [diff] [blame] | 43 | sanitize: { |
| 44 | misc_undefined: [ |
| 45 | "signed-integer-overflow", |
| 46 | "unsigned-integer-overflow", |
| 47 | "shift", |
| 48 | "integer-divide-by-zero", |
| 49 | "implicit-signed-integer-truncation", |
| 50 | // TODO: Fix crash when we enable this option |
| 51 | // "implicit-unsigned-integer-truncation", |
| 52 | // TODO: not tested yet. |
| 53 | // "implicit-integer-sign-change", |
| 54 | ], |
| 55 | }, |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | cc_defaults { |
| 59 | name: "libziparchive_defaults", |
| 60 | srcs: [ |
| 61 | "zip_archive.cc", |
| 62 | "zip_archive_stream_entry.cc", |
| 63 | "zip_writer.cc", |
| 64 | ], |
| 65 | |
| 66 | target: { |
| 67 | windows: { |
| 68 | cflags: ["-mno-ms-bitfields"], |
| 69 | |
| 70 | enabled: true, |
| 71 | }, |
| 72 | }, |
| 73 | |
| 74 | shared_libs: [ |
| 75 | "libbase", |
| 76 | "liblog", |
| 77 | ], |
Andreas Gampe | a10a7e7 | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 78 | |
| 79 | export_include_dirs: ["include"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 82 | cc_library { |
| 83 | name: "libziparchive", |
| 84 | host_supported: true, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 85 | vendor_available: true, |
Jiyong Park | 011ee12 | 2018-05-29 16:41:30 +0900 | [diff] [blame] | 86 | recovery_available: true, |
dimitry | a808b11 | 2019-05-06 14:01:58 +0200 | [diff] [blame] | 87 | native_bridge_supported: true, |
Justin Yun | 096114d | 2017-08-03 15:51:33 +0900 | [diff] [blame] | 88 | vndk: { |
| 89 | enabled: true, |
| 90 | }, |
Jiyong Park | 9168787 | 2018-04-09 12:20:48 +0900 | [diff] [blame] | 91 | double_loadable: true, |
Elliott Hughes | a56a729 | 2018-10-26 10:34:53 -0700 | [diff] [blame] | 92 | export_shared_lib_headers: ["libbase"], |
Jayant Chowdhary | 2c87bcc | 2017-05-16 13:09:54 -0700 | [diff] [blame] | 93 | |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 94 | defaults: [ |
| 95 | "libziparchive_defaults", |
| 96 | "libziparchive_flags", |
| 97 | ], |
| 98 | shared_libs: [ |
| 99 | "liblog", |
| 100 | "libbase", |
Dan Willemsen | 5cfa006 | 2017-09-27 16:24:45 -0700 | [diff] [blame] | 101 | "libz", |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 102 | ], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 103 | target: { |
Dan Willemsen | ab34b47 | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 104 | linux_bionic: { |
Dan Willemsen | ab34b47 | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 105 | enabled: true, |
| 106 | }, |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 107 | }, |
| 108 | } |
| 109 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 110 | // Tests. |
| 111 | cc_test { |
| 112 | name: "ziparchive-tests", |
| 113 | host_supported: true, |
| 114 | defaults: ["libziparchive_flags"], |
| 115 | |
Elliott Hughes | bde0ec9 | 2018-04-25 12:49:19 -0700 | [diff] [blame] | 116 | data: [ |
| 117 | "testdata/**/*", |
| 118 | ], |
| 119 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 120 | srcs: [ |
| 121 | "entry_name_utils_test.cc", |
| 122 | "zip_archive_test.cc", |
| 123 | "zip_writer_test.cc", |
| 124 | ], |
| 125 | shared_libs: [ |
| 126 | "libbase", |
| 127 | "liblog", |
| 128 | ], |
| 129 | |
| 130 | static_libs: [ |
| 131 | "libziparchive", |
| 132 | "libz", |
| 133 | "libutils", |
| 134 | ], |
| 135 | |
| 136 | target: { |
| 137 | host: { |
| 138 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 139 | }, |
| 140 | windows: { |
| 141 | enabled: true, |
| 142 | }, |
| 143 | }, |
Elliott Hughes | e038f49 | 2018-10-29 12:29:34 -0700 | [diff] [blame] | 144 | test_suites: ["device-tests"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 145 | } |
Sebastian Pop | 0a94c56 | 2017-05-30 09:14:20 -0500 | [diff] [blame] | 146 | |
| 147 | // Performance benchmarks. |
| 148 | cc_benchmark { |
| 149 | name: "ziparchive-benchmarks", |
| 150 | defaults: ["libziparchive_flags"], |
| 151 | |
| 152 | srcs: [ |
| 153 | "zip_archive_benchmark.cpp", |
| 154 | ], |
| 155 | shared_libs: [ |
| 156 | "libbase", |
| 157 | "liblog", |
| 158 | ], |
| 159 | |
| 160 | static_libs: [ |
| 161 | "libziparchive", |
| 162 | "libz", |
| 163 | "libutils", |
| 164 | ], |
| 165 | |
| 166 | target: { |
| 167 | host: { |
| 168 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 169 | }, |
| 170 | }, |
| 171 | } |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 172 | |
| 173 | cc_binary { |
| 174 | name: "unzip", |
| 175 | defaults: ["libziparchive_flags"], |
| 176 | srcs: ["unzip.cpp"], |
| 177 | shared_libs: [ |
| 178 | "libbase", |
| 179 | "libziparchive", |
| 180 | ], |
Elliott Hughes | ab08933 | 2018-09-04 13:33:30 -0700 | [diff] [blame] | 181 | recovery_available: true, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 182 | } |