Skip to content

Commit e6d1ab9

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Replace "facebook.proguard.annotations" with "facebook.yoga.annotations" (#35841)
Summary: Pull Request resolved: #35841 X-link: facebook/litho#928 X-link: facebook/yoga#1216 The Yoga JNI bindings use Reflection, so we need to let ProGuard know not to strip certain annotated fields. This is done internally using a single copy of `com.facebook.proguard.annotations` from fbandroid (sometimes), which is then repackaged externally, and published as its own whole Yoga specific package. We never actually inform the stock Gradle project of the rules for the annotations though, so apps must add these manually. This simplifies the setup, where Yoga has its own self-contained annotations/rules. The rules are exposed for Gradle/Buck dependencies, but RN and Litho both consume Yoga via dirsync + custom Gradle logic, so we need to duplicate the proguard rules to them instead of them being propagated automatically. Changelog: [Internal] Reviewed By: rshest Differential Revision: D42406641 fbshipit-source-id: c2b12fd498f93f144e5651917ca878d2a5050e08
1 parent cb80f16 commit e6d1ab9

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

ReactAndroid/proguard-rules.pro

+7
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@
6060
-dontwarn java.nio.file.*
6161
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
6262
-dontwarn okio.**
63+
64+
# yoga
65+
-keep,allowobfuscation @interface com.facebook.yoga.annotations.DoNotStrip
66+
-keep @com.facebook.yoga.annotations.DoNotStrip class *
67+
-keepclassmembers class * {
68+
@com.facebook.yoga.annotations.DoNotStrip *;
69+
}

ReactAndroid/src/main/java/com/facebook/BUCK

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra
22

33
rn_android_library(
44
name = "yoga",
5-
srcs = glob(["yoga/*.java"]),
5+
srcs = glob(["yoga/**/*.java"]),
66
autoglob = False,
77
language = "JAVA",
88
visibility = ["PUBLIC"],

ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
package com.facebook.yoga;
1111

12-
import com.facebook.proguard.annotations.DoNotStrip;
12+
import com.facebook.yoga.annotations.DoNotStrip;
1313

1414
@DoNotStrip
1515
public enum YogaLogLevel {

ReactAndroid/src/main/java/com/facebook/yoga/YogaLogger.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package com.facebook.yoga;
99

10-
import com.facebook.proguard.annotations.DoNotStrip;
10+
import com.facebook.yoga.annotations.DoNotStrip;
1111

1212
/**
1313
* Interface for receiving logs from native layer. Use by setting YogaNode.setLogger(myLogger);

ReactAndroid/src/main/java/com/facebook/yoga/YogaNative.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package com.facebook.yoga;
99

10-
import com.facebook.proguard.annotations.DoNotStrip;
10+
import com.facebook.yoga.annotations.DoNotStrip;
1111
import com.facebook.soloader.SoLoader;
1212

1313
@DoNotStrip

ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package com.facebook.yoga;
99

10-
import com.facebook.proguard.annotations.DoNotStrip;
10+
import com.facebook.yoga.annotations.DoNotStrip;
1111
import java.util.ArrayList;
1212
import java.util.List;
1313
import javax.annotation.Nullable;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.yoga.annotations;
9+
10+
import java.lang.annotation.ElementType;
11+
import java.lang.annotation.Retention;
12+
import java.lang.annotation.Target;
13+
14+
import static java.lang.annotation.RetentionPolicy.CLASS;
15+
16+
@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
17+
@Retention(CLASS)
18+
public @interface DoNotStrip { }

0 commit comments

Comments
 (0)