Use defaults from external/sqlite am: 8cc6a24726 am: 355708aa90

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/libsqlite3-sys/+/1674871

Change-Id: Ia56c8b0939fd0873b7593cd36d36ddcfe678583f
diff --git a/Android.bp b/Android.bp
index 982f3fb..46b94a4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,5 @@
 // This file is generated by cargo2android.py --device --run --dependencies --test --patch=patches/Android.bp.patch.
+// Do not modify this file as changes will be overridden on upgrade.
 
 // We renamed the shared_libs dependence from libsqlite3 to libsqlite.
 // srcs has been moved out of _defaults to work around b/163420435
@@ -79,6 +80,9 @@
         ":libsqlite3_bindgen",
     ],
     defaults: ["libsqlite3-sys_defaults"],
+    test_options: {
+        unit_test: true,
+    },
 }
 
 rust_test {
@@ -93,38 +97,6 @@
 // dependent_library ["feature_list"]
 //   pkg-config-0.3.19
 
-// Keep this array in sync with the cflags used in external/sqlite
-// After b/163598610 is resolved, use defaults instead.
-sqlite3_bindgen_clang_flags = [
-    " -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",
-    " -DHAVE_POSIX_FALLOCATE=1",
-    // extra -D flags for android targets
-    " -DUSE_PREAD64",
-    " -Dfdatasync=fdatasync",
-    " -DHAVE_MALLOC_H=1",
-    " -DHAVE_MALLOC_USABLE_SIZE",
-    " -Wno-unused-parameter",
-]
-
 rust_bindgen {
     name: "libsqlite3_bindgen",
     host_supported: true,
@@ -132,5 +104,6 @@
     custom_bindgen: "sqlite3_bindgen_build",
     wrapper_src: "wrapper.h",
     source_stem: "bindgen",
-    cflags: ["-I external/sqlite/dist"] + sqlite3_bindgen_clang_flags,
+    cflags: ["-I external/sqlite/dist"],
+    defaults: ["sqlite-defaults"],
 }
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 6716814..a731acb 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,8 +1,14 @@
-// Generated by cargo2android.py for tests in Android.bp
+// Generated by update_crate_tests.py for tests that depend on this crate.
 {
   "presubmit": [
     {
+      "name": "keystore2_test"
+    },
+    {
       "name": "libsqlite3-sys_device_test_src_lib"
+    },
+    {
+      "name": "vpnprofilestore_test"
     }
   ]
 }
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
index 0a2d5c3..0b9b65e 100644
--- a/patches/Android.bp.patch
+++ b/patches/Android.bp.patch
@@ -1,12 +1,6 @@
---- Android.bp	2020-10-30 16:41:52.854552104 -0700
-+++ Android.bp	2020-10-30 16:47:00.153323579 -0700
-@@ -1,10 +1,16 @@
- // This file is generated by cargo2android.py --device --run --dependencies --test --patch=patches/Android.bp.patch.
- 
-+// We renamed the shared_libs dependence from libsqlite3 to libsqlite.
-+// srcs has been moved out of _defaults to work around b/163420435
-+
- rust_library {
+--- Android.bp	2021-04-14 17:32:44.882379059 +0000
++++ Android.bp	2021-04-14 17:33:25.765957305 +0000
+@@ -40,7 +40,10 @@
      name: "liblibsqlite3_sys",
      host_supported: true,
      crate_name: "libsqlite3_sys",
@@ -18,7 +12,7 @@
      edition: "2018",
      features: [
          "default",
-@@ -12,13 +18,14 @@
+@@ -48,13 +51,14 @@
          "pkg-config",
          "vcpkg",
      ],
@@ -35,7 +29,7 @@
      test_suites: ["general-tests"],
      auto_gen_config: true,
      edition: "2018",
-@@ -28,23 +35,70 @@
+@@ -64,11 +68,17 @@
          "pkg-config",
          "vcpkg",
      ],
@@ -52,7 +46,9 @@
 +        ":libsqlite3_bindgen",
 +    ],
      defaults: ["libsqlite3-sys_defaults"],
- }
+     test_options: {
+         unit_test: true,
+@@ -77,13 +87,23 @@
  
  rust_test {
      name: "libsqlite3-sys_device_test_src_lib",
@@ -69,39 +65,7 @@
 -Errors in cargo.out:
 -error: linking with `cc` failed: exit code: 1
 -error: aborting due to previous error
--error: could not compile `libsqlite3-sys`.
-+// Keep this array in sync with the cflags used in external/sqlite
-+// After b/163598610 is resolved, use defaults instead.
-+sqlite3_bindgen_clang_flags = [
-+    " -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",
-+    " -DHAVE_POSIX_FALLOCATE=1",
-+    // extra -D flags for android targets
-+    " -DUSE_PREAD64",
-+    " -Dfdatasync=fdatasync",
-+    " -DHAVE_MALLOC_H=1",
-+    " -DHAVE_MALLOC_USABLE_SIZE",
-+    " -Wno-unused-parameter",
-+]
-+
+-error: could not compile `libsqlite3-sys`
 +rust_bindgen {
 +    name: "libsqlite3_bindgen",
 +    host_supported: true,
@@ -109,5 +73,6 @@
 +    custom_bindgen: "sqlite3_bindgen_build",
 +    wrapper_src: "wrapper.h",
 +    source_stem: "bindgen",
-+    cflags: ["-I external/sqlite/dist"] + sqlite3_bindgen_clang_flags,
++    cflags: ["-I external/sqlite/dist"],
++    defaults: ["sqlite-defaults"],
 +}