Avoid double glog init internally

Summary:
glog logging was being sent to adb logcat twice since `fbgloginit` uses `force_static = True` and was being linked as two separate copies.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D43842295

fbshipit-source-id: da4233d29dbddc2b3cefdca979c873479672b11c
This commit is contained in:
Pieter De Baets
2023-03-08 05:38:55 -08:00
committed by Facebook GitHub Bot
parent d72697ca95
commit 06e55ec5ea
2 changed files with 11 additions and 4 deletions
+5 -4
View File
@@ -1,4 +1,4 @@
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "IS_OSS_BUILD", "react_native_target", "react_native_xplat_dep", "react_native_xplat_target", "rn_xplat_cxx_library")
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBGLOGINIT_TARGET", "FBJNI_TARGET", "IS_OSS_BUILD", "react_native_target", "react_native_xplat_dep", "react_native_xplat_target", "rn_xplat_cxx_library")
EXPORTED_HEADERS = [
"CxxModuleWrapper.h",
@@ -48,7 +48,7 @@ rn_xplat_cxx_library(
"-DLOG_TAG=\"ReactNativeJNI\"",
"-DWITH_FBSYSTRACE=1",
"-DWITH_INSPECTOR=1",
],
] + ["-DWITH_GLOGINIT=0"] if not IS_OSS_BUILD else [],
soname = "libreactnativejni.$(ext)",
visibility = [
"PUBLIC",
@@ -59,7 +59,6 @@ rn_xplat_cxx_library(
"//third-party/glog:glog",
"//xplat/folly:dynamic",
"//xplat/folly:json",
"//fbandroid/xplat/fbgloginit:fbgloginit",
"//xplat/fbsystrace:fbsystrace",
react_native_target("jni/react/turbomodule:callinvokerholder"),
react_native_xplat_target("cxxreact:bridge"),
@@ -71,5 +70,7 @@ rn_xplat_cxx_library(
react_native_xplat_target("logger:logger"),
react_native_xplat_dep("jsi:jsi"),
FBJNI_TARGET,
] if not IS_OSS_BUILD else [],
] + ([
FBGLOGINIT_TARGET,
] if IS_OSS_BUILD else []),
)
@@ -25,6 +25,10 @@
#include "JInspector.h"
#endif
#ifndef WITH_GLOGINIT
#define WITH_GLOGINIT 1
#endif
using namespace facebook::jni;
namespace facebook {
@@ -67,8 +71,10 @@ class ProxyJavaScriptExecutorHolder : public HybridClass<
extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
return initialize(vm, [] {
#if WITH_GLOGINIT
gloginit::initialize();
FLAGS_minloglevel = 0;
#endif
ProxyJavaScriptExecutorHolder::registerNatives();
CatalystInstanceImpl::registerNatives();
CxxModuleWrapperBase::registerNatives();