mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ec4833f06d
Summary: BUCK always defines NDEBUG on Android builds. This is a longstanding issue and it's tricky to work around. Previous attempts to fix this within React Native were difficult because disabling NDEBUG caused lots of issues that were difficult to track down. Instead, I am (1) introducing a new RN_DEBUG flag that can be used cross-platform, (2) whenever NDEBUG is *not* enabled, RN_DEBUG will automatically be defined, (3) enables debug-only code to be compiled on Android, (4) enables us to selectively, slowly migrate `assert` to `rn_assert` in a way that doesn't impact non-Android platforms, but allows us to maintain stability of Android debug builds. Actually enabling the RN_DEBUG flag in debug builds is done in FB-internal code. I assume the NDEBUG issue is not a problem when compiling in open-source without BUCK. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26409355 fbshipit-source-id: 285b8073bba3756834925727bfa28d3c6bc06335
40 lines
1003 B
C++
40 lines
1003 B
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#ifdef __ANDROID__
|
|
|
|
#include <android/log.h>
|
|
|
|
// Provide a prototype to silence missing prototype warning in release
|
|
// mode.
|
|
extern "C" void
|
|
rn_assert_fail(const char *func, const char *file, int line, const char *expr);
|
|
|
|
extern "C" void
|
|
rn_assert_fail(const char *func, const char *file, int line, const char *expr) {
|
|
// Print as an error so it shows up in logcat before crash....
|
|
__android_log_print(
|
|
ANDROID_LOG_ERROR,
|
|
"ReactNative",
|
|
"%s:%d: function %s: assertion failed (%s)",
|
|
file,
|
|
line,
|
|
func,
|
|
expr);
|
|
// Print as a fatal so it crashes and shows up in uploaded logs
|
|
__android_log_print(
|
|
ANDROID_LOG_FATAL,
|
|
"ReactNative",
|
|
"%s:%d: function %s: assertion failed (%s)",
|
|
file,
|
|
line,
|
|
func,
|
|
expr);
|
|
}
|
|
|
|
#endif // __ANDROID__
|