Exclude logging functionality outside debug builds
Summary: Don't compile in YGNodePrint in production builds Reviewed By: davidaurelio Differential Revision: D14258269 fbshipit-source-id: 15b5e94d241a752fea74a45263aa343265071451
This commit is contained in:
committed by
Facebook Github Bot
parent
0d96098fd9
commit
14f3827491
17
BUCK
17
BUCK
@@ -15,6 +15,7 @@ COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
|
|||||||
|
|
||||||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
||||||
"-std=c++1y",
|
"-std=c++1y",
|
||||||
|
"-DDEBUG",
|
||||||
]
|
]
|
||||||
|
|
||||||
yoga_cxx_library(
|
yoga_cxx_library(
|
||||||
@@ -31,6 +32,20 @@ yoga_cxx_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
yoga_cxx_library(
|
||||||
|
name = "yogaForDebug",
|
||||||
|
srcs = glob(["yoga/*.cpp"]),
|
||||||
|
header_namespace = "",
|
||||||
|
exported_headers = subdir_glob([("", "yoga/*.h")]),
|
||||||
|
compiler_flags = TEST_COMPILER_FLAGS,
|
||||||
|
soname = "libyogacore.$(ext)",
|
||||||
|
tests = [":YogaTests"],
|
||||||
|
visibility = ["PUBLIC"],
|
||||||
|
deps = [
|
||||||
|
yoga_dep("lib/fb:ndklog"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
yoga_cxx_test(
|
yoga_cxx_test(
|
||||||
name = "YogaTests",
|
name = "YogaTests",
|
||||||
srcs = glob(["tests/*.cpp"]),
|
srcs = glob(["tests/*.cpp"]),
|
||||||
@@ -39,7 +54,7 @@ yoga_cxx_test(
|
|||||||
contacts = ["emilsj@fb.com"],
|
contacts = ["emilsj@fb.com"],
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
":yoga",
|
":yogaForDebug",
|
||||||
GTEST_TARGET,
|
GTEST_TARGET,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@@ -352,11 +352,13 @@ void jni_YGNodeReset(jlong nativePointer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodePrint(jlong nativePointer) {
|
void jni_YGNodePrint(jlong nativePointer) {
|
||||||
|
#ifdef DEBUG
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
YGNodePrint(
|
YGNodePrint(
|
||||||
node,
|
node,
|
||||||
(YGPrintOptions)(
|
(YGPrintOptions)(
|
||||||
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
|
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeInsertChild(
|
void jni_YGNodeInsertChild(
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
* file in the root directory of this source tree.
|
* file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
#ifdef DEBUG
|
||||||
#include "YGNodePrint.h"
|
#include "YGNodePrint.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "YGEnums.h"
|
#include "YGEnums.h"
|
||||||
@@ -230,3 +231,4 @@ void YGNodeToString(
|
|||||||
}
|
}
|
||||||
} // namespace yoga
|
} // namespace yoga
|
||||||
} // namespace facebook
|
} // namespace facebook
|
||||||
|
#endif
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
* file in the root directory of this source tree.
|
* file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
#ifdef DEBUG
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -20,3 +21,4 @@ void YGNodeToString(
|
|||||||
|
|
||||||
} // namespace yoga
|
} // namespace yoga
|
||||||
} // namespace facebook
|
} // namespace facebook
|
||||||
|
#endif
|
||||||
|
@@ -979,6 +979,7 @@ bool YGLayoutNodeInternal(
|
|||||||
YGMarkerLayoutData& layoutMarkerData,
|
YGMarkerLayoutData& layoutMarkerData,
|
||||||
void* const layoutContext);
|
void* const layoutContext);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
static void YGNodePrintInternal(
|
static void YGNodePrintInternal(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGPrintOptions options) {
|
const YGPrintOptions options) {
|
||||||
@@ -990,6 +991,7 @@ static void YGNodePrintInternal(
|
|||||||
void YGNodePrint(const YGNodeRef node, const YGPrintOptions options) {
|
void YGNodePrint(const YGNodeRef node, const YGPrintOptions options) {
|
||||||
YGNodePrintInternal(node, options);
|
YGNodePrintInternal(node, options);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const std::array<YGEdge, 4> leading = {
|
const std::array<YGEdge, 4> leading = {
|
||||||
{YGEdgeTop, YGEdgeBottom, YGEdgeLeft, YGEdgeRight}};
|
{YGEdgeTop, YGEdgeBottom, YGEdgeLeft, YGEdgeRight}};
|
||||||
@@ -4091,6 +4093,7 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth);
|
node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth);
|
||||||
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
|
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
if (node->getConfig()->printTree) {
|
if (node->getConfig()->printTree) {
|
||||||
YGNodePrint(
|
YGNodePrint(
|
||||||
node,
|
node,
|
||||||
@@ -4098,6 +4101,7 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
YGPrintOptionsLayout | YGPrintOptionsChildren |
|
YGPrintOptionsLayout | YGPrintOptionsChildren |
|
||||||
YGPrintOptionsStyle));
|
YGPrintOptionsStyle));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we
|
// We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we
|
||||||
@@ -4147,6 +4151,7 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
!originalNode->isLayoutTreeEqualToNode(*node);
|
!originalNode->isLayoutTreeEqualToNode(*node);
|
||||||
node->setLayoutDoesLegacyFlagAffectsLayout(neededLegacyStretchBehaviour);
|
node->setLayoutDoesLegacyFlagAffectsLayout(neededLegacyStretchBehaviour);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
if (originalNode->getConfig()->printTree) {
|
if (originalNode->getConfig()->printTree) {
|
||||||
YGNodePrint(
|
YGNodePrint(
|
||||||
originalNode,
|
originalNode,
|
||||||
@@ -4154,6 +4159,7 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
YGPrintOptionsLayout | YGPrintOptionsChildren |
|
YGPrintOptionsLayout | YGPrintOptionsChildren |
|
||||||
YGPrintOptionsStyle));
|
YGPrintOptionsStyle));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
YGConfigFreeRecursive(originalNode);
|
YGConfigFreeRecursive(originalNode);
|
||||||
YGNodeFreeRecursive(originalNode);
|
YGNodeFreeRecursive(originalNode);
|
||||||
|
Reference in New Issue
Block a user