• 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        "-Wno-unused-parameter",
74        "-Werror",
75
76        // Default value causes sqlite3_open_v2 to return error if DB is missing.
77        "-ftrivial-auto-var-init=pattern",
78    ],
79
80    target: {
81        linux_glibc: {
82            cflags: ["-DHAVE_POSIX_FALLOCATE=1"],
83        },
84    },
85}
86
87cc_defaults {
88    name: "sqlite-defaults",
89    defaults: ["sqlite-minimal-defaults"],
90    target: {
91        android: {
92            cflags: [
93                "-DUSE_PREAD64",
94                "-Dfdatasync=fdatasync",
95                "-DHAVE_MALLOC_H=1",
96                "-DHAVE_MALLOC_USABLE_SIZE",
97                "-DSQLITE_ENABLE_DBSTAT_VTAB",
98            ],
99        },
100    },
101}
102
103cc_library {
104    name: "libsqlite",
105    defaults: ["sqlite-defaults"],
106    vendor_available: true,
107    native_bridge_supported: true,
108    vndk: {
109        enabled: true,
110    },
111
112    srcs: ["sqlite3.c"],
113
114    target: {
115        android: {
116            shared_libs: [
117                "libdl",
118                "liblog",
119                "libandroidicu",
120            ],
121            cflags: ["-DSQLITE_ENABLE_ICU"],
122
123            // include android specific methods
124            whole_static_libs: ["libsqlite3_android"],
125        },
126        host: {
127            static_libs: [
128                "liblog",
129            ],
130        },
131        not_windows: {
132            shared_libs: [
133                "libicui18n",
134                "libicuuc",
135            ],
136
137            // include android specific methods
138            whole_static_libs: ["libsqlite3_android"],
139        },
140        windows: {
141            enabled: true,
142        },
143        vendor: {
144            cflags: ["-USQLITE_ENABLE_ICU"],
145            exclude_shared_libs: ["libandroidicu"],
146            exclude_static_libs: ["libsqlite3_android"],
147        },
148    },
149    export_include_dirs: ["."],
150}
151
152// This static library is variant of libsqlite built without the ICU extension.
153// The library is supposed to be used in environments where the ICU extension
154// is not needed and the dependency to ICU (which is as large as 60+ MB) is not
155// desirable, like microdroid.
156cc_library_static {
157    name: "libsqlite_static_noicu",
158    defaults: ["sqlite-defaults"],
159    srcs: ["sqlite3.c"],
160    whole_static_libs: ["libsqlite3_android_noicu"],
161    // Not define SQLITE_ENABLE_ICU
162    export_include_dirs: ["."],
163    apex_available: [
164        "//apex_available:platform",
165        "com.android.os.statsd",
166        "test_com.android.os.statsd",
167    ],
168    min_sdk_version: "apex_inherit",
169}
170
171//
172//
173// Build the device command line tool sqlite3
174//
175//
176
177cc_binary {
178    name: "sqlite3",
179    defaults: ["sqlite-defaults"],
180
181    srcs: ["shell.c"],
182
183    target: {
184        android: {
185            shared_libs: [
186                "libsqlite",
187                "libandroidicu",
188                "liblog",
189                "libutils",
190            ],
191        },
192        host: {
193            cflags: ["-DNO_ANDROID_FUNCS=1"],
194            static_libs: [
195                "libsqlite",
196                // sqlite3MemsysAlarm uses LOG()
197                "liblog",
198            ],
199        },
200
201        windows: {
202            enabled: true,
203        },
204    },
205}
206
207// Build a minimal version of sqlite3 without any android specific
208// features against the NDK. This is used by libcore's JDBC related
209// unit tests.
210cc_library_static {
211    name: "libsqlite_static_minimal",
212    defaults: ["sqlite-minimal-defaults"],
213    srcs: ["sqlite3.c"],
214    sdk_version: "23",
215    export_include_dirs: ["."],
216}
217
218cc_library_static {
219    name: "sqlite_ext_percentile",
220    srcs: [
221        "ext/misc/percentile.c",
222    ],
223    defaults: ["sqlite-defaults"],
224    host_supported: true,
225    export_include_dirs: ["."],
226}
227