Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rn-tester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ project.ext.react = [
inputExcludes: ["android/**", "./**", ".gradle/**"],
composeSourceMapsPath: "$rootDir/scripts/compose-source-maps.js",
hermesCommand: "$rootDir/node_modules/hermes-engine/%OS-BIN%/hermesc",
enableHermesForVariant: { def v -> v.name.contains("hermes") },
enableHermesForVariant: { def name -> name.contains("hermes") },
jsRootDir: "$rootDir/RNTester",
enableCodegen: true, // Keep this here until it's sync'ed to Android template.
enableFabric: (System.getenv('USE_FABRIC') ?: '0').toBoolean(),
Expand Down
61 changes: 19 additions & 42 deletions react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ android {
resValue "integer", "react_native_dev_server_port", reactNativeDevServerPort()
resValue "integer", "react_native_inspector_proxy_port", reactNativeInspectorProxyPort()
}

packagingOptions {
// Delete the VM related libraries that this build doesn't need.
// The application can manage this manually by setting 'enableVmCleanup: false'
//
// This should really be done by packaging all Hermes related libs into
// two separate HermesDebug and HermesRelease AARs, but until then we'll just exclude them here
def taskName = getGradle().getStartParameter().getTaskRequests().toString()
if (enableHermesForVariant(taskName) && enableVmCleanup) {
exclude "**/libjsc*.so"
if (taskName.toLowerCase().contains("release")) {
exclude '**/libhermes-inspector.so'
exclude '**/libhermes-executor-debug.so'
} else {
exclude '**/libhermes-executor-release.so'
}
}
}
}

afterEvaluate {
Expand Down Expand Up @@ -127,7 +145,7 @@ afterEvaluate {
execCommand.addAll([*nodeExecutableAndArgs, cliPath])
}

def enableHermes = enableHermesForVariant(variant)
def enableHermes = enableHermesForVariant(variant.name)

def currentBundleTask = tasks.create(
name: "bundle${targetName}JsAndAssets",
Expand Down Expand Up @@ -311,46 +329,5 @@ afterEvaluate {
if (buildPreBundleTask != null) {
buildPreBundleTask.dependsOn(currentAssetsCopyTask)
}

// Delete the VM related libraries that this build doesn't need.
// The application can manage this manually by setting 'enableVmCleanup: false'
//
// This should really be done by packaging all Hermes releated libs into
// two separate HermesDebug and HermesRelease AARs, but until then we'll
// kludge it by deleting the .so files out of the /transforms/ directory.
def isRelease = targetName.toLowerCase().contains("release")
def libDir = "$buildDir/intermediates/transforms/"
def vmSelectionAction = {
fileTree(libDir).matching {
if (enableHermes) {
// For Hermes, delete all the libjsc* files
include "**/libjsc*.so"

if (isRelease) {
// Reduce size by deleting the debugger/inspector
include '**/libhermes-inspector.so'
include '**/libhermes-executor-debug.so'
} else {
// Release libs take precedence and must be removed
// to allow debugging
include '**/libhermes-executor-release.so'
}
} else {
// For JSC, delete all the libhermes* files
include "**/libhermes*.so"
}
}.visit { details ->
def targetVariant = ".*/transforms/[^/]*/${targetPath}/.*"
def path = details.file.getAbsolutePath().replace(File.separatorChar, '/' as char)
if (path.matches(targetVariant) && details.file.isFile()) {
details.file.delete()
}
}
}

if (enableVmCleanup) {
def task = tasks.findByName("package${targetName}")
task.doFirst(vmSelectionAction)
}
}
}