Back out "Use NSCAssert() in react_native_assert instead of C assert()"

Summary:
Original commit changeset: 43c4e4f1ae6b

Original Phabricator Diff: D43275024 (c5bc3f1373)

D43587488 reverted D43275024 (c5bc3f1373), but it was only committed to the fbobjc/releases/release-fbios-2023.03.01 branch (v404).

We still aren't seeing successful fbios-pika-iphoneos-release builds for v405 (https://fburl.com/mobile/7zac3b5w). This is preventing QA and employee dogfooding of v405 (S325502).

(Note: this ignores all push blocking failures!)

Reviewed By: abashyam

Differential Revision: D43609260

fbshipit-source-id: d411294ad8cdb22ff9e812bf0689d9b7bdff8d2e
This commit is contained in:
Jeffrey Beauchamp 2023-02-26 10:24:40 -08:00 коммит произвёл Facebook GitHub Bot
Родитель e57b6d11fa
Коммит 6e28e2dc99
6 изменённых файлов: 43 добавлений и 38 удалений

Просмотреть файл

@ -235,8 +235,7 @@ Pod::Spec.new do |s|
s.subspec "debug_core" do |ss|
ss.dependency folly_dep_name, folly_version
ss.compiler_flags = folly_compiler_flags
ss.source_files = "react/debug/*.h",
"react/debug/ios/**/*.{m,mm,cpp,h}"
ss.source_files = "react/debug/**/*.{m,mm,cpp,h}"
ss.exclude_files = "react/debug/tests"
ss.header_dir = "react/debug"
end

Просмотреть файл

@ -14,6 +14,10 @@ APPLE_COMPILER_FLAGS = get_apple_compiler_flags()
rn_xplat_cxx_library(
name = "debug",
srcs = glob(
["**/*.cpp"],
exclude = glob(["tests/**/*.cpp"]),
),
headers = glob(
["**/*.h"],
exclude = glob(["tests/**/*.h"]),
@ -36,10 +40,8 @@ rn_xplat_cxx_library(
# for android react_native_assert
"-llog",
],
fbandroid_srcs = glob(["android/**/*.cpp"]),
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
fbobjc_srcs = glob(["ios/**/*.mm"]),
force_static = True,
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",

Просмотреть файл

@ -16,7 +16,7 @@ add_compile_options(
-DLOG_TAG=\"Fabric\")
file(GLOB react_debug_SRC CONFIGURE_DEPENDS android/*.cpp)
file(GLOB react_debug_SRC CONFIGURE_DEPENDS *.cpp)
add_library(react_debug SHARED ${react_debug_SRC})
target_include_directories(react_debug PUBLIC ${REACT_COMMON_DIR})

Просмотреть файл

@ -1,27 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/NSException.h>
#import <glog/logging.h>
#import <react/debug/react_native_assert.h>
#ifdef REACT_NATIVE_DEBUG
extern "C" void react_native_assert_fail(const char *func, const char *file, int line, const char *expr)
{
// flush logs because some might be lost on iOS if an assert is hit right after
// this. If you are trying to debug something actively and have added lots of
// LOG statements to track down an issue, there is race between flushing the
// final logs and stopping execution when the assert hits. Thus, if we know an
// assert will fail, we force flushing to happen right before the assert.
LOG(ERROR) << "react_native_assert failure: " << expr;
google::FlushLogFiles(google::GLOG_INFO /*min_severity*/);
NSCAssert(false, @"%s:%d: function %s: assertion failed (%s)", file, line, func, expr);
}
#endif

Просмотреть файл

@ -5,10 +5,17 @@
* LICENSE file in the root directory of this source tree.
*/
#include <android/log.h>
#include <react/debug/react_native_assert.h>
#ifdef __ANDROID__
#ifdef REACT_NATIVE_DEBUG
#include <android/log.h>
// Provide a prototype to silence missing prototype warning in release
// mode.
extern "C" void react_native_assert_fail(
const char *func,
const char *file,
int line,
const char *expr);
extern "C" void react_native_assert_fail(
const char *func,
@ -35,4 +42,4 @@ extern "C" void react_native_assert_fail(
expr);
}
#endif
#endif // __ANDROID__

Просмотреть файл

@ -28,8 +28,9 @@
#else // REACT_NATIVE_DEBUG
#define react_native_assert(e) \
((e) ? (void)0 : react_native_assert_fail(__func__, __FILE__, __LINE__, #e))
#ifdef __ANDROID__
#include <android/log.h>
#ifdef __cplusplus
extern "C" {
@ -43,4 +44,27 @@ void react_native_assert_fail(
}
#endif // __cpusplus
#define react_native_assert(e) \
((e) ? (void)0 : react_native_assert_fail(__func__, __FILE__, __LINE__, #e))
#else // __ANDROID__
#include <glog/logging.h>
#include <cassert>
// For all platforms, but iOS+Xcode especially: flush logs because some might be
// lost on iOS if an assert is hit right after this. If you are trying to debug
// something actively and have added lots of LOG statements to track down an
// issue, there is race between flushing the final logs and stopping execution
// when the assert hits. Thus, if we know an assert will fail, we force flushing
// to happen right before the assert.
#define react_native_assert(cond) \
if (!(cond)) { \
LOG(ERROR) << "react_native_assert failure: " << #cond; \
google::FlushLogFiles(google::GLOG_INFO); \
assert(cond); \
}
#endif // platforms besides __ANDROID__
#endif // REACT_NATIVE_DEBUG