Android boringssl 添加 log

代码在external/boringssl
主要是Android.bp中的liblog要加对位置,加完后,先用mm看能不能编过,根据报错的位置,添加liblog即可

--- a/Android.bp
+++ b/Android.bp
@@ -102,6 +102,7 @@ cc_defaults {
         },
     },
 
+    shared_libs: ["liblog"],
     local_include_dirs: ["src/crypto"],
     stl: "none",
 }
@@ -518,6 +519,7 @@ cc_test_library {
     static_libs: [
         "libcrypto_fuzz_unsafe",
     ],
+    shared_libs: ["liblog"],
 }
 
 // Tool
@@ -641,6 +643,7 @@ cc_test {
         "boringssl_crypto_test_sources",
         "boringssl_flags",
     ],
+    shared_libs: ["liblog"],
     whole_static_libs: ["boringssl_test_support"],
     // Statically link the library to test to ensure we always pick up the
     // correct version regardless of device linker configuration.
@@ -677,6 +680,7 @@ cc_test {
         "libcrypto_static",
         "libssl",
     ],
+    shared_libs: ["liblog"],
     target: {
         android: {
             test_suites: ["mts-conscrypt"],

另外host也会用到boringssl,所以要用__ANDROID__来隔开code,让host编的时候不去吃log.h头文件,不然头文件可以找到,但是链接的时候找不到__android_log_print

#ifdef __ANDROID__
#include 
#else
#define ANDROID_LOG_INFO ""
#define __android_log_print
#endif

然后比如在EVP_PKEY_verify中插入

__android_log_print(ANDROID_LOG_INFO, "boringssl","====>>>debug boringssl %s %d",__func__,__LINE__);

Android开机就可以看到这个log,

logcat|grep boringssl
01-01 00:36:42.108   677   677 I boringssl : ====>>>debug boringssl EVP_PKEY_verify 260

备注:liblog_for_runtime_apex是liblog的静态库,暂时还未调通,有后续再来补充。

你可能感兴趣的:(keymint,android)