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, |
Jayant Chowdhary | 2c87bcc | 2017-05-16 13:09:54 -0700 | [diff] [blame] | 61 | |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 62 | defaults: [ |
| 63 | "libziparchive_defaults", |
| 64 | "libziparchive_flags", |
| 65 | ], |
| 66 | shared_libs: [ |
| 67 | "liblog", |
| 68 | "libbase", |
| 69 | ], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 70 | target: { |
| 71 | android: { |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 72 | shared_libs: [ |
| 73 | "libz", |
| 74 | "libutils", |
| 75 | ], |
Jaekyun Seok | 86e80b9 | 2016-12-21 14:22:00 +0900 | [diff] [blame] | 76 | }, |
| 77 | host: { |
| 78 | static_libs: ["libutils"], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 79 | }, |
Dan Willemsen | ab34b47 | 2016-11-29 13:32:55 -0800 | [diff] [blame] | 80 | linux_bionic: { |
| 81 | static_libs: ["libz"], |
| 82 | enabled: true, |
| 83 | }, |
| 84 | linux: { |
| 85 | shared_libs: ["libz-host"], |
| 86 | }, |
| 87 | darwin: { |
| 88 | shared_libs: ["libz-host"], |
| 89 | }, |
| 90 | windows: { |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 91 | shared_libs: ["libz-host"], |
| 92 | }, |
| 93 | }, |
| 94 | } |
| 95 | |
| 96 | // Also provide libziparchive-host until everything is switched over to using libziparchive |
| 97 | cc_library { |
| 98 | name: "libziparchive-host", |
| 99 | host_supported: true, |
| 100 | device_supported: false, |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 101 | defaults: [ |
| 102 | "libziparchive_defaults", |
| 103 | "libziparchive_flags", |
| 104 | ], |
Colin Cross | 45566ba | 2016-07-12 18:45:19 -0700 | [diff] [blame] | 105 | shared_libs: ["libz-host"], |
| 106 | static_libs: ["libutils"], |
| 107 | } |
| 108 | |
| 109 | // Tests. |
| 110 | cc_test { |
| 111 | name: "ziparchive-tests", |
| 112 | host_supported: true, |
| 113 | defaults: ["libziparchive_flags"], |
| 114 | |
| 115 | srcs: [ |
| 116 | "entry_name_utils_test.cc", |
| 117 | "zip_archive_test.cc", |
| 118 | "zip_writer_test.cc", |
| 119 | ], |
| 120 | shared_libs: [ |
| 121 | "libbase", |
| 122 | "liblog", |
| 123 | ], |
| 124 | |
| 125 | static_libs: [ |
| 126 | "libziparchive", |
| 127 | "libz", |
| 128 | "libutils", |
| 129 | ], |
| 130 | |
| 131 | target: { |
| 132 | host: { |
| 133 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 134 | }, |
| 135 | windows: { |
| 136 | enabled: true, |
| 137 | }, |
| 138 | }, |
| 139 | } |
Sebastian Pop | 0a94c56 | 2017-05-30 09:14:20 -0500 | [diff] [blame] | 140 | |
| 141 | // Performance benchmarks. |
| 142 | cc_benchmark { |
| 143 | name: "ziparchive-benchmarks", |
| 144 | defaults: ["libziparchive_flags"], |
| 145 | |
| 146 | srcs: [ |
| 147 | "zip_archive_benchmark.cpp", |
| 148 | ], |
| 149 | shared_libs: [ |
| 150 | "libbase", |
| 151 | "liblog", |
| 152 | ], |
| 153 | |
| 154 | static_libs: [ |
| 155 | "libziparchive", |
| 156 | "libz", |
| 157 | "libutils", |
| 158 | ], |
| 159 | |
| 160 | target: { |
| 161 | host: { |
| 162 | cppflags: ["-Wno-unnamed-type-template-args"], |
| 163 | }, |
| 164 | }, |
| 165 | } |
Elliott Hughes | 55fd293 | 2017-05-28 22:59:04 -0700 | [diff] [blame] | 166 | |
| 167 | cc_binary { |
| 168 | name: "unzip", |
| 169 | defaults: ["libziparchive_flags"], |
| 170 | srcs: ["unzip.cpp"], |
| 171 | shared_libs: [ |
| 172 | "libbase", |
| 173 | "libziparchive", |
| 174 | ], |
| 175 | } |