summaryrefslogtreecommitdiff
path: root/dist/Android.bp
blob: c47dfe5cf7562220a24d8ab66072d783f42398cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
//
//
// Build the library
//
//

package {
    default_applicable_licenses: ["external_sqlite_dist_license"],
}

// Added automatically by a large-scale-change that took the approach of
// 'apply every license found to every target'. While this makes sure we respect
// every license restriction, it may not be entirely correct.
//
// e.g. GPL in an MIT project might only apply to the contrib/ directory.
//
// Please consider splitting the single license below into multiple licenses,
// taking care not to lose any license_kind information, and overriding the
// default license using the 'licenses: [...]' property on targets as needed.
//
// For unused files, consider creating a 'fileGroup' with "//visibility:private"
// to attach the license to, and including a comment whether the files may be
// used in the current project.
// See: http://go/android-license-faq
license {
    name: "external_sqlite_dist_license",
    visibility: [":__subpackages__"],
    license_kinds: [
        "legacy_permissive",
        "legacy_unencumbered",
    ],
    license_text: [
        "NOTICE",
    ],
}

cc_defaults {
    name: "sqlite-minimal-defaults",
    host_supported: true,

    // static analysis is too slow on these huge files.
    tidy_checks: [
        "-clang-analyzer-*",
    ],

    // NOTE the following flags,
    //   SQLITE_TEMP_STORE=3 causes all TEMP files to go into RAM. and thats the behavior we want
    //   SQLITE_ENABLE_FTS3   enables usage of FTS3 - NOT FTS1 or 2.
    //   SQLITE_DEFAULT_AUTOVACUUM=1  causes the databases to be subject to auto-vacuum
    cflags: [
        "-DNDEBUG=1",
        "-DHAVE_USLEEP=1",
        "-DSQLITE_HAVE_ISNAN",
        "-DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
        "-DSQLITE_THREADSAFE=2",
        "-DSQLITE_TEMP_STORE=3",
        "-DSQLITE_POWERSAFE_OVERWRITE=1",
        "-DSQLITE_DEFAULT_FILE_FORMAT=4",
        "-DSQLITE_DEFAULT_AUTOVACUUM=1",
        "-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1",
        "-DSQLITE_ENABLE_FTS3",
        "-DSQLITE_ENABLE_FTS3_BACKWARDS",
        "-DSQLITE_ENABLE_FTS4",
        "-DSQLITE_OMIT_BUILTIN_TEST",
        "-DSQLITE_OMIT_COMPILEOPTION_DIAGS",
        "-DSQLITE_OMIT_LOAD_EXTENSION",
        "-DSQLITE_DEFAULT_FILE_PERMISSIONS=0600",
        "-DSQLITE_SECURE_DELETE",
        "-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE",
        "-DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD",
        "-DSQLITE_DEFAULT_LEGACY_ALTER_TABLE",
        "-DSQLITE_ALLOW_ROWID_IN_VIEW",
        "-DSQLITE_ENABLE_BYTECODE_VTAB",
        "-Wno-unused-parameter",
        "-Werror",

        // Default value causes sqlite3_open_v2 to return error if DB is missing.
        "-ftrivial-auto-var-init=pattern",
    ],

    target: {
        linux_glibc: {
            cflags: ["-DHAVE_POSIX_FALLOCATE=1"],
        },
    },
}

cc_defaults {
    name: "sqlite-defaults",
    defaults: ["sqlite-minimal-defaults"],
    target: {
        android: {
            cflags: [
                "-DUSE_PREAD64",
                "-Dfdatasync=fdatasync",
                "-DHAVE_MALLOC_H=1",
                "-DHAVE_MALLOC_USABLE_SIZE",
                "-DSQLITE_ENABLE_DBSTAT_VTAB",
            ],
        },
    },
}

soong_config_module_type {
    name: "release_package_libsqlite3_library_defaults_config",
    module_type: "cc_defaults",
    config_namespace: "libsqlite3",
    value_variables: ["release_package_libsqlite3"],
    properties: [
        "export_include_dirs",
        "srcs",
    ],
}

// Construct the correct source and includes for sqlite libraries,
// based on the build flag.
release_package_libsqlite3_library_defaults_config {
    name: "release_package_libsqlite3_library_defaults",
    soong_config_variables: {
        release_package_libsqlite3: {
            export_include_dirs: ["sqlite-autoconf-%s"],
            srcs: ["sqlite-autoconf-%s/sqlite3.c"],
            conditions_default: {
                export_include_dirs: ["sqlite-default"],
                srcs: ["sqlite-default/sqlite3.c"],
            },
        },
    },
}

cc_defaults {
    name: "libsqlite_defaults",
    defaults: [
        "sqlite-defaults",
        "release_package_libsqlite3_library_defaults",
    ],
}

cc_library {
    name: "libsqlite",
    defaults: [
        "sqlite-defaults",
        "release_package_libsqlite3_library_defaults",
    ],
    vendor_available: true,
    native_bridge_supported: true,
    vndk: {
        enabled: true,
    },

    target: {
        android: {
            shared_libs: [
                "libdl",
                "liblog",
                "libandroidicu",
            ],
            cflags: ["-DSQLITE_ENABLE_ICU"],

            // include android specific methods
            whole_static_libs: ["libsqlite3_android"],
        },
        host: {
            static_libs: [
                "liblog",
            ],
            shared_libs: [
                "libicui18n",
                "libicuuc",
            ],
            cflags: ["-DSQLITE_ENABLE_ICU"],
            // include android specific methods
            whole_static_libs: ["libsqlite3_android"],
        },
        windows: {
            enabled: true,
        },
        vendor: {
            cflags: ["-USQLITE_ENABLE_ICU"],
            exclude_shared_libs: ["libandroidicu"],
            exclude_static_libs: ["libsqlite3_android"],
        },
    },
    apex_available: [
        "//apex_available:platform",
        "com.android.virt",
    ],

    afdo: true,
}

// This static library is variant of libsqlite built without the ICU extension.
// The library is supposed to be used in environments where the ICU extension
// is not needed and the dependency to ICU (which is as large as 60+ MB) is not
// desirable, like microdroid.
cc_library_static {
    name: "libsqlite_static_noicu",
    defaults: [
        "sqlite-defaults",
        "release_package_libsqlite3_library_defaults",
    ],
    whole_static_libs: ["libsqlite3_android_noicu"],
    // Not define SQLITE_ENABLE_ICU
    apex_available: [
        "//apex_available:platform",
        "com.android.os.statsd",
        "test_com.android.os.statsd",
    ],
    min_sdk_version: "apex_inherit",
    host_supported: true,
}

// Build a minimal version of sqlite3 without any android specific
// features against the NDK. This is used by libcore's JDBC related
// unit tests.
cc_library_static {
    name: "libsqlite_static_minimal",
    defaults: [
        "sqlite-minimal-defaults",
        "release_package_libsqlite3_library_defaults",
    ],
    sdk_version: "23",
}

soong_config_module_type {
    name: "release_package_libsqlite3_library_percentile_config",
    module_type: "cc_library_static",
    config_namespace: "libsqlite3",
    value_variables: ["release_package_libsqlite3"],
    properties: [
        "export_include_dirs",
    ],
}

release_package_libsqlite3_library_percentile_config {
    name: "sqlite_ext_percentile",
    soong_config_variables: {
        release_package_libsqlite3: {
            export_include_dirs: ["sqlite-autoconf-%s"],
            conditions_default: {
                export_include_dirs: ["sqlite-default"],
            },
        },
    },
    srcs: [
        "ext/misc/percentile.c",
    ],
    defaults: ["sqlite-defaults"],
    host_supported: true,
}

//
//
// Build the device command line tool sqlite3
//
//

soong_config_module_type {
    name: "release_package_libsqlite3_library_shell_config",
    module_type: "cc_binary",
    config_namespace: "libsqlite3",
    value_variables: ["release_package_libsqlite3"],
    properties: [
        "srcs",
    ],
}

// Construct the correct source and includes for sqlite libraries,
// based on the build flag.
release_package_libsqlite3_library_shell_config {
    name: "sqlite3",
    soong_config_variables: {
        release_package_libsqlite3: {
            srcs: ["sqlite-autoconf-%s/shell.c"],
            conditions_default: {
                srcs: ["sqlite-default/shell.c"],
            },
        },
    },
    defaults: ["sqlite-defaults"],

    target: {
        android: {
            shared_libs: [
                "libsqlite",
                "libandroidicu",
                "liblog",
                "libutils",
            ],
        },
        host: {
            cflags: ["-DNO_ANDROID_FUNCS=1"],
            static_libs: [
                "libsqlite",
                // sqlite3MemsysAlarm uses LOG()
                "liblog",
                "libicui18n",
                "libicuuc",
                "libicuuc_stubdata",
            ],
        },
        windows: {
            enabled: true,
        },
    },
}