@ohos-ports/react-native-gradle-plugin 0.71.19-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/build/libs/react-native-gradle-plugin.jar +0 -0
- package/build.gradle.kts +59 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/gradlew +234 -0
- package/gradlew.bat +89 -0
- package/index.js +73 -0
- package/package.json +30 -0
- package/settings.gradle.kts +16 -0
- package/src/main/kotlin/com/facebook/react/ReactExtension.kt +151 -0
- package/src/main/kotlin/com/facebook/react/ReactPlugin.kt +212 -0
- package/src/main/kotlin/com/facebook/react/TaskConfiguration.kt +81 -0
- package/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt +56 -0
- package/src/main/kotlin/com/facebook/react/model/ModelCodegenConfig.kt +15 -0
- package/src/main/kotlin/com/facebook/react/model/ModelCodegenConfigAndroid.kt +10 -0
- package/src/main/kotlin/com/facebook/react/model/ModelPackageJson.kt +10 -0
- package/src/main/kotlin/com/facebook/react/tasks/BuildCodegenCLITask.kt +58 -0
- package/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt +200 -0
- package/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt +83 -0
- package/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt +82 -0
- package/src/main/kotlin/com/facebook/react/tasks/internal/PrepareBoostTask.kt +46 -0
- package/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGlogTask.kt +79 -0
- package/src/main/kotlin/com/facebook/react/tasks/internal/PrepareJSCTask.kt +50 -0
- package/src/main/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTask.kt +51 -0
- package/src/main/kotlin/com/facebook/react/tasks/internal/PreparePrefabHeadersTask.kt +62 -0
- package/src/main/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntry.kt +27 -0
- package/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt +54 -0
- package/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt +48 -0
- package/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +109 -0
- package/src/main/kotlin/com/facebook/react/utils/FileUtils.kt +20 -0
- package/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt +21 -0
- package/src/main/kotlin/com/facebook/react/utils/NdkConfiguratorUtils.kt +147 -0
- package/src/main/kotlin/com/facebook/react/utils/Os.kt +44 -0
- package/src/main/kotlin/com/facebook/react/utils/PathUtils.kt +231 -0
- package/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +55 -0
- package/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt +28 -0
|
@@ -0,0 +1,83 @@
|
|
|
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.react.tasks
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.utils.JsonUtils
|
|
11
|
+
import com.facebook.react.utils.Os.cliPath
|
|
12
|
+
import com.facebook.react.utils.windowsAwareCommandLine
|
|
13
|
+
import org.gradle.api.file.Directory
|
|
14
|
+
import org.gradle.api.file.DirectoryProperty
|
|
15
|
+
import org.gradle.api.file.RegularFile
|
|
16
|
+
import org.gradle.api.file.RegularFileProperty
|
|
17
|
+
import org.gradle.api.provider.ListProperty
|
|
18
|
+
import org.gradle.api.provider.Property
|
|
19
|
+
import org.gradle.api.provider.Provider
|
|
20
|
+
import org.gradle.api.tasks.Exec
|
|
21
|
+
import org.gradle.api.tasks.Input
|
|
22
|
+
import org.gradle.api.tasks.InputFile
|
|
23
|
+
import org.gradle.api.tasks.Internal
|
|
24
|
+
import org.gradle.api.tasks.OutputDirectory
|
|
25
|
+
|
|
26
|
+
abstract class GenerateCodegenArtifactsTask : Exec() {
|
|
27
|
+
|
|
28
|
+
@get:Internal abstract val reactNativeDir: DirectoryProperty
|
|
29
|
+
|
|
30
|
+
@get:Internal abstract val generatedSrcDir: DirectoryProperty
|
|
31
|
+
|
|
32
|
+
@get:InputFile abstract val packageJsonFile: RegularFileProperty
|
|
33
|
+
|
|
34
|
+
@get:Input abstract val nodeExecutableAndArgs: ListProperty<String>
|
|
35
|
+
|
|
36
|
+
@get:Input abstract val codegenJavaPackageName: Property<String>
|
|
37
|
+
|
|
38
|
+
@get:Input abstract val libraryName: Property<String>
|
|
39
|
+
|
|
40
|
+
@get:InputFile
|
|
41
|
+
val generatedSchemaFile: Provider<RegularFile> = generatedSrcDir.file("schema.json")
|
|
42
|
+
|
|
43
|
+
@get:OutputDirectory val generatedJavaFiles: Provider<Directory> = generatedSrcDir.dir("java")
|
|
44
|
+
|
|
45
|
+
@get:OutputDirectory val generatedJniFiles: Provider<Directory> = generatedSrcDir.dir("jni")
|
|
46
|
+
|
|
47
|
+
override fun exec() {
|
|
48
|
+
val (resolvedLibraryName, resolvedCodegenJavaPackageName) = resolveTaskParameters()
|
|
49
|
+
setupCommandLine(resolvedLibraryName, resolvedCodegenJavaPackageName)
|
|
50
|
+
super.exec()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
internal fun resolveTaskParameters(): Pair<String, String> {
|
|
54
|
+
val parsedPackageJson =
|
|
55
|
+
if (packageJsonFile.isPresent && packageJsonFile.get().asFile.exists()) {
|
|
56
|
+
JsonUtils.fromCodegenJson(packageJsonFile.get().asFile)
|
|
57
|
+
} else {
|
|
58
|
+
null
|
|
59
|
+
}
|
|
60
|
+
val resolvedLibraryName = parsedPackageJson?.codegenConfig?.name ?: libraryName.get()
|
|
61
|
+
val resolvedCodegenJavaPackageName =
|
|
62
|
+
parsedPackageJson?.codegenConfig?.android?.javaPackageName ?: codegenJavaPackageName.get()
|
|
63
|
+
return resolvedLibraryName to resolvedCodegenJavaPackageName
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
internal fun setupCommandLine(libraryName: String, codegenJavaPackageName: String) {
|
|
67
|
+
val workingDir = project.projectDir
|
|
68
|
+
commandLine(
|
|
69
|
+
windowsAwareCommandLine(
|
|
70
|
+
*nodeExecutableAndArgs.get().toTypedArray(),
|
|
71
|
+
reactNativeDir.file("scripts/generate-specs-cli.js").get().asFile.cliPath(workingDir),
|
|
72
|
+
"--platform",
|
|
73
|
+
"android",
|
|
74
|
+
"--schemaPath",
|
|
75
|
+
generatedSchemaFile.get().asFile.cliPath(workingDir),
|
|
76
|
+
"--outputDir",
|
|
77
|
+
generatedSrcDir.get().asFile.cliPath(workingDir),
|
|
78
|
+
"--libraryName",
|
|
79
|
+
libraryName,
|
|
80
|
+
"--javaPackageName",
|
|
81
|
+
codegenJavaPackageName))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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.react.tasks
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.utils.Os.cliPath
|
|
11
|
+
import com.facebook.react.utils.windowsAwareCommandLine
|
|
12
|
+
import org.gradle.api.file.DirectoryProperty
|
|
13
|
+
import org.gradle.api.file.RegularFile
|
|
14
|
+
import org.gradle.api.provider.ListProperty
|
|
15
|
+
import org.gradle.api.provider.Provider
|
|
16
|
+
import org.gradle.api.tasks.*
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A task that will collect all the *.js files inside the provided [jsRootDir] and will run the
|
|
20
|
+
* `combine-js-to-schema-cli.js` on top of it (from `react-native-codegen`). The output is a
|
|
21
|
+
* `schema.json` file that contains an intermediate representation of the code to be generated.
|
|
22
|
+
*/
|
|
23
|
+
abstract class GenerateCodegenSchemaTask : Exec() {
|
|
24
|
+
|
|
25
|
+
@get:Internal abstract val jsRootDir: DirectoryProperty
|
|
26
|
+
|
|
27
|
+
@get:Internal abstract val codegenDir: DirectoryProperty
|
|
28
|
+
|
|
29
|
+
@get:Internal abstract val generatedSrcDir: DirectoryProperty
|
|
30
|
+
|
|
31
|
+
@get:Input abstract val nodeExecutableAndArgs: ListProperty<String>
|
|
32
|
+
|
|
33
|
+
@get:InputFiles
|
|
34
|
+
val jsInputFiles =
|
|
35
|
+
project.fileTree(jsRootDir) {
|
|
36
|
+
it.include("**/*.js")
|
|
37
|
+
it.include("**/*.ts")
|
|
38
|
+
// Those are known build paths where the source map or other
|
|
39
|
+
// .js files could be stored/generated. We want to make sure we don't pick them up
|
|
40
|
+
// for execution avoidance.
|
|
41
|
+
it.exclude("**/generated/source/codegen/**/*")
|
|
42
|
+
it.exclude("**/build/ASSETS/**/*")
|
|
43
|
+
it.exclude("**/build/RES/**/*")
|
|
44
|
+
it.exclude("**/build/generated/assets/react/**/*")
|
|
45
|
+
it.exclude("**/build/generated/res/react/**/*")
|
|
46
|
+
it.exclude("**/build/generated/sourcemaps/react/**/*")
|
|
47
|
+
it.exclude("**/build/intermediates/sourcemaps/react/**/*")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@get:OutputFile
|
|
51
|
+
val generatedSchemaFile: Provider<RegularFile> = generatedSrcDir.file("schema.json")
|
|
52
|
+
|
|
53
|
+
override fun exec() {
|
|
54
|
+
wipeOutputDir()
|
|
55
|
+
setupCommandLine()
|
|
56
|
+
super.exec()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
internal fun wipeOutputDir() {
|
|
60
|
+
generatedSrcDir.asFile.get().apply {
|
|
61
|
+
deleteRecursively()
|
|
62
|
+
mkdirs()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
internal fun setupCommandLine() {
|
|
67
|
+
val workingDir = project.projectDir
|
|
68
|
+
commandLine(
|
|
69
|
+
windowsAwareCommandLine(
|
|
70
|
+
*nodeExecutableAndArgs.get().toTypedArray(),
|
|
71
|
+
codegenDir
|
|
72
|
+
.file("lib/cli/combine/combine-js-to-schema-cli.js")
|
|
73
|
+
.get()
|
|
74
|
+
.asFile
|
|
75
|
+
.cliPath(workingDir),
|
|
76
|
+
"--platform",
|
|
77
|
+
"android",
|
|
78
|
+
generatedSchemaFile.get().asFile.cliPath(workingDir),
|
|
79
|
+
jsRootDir.asFile.get().cliPath(workingDir),
|
|
80
|
+
))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.react.tasks.internal
|
|
9
|
+
|
|
10
|
+
import java.io.File
|
|
11
|
+
import org.gradle.api.DefaultTask
|
|
12
|
+
import org.gradle.api.file.ConfigurableFileCollection
|
|
13
|
+
import org.gradle.api.file.DirectoryProperty
|
|
14
|
+
import org.gradle.api.provider.Property
|
|
15
|
+
import org.gradle.api.tasks.*
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A task that takes care of extracting Boost from a source folder/zip and preparing it to be
|
|
19
|
+
* consumed by the NDK
|
|
20
|
+
*/
|
|
21
|
+
abstract class PrepareBoostTask : DefaultTask() {
|
|
22
|
+
|
|
23
|
+
@get:InputFiles abstract val boostPath: ConfigurableFileCollection
|
|
24
|
+
|
|
25
|
+
@get:Input abstract val boostVersion: Property<String>
|
|
26
|
+
|
|
27
|
+
@get:OutputDirectory abstract val outputDir: DirectoryProperty
|
|
28
|
+
|
|
29
|
+
@TaskAction
|
|
30
|
+
fun taskAction() {
|
|
31
|
+
project.copy { it ->
|
|
32
|
+
it.from(boostPath)
|
|
33
|
+
it.from(project.file("src/main/jni/third-party/boost"))
|
|
34
|
+
it.include(
|
|
35
|
+
"CMakeLists.txt",
|
|
36
|
+
"boost_${boostVersion.get()}/boost/**/*.hpp",
|
|
37
|
+
"boost/boost/**/*.hpp",
|
|
38
|
+
"asm/**/*.S")
|
|
39
|
+
it.includeEmptyDirs = false
|
|
40
|
+
it.into(outputDir)
|
|
41
|
+
}
|
|
42
|
+
File(outputDir.asFile.get(), "boost").apply {
|
|
43
|
+
renameTo(File(this.parentFile, "boost_${boostVersion.get()}"))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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.react.tasks.internal
|
|
9
|
+
|
|
10
|
+
import java.io.File
|
|
11
|
+
import org.apache.tools.ant.filters.ReplaceTokens
|
|
12
|
+
import org.gradle.api.DefaultTask
|
|
13
|
+
import org.gradle.api.file.ConfigurableFileCollection
|
|
14
|
+
import org.gradle.api.file.DirectoryProperty
|
|
15
|
+
import org.gradle.api.file.DuplicatesStrategy
|
|
16
|
+
import org.gradle.api.provider.Property
|
|
17
|
+
import org.gradle.api.tasks.*
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A task that takes care of extracting Glog from a source folder/zip and preparing it to be
|
|
21
|
+
* consumed by the NDK. This task will also take care of applying the mapping for Glog parameters.
|
|
22
|
+
*/
|
|
23
|
+
abstract class PrepareGlogTask : DefaultTask() {
|
|
24
|
+
|
|
25
|
+
@get:InputFiles abstract val glogPath: ConfigurableFileCollection
|
|
26
|
+
|
|
27
|
+
@get:Input abstract val glogVersion: Property<String>
|
|
28
|
+
|
|
29
|
+
@get:OutputDirectory abstract val outputDir: DirectoryProperty
|
|
30
|
+
|
|
31
|
+
@TaskAction
|
|
32
|
+
fun taskAction() {
|
|
33
|
+
project.copy {
|
|
34
|
+
it.from(glogPath)
|
|
35
|
+
it.from(project.file("src/main/jni/third-party/glog/"))
|
|
36
|
+
it.include("glog-${glogVersion.get()}/src/**/*", "CMakeLists.txt", "config.h")
|
|
37
|
+
it.duplicatesStrategy = DuplicatesStrategy.WARN
|
|
38
|
+
it.includeEmptyDirs = false
|
|
39
|
+
it.filesMatching("**/*.h.in") { matchedFile ->
|
|
40
|
+
matchedFile.filter(
|
|
41
|
+
mapOf(
|
|
42
|
+
"tokens" to
|
|
43
|
+
mapOf(
|
|
44
|
+
"ac_cv_have_unistd_h" to "1",
|
|
45
|
+
"ac_cv_have_stdint_h" to "1",
|
|
46
|
+
"ac_cv_have_systypes_h" to "1",
|
|
47
|
+
"ac_cv_have_inttypes_h" to "1",
|
|
48
|
+
"ac_cv_have_libgflags" to "0",
|
|
49
|
+
"ac_google_start_namespace" to "namespace google {",
|
|
50
|
+
"ac_cv_have_uint16_t" to "1",
|
|
51
|
+
"ac_cv_have_u_int16_t" to "1",
|
|
52
|
+
"ac_cv_have___uint16" to "0",
|
|
53
|
+
"ac_google_end_namespace" to "}",
|
|
54
|
+
"ac_cv_have___builtin_expect" to "1",
|
|
55
|
+
"ac_google_namespace" to "google",
|
|
56
|
+
"ac_cv___attribute___noinline" to "__attribute__ ((noinline))",
|
|
57
|
+
"ac_cv___attribute___noreturn" to "__attribute__ ((noreturn))",
|
|
58
|
+
"ac_cv___attribute___printf_4_5" to
|
|
59
|
+
"__attribute__((__format__ (__printf__, 4, 5)))")),
|
|
60
|
+
ReplaceTokens::class.java)
|
|
61
|
+
matchedFile.path = (matchedFile.name.removeSuffix(".in"))
|
|
62
|
+
}
|
|
63
|
+
it.into(outputDir)
|
|
64
|
+
}
|
|
65
|
+
val exportedDir = File(outputDir.asFile.get(), "exported/glog/").apply { mkdirs() }
|
|
66
|
+
project.copy {
|
|
67
|
+
it.from(outputDir)
|
|
68
|
+
it.include(
|
|
69
|
+
"stl_logging.h",
|
|
70
|
+
"logging.h",
|
|
71
|
+
"raw_logging.h",
|
|
72
|
+
"vlog_is_on.h",
|
|
73
|
+
"**/src/glog/log_severity.h")
|
|
74
|
+
it.eachFile { file -> file.path = file.name }
|
|
75
|
+
it.includeEmptyDirs = false
|
|
76
|
+
it.into(exportedDir)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.react.tasks.internal
|
|
9
|
+
|
|
10
|
+
import java.io.File
|
|
11
|
+
import org.gradle.api.DefaultTask
|
|
12
|
+
import org.gradle.api.file.DirectoryProperty
|
|
13
|
+
import org.gradle.api.provider.Property
|
|
14
|
+
import org.gradle.api.tasks.*
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A task that takes care of unbundling JSC and preparing it for be consumed by the Android NDK.
|
|
18
|
+
* Specifically it will unbundle shared libs, headers and will copy over the Makefile from
|
|
19
|
+
* `src/main/jni/third-party/jsc/`
|
|
20
|
+
*/
|
|
21
|
+
abstract class PrepareJSCTask : DefaultTask() {
|
|
22
|
+
|
|
23
|
+
@get:Input abstract val jscPackagePath: Property<String>
|
|
24
|
+
|
|
25
|
+
@get:OutputDirectory abstract val outputDir: DirectoryProperty
|
|
26
|
+
|
|
27
|
+
@TaskAction
|
|
28
|
+
fun taskAction() {
|
|
29
|
+
if (!jscPackagePath.isPresent || jscPackagePath.orNull == null) {
|
|
30
|
+
error("Could not find the jsc-android npm package")
|
|
31
|
+
}
|
|
32
|
+
val jscDist = File(jscPackagePath.get(), "dist")
|
|
33
|
+
if (!jscDist.exists()) {
|
|
34
|
+
error("The jsc-android npm package is missing its \"dist\" directory")
|
|
35
|
+
}
|
|
36
|
+
val jscAAR =
|
|
37
|
+
project.fileTree(jscDist).matching { it.include("**/android-jsc/**/*.aar") }.singleFile
|
|
38
|
+
val soFiles = project.zipTree(jscAAR).matching { it.include("**/*.so") }
|
|
39
|
+
val headerFiles = project.fileTree(jscDist).matching { it.include("**/include/*.h") }
|
|
40
|
+
|
|
41
|
+
project.copy { it ->
|
|
42
|
+
it.from(soFiles)
|
|
43
|
+
it.from(headerFiles)
|
|
44
|
+
it.from(project.file("src/main/jni/third-party/jsc/CMakeLists.txt"))
|
|
45
|
+
it.filesMatching("**/*.h") { it.path = "JavaScriptCore/${it.name}" }
|
|
46
|
+
it.includeEmptyDirs = false
|
|
47
|
+
it.into(outputDir)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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.react.tasks.internal
|
|
9
|
+
|
|
10
|
+
import java.io.File
|
|
11
|
+
import org.gradle.api.DefaultTask
|
|
12
|
+
import org.gradle.api.file.ConfigurableFileCollection
|
|
13
|
+
import org.gradle.api.file.DirectoryProperty
|
|
14
|
+
import org.gradle.api.provider.Property
|
|
15
|
+
import org.gradle.api.tasks.*
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A task that takes care of extracting Libevent from a source folder/zip and preparing it to be
|
|
19
|
+
* consumed by the NDK.
|
|
20
|
+
*/
|
|
21
|
+
abstract class PrepareLibeventTask : DefaultTask() {
|
|
22
|
+
|
|
23
|
+
@get:InputFiles abstract val libeventPath: ConfigurableFileCollection
|
|
24
|
+
|
|
25
|
+
@get:Input abstract val libeventVersion: Property<String>
|
|
26
|
+
|
|
27
|
+
@get:OutputDirectory abstract val outputDir: DirectoryProperty
|
|
28
|
+
|
|
29
|
+
@TaskAction
|
|
30
|
+
fun taskAction() {
|
|
31
|
+
project.copy { it ->
|
|
32
|
+
it.from(libeventPath)
|
|
33
|
+
it.from(project.file("src/main/jni/third-party/libevent/"))
|
|
34
|
+
it.include(
|
|
35
|
+
"libevent-${libeventVersion.get()}-stable/*.c",
|
|
36
|
+
"libevent-${libeventVersion.get()}-stable/*.h",
|
|
37
|
+
"libevent-${libeventVersion.get()}-stable/include/**/*",
|
|
38
|
+
"evconfig-private.h",
|
|
39
|
+
"event-config.h",
|
|
40
|
+
"CMakeLists.txt")
|
|
41
|
+
it.eachFile { it.path = it.path.removePrefix("libevent-${libeventVersion.get()}-stable/") }
|
|
42
|
+
it.includeEmptyDirs = false
|
|
43
|
+
it.into(outputDir)
|
|
44
|
+
}
|
|
45
|
+
File(outputDir.asFile.get(), "event-config.h").apply {
|
|
46
|
+
val destination =
|
|
47
|
+
File(this.parentFile, "include/event2/event-config.h").apply { parentFile.mkdirs() }
|
|
48
|
+
renameTo(destination)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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.react.tasks.internal
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.tasks.internal.utils.PrefabPreprocessingEntry
|
|
11
|
+
import java.io.File
|
|
12
|
+
import javax.inject.Inject
|
|
13
|
+
import org.gradle.api.DefaultTask
|
|
14
|
+
import org.gradle.api.file.DirectoryProperty
|
|
15
|
+
import org.gradle.api.file.FileSystemOperations
|
|
16
|
+
import org.gradle.api.file.RegularFile
|
|
17
|
+
import org.gradle.api.provider.ListProperty
|
|
18
|
+
import org.gradle.api.tasks.Input
|
|
19
|
+
import org.gradle.api.tasks.OutputDirectory
|
|
20
|
+
import org.gradle.api.tasks.TaskAction
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A task that takes care of copying headers and filtering them so that can be consumed by the
|
|
24
|
+
* Prefab protocol. This task handles also the header prefixes.
|
|
25
|
+
*
|
|
26
|
+
* It currently filters out some of the Boost headers as they're not used by React Native and are
|
|
27
|
+
* resulting in bigger .aar (250Mb+).
|
|
28
|
+
*
|
|
29
|
+
* You should provide in input a list fo [PrefabPreprocessingEntry] that will be used by this task
|
|
30
|
+
* to do the necessary copy operations.
|
|
31
|
+
*/
|
|
32
|
+
abstract class PreparePrefabHeadersTask : DefaultTask() {
|
|
33
|
+
|
|
34
|
+
@get:Input abstract val input: ListProperty<PrefabPreprocessingEntry>
|
|
35
|
+
|
|
36
|
+
@get:OutputDirectory abstract val outputDir: DirectoryProperty
|
|
37
|
+
|
|
38
|
+
@get:Inject abstract val fs: FileSystemOperations
|
|
39
|
+
|
|
40
|
+
@TaskAction
|
|
41
|
+
fun taskAction() {
|
|
42
|
+
input.get().forEach { (libraryName, pathToPrefixCouples) ->
|
|
43
|
+
val outputFolder: RegularFile = outputDir.file(libraryName).get()
|
|
44
|
+
pathToPrefixCouples.forEach { (headerPath, headerPrefix) ->
|
|
45
|
+
fs.copy {
|
|
46
|
+
it.from(headerPath)
|
|
47
|
+
it.include("**/*.h")
|
|
48
|
+
it.exclude("**/*.cpp")
|
|
49
|
+
it.exclude("**/*.txt")
|
|
50
|
+
// We don't want to copy all the boost headers as they are 250Mb+
|
|
51
|
+
it.include("boost/config.hpp")
|
|
52
|
+
it.include("boost/config/**/*.hpp")
|
|
53
|
+
it.include("boost/core/*.hpp")
|
|
54
|
+
it.include("boost/detail/workaround.hpp")
|
|
55
|
+
it.include("boost/operators.hpp")
|
|
56
|
+
it.include("boost/preprocessor/**/*.hpp")
|
|
57
|
+
it.into(File(outputFolder.asFile, headerPrefix))
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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.react.tasks.internal.utils
|
|
9
|
+
|
|
10
|
+
import java.io.Serializable
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This data class represents an entry that can be consumed by the [PreparePrefabHeadersTask].
|
|
14
|
+
* @param libraryName The name of the library that you're preparing for Prefab
|
|
15
|
+
* @param pathToPrefixCouples A list of pairs Path to Header prefix. You can use this list to supply
|
|
16
|
+
* a list of paths that you want to be considered for prefab. Each path can specify an header prefix
|
|
17
|
+
* that will be used by prefab to re-created the header layout.
|
|
18
|
+
*/
|
|
19
|
+
data class PrefabPreprocessingEntry(
|
|
20
|
+
val libraryName: String,
|
|
21
|
+
val pathToPrefixCouples: List<Pair<String, String>>,
|
|
22
|
+
) : Serializable {
|
|
23
|
+
constructor(
|
|
24
|
+
libraryName: String,
|
|
25
|
+
pathToPrefixCouple: Pair<String, String>
|
|
26
|
+
) : this(libraryName, listOf(pathToPrefixCouple))
|
|
27
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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.react.utils
|
|
9
|
+
|
|
10
|
+
import com.android.build.api.variant.AndroidComponentsExtension
|
|
11
|
+
import com.facebook.react.utils.ProjectUtils.isHermesEnabled
|
|
12
|
+
import com.facebook.react.utils.ProjectUtils.isNewArchEnabled
|
|
13
|
+
import org.gradle.api.Action
|
|
14
|
+
import org.gradle.api.Project
|
|
15
|
+
import org.gradle.api.plugins.AppliedPlugin
|
|
16
|
+
|
|
17
|
+
@Suppress("UnstableApiUsage")
|
|
18
|
+
internal object AgpConfiguratorUtils {
|
|
19
|
+
|
|
20
|
+
fun configureBuildConfigFields(project: Project) {
|
|
21
|
+
val action =
|
|
22
|
+
Action<AppliedPlugin> {
|
|
23
|
+
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
|
24
|
+
ext.defaultConfig.buildConfigField(
|
|
25
|
+
"boolean", "IS_NEW_ARCHITECTURE_ENABLED", project.isNewArchEnabled.toString())
|
|
26
|
+
ext.defaultConfig.buildConfigField(
|
|
27
|
+
"boolean", "IS_HERMES_ENABLED", project.isHermesEnabled.toString())
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
project.pluginManager.withPlugin("com.android.application", action)
|
|
31
|
+
project.pluginManager.withPlugin("com.android.library", action)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fun configureDevPorts(project: Project) {
|
|
35
|
+
val devServerPort =
|
|
36
|
+
project.properties["reactNativeDevServerPort"]?.toString() ?: DEFAULT_DEV_SERVER_PORT
|
|
37
|
+
val inspectorProxyPort =
|
|
38
|
+
project.properties["reactNativeInspectorProxyPort"]?.toString() ?: devServerPort
|
|
39
|
+
|
|
40
|
+
val action =
|
|
41
|
+
Action<AppliedPlugin> {
|
|
42
|
+
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
|
43
|
+
ext.defaultConfig.resValue("integer", "react_native_dev_server_port", devServerPort)
|
|
44
|
+
ext.defaultConfig.resValue(
|
|
45
|
+
"integer", "react_native_inspector_proxy_port", inspectorProxyPort)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
project.pluginManager.withPlugin("com.android.application", action)
|
|
50
|
+
project.pluginManager.withPlugin("com.android.library", action)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const val DEFAULT_DEV_SERVER_PORT = "8081"
|
|
@@ -0,0 +1,48 @@
|
|
|
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.react.utils
|
|
9
|
+
|
|
10
|
+
import java.util.*
|
|
11
|
+
import org.gradle.api.Project
|
|
12
|
+
|
|
13
|
+
internal object BackwardCompatUtils {
|
|
14
|
+
|
|
15
|
+
fun configureBackwardCompatibilityReactMap(project: Project) {
|
|
16
|
+
if (project.extensions.extraProperties.has("react")) {
|
|
17
|
+
@Suppress("UNCHECKED_CAST")
|
|
18
|
+
val reactMap =
|
|
19
|
+
project.extensions.extraProperties.get("react") as? Map<String, Any?> ?: mapOf()
|
|
20
|
+
if (reactMap.isNotEmpty()) {
|
|
21
|
+
project.logger.error(
|
|
22
|
+
"""
|
|
23
|
+
********************************************************************************
|
|
24
|
+
|
|
25
|
+
ERROR: Using old project.ext.react configuration.
|
|
26
|
+
We identified that your project is using a old configuration block as:
|
|
27
|
+
|
|
28
|
+
project.ext.react = [
|
|
29
|
+
// ...
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
You should migrate to the new configuration:
|
|
33
|
+
|
|
34
|
+
react {
|
|
35
|
+
// ...
|
|
36
|
+
}
|
|
37
|
+
You can find documentation inside `android/app/build.gradle` on how to use it.
|
|
38
|
+
|
|
39
|
+
********************************************************************************
|
|
40
|
+
"""
|
|
41
|
+
.trimIndent())
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// We set an empty react[] map so if a library is reading it, they will find empty values.
|
|
46
|
+
project.extensions.extraProperties.set("react", mapOf<String, String>())
|
|
47
|
+
}
|
|
48
|
+
}
|