Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android][WIP] Migrate to FBJNI to support Flipper upgrade #27729

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .buckconfig
Expand Up @@ -8,6 +8,7 @@
[maven_repositories]
central = https://repo1.maven.org/maven2
google = https://maven.google.com/
jcenter = https://jcenter.bintray.com/

[alias]
rntester = //RNTester/android/app:app
Expand Up @@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.uiapp;

import android.content.Context;
Expand Down
43 changes: 41 additions & 2 deletions ReactAndroid/build.gradle
Expand Up @@ -296,7 +296,8 @@ def getNdkBuildFullPath() {
}

def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
dependsOn(prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog)
dependsOn(prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog, extractAARHeaders, extractJNIFiles)

inputs.dir("$projectDir/../ReactCommon")
inputs.dir("src/main/jni")
inputs.dir("src/main/java/com/facebook/react/modules/blob")
Expand Down Expand Up @@ -344,6 +345,34 @@ def packageReactNdkLibsForBuck = tasks.register("packageReactNdkLibsForBuck", Co
into("src/main/jni/prebuilt/lib")
}

task extractAARHeaders {
doLast {
configurations.extractHeaders.files.each {
def file = it.absoluteFile
def packageName = file.name.tokenize('-')[0]
copy {
from zipTree(file)
into "$projectDir/src/main/jni/first-party/$packageName/headers"
include "**/*.h"
}
}
}
}

task extractJNIFiles {
doLast {
configurations.extractJNI.files.each {
def file = it.absoluteFile
def packageName = file.name.tokenize('-')[0]
copy {
from zipTree(file)
into "$projectDir/src/main/jni/first-party/$packageName/"
include "jni/**/*"
}
}
}
}

android {
compileSdkVersion 28

Expand Down Expand Up @@ -386,18 +415,25 @@ android {
}

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(packageReactNdkLibs)
compileTask ->
compileTask.dependsOn(packageReactNdkLibs)
}

clean.dependsOn(cleanReactNdkLib)

lintOptions {
abortOnError(false)
}

packagingOptions {
exclude("META-INF/NOTICE")
exclude("META-INF/LICENSE")
}

configurations {
extractHeaders
extractJNI
}
}

dependencies {
Expand All @@ -412,6 +448,9 @@ dependencies {
api("com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}")
api("com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP_VERSION}")
api("com.squareup.okio:okio:1.15.0")
api("com.facebook.fbjni:fbjni-java-only:0.0.3")
extractHeaders("com.facebook.fbjni:fbjni:0.0.2:headers")
extractJNI("com.facebook.fbjni:fbjni:0.0.2")

testImplementation("junit:junit:${JUNIT_VERSION}")
testImplementation("org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}")
Expand Down
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/java/com/facebook/BUCK
Expand Up @@ -5,7 +5,7 @@ rn_android_library(
srcs = glob(["yoga/*.java"]),
visibility = ["PUBLIC"],
deps = [
react_native_dep("java/com/facebook/jni:jni"),
react_native_dep("libraries/fbjni/java/com/facebook/fbjni:fbjni"),
react_native_dep("java/com/facebook/proguard/annotations:annotations"),
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
Expand Down
Expand Up @@ -19,7 +19,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
LOCAL_CPP_FEATURES := exceptions

LOCAL_STATIC_LIBRARIES := libjsireact libjsi
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libhermes
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes

include $(BUILD_SHARED_LIBRARY)

Expand Down
Expand Up @@ -15,7 +15,7 @@ rn_android_library(
deps = [
react_native_dep("java/com/facebook/proguard/annotations:annotations"),
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
react_native_dep("java/com/facebook/jni:jni"),
react_native_dep("libraries/fbjni/java/com/facebook/fbjni:fbjni"),
":jni_hermes_samplingprofiler",
],
)
Expand Down
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include <fb/fbjni.h>
#include <fbjni/fbjni.h>
#include <string>

namespace facebook {
Expand Down
Expand Up @@ -8,8 +8,7 @@
#ifndef HERMESSAMPLINGPROFILER_H_
#define HERMESSAMPLINGPROFILER_H_

#include <fb/fbjni.h>
#include <jni/Registration.h>
#include <fbjni/fbjni.h>
#include <jsi/jsi.h>

namespace facebook {
Expand Down
Expand Up @@ -18,7 +18,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
LOCAL_CPP_FEATURES := exceptions

LOCAL_STATIC_LIBRARIES := libjsireact libjsi
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libhermes
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes

include $(BUILD_SHARED_LIBRARY)

Expand All @@ -35,6 +35,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
LOCAL_CPP_FEATURES := exceptions

LOCAL_STATIC_LIBRARIES := libjsireact libjsi libhermes-inspector
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libhermes
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes

include $(BUILD_SHARED_LIBRARY)
Expand Up @@ -7,7 +7,7 @@

#include <../instrumentation/HermesMemoryDumper.h>
#include <HermesExecutorFactory.h>
#include <fb/fbjni.h>
#include <fbjni/fbjni.h>
#include <hermes/Public/GCConfig.h>
#include <hermes/Public/RuntimeConfig.h>
#include <jni.h>
Expand Down
16 changes: 0 additions & 16 deletions ReactAndroid/src/main/java/com/facebook/jni/BUCK

This file was deleted.

39 changes: 0 additions & 39 deletions ReactAndroid/src/main/java/com/facebook/jni/Countable.java

This file was deleted.

This file was deleted.

139 changes: 0 additions & 139 deletions ReactAndroid/src/main/java/com/facebook/jni/DestructorThread.java

This file was deleted.