blob: e007749f087a93e78e85fce677190f43dcd925b9 [file] [log] [blame]
Chih-Hung Hsieh9a627fb2020-07-29 20:55:10 -07001// This file is generated by cargo2android.py --device --run --dependencies --test.
2
3// We renamed the shared_libs dependence from libsqlite3 to libsqlite.
4
5rust_library {
6 name: "liblibsqlite3_sys",
7 host_supported: true,
8 crate_name: "libsqlite3_sys",
9 srcs: ["src/lib.rs"],
10 edition: "2018",
11 // Note that the following features are default for this package,
12 // unrelated to the generation of bindings for external/sqlite.
13 // We might need to consider the non-default features for Android.
14 // If you add/change features, please check any impact to bindgen flags.
15 features: [
16 "default",
17 "min_sqlite_version_3_6_8",
18 "pkg-config",
19 "vcpkg",
20 ],
21 shared_libs: [
22 "libsqlite",
23 ],
24 arch: {
25 // depend on external/sqlite/rust bindgen modules
26 // and include the output file from those modules
27 x86: {
28 srcs: [":sqlite3_bindgen_x86"],
29 },
30 x86_64: {
31 srcs: [":sqlite3_bindgen_x86_64"],
32 },
33 arm: {
34 srcs: [":sqlite3_bindgen_arm"],
35 },
36 arm64: {
37 srcs: [":sqlite3_bindgen_arm64"],
38 },
39 },
40}
41
42rust_defaults {
43 name: "libsqlite3-sys_defaults",
44 crate_name: "libsqlite3_sys",
45 srcs: ["src/lib.rs"],
46 test_suites: ["general-tests"],
47 auto_gen_config: true,
48 edition: "2018",
49 features: [
50 "default",
51 "min_sqlite_version_3_6_8",
52 "pkg-config",
53 "vcpkg",
54 ],
55 shared_libs: [
56 "libsqlite",
57 ],
58 arch: {
59 // depend on external/sqlite/rust bindgen modules
60 // and include the output file from those modules
61 x86: {
62 srcs: [":sqlite3_bindgen_x86"],
63 },
64 x86_64: {
65 srcs: [":sqlite3_bindgen_x86_64"],
66 },
67 arm: {
68 srcs: [":sqlite3_bindgen_arm"],
69 },
70 arm64: {
71 srcs: [":sqlite3_bindgen_arm64"],
72 },
73 },
74}
75
76rust_test_host {
77 name: "libsqlite3-sys_host_test_src_lib",
78 defaults: ["libsqlite3-sys_defaults"],
79}
80
81rust_test {
82 name: "libsqlite3-sys_device_test_src_lib",
83 defaults: ["libsqlite3-sys_defaults"],
84}
85
86// dependent_library ["feature_list"]
87// pkg-config-0.3.18
88
89// Extra modules to generate bindings for external/sqlite.
90// Generated file is called bindgen.rs and saved into android/<arch>/bindings.rs.
91
92common_bindgen_flags = " -o $(out) $(in) -- -MD -MF $(depfile)"
93
94// Here is the place to add bindgen flags for sqlite3.
95// The following ignore options are copied from build.rs.
96sqlite3_bindgen_flags =
97 " --blacklist-function sqlite3_vmprintf"
98 + " --blacklist-function sqlite3_vsnprintf"
99 + " --blacklist-function sqlite3_str_vappendf"
100 + " --blacklist-type va_list"
101 + " --blacklist-type __builtin_va_list"
102 + " --blacklist-type __gnuc_va_list"
103 + " --blacklist-type __va_list_tag"
104 + " --blacklist-item __GNUC_VA_LIST"
105
106// The cflags defined in cc_defaults of external/sqlite/dist/Android.bp
107// should be passed to clang for bindgen.
108// The list of strings used in cflags cannot be easily
109// shared with the command string used in genrule yet,
110// since there is no string join function in .bp.
111sqlite3_bindgen_clang_flags = " -I external/sqlite/dist"
112 + " -DNDEBUG=1"
113 + " -DHAVE_USLEEP=1"
114 + " -DSQLITE_HAVE_ISNAN"
115 + " -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576"
116 + " -DSQLITE_THREADSAFE=2"
117 + " -DSQLITE_TEMP_STORE=3"
118 + " -DSQLITE_POWERSAFE_OVERWRITE=1"
119 + " -DSQLITE_DEFAULT_FILE_FORMAT=4"
120 + " -DSQLITE_DEFAULT_AUTOVACUUM=1"
121 + " -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1"
122 + " -DSQLITE_ENABLE_FTS3"
123 + " -DSQLITE_ENABLE_FTS3_BACKWARDS"
124 + " -DSQLITE_ENABLE_FTS4"
125 + " -DSQLITE_OMIT_BUILTIN_TEST"
126 + " -DSQLITE_OMIT_COMPILEOPTION_DIAGS"
127 + " -DSQLITE_OMIT_LOAD_EXTENSION"
128 + " -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600"
129 + " -DSQLITE_SECURE_DELETE"
130 + " -DSQLITE_ENABLE_BATCH_ATOMIC_WRITE"
131 + " -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD"
132 + " -DHAVE_POSIX_FALLOCATE=1"
133 // extra -D flags for android targets
134 + " -DUSE_PREAD64"
135 + " -Dfdatasync=fdatasync"
136 + " -DHAVE_MALLOC_H=1"
137 + " -DHAVE_MALLOC_USABLE_SIZE"
138 + " -Wno-unused-parameter"
139
140genrule_defaults {
141 name: "sqlite3_bindgen_defaults",
142 tools: ["bindgen.sh", "bindgen"],
143 depfile: true,
144 srcs: ["android/bindgen.h"],
145 out: ["bindgen.rs"],
146}
147
148// This is a temporary hack to fix bindgen output files,
149// until a newer bindgen can do it with a flag.
150// The default int type for macros are changed
151// from u32 to i32 to work with other existing Rust.
152// Both u32 and i32 values should work with C libsqlite
153// as those macros have values in both i32 and u32 range.
154// See comments in later genrule modules about diff/patch
155// to detect and fix errors.
156bindgen_post_edit_cmd = " sed -i 's/: u32 /: i32 /' $(out) &&"
157
158genrule_default_cmd = "$(location bindgen.sh)"
159 + sqlite3_bindgen_flags
160 + common_bindgen_flags
161 + sqlite3_bindgen_clang_flags
162
163// In these genrule modules, diff -U3 is used to check if the
164// generated files are the same as the saved version.
165// This also catches any change made by bindgen_post_edit_cmd.
166// Any sed command failure or output difference will stop the genrule module.
167// To fix and resume the build, the diff -U3 output in stdout should
168// be saved and passed to the 'patch' command to fix the bindings.rs file.
169// The changes to bindgings.rs should be manually verified and tested.
170genrule {
171 name: "sqlite3_bindgen_x86",
172 defaults: ["sqlite3_bindgen_defaults"],
173 cmd: genrule_default_cmd + " --target=i386 &&"
174 + bindgen_post_edit_cmd
175 + " diff -U3 `dirname $(in)`/x86/bindings.rs $(out)",
176}
177
178genrule {
179 name: "sqlite3_bindgen_x86_64",
180 defaults: ["sqlite3_bindgen_defaults"],
181 cmd: genrule_default_cmd + " --target=x86_64 &&"
182 + bindgen_post_edit_cmd
183 + " diff -U3 `dirname $(in)`/x86_64/bindings.rs $(out)",
184}
185
186genrule {
187 name: "sqlite3_bindgen_arm",
188 defaults: ["sqlite3_bindgen_defaults"],
189 cmd: genrule_default_cmd + " --target=arm &&"
190 + bindgen_post_edit_cmd
191 + " diff -U3 `dirname $(in)`/arm/bindings.rs $(out)",
192}
193
194genrule {
195 name: "sqlite3_bindgen_arm64",
196 defaults: ["sqlite3_bindgen_defaults"],
197 cmd: genrule_default_cmd + " --target=arm64 &&"
198 + bindgen_post_edit_cmd
199 + " diff -U3 `dirname $(in)`/arm64/bindings.rs $(out)",
200}