-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
Use node package dependency to manage JSC version #24276
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,21 +133,14 @@ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) | |
} | ||
} | ||
|
||
task downloadJSC(dependsOn: createNativeDepsDirectories, type: Download) { | ||
src("https://registry.npmjs.org/jsc-android/-/jsc-android-${JSC_VERSION}.tgz") | ||
onlyIfNewer(true) | ||
overwrite(false) | ||
dest(new File(downloadsDir, "jsc-${JSC_VERSION}.tar.gz")) | ||
} | ||
|
||
// Create Android.mk library module based on jsc from npm | ||
task prepareJSC(dependsOn: downloadJSC) { | ||
task prepareJSC { | ||
doLast { | ||
def jscTar = tarTree(downloadJSC.dest) | ||
def jscAAR = jscTar.matching({ it.include "**/android-jsc/**/*.aar" }).singleFile | ||
def jscPackageRoot = fileTree("$projectDir/../node_modules/jsc-android/dist") | ||
def jscAAR = jscPackageRoot.matching({ it.include "**/android-jsc/**/*.aar" }).singleFile | ||
def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" }) | ||
|
||
def headerFiles = jscTar.matching({ it.include "**/include/*.h" }) | ||
def headerFiles = jscPackageRoot.matching({ it.include "**/include/*.h" }) | ||
|
||
copy { | ||
from(soFiles) | ||
|
@@ -168,7 +161,6 @@ task downloadNdkBuildDependencies { | |
dependsOn(downloadDoubleConversion) | ||
dependsOn(downloadFolly) | ||
dependsOn(downloadGlog) | ||
dependsOn(downloadJSC) | ||
} | ||
|
||
def getNdkBuildName() { | ||
|
@@ -255,8 +247,8 @@ task cleanReactNdkLib(type: Exec) { | |
|
||
task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) { | ||
from("$buildDir/react-ndk/all") | ||
from("$thirdPartyNdkDir/jsc/jni") | ||
into("$buildDir/react-ndk/exported") | ||
exclude("**/libjsc.so") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this redundant ? By default gradle deps won't bundled in the aar. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. libjsc.so will be copied into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also exclude libc++_shared.so too so that app packages don't have to do that It's a dangerous thing in case there are other dependencies than RN that bring in libc++_shared.so as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a good point and I don't have a good solution right now. There is also an assumption that NDK maintains ABI compatibilities because RN and JSC may build from different NDK version, e.g. old JSC is built by NDK r10c. Possible solutions like:
IMO, excluding libc++_shared.so from jsc-android-buildscripts is better than pickFirst as pickFirst may impact to application level. |
||
} | ||
|
||
task packageReactNdkLibsForBuck(dependsOn: packageReactNdkLibs, type: Copy) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit confused about removing downloadJSC dependency.
What makes it appear jsc-android at
"$projectDir/../node_modules/jsc-android/dist"
location by the time this script runs?FYI I don't see build.gradle invoking npm at any point, so unless I'm missing it somewhere this may make builds without invoking
npm install
first always fail.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is inside of
node_modules/react-native
when using React Native, so JSC should definitely be there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant when building RN from source, not when consuming it. While consuming none of ReactAndroid/build.gradle matters anyways.
The current instructions to build from source is simple download RN and run
./gradlew :ReactAndroid:installArchives
I am asking will this work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Is there a way we can invoke "yarn" from gradle just to make sure node modules are in sync?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment from when new JSC was checked in #22263 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @DanielZlotin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my point of view, RN itself is tightly coupled with node_modules, i.e. you cannot simply get a AAR or APK to run without metro or node_modules stuffs.
I also prefer to maintain even native dependencies in single source of truth, the pakcage.json.
Otherwise, we currently have multiple place to declare dependency version.
E.g. folly version 2018.10.22.00 defines in multiple places like gradle, CocoaPods, and Xcodeproj.
Invoking yarn by gradle is good to me.
Or at least we could check if node_modules is not there and prompt user to run yarn manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this also broke the docker build
yarn test-android-unit
. I tried changing theDockerfile.android
toRUN yarn
before./gradlew :ReactAndroid:packageReactNdkLibsForBuck
(and removed the dead reference todownloadJSC
) but that didn't work, it still failed with