• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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                "-DHAVE_MALLOC_USABLE_SIZE",
98                "-DSQLITE_ENABLE_DBSTAT_VTAB",
99            ],
100        },
101    },
102}
103
104soong_config_module_type {
105    name: "release_package_libsqlite3_library_defaults_config",
106    module_type: "cc_defaults",
107    config_namespace: "libsqlite3",
108    value_variables: ["release_package_libsqlite3"],
109    properties: [
110        "export_include_dirs",
111        "srcs",
112    ],
113}
114
115// Construct the correct source and includes for sqlite libraries,
116// based on the build flag.
117release_package_libsqlite3_library_defaults_config {
118    name: "release_package_libsqlite3_library_defaults",
119    soong_config_variables: {
120        release_package_libsqlite3: {
121            export_include_dirs: ["sqlite-autoconf-%s"],
122            srcs: ["sqlite-autoconf-%s/sqlite3.c"],
123            conditions_default: {
124                export_include_dirs: ["sqlite-default"],
125                srcs: ["sqlite-default/sqlite3.c"],
126            },
127        },
128    },
129}
130
131cc_defaults {
132    name: "libsqlite_defaults",
133    defaults: [
134        "sqlite-defaults",
135        "release_package_libsqlite3_library_defaults",
136    ],
137}
138
139cc_library {
140    name: "libsqlite",
141    defaults: [
142        "sqlite-defaults",
143        "release_package_libsqlite3_library_defaults",
144    ],
145    vendor_available: true,
146    native_bridge_supported: true,
147
148    target: {
149        android: {
150            shared_libs: [
151                "libdl",
152                "liblog",
153                "libandroidicu",
154            ],
155            cflags: ["-DSQLITE_ENABLE_ICU"],
156
157            // include android specific methods
158            whole_static_libs: ["libsqlite3_android"],
159        },
160        host: {
161            static_libs: [
162                "liblog",
163            ],
164            shared_libs: [
165                "libicui18n",
166                "libicuuc",
167            ],
168            cflags: ["-DSQLITE_ENABLE_ICU"],
169            // include android specific methods
170            whole_static_libs: ["libsqlite3_android"],
171        },
172        windows: {
173            enabled: true,
174        },
175        vendor: {
176            cflags: ["-USQLITE_ENABLE_ICU"],
177            exclude_shared_libs: ["libandroidicu"],
178            exclude_static_libs: ["libsqlite3_android"],
179        },
180    },
181    apex_available: [
182        "//apex_available:platform",
183        "com.android.virt",
184    ],
185
186    afdo: true,
187    // libsqlite is a single gigantic C file, no need to run LTO.
188    lto: {
189         never: true,
190    },
191}
192
193// This static library is variant of libsqlite built without the ICU extension.
194// The library is supposed to be used in environments where the ICU extension
195// is not needed and the dependency to ICU (which is as large as 60+ MB) is not
196// desirable, like microdroid.
197cc_library_static {
198    name: "libsqlite_static_noicu",
199    defaults: [
200        "sqlite-defaults",
201        "release_package_libsqlite3_library_defaults",
202    ],
203    whole_static_libs: ["libsqlite3_android_noicu"],
204    // Not define SQLITE_ENABLE_ICU
205    apex_available: [
206        "//apex_available:platform",
207        "com.android.os.statsd",
208        "test_com.android.os.statsd",
209    ],
210    min_sdk_version: "apex_inherit",
211    host_supported: true,
212}
213
214// Build a minimal version of sqlite3 without any android specific
215// features against the NDK. This is used by libcore's JDBC related
216// unit tests.
217cc_library_static {
218    name: "libsqlite_static_minimal",
219    defaults: [
220        "sqlite-minimal-defaults",
221        "release_package_libsqlite3_library_defaults",
222    ],
223    sdk_version: "23",
224}
225
226soong_config_module_type {
227    name: "release_package_libsqlite3_library_percentile_config",
228    module_type: "cc_library_static",
229    config_namespace: "libsqlite3",
230    value_variables: ["release_package_libsqlite3"],
231    properties: [
232        "export_include_dirs",
233    ],
234}
235
236release_package_libsqlite3_library_percentile_config {
237    name: "sqlite_ext_percentile",
238    soong_config_variables: {
239        release_package_libsqlite3: {
240            export_include_dirs: ["sqlite-autoconf-%s"],
241            conditions_default: {
242                export_include_dirs: ["sqlite-default"],
243            },
244        },
245    },
246    srcs: [
247        "ext/misc/percentile.c",
248    ],
249    defaults: ["sqlite-defaults"],
250    host_supported: true,
251}
252
253//
254//
255// Build the device command line tool sqlite3
256//
257//
258
259soong_config_module_type {
260    name: "release_package_libsqlite3_library_shell_config",
261    module_type: "cc_binary",
262    config_namespace: "libsqlite3",
263    value_variables: ["release_package_libsqlite3"],
264    properties: [
265        "srcs",
266    ],
267}
268
269// Construct the correct source and includes for sqlite libraries,
270// based on the build flag.
271release_package_libsqlite3_library_shell_config {
272    name: "sqlite3",
273    soong_config_variables: {
274        release_package_libsqlite3: {
275            srcs: ["sqlite-autoconf-%s/shell.c"],
276            conditions_default: {
277                srcs: ["sqlite-default/shell.c"],
278            },
279        },
280    },
281    defaults: ["sqlite-defaults"],
282
283    target: {
284        android: {
285            shared_libs: [
286                "libsqlite",
287                "libandroidicu",
288                "liblog",
289                "libutils",
290            ],
291        },
292        host: {
293            cflags: ["-DNO_ANDROID_FUNCS=1"],
294            static_libs: [
295                "libsqlite",
296                // sqlite3MemsysAlarm uses LOG()
297                "liblog",
298                "libicui18n",
299                "libicuuc",
300                "libicuuc_stubdata",
301            ],
302        },
303        windows: {
304            enabled: true,
305        },
306    },
307}
308