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", |
| 29 | ], |
Pirama Arumuga Nainar | 53f5945 | 2018-09-18 14:58:17 -0700 | [diff] [blame] | 30 | |
| 31 | // Enable -Wold-style-cast only for non-Windows targets. _islower_l, |
| 32 | // _isupper_l etc. in MinGW locale_win32.h (included from |
| 33 | // libcxx/include/__locale) has an old-style-cast. |
| 34 | target: { |
| 35 | not_windows: { |
| 36 | cppflags: [ |
| 37 | "-Wold-style-cast", |
| 38 | ], |
| 39 | }, |
| 40 | }, |
Nick Kralevich | 30dec07 | 2019-03-20 13:04:02 -0700 | [diff] [blame^] | 41 | sanitize: { |
| 42 | misc_undefined: [ |
| 43 | "signed-integer-overflow", |
| 44 | "unsigned-integer-overflow", |
| 45 | "shift", |
| 46 | "integer-divide-by-zero", |
| 47 | "implicit-signed-integer-truncation", |
| 48 | // TODO: Fix crash when we enable this option |
| 49 | // "implicit-unsigned-integer-truncation", |
| 50 | // TODO: not tested yet. |
| 51 | // "implicit-integer-sign-change", |
| 52 | ], |
| 53 | }, |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | cc_defaults { |
| 57 | name: "libziparchive_defaults", |
| 58 | srcs: [ |
| 59 | "zip_archive.cc", |
| 60 | "zip_archive_stream_entry.cc", |
| 61 | "zip_writer.cc", |
| 62 | ], |
| 63 | |
| 64 | target: { |
| 65 | windows: { |
| 66 | cflags: ["-mno-ms-bitfields"], |
| 67 | |
| 68 | enabled: true, |
| 69 | }, |
| 70 | }, |
| 71 | |
| 72 | shared_libs: [ |
| 73 | "libbase", |
| 74 | "liblog", |
| 75 | ], |
Andreas Gampe | a10a7e7 | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 76 | |
| 77 | export_include_dirs: ["include"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 80 | cc_library { |
| 81 | name: "libziparchive", |
| 82 | host_supported: true, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 83 | vendor_available: true, |
Jiyong Park | 011ee12 | 2018-05-29 16:41:30 +0900 | [diff] [blame] | 84 | recovery_available: true, |
Justin Yun | 096114d | 2017-08-03 15:51:33 +0900 | [diff] [blame] | 85 | vndk: { |
| 86 | enabled: true, |
| 87 | }, |
Jiyong Park | 9168787 | 2018-04-09 12:20:48 +0900 | [diff] [blame] | 88 | double_loadable: true, |
Elliott Hughes | a56a729 | 2018-10-26 10:34:53 -0700 | [diff] [blame] | 89 | export_shared_lib_headers: ["libbase"], |
Jayant Chowdhary | 2c87bcc | 2017-05-16 13:09:54 -0700 | [diff] [blame] | 90 | |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 91 | defaults: [ |
| 92 | "libziparchive_defaults", |
| 93 | "libziparchive_flags", |
| 94 | ], |
| 95 | shared_libs: [ |
| 96 | "liblog", |
| 97 | "libbase", |
Dan Willemsen | 5cfa006 | 2017-09-27 16:24:45 -0700 | [diff] [blame] | 98 | "libz", |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 99 | ], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 100 | target: { |
Dan Willemsen | ab34b47 | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 101 | linux_bionic: { |
Dan Willemsen | ab34b47 | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 102 | enabled: true, |
| 103 | }, |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 104 | }, |
| 105 | } |
| 106 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 107 | // Tests. |
| 108 | cc_test { |
| 109 | name: "ziparchive-tests", |
| 110 | host_supported: true, |
| 111 | defaults: ["libziparchive_flags"], |
| 112 | |
Elliott Hughes | bde0ec9 | 2018-04-25 12:49:19 -0700 | [diff] [blame] | 113 | data: [ |
| 114 | "testdata/**/*", |
| 115 | ], |
| 116 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 117 | srcs: [ |
| 118 | "entry_name_utils_test.cc", |
| 119 | "zip_archive_test.cc", |
| 120 | "zip_writer_test.cc", |
| 121 | ], |
| 122 | shared_libs: [ |
| 123 | "libbase", |
| 124 | "liblog", |
| 125 | ], |
| 126 | |
| 127 | static_libs: [ |
| 128 | "libziparchive", |
| 129 | "libz", |
| 130 | "libutils", |
| 131 | ], |
| 132 | |
| 133 | target: { |
| 134 | host: { |
| 135 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 136 | }, |
| 137 | windows: { |
| 138 | enabled: true, |
| 139 | }, |
| 140 | }, |
Elliott Hughes | e038f49 | 2018-10-29 12:29:34 -0700 | [diff] [blame] | 141 | test_suites: ["device-tests"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 142 | } |
Sebastian Pop | 0a94c56 | 2017-05-30 09:14:20 -0500 | [diff] [blame] | 143 | |
| 144 | // Performance benchmarks. |
| 145 | cc_benchmark { |
| 146 | name: "ziparchive-benchmarks", |
| 147 | defaults: ["libziparchive_flags"], |
| 148 | |
| 149 | srcs: [ |
| 150 | "zip_archive_benchmark.cpp", |
| 151 | ], |
| 152 | shared_libs: [ |
| 153 | "libbase", |
| 154 | "liblog", |
| 155 | ], |
| 156 | |
| 157 | static_libs: [ |
| 158 | "libziparchive", |
| 159 | "libz", |
| 160 | "libutils", |
| 161 | ], |
| 162 | |
| 163 | target: { |
| 164 | host: { |
| 165 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 166 | }, |
| 167 | }, |
| 168 | } |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 169 | |
| 170 | cc_binary { |
| 171 | name: "unzip", |
| 172 | defaults: ["libziparchive_flags"], |
| 173 | srcs: ["unzip.cpp"], |
| 174 | shared_libs: [ |
| 175 | "libbase", |
| 176 | "libziparchive", |
| 177 | ], |
Elliott Hughes | ab08933 | 2018-09-04 13:33:30 -0700 | [diff] [blame] | 178 | recovery_available: true, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 179 | } |