1//
2//
3// Build the library
4//
5//
6
7cc_defaults {
8    name: "sqlite-minimal-defaults",
9    host_supported: true,
10
11    // static analysis is too slow on these huge files.
12    tidy_checks: [
13        "-clang-analyzer-*",
14    ],
15
16    // NOTE the following flags,
17    //   SQLITE_TEMP_STORE=3 causes all TEMP files to go into RAM. and thats the behavior we want
18    //   SQLITE_ENABLE_FTS3   enables usage of FTS3 - NOT FTS1 or 2.
19    //   SQLITE_DEFAULT_AUTOVACUUM=1  causes the databases to be subject to auto-vacuum
20    cflags: [
21        "-DNDEBUG=1",
22        "-DHAVE_USLEEP=1",
23        "-DSQLITE_HAVE_ISNAN",
24        "-DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
25        "-DSQLITE_THREADSAFE=2",
26        "-DSQLITE_TEMP_STORE=3",
27        "-DSQLITE_POWERSAFE_OVERWRITE=1",
28        "-DSQLITE_DEFAULT_FILE_FORMAT=4",
29        "-DSQLITE_DEFAULT_AUTOVACUUM=1",
30        "-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1",
31        "-DSQLITE_ENABLE_FTS3",
32        "-DSQLITE_ENABLE_FTS3_BACKWARDS",
33        "-DSQLITE_ENABLE_FTS4",
34        "-DSQLITE_OMIT_BUILTIN_TEST",
35        "-DSQLITE_OMIT_COMPILEOPTION_DIAGS",
36        "-DSQLITE_OMIT_LOAD_EXTENSION",
37        "-DSQLITE_DEFAULT_FILE_PERMISSIONS=0600",
38        "-DSQLITE_SECURE_DELETE",
39        "-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE",
40        "-DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD",
41        "-Wno-unused-parameter",
42        "-Werror",
43    ],
44
45    target: {
46        linux_glibc: {
47            cflags: ["-DHAVE_POSIX_FALLOCATE=1"],
48        },
49    },
50}
51
52cc_defaults {
53    name: "sqlite-defaults",
54    defaults: ["sqlite-minimal-defaults"],
55    target: {
56        android: {
57            cflags: [
58                "-DUSE_PREAD64",
59                "-Dfdatasync=fdatasync",
60                "-DHAVE_MALLOC_H=1",
61                "-DHAVE_MALLOC_USABLE_SIZE",
62            ],
63        },
64    },
65}
66
67cc_library {
68    name: "libsqlite",
69    defaults: ["sqlite-defaults"],
70    vendor_available: true,
71    vndk: {
72        enabled: true,
73    },
74
75    srcs: ["sqlite3.c"],
76
77    target: {
78        android: {
79            shared_libs: [
80                "libdl",
81                "liblog",
82                "libutils",
83                "libandroidicu",
84            ],
85            cflags: ["-DSQLITE_ENABLE_ICU"],
86
87            // include android specific methods
88            whole_static_libs: ["libsqlite3_android"],
89        },
90        host: {
91            static_libs: [
92                "liblog",
93                "libutils",
94            ],
95        },
96        not_windows: {
97            shared_libs: [
98                "libandroidicu",
99            ],
100
101            // include android specific methods
102            whole_static_libs: ["libsqlite3_android"],
103        },
104        windows: {
105            enabled: true,
106        },
107        vendor: {
108            cflags: ["-USQLITE_ENABLE_ICU"],
109            exclude_shared_libs: ["libandroidicu"],
110        },
111    },
112
113    export_include_dirs: ["."],
114}
115
116//
117//
118// Build the device command line tool sqlite3
119//
120//
121
122cc_binary {
123    name: "sqlite3",
124    defaults: ["sqlite-defaults"],
125
126    srcs: ["shell.c"],
127
128    target: {
129        android: {
130            shared_libs: [
131                "libsqlite",
132                "libandroidicu",
133                "liblog",
134                "libutils",
135            ],
136        },
137        host: {
138            cflags: ["-DNO_ANDROID_FUNCS=1"],
139            static_libs: [
140                "libsqlite",
141                // sqlite3MemsysAlarm uses LOG()
142                "liblog",
143            ],
144        },
145
146        windows: {
147            enabled: true,
148        },
149    },
150}
151
152// Build a minimal version of sqlite3 without any android specific
153// features against the NDK. This is used by libcore's JDBC related
154// unit tests.
155cc_library_static {
156    name: "libsqlite_static_minimal",
157    defaults: ["sqlite-minimal-defaults"],
158    srcs: ["sqlite3.c"],
159    sdk_version: "23",
160    export_include_dirs: ["."],
161}
162