1// 2// 3// Build the library 4// 5// 6 7package { 8 default_applicable_licenses: ["external_sqlite_dist_license"], 9} 10 11// Added automatically by a large-scale-change that took the approach of 12// 'apply every license found to every target'. While this makes sure we respect 13// every license restriction, it may not be entirely correct. 14// 15// e.g. GPL in an MIT project might only apply to the contrib/ directory. 16// 17// Please consider splitting the single license below into multiple licenses, 18// taking care not to lose any license_kind information, and overriding the 19// default license using the 'licenses: [...]' property on targets as needed. 20// 21// For unused files, consider creating a 'fileGroup' with "//visibility:private" 22// to attach the license to, and including a comment whether the files may be 23// used in the current project. 24// See: http://go/android-license-faq 25license { 26 name: "external_sqlite_dist_license", 27 visibility: [":__subpackages__"], 28 license_kinds: [ 29 "legacy_permissive", 30 "legacy_unencumbered", 31 ], 32 license_text: [ 33 "NOTICE", 34 ], 35} 36 37cc_defaults { 38 name: "sqlite-minimal-defaults", 39 host_supported: true, 40 41 // static analysis is too slow on these huge files. 42 tidy_checks: [ 43 "-clang-analyzer-*", 44 ], 45 46 // NOTE the following flags, 47 // SQLITE_TEMP_STORE=3 causes all TEMP files to go into RAM. and thats the behavior we want 48 // SQLITE_ENABLE_FTS3 enables usage of FTS3 - NOT FTS1 or 2. 49 // SQLITE_DEFAULT_AUTOVACUUM=1 causes the databases to be subject to auto-vacuum 50 cflags: [ 51 "-DNDEBUG=1", 52 "-DHAVE_USLEEP=1", 53 "-DSQLITE_HAVE_ISNAN", 54 "-DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576", 55 "-DSQLITE_THREADSAFE=2", 56 "-DSQLITE_TEMP_STORE=3", 57 "-DSQLITE_POWERSAFE_OVERWRITE=1", 58 "-DSQLITE_DEFAULT_FILE_FORMAT=4", 59 "-DSQLITE_DEFAULT_AUTOVACUUM=1", 60 "-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1", 61 "-DSQLITE_ENABLE_FTS3", 62 "-DSQLITE_ENABLE_FTS3_BACKWARDS", 63 "-DSQLITE_ENABLE_FTS4", 64 "-DSQLITE_OMIT_BUILTIN_TEST", 65 "-DSQLITE_OMIT_COMPILEOPTION_DIAGS", 66 "-DSQLITE_OMIT_LOAD_EXTENSION", 67 "-DSQLITE_DEFAULT_FILE_PERMISSIONS=0600", 68 "-DSQLITE_SECURE_DELETE", 69 "-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE", 70 "-DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD", 71 "-DSQLITE_DEFAULT_LEGACY_ALTER_TABLE", 72 "-DSQLITE_ALLOW_ROWID_IN_VIEW", 73 "-DSQLITE_ENABLE_BYTECODE_VTAB", 74 "-Wno-unused-parameter", 75 "-Werror", 76 77 // Default value causes sqlite3_open_v2 to return error if DB is missing. 78 "-ftrivial-auto-var-init=pattern", 79 ], 80 81 target: { 82 linux_glibc: { 83 cflags: ["-DHAVE_POSIX_FALLOCATE=1"], 84 }, 85 }, 86} 87 88cc_defaults { 89 name: "sqlite-defaults", 90 defaults: ["sqlite-minimal-defaults"], 91 target: { 92 android: { 93 cflags: [ 94 "-DUSE_PREAD64", 95 "-Dfdatasync=fdatasync", 96 "-DHAVE_MALLOC_H=1", 97 "-DSQLITE_ENABLE_DBSTAT_VTAB", 98 ], 99 }, 100 }, 101 cflags: [ 102 "-U_FORTIFY_SOURCE", 103 "-D_FORTIFY_SOURCE=3", 104 ], 105} 106 107soong_config_module_type { 108 name: "release_package_libsqlite3_library_defaults_config", 109 module_type: "cc_defaults", 110 config_namespace: "libsqlite3", 111 value_variables: ["release_package_libsqlite3"], 112 properties: [ 113 "export_include_dirs", 114 "srcs", 115 ], 116} 117 118// Construct the correct source and includes for sqlite libraries, 119// based on the build flag. 120release_package_libsqlite3_library_defaults_config { 121 name: "release_package_libsqlite3_library_defaults", 122 soong_config_variables: { 123 release_package_libsqlite3: { 124 export_include_dirs: ["sqlite-autoconf-%s"], 125 srcs: ["sqlite-autoconf-%s/sqlite3.c"], 126 conditions_default: { 127 export_include_dirs: ["sqlite-default"], 128 srcs: ["sqlite-default/sqlite3.c"], 129 }, 130 }, 131 }, 132} 133 134cc_defaults { 135 name: "libsqlite_defaults", 136 defaults: [ 137 "sqlite-defaults", 138 "release_package_libsqlite3_library_defaults", 139 ], 140} 141 142cc_library { 143 name: "libsqlite", 144 defaults: [ 145 "sqlite-defaults", 146 "release_package_libsqlite3_library_defaults", 147 ], 148 product_available: true, 149 vendor_available: true, 150 native_bridge_supported: true, 151 152 target: { 153 android: { 154 shared_libs: [ 155 "libdl", 156 "liblog", 157 "libandroidicu", 158 ], 159 cflags: ["-DSQLITE_ENABLE_ICU"], 160 161 // include android specific methods 162 whole_static_libs: ["libsqlite3_android"], 163 }, 164 host: { 165 static_libs: [ 166 "liblog", 167 ], 168 shared_libs: [ 169 "libicui18n", 170 "libicuuc", 171 ], 172 cflags: ["-DSQLITE_ENABLE_ICU"], 173 // include android specific methods 174 whole_static_libs: ["libsqlite3_android"], 175 }, 176 windows: { 177 enabled: true, 178 }, 179 product: { 180 cflags: ["-USQLITE_ENABLE_ICU"], 181 exclude_shared_libs: ["libandroidicu"], 182 exclude_static_libs: ["libsqlite3_android"], 183 }, 184 vendor: { 185 cflags: ["-USQLITE_ENABLE_ICU"], 186 exclude_shared_libs: ["libandroidicu"], 187 exclude_static_libs: ["libsqlite3_android"], 188 }, 189 }, 190 apex_available: [ 191 "//apex_available:platform", 192 "com.android.virt", 193 "com.sdv.*", 194 ], 195 196 afdo: true, 197 // libsqlite is a single gigantic C file, no need to run LTO. 198 lto: { 199 never: true, 200 }, 201} 202 203// This static library is variant of libsqlite built without the ICU extension. 204// The library is supposed to be used in environments where the ICU extension 205// is not needed and the dependency to ICU (which is as large as 60+ MB) is not 206// desirable, like microdroid. 207cc_library_static { 208 name: "libsqlite_static_noicu", 209 defaults: [ 210 "sqlite-defaults", 211 "release_package_libsqlite3_library_defaults", 212 ], 213 whole_static_libs: ["libsqlite3_android_noicu"], 214 // Not define SQLITE_ENABLE_ICU 215 apex_available: [ 216 "//apex_available:platform", 217 "com.android.os.statsd", 218 "test_com.android.os.statsd", 219 ], 220 min_sdk_version: "apex_inherit", 221 host_supported: true, 222} 223 224// Build a minimal version of sqlite3 without any android specific 225// features against the NDK. This is used by libcore's JDBC related 226// unit tests. 227cc_library_static { 228 name: "libsqlite_static_minimal", 229 defaults: [ 230 "sqlite-minimal-defaults", 231 "release_package_libsqlite3_library_defaults", 232 ], 233 sdk_version: "23", 234} 235 236soong_config_module_type { 237 name: "release_package_libsqlite3_library_percentile_config", 238 module_type: "cc_library_static", 239 config_namespace: "libsqlite3", 240 value_variables: ["release_package_libsqlite3"], 241 properties: [ 242 "export_include_dirs", 243 ], 244} 245 246release_package_libsqlite3_library_percentile_config { 247 name: "sqlite_ext_percentile", 248 soong_config_variables: { 249 release_package_libsqlite3: { 250 export_include_dirs: ["sqlite-autoconf-%s"], 251 conditions_default: { 252 export_include_dirs: ["sqlite-default"], 253 }, 254 }, 255 }, 256 srcs: [ 257 "ext/misc/percentile.c", 258 ], 259 defaults: ["sqlite-defaults"], 260 host_supported: true, 261} 262 263// 264// 265// Build the device command line tool sqlite3 266// 267// 268 269soong_config_module_type { 270 name: "release_package_libsqlite3_library_shell_config", 271 module_type: "cc_binary", 272 config_namespace: "libsqlite3", 273 value_variables: ["release_package_libsqlite3"], 274 properties: [ 275 "srcs", 276 ], 277} 278 279// Construct the correct source and includes for sqlite libraries, 280// based on the build flag. 281release_package_libsqlite3_library_shell_config { 282 name: "sqlite3", 283 soong_config_variables: { 284 release_package_libsqlite3: { 285 srcs: ["sqlite-autoconf-%s/shell.c"], 286 conditions_default: { 287 srcs: ["sqlite-default/shell.c"], 288 }, 289 }, 290 }, 291 defaults: ["sqlite-defaults"], 292 293 target: { 294 android: { 295 shared_libs: [ 296 "libsqlite", 297 "libandroidicu", 298 "liblog", 299 "libutils", 300 ], 301 }, 302 host: { 303 cflags: ["-DNO_ANDROID_FUNCS=1"], 304 static_libs: [ 305 "libsqlite", 306 // sqlite3MemsysAlarm uses LOG() 307 "liblog", 308 "libicui18n", 309 "libicuuc", 310 "libicuuc_stubdata", 311 ], 312 }, 313 windows: { 314 enabled: true, 315 }, 316 }, 317} 318