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: [ |
| 26 | "-Wold-style-cast", |
| 27 | // Incorrectly warns when C++11 empty brace {} initializer is used. |
| 28 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489 |
| 29 | "-Wno-missing-field-initializers", |
| 30 | ], |
| 31 | } |
| 32 | |
| 33 | cc_defaults { |
| 34 | name: "libziparchive_defaults", |
| 35 | srcs: [ |
| 36 | "zip_archive.cc", |
| 37 | "zip_archive_stream_entry.cc", |
| 38 | "zip_writer.cc", |
| 39 | ], |
| 40 | |
| 41 | target: { |
| 42 | windows: { |
| 43 | cflags: ["-mno-ms-bitfields"], |
| 44 | |
| 45 | enabled: true, |
| 46 | }, |
| 47 | }, |
| 48 | |
| 49 | shared_libs: [ |
| 50 | "libbase", |
| 51 | "liblog", |
| 52 | ], |
Andreas Gampe | a10a7e7 | 2017-07-05 22:02:54 -0700 | [diff] [blame] | 53 | |
| 54 | export_include_dirs: ["include"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 57 | cc_library { |
| 58 | name: "libziparchive", |
| 59 | host_supported: true, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 60 | vendor_available: true, |
Justin Yun | 096114d | 2017-08-03 15:51:33 +0900 | [diff] [blame] | 61 | vndk: { |
| 62 | enabled: true, |
| 63 | }, |
Jayant Chowdhary | 2c87bcc | 2017-05-16 13:09:54 -0700 | [diff] [blame] | 64 | |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 65 | defaults: [ |
| 66 | "libziparchive_defaults", |
| 67 | "libziparchive_flags", |
| 68 | ], |
| 69 | shared_libs: [ |
| 70 | "liblog", |
| 71 | "libbase", |
| 72 | ], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 73 | target: { |
| 74 | android: { |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 75 | shared_libs: [ |
| 76 | "libz", |
| 77 | "libutils", |
| 78 | ], |
Jaekyun Seok | 86e80b9 | 2016-12-21 14:22:00 +0900 | [diff] [blame] | 79 | }, |
| 80 | host: { |
| 81 | static_libs: ["libutils"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 82 | }, |
Dan Willemsen | ab34b47 | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 83 | linux_bionic: { |
| 84 | static_libs: ["libz"], |
| 85 | enabled: true, |
| 86 | }, |
| 87 | linux: { |
| 88 | shared_libs: ["libz-host"], |
| 89 | }, |
| 90 | darwin: { |
| 91 | shared_libs: ["libz-host"], |
| 92 | }, |
| 93 | windows: { |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 94 | shared_libs: ["libz-host"], |
| 95 | }, |
| 96 | }, |
| 97 | } |
| 98 | |
| 99 | // Also provide libziparchive-host until everything is switched over to using libziparchive |
| 100 | cc_library { |
| 101 | name: "libziparchive-host", |
| 102 | host_supported: true, |
| 103 | device_supported: false, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 104 | defaults: [ |
| 105 | "libziparchive_defaults", |
| 106 | "libziparchive_flags", |
| 107 | ], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 108 | shared_libs: ["libz-host"], |
| 109 | static_libs: ["libutils"], |
| 110 | } |
| 111 | |
| 112 | // Tests. |
| 113 | cc_test { |
| 114 | name: "ziparchive-tests", |
| 115 | host_supported: true, |
| 116 | defaults: ["libziparchive_flags"], |
| 117 | |
| 118 | srcs: [ |
| 119 | "entry_name_utils_test.cc", |
| 120 | "zip_archive_test.cc", |
| 121 | "zip_writer_test.cc", |
| 122 | ], |
| 123 | shared_libs: [ |
| 124 | "libbase", |
| 125 | "liblog", |
| 126 | ], |
| 127 | |
| 128 | static_libs: [ |
| 129 | "libziparchive", |
| 130 | "libz", |
| 131 | "libutils", |
| 132 | ], |
| 133 | |
| 134 | target: { |
| 135 | host: { |
| 136 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 137 | }, |
| 138 | windows: { |
| 139 | enabled: true, |
| 140 | }, |
| 141 | }, |
| 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 | ], |
| 178 | } |