From b7b22db2501ecdb93ac12374fe23145289307b71 Mon Sep 17 00:00:00 2001 From: Luke Huang Date: Fri, 21 May 2021 08:05:50 +0000 Subject: Add libquiche_static and use cargo2android.json to generate bp file In order to solve the compatibility issue for doh_unit_test, it's required to have a quiche target statically linked to libcrypto_static and libssl. Bug: 186070162 Test: TH Test: atest doh_unit_test Original-Change: https://android-review.googlesource.com/1710969 Merged-In: If2d0a95fb112942ceec252232486cd6392d11731 Change-Id: If2d0a95fb112942ceec252232486cd6392d11731 --- Android.bp | 40 ++++++++++++----- TEST_MAPPING | 5 ++- cargo2android.json | 12 +++++ patches/Android.bp.patch | 111 +++++++++++++++++++++++------------------------ 4 files changed, 99 insertions(+), 69 deletions(-) create mode 100644 cargo2android.json diff --git a/Android.bp b/Android.bp index 981eb96..578cc68 100644 --- a/Android.bp +++ b/Android.bp @@ -1,4 +1,5 @@ -// This file is generated by cargo2android.py --run --device --dependencies --tests --patch=patches/Android.bp.patch. +// This file is generated by cargo2android.py --config cargo2android.json. +// Do not modify this file as changes will be overridden on upgrade. package { default_applicable_licenses: ["external_rust_crates_quiche_license"], @@ -62,10 +63,6 @@ rust_defaults { "libring", ], prefer_rlib: true, - shared_libs: [ - "libcrypto", - "libssl", - ], // For DnsResolver (Mainline module introduced in Q). apex_available: [ "//apex_available:platform", @@ -77,11 +74,30 @@ rust_defaults { rust_ffi { name: "libquiche_ffi", defaults: ["libquiche_defaults"], + shared_libs: [ + "libcrypto", + "libssl", + ], } rust_library { name: "libquiche", defaults: ["libquiche_defaults"], + shared_libs: [ + "libcrypto", + "libssl", + ], +} + +// This target is used by doh_unit_test to prevent compatibility issues +// because doh_unit_test needs to be run on the R platform. +rust_library_rlib { + name: "libquiche_static", + defaults: ["libquiche_defaults"], + static_libs: [ + "libcrypto_static", + "libssl", + ], } rust_defaults { @@ -136,27 +152,27 @@ rust_test { } // dependent_library ["feature_list"] -// cc-1.0.66 +// cc-1.0.67 // cfg-if-0.1.10 // cfg-if-1.0.0 // cmake-0.1.45 // idna-0.1.5 // iovec-0.1.4 // lazy_static-1.4.0 -// libc-0.2.85 "default,std" +// libc-0.2.94 "default,std" // libm-0.2.1 "default" // log-0.4.14 "std" // matches-0.1.8 // mio-0.6.23 "default,with-deprecated" // net2-0.2.37 "default,duration" -// once_cell-1.5.2 "alloc,std" +// once_cell-1.7.2 "alloc,race,std" // percent-encoding-1.0.1 // ring-0.16.20 "alloc,default,dev_urandom_fallback,once_cell" -// slab-0.4.2 +// slab-0.4.3 "default,std" // spin-0.5.2 -// tinyvec-1.1.1 "alloc,default,tinyvec_macros" +// tinyvec-1.2.0 "alloc,default,tinyvec_macros" // tinyvec_macros-0.1.0 -// unicode-bidi-0.3.4 "default" -// unicode-normalization-0.1.16 "default,std" +// unicode-bidi-0.3.5 "default" +// unicode-normalization-0.1.17 "default,std" // untrusted-0.7.1 // url-1.7.2 diff --git a/TEST_MAPPING b/TEST_MAPPING index d06f91d..ba9a257 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,6 +1,9 @@ -// Generated by cargo2android.py for tests in Android.bp +// Generated by update_crate_tests.py for tests that depend on this crate. { "presubmit": [ + { + "name": "doh_unit_test" + }, { "name": "quiche_device_test_src_lib" } diff --git a/cargo2android.json b/cargo2android.json new file mode 100644 index 0000000..e34fbf5 --- /dev/null +++ b/cargo2android.json @@ -0,0 +1,12 @@ +{ + "apex-available": [ + "//apex_available:platform", + "com.android.resolv" + ], + "min_sdk_version": "29", + "dependencies": true, + "tests": true, + "device": true, + "run": true, + "patch": "patches/Android.bp.patch" + } \ No newline at end of file diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch index 98cd60a..fbd8d17 100644 --- a/patches/Android.bp.patch +++ b/patches/Android.bp.patch @@ -1,47 +1,16 @@ diff --git a/Android.bp b/Android.bp -index 130d4f3..981eb96 100644 +index aced8a6..578cc68 100644 --- a/Android.bp +++ b/Android.bp -@@ -32,75 +32,56 @@ license { - ], +@@ -43,25 +43,38 @@ cc_library_headers { + min_sdk_version: "29", } -rust_ffi_shared { - name: "libquiche_shared", -- stem: "libquiche", -- host_supported: true, -- crate_name: "quiche", -- srcs: ["src/lib.rs"], -- edition: "2018", -- features: [ -- "boringssl-vendored", -- "default", -- ], -- rustlibs: [ -- "liblazy_static", -- "liblibc", -- "liblibm", -- "liblog_rust", -- "libring", -- ], -- static_libs: [ -- "libcrypto", -- "libssl", -+cc_library_headers { -+ name: "libquiche_ffi_headers", -+ export_include_dirs: ["include"], -+ apex_available: [ -+ "//apex_available:platform", -+ "com.android.resolv", - ], -+ min_sdk_version: "29", - } - --rust_library { -- name: "libquiche", +rust_defaults { + name: "libquiche_defaults", -+ stem: "libquiche", + stem: "libquiche", host_supported: true, crate_name: "quiche", srcs: ["src/lib.rs"], @@ -62,20 +31,58 @@ index 130d4f3..981eb96 100644 ], - static_libs: [ + prefer_rlib: true, -+ shared_libs: [ - "libcrypto", - "libssl", - ], + // For DnsResolver (Mainline module introduced in Q). + apex_available: [ + "//apex_available:platform", + "com.android.resolv", + ], + min_sdk_version: "29", ++} ++ ++rust_ffi { ++ name: "libquiche_ffi", ++ defaults: ["libquiche_defaults"], ++ shared_libs: [ + "libcrypto", + "libssl", + ], +@@ -69,52 +82,20 @@ rust_ffi_shared { + + rust_library { + name: "libquiche", +- host_supported: true, +- crate_name: "quiche", +- srcs: ["src/lib.rs"], +- edition: "2018", +- features: [ +- "boringssl-vendored", +- "default", +- ], +- rustlibs: [ +- "liblazy_static", +- "liblibc", +- "liblibm", +- "liblog_rust", +- "libring", +- ], +- static_libs: [ ++ defaults: ["libquiche_defaults"], ++ shared_libs: [ + "libcrypto", + "libssl", + ], +- apex_available: [ +- "//apex_available:platform", +- "com.android.resolv", +- ], +- min_sdk_version: "29", } -rust_ffi_static { -- name: "libquiche_static", ++// This target is used by doh_unit_test to prevent compatibility issues ++// because doh_unit_test needs to be run on the R platform. ++rust_library_rlib { + name: "libquiche_static", - stem: "libquiche", - host_supported: true, - crate_name: "quiche", @@ -92,22 +99,14 @@ index 130d4f3..981eb96 100644 - "liblog_rust", - "libring", - ], -- static_libs: [ -- "libcrypto", -- "libssl", -- ], -+rust_ffi { -+ name: "libquiche_ffi", -+ defaults: ["libquiche_defaults"], -+} -+ -+rust_library { -+ name: "libquiche", + defaults: ["libquiche_defaults"], + static_libs: [ +- "libcrypto", ++ "libcrypto_static", + "libssl", + ], } - - rust_defaults { -@@ -111,7 +92,7 @@ rust_defaults { +@@ -127,7 +108,7 @@ rust_defaults { auto_gen_config: true, edition: "2018", features: [ @@ -116,7 +115,7 @@ index 130d4f3..981eb96 100644 "default", ], rustlibs: [ -@@ -123,10 +104,12 @@ rust_defaults { +@@ -139,10 +120,12 @@ rust_defaults { "libring", "liburl", ], @@ -133,7 +132,7 @@ index 130d4f3..981eb96 100644 } rust_test_host { -@@ -135,11 +118,21 @@ rust_test_host { +@@ -151,11 +134,21 @@ rust_test_host { test_options: { unit_test: true, }, -- cgit v1.2.3