Skip to content

Commit d729f0e

Browse files
Use compiler flag -fvisibility=hidden
Summary: Using compiler flag -fvisibility=hidden and explicitly setting visibility to default to public methods #Changelog: [Internal] [Yoga] Use compiler flag -fvisibility=hidden for reducing yoga binary size Reviewed By: astreet Differential Revision: D18029030 fbshipit-source-id: 545e73f9c25f3108fc9d9bb7f08c157dbc8da005
1 parent f2bb793 commit d729f0e

File tree

11 files changed

+220
-137
lines changed

11 files changed

+220
-137
lines changed

ReactAndroid/src/main/jni/first-party/yogajni/jni/corefunctions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ jint ensureInitialized(JNIEnv** env, JavaVM* vm) {
4242
return JNI_VERSION_1_6;
4343
}
4444

45-
JNIEnv* getCurrentEnv() {
45+
// TODO why we need JNIEXPORT for getCurrentEnv ?
46+
JNIEXPORT JNIEnv* getCurrentEnv() {
4647
JNIEnv* env;
4748
jint ret = globalVm->GetEnv((void**) &env, JNI_VERSION_1_6);
4849
if (ret != JNI_OK) {

ReactCommon/yoga/yoga/CompactValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#pragma once
99

1010
#include "YGValue.h"
11-
11+
#include "YGMacros.h"
1212
#include <cmath>
1313
#include <cstdint>
1414
#include <limits>
@@ -40,7 +40,7 @@ namespace detail {
4040
// 0x40000000 0x7f7fffff
4141
// - Zero is supported, negative zero is not
4242
// - values outside of the representable range are clamped
43-
class CompactValue {
43+
class YOGA_EXPORT CompactValue {
4444
friend constexpr bool operator==(CompactValue, CompactValue) noexcept;
4545

4646
public:

ReactCommon/yoga/yoga/YGConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "Yoga-internal.h"
1010
#include "Yoga.h"
1111

12-
struct YGConfig {
12+
struct YOGA_EXPORT YGConfig {
1313
using LogWithContextFn = int (*)(
1414
YGConfigRef config,
1515
YGNodeRef node,

ReactCommon/yoga/yoga/YGMacros.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
#define WIN_EXPORT
2222
#endif
2323

24+
#ifndef YOGA_EXPORT
25+
#ifdef _MSC_VER
26+
#define YOGA_EXPORT
27+
#else
28+
#define YOGA_EXPORT __attribute__((visibility("default")))
29+
#endif
30+
#endif
31+
2432
#ifdef NS_ENUM
2533
// Cannot use NSInteger as NSInteger has a different size than int (which is the
2634
// default type of a enum). Therefor when linking the Yoga C library into obj-c

ReactCommon/yoga/yoga/YGNode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
188188
setMeasureFunc(m);
189189
}
190190

191-
void YGNode::setMeasureFunc(MeasureWithContextFn measureFunc) {
191+
YOGA_EXPORT void YGNode::setMeasureFunc(MeasureWithContextFn measureFunc) {
192192
flags_.at<measureUsesContext_>() = true;
193193
decltype(YGNode::measure_) m;
194194
m.withContext = measureFunc;
@@ -378,7 +378,7 @@ YGDirection YGNode::resolveDirection(const YGDirection ownerDirection) {
378378
}
379379
}
380380

381-
void YGNode::clearChildren() {
381+
YOGA_EXPORT void YGNode::clearChildren() {
382382
children_.clear();
383383
children_.shrink_to_fit();
384384
}

ReactCommon/yoga/yoga/YGNode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
YGConfigRef YGConfigGetDefault();
2020

21-
struct YGNode {
21+
struct YOGA_EXPORT YGNode {
2222
using MeasureWithContextFn =
2323
YGSize (*)(YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*);
2424
using BaselineWithContextFn = float (*)(YGNode*, float, float, void*);

ReactCommon/yoga/yoga/YGStyle.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "Yoga-internal.h"
1818
#include "Yoga.h"
1919

20-
class YGStyle {
20+
class YOGA_EXPORT YGStyle {
2121
template <typename Enum>
2222
using Values =
2323
facebook::yoga::detail::Values<facebook::yoga::enums::count<Enum>()>;
@@ -197,7 +197,7 @@ class YGStyle {
197197
Ref<YGFloatOptional, &YGStyle::aspectRatio_> aspectRatio() { return {*this}; }
198198
};
199199

200-
bool operator==(const YGStyle& lhs, const YGStyle& rhs);
201-
inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
200+
YOGA_EXPORT bool operator==(const YGStyle& lhs, const YGStyle& rhs);
201+
YOGA_EXPORT inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
202202
return !(lhs == rhs);
203203
}

ReactCommon/yoga/yoga/YGValue.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ typedef struct YGValue {
2626
YGUnit unit;
2727
} YGValue;
2828

29-
extern const YGValue YGValueAuto;
30-
extern const YGValue YGValueUndefined;
31-
extern const YGValue YGValueZero;
29+
YOGA_EXPORT extern const YGValue YGValueAuto;
30+
YOGA_EXPORT extern const YGValue YGValueUndefined;
31+
YOGA_EXPORT extern const YGValue YGValueZero;
3232

3333
YG_EXTERN_C_END
3434

0 commit comments

Comments
 (0)