@ohos-ports/react-native-gradle-plugin 0.71.19-beta.0 → 0.86.0-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 +11 -4
- package/build.gradle.kts +33 -41
- package/gradle/libs.versions.toml +22 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +3 -1
- package/gradle.properties +2 -0
- package/gradlew +32 -18
- package/gradlew.bat +22 -18
- package/package.json +21 -11
- package/react-native-gradle-plugin/README.md +17 -0
- package/react-native-gradle-plugin/build.gradle.kts +83 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/ReactExtension.kt +78 -10
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +320 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt +86 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/TaskConfiguration.kt +36 -25
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt +11 -4
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt +60 -50
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTask.kt +252 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt +8 -3
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt +11 -18
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateEntryPointTask.kt +108 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt +214 -0
- package/{src/main/kotlin/com/facebook/react/tasks → react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal}/BuildCodegenCLITask.kt +24 -17
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/CustomExecTask.kt +46 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/internal/PrepareBoostTask.kt +10 -4
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGflagsTask.kt +119 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/internal/PrepareGlogTask.kt +26 -18
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/internal/PreparePrefabHeadersTask.kt +28 -12
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/tasks/internal/utils/PrefabPreprocessingEntry.kt +4 -3
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt +163 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt +71 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +299 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt +64 -0
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/utils/NdkConfiguratorUtils.kt +59 -65
- package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/utils/PathUtils.kt +44 -30
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +119 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt +96 -0
- package/settings-plugin/build.gradle.kts +73 -0
- package/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt +217 -0
- package/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsPlugin.kt +23 -0
- package/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt +475 -0
- package/settings.gradle.kts +10 -1
- package/shared/build.gradle.kts +52 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingAndroidProjectJson.kt +18 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingConfigJson.kt +14 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesJson.kt +18 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesPlatformAndroidJson.kt +23 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingDependenciesPlatformJson.kt +12 -0
- package/shared/src/main/kotlin/com/facebook/react/model/ModelAutolinkingProjectJson.kt +10 -0
- package/{src → shared/src}/main/kotlin/com/facebook/react/model/ModelCodegenConfig.kt +2 -1
- package/{src → shared/src}/main/kotlin/com/facebook/react/model/ModelPackageJson.kt +1 -1
- package/shared/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt +43 -0
- package/shared/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt +32 -0
- package/{src → shared/src}/main/kotlin/com/facebook/react/utils/Os.kt +7 -6
- package/{src → shared/src}/main/kotlin/com/facebook/react/utils/TaskUtils.kt +4 -5
- package/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt +382 -0
- package/shared/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt +82 -0
- package/shared/src/test/kotlin/com/facebook/react/utils/OsTest.kt +87 -0
- package/shared/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt +76 -0
- package/shared-testutil/build.gradle.kts +46 -0
- package/shared-testutil/src/main/kotlin/com/facebook/react/tests/OsRule.kt +52 -0
- package/shared-testutil/src/main/kotlin/com/facebook/react/tests/WithOs.kt +17 -0
- package/build/libs/react-native-gradle-plugin.jar +0 -0
- package/index.js +0 -73
- package/src/main/kotlin/com/facebook/react/ReactPlugin.kt +0 -212
- package/src/main/kotlin/com/facebook/react/tasks/internal/PrepareJSCTask.kt +0 -50
- package/src/main/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTask.kt +0 -51
- package/src/main/kotlin/com/facebook/react/utils/AgpConfiguratorUtils.kt +0 -54
- package/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt +0 -48
- package/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +0 -109
- package/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt +0 -21
- package/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +0 -55
- /package/{src → react-native-gradle-plugin/src}/main/kotlin/com/facebook/react/utils/FileUtils.kt +0 -0
- /package/{src → shared/src}/main/kotlin/com/facebook/react/model/ModelCodegenConfigAndroid.kt +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
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.model.ModelAutolinkingConfigJson
|
|
11
|
+
import com.facebook.react.model.ModelAutolinkingDependenciesPlatformAndroidJson
|
|
12
|
+
import com.facebook.react.utils.JsonUtils
|
|
13
|
+
import java.io.File
|
|
14
|
+
import org.gradle.api.DefaultTask
|
|
15
|
+
import org.gradle.api.file.DirectoryProperty
|
|
16
|
+
import org.gradle.api.file.RegularFileProperty
|
|
17
|
+
import org.gradle.api.tasks.InputFile
|
|
18
|
+
import org.gradle.api.tasks.OutputDirectory
|
|
19
|
+
import org.gradle.api.tasks.TaskAction
|
|
20
|
+
|
|
21
|
+
abstract class GeneratePackageListTask : DefaultTask() {
|
|
22
|
+
|
|
23
|
+
init {
|
|
24
|
+
group = "react"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@get:InputFile abstract val autolinkInputFile: RegularFileProperty
|
|
28
|
+
|
|
29
|
+
@get:OutputDirectory abstract val generatedOutputDirectory: DirectoryProperty
|
|
30
|
+
|
|
31
|
+
@TaskAction
|
|
32
|
+
fun taskAction() {
|
|
33
|
+
val model =
|
|
34
|
+
JsonUtils.fromAutolinkingConfigJson(autolinkInputFile.get().asFile)
|
|
35
|
+
?: error(
|
|
36
|
+
"""
|
|
37
|
+
RNGP - Autolinking: Could not parse autolinking config file:
|
|
38
|
+
${autolinkInputFile.get().asFile.absolutePath}
|
|
39
|
+
|
|
40
|
+
The file is either missing or not containing valid JSON so the build won't succeed.
|
|
41
|
+
"""
|
|
42
|
+
.trimIndent()
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
val packageName =
|
|
46
|
+
model.project?.android?.packageName
|
|
47
|
+
?: error(
|
|
48
|
+
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field."
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
val androidPackages = filterAndroidPackages(model)
|
|
52
|
+
val packageClassInstance = composePackageInstance(packageName, androidPackages)
|
|
53
|
+
val generatedFileContents = composeFileContent(packageClassInstance)
|
|
54
|
+
|
|
55
|
+
val outputDir = generatedOutputDirectory.get().asFile
|
|
56
|
+
outputDir.mkdirs()
|
|
57
|
+
File(outputDir, GENERATED_FILENAME).apply {
|
|
58
|
+
parentFile.mkdirs()
|
|
59
|
+
writeText(generatedFileContents)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Extracts the fully qualified class name from an import statement. E.g., "import
|
|
65
|
+
* com.foo.bar.MyClass;" -> "com.foo.bar.MyClass"
|
|
66
|
+
*/
|
|
67
|
+
internal fun extractFqcnFromImport(importStatement: String): String? {
|
|
68
|
+
val match = Regex("import\\s+([\\w.]+)\\s*;").find(importStatement)
|
|
69
|
+
return match?.groupValues?.get(1)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
internal fun composePackageInstance(
|
|
73
|
+
packageName: String,
|
|
74
|
+
packages: Map<String, ModelAutolinkingDependenciesPlatformAndroidJson>,
|
|
75
|
+
): String {
|
|
76
|
+
if (packages.isEmpty()) {
|
|
77
|
+
return ""
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
val instances =
|
|
81
|
+
packages.entries.map { (name, dep) ->
|
|
82
|
+
val packageInstance =
|
|
83
|
+
requireNotNull(dep.packageInstance) {
|
|
84
|
+
"RNGP - Autolinking: Missing `packageInstance` in `config` for dependency $name. This is required to generate the autolinking package list."
|
|
85
|
+
}
|
|
86
|
+
val packageImportPath = dep.packageImportPath
|
|
87
|
+
val interpolated = interpolateDynamicValues(packageInstance, packageName)
|
|
88
|
+
|
|
89
|
+
// Use FQCN to avoid class name collisions between different packages
|
|
90
|
+
val fqcn = extractFqcnFromImport(interpolateDynamicValues(packageImportPath, packageName))
|
|
91
|
+
val fqcnInstance =
|
|
92
|
+
if (fqcn != null) {
|
|
93
|
+
val className = fqcn.substringAfterLast('.')
|
|
94
|
+
// Replace the short class name with FQCN in the instance
|
|
95
|
+
interpolated.replace(Regex("\\b${Regex.escape(className)}\\b")) { fqcn }
|
|
96
|
+
} else {
|
|
97
|
+
interpolated
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Add comment with package name before each instance
|
|
101
|
+
"// $name\n $fqcnInstance"
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return ",\n " + instances.joinToString(",\n ")
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
internal fun filterAndroidPackages(
|
|
108
|
+
model: ModelAutolinkingConfigJson?
|
|
109
|
+
): Map<String, ModelAutolinkingDependenciesPlatformAndroidJson> {
|
|
110
|
+
val packages = model?.dependencies?.values ?: emptyList()
|
|
111
|
+
return packages
|
|
112
|
+
.filter { it.platforms?.android != null }
|
|
113
|
+
// The pure C++ dependencies won't have a .java/.kt file to import
|
|
114
|
+
.filterNot { it.platforms?.android?.isPureCxxDependency == true }
|
|
115
|
+
.associate { it.name to checkNotNull(it.platforms?.android) }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
internal fun composeFileContent(packageClassInstance: String): String =
|
|
119
|
+
generatedFileContentsTemplate.replace("{{ packageClassInstances }}", packageClassInstance)
|
|
120
|
+
|
|
121
|
+
companion object {
|
|
122
|
+
const val GENERATED_FILENAME = "com/facebook/react/PackageList.java"
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Before adding the package replacement mechanism, BuildConfig and R classes were imported
|
|
126
|
+
* automatically into the scope of the file. We want to replace all non-FQDN references to those
|
|
127
|
+
* classes with the package name of the MainApplication.
|
|
128
|
+
*
|
|
129
|
+
* We want to match "R" or "BuildConfig":
|
|
130
|
+
* - new Package(R.string…),
|
|
131
|
+
* - Module.configure(BuildConfig);
|
|
132
|
+
* ^ hence including (BuildConfig|R)
|
|
133
|
+
* but we don't want to match "R":
|
|
134
|
+
* - new Package(getResources…),
|
|
135
|
+
* - new PackageR…,
|
|
136
|
+
* - new Royal…,
|
|
137
|
+
* ^ hence excluding \w before and after matches
|
|
138
|
+
* and "BuildConfig" that has FQDN reference:
|
|
139
|
+
* - Module.configure(com.acme.BuildConfig);
|
|
140
|
+
* ^ hence excluding . before the match.
|
|
141
|
+
*/
|
|
142
|
+
internal fun interpolateDynamicValues(input: String, packageName: String): String =
|
|
143
|
+
input.replace(Regex("([^.\\w])(BuildConfig|R)(\\W)")) { match ->
|
|
144
|
+
val (prefix, className, suffix) = match.destructured
|
|
145
|
+
"${prefix}${packageName}.${className}${suffix}"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// language=java
|
|
149
|
+
val generatedFileContentsTemplate =
|
|
150
|
+
"""
|
|
151
|
+
package com.facebook.react;
|
|
152
|
+
|
|
153
|
+
import android.app.Application;
|
|
154
|
+
import android.content.Context;
|
|
155
|
+
import android.content.res.Resources;
|
|
156
|
+
|
|
157
|
+
import com.facebook.react.ReactPackage;
|
|
158
|
+
import com.facebook.react.shell.MainPackageConfig;
|
|
159
|
+
import com.facebook.react.shell.MainReactPackage;
|
|
160
|
+
import java.util.Arrays;
|
|
161
|
+
import java.util.ArrayList;
|
|
162
|
+
|
|
163
|
+
@SuppressWarnings("deprecation")
|
|
164
|
+
public class PackageList {
|
|
165
|
+
private Application application;
|
|
166
|
+
private ReactNativeHost reactNativeHost;
|
|
167
|
+
private MainPackageConfig mConfig;
|
|
168
|
+
|
|
169
|
+
public PackageList(ReactNativeHost reactNativeHost) {
|
|
170
|
+
this(reactNativeHost, null);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public PackageList(Application application) {
|
|
174
|
+
this(application, null);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) {
|
|
178
|
+
this.reactNativeHost = reactNativeHost;
|
|
179
|
+
mConfig = config;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public PackageList(Application application, MainPackageConfig config) {
|
|
183
|
+
this.reactNativeHost = null;
|
|
184
|
+
this.application = application;
|
|
185
|
+
mConfig = config;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private ReactNativeHost getReactNativeHost() {
|
|
189
|
+
return this.reactNativeHost;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private Resources getResources() {
|
|
193
|
+
return this.getApplication().getResources();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private Application getApplication() {
|
|
197
|
+
if (this.reactNativeHost == null) return this.application;
|
|
198
|
+
return this.reactNativeHost.getApplication();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private Context getApplicationContext() {
|
|
202
|
+
return this.getApplication().getApplicationContext();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public ArrayList<ReactPackage> getPackages() {
|
|
206
|
+
return new ArrayList<>(Arrays.<ReactPackage>asList(
|
|
207
|
+
new MainReactPackage(mConfig){{ packageClassInstances }}
|
|
208
|
+
));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
"""
|
|
212
|
+
.trimIndent()
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
package com.facebook.react.tasks
|
|
8
|
+
package com.facebook.react.tasks.internal
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.utils.Os.unixifyPath
|
|
11
11
|
import com.facebook.react.utils.windowsAwareBashCommandLine
|
|
12
|
+
import java.io.FileOutputStream
|
|
12
13
|
import org.gradle.api.file.DirectoryProperty
|
|
13
|
-
import org.gradle.api.file.
|
|
14
|
+
import org.gradle.api.file.FileTree
|
|
15
|
+
import org.gradle.api.file.RegularFileProperty
|
|
14
16
|
import org.gradle.api.provider.Property
|
|
15
17
|
import org.gradle.api.tasks.*
|
|
16
18
|
|
|
@@ -26,29 +28,34 @@ abstract class BuildCodegenCLITask : Exec() {
|
|
|
26
28
|
|
|
27
29
|
@get:Internal abstract val bashWindowsHome: Property<String>
|
|
28
30
|
|
|
29
|
-
@get:
|
|
30
|
-
val input: FileCollection by lazy {
|
|
31
|
-
codegenDir.get().files("scripts", "src", "package.json", ".babelrc", ".prettierrc")
|
|
32
|
-
}
|
|
31
|
+
@get:Internal abstract val rootProjectName: Property<String>
|
|
33
32
|
|
|
34
|
-
@get:
|
|
35
|
-
val output: FileCollection by lazy { codegenDir.get().files("lib", "node_modules") }
|
|
33
|
+
@get:InputFiles abstract val inputFiles: Property<FileTree>
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
onlyIf {
|
|
41
|
-
val cliDir = codegenDir.file("lib/cli/").get().asFile
|
|
42
|
-
!cliDir.exists() || cliDir.listFiles()?.size == 0
|
|
43
|
-
}
|
|
44
|
-
}
|
|
35
|
+
@get:OutputFiles abstract val outputFiles: Property<FileTree>
|
|
36
|
+
|
|
37
|
+
@get:OutputFile abstract val logFile: RegularFileProperty
|
|
45
38
|
|
|
46
39
|
override fun exec() {
|
|
40
|
+
// For build from source scenario, we don't need to build the codegen at all.
|
|
41
|
+
if (rootProjectName.get() == "react-native-build-from-source") {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
val logFileConcrete =
|
|
45
|
+
logFile.get().asFile.apply {
|
|
46
|
+
parentFile.mkdirs()
|
|
47
|
+
if (exists()) {
|
|
48
|
+
delete()
|
|
49
|
+
}
|
|
50
|
+
createNewFile()
|
|
51
|
+
}
|
|
52
|
+
standardOutput = FileOutputStream(logFileConcrete)
|
|
47
53
|
commandLine(
|
|
48
54
|
windowsAwareBashCommandLine(
|
|
49
55
|
codegenDir.asFile.get().canonicalPath.unixifyPath().plus(BUILD_SCRIPT_PATH),
|
|
50
56
|
bashWindowsHome = bashWindowsHome.orNull,
|
|
51
|
-
)
|
|
57
|
+
)
|
|
58
|
+
)
|
|
52
59
|
super.exec()
|
|
53
60
|
}
|
|
54
61
|
|
|
@@ -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 java.io.FileOutputStream
|
|
12
|
+
import org.gradle.api.file.RegularFileProperty
|
|
13
|
+
import org.gradle.api.provider.Property
|
|
14
|
+
import org.gradle.api.tasks.Exec
|
|
15
|
+
import org.gradle.api.tasks.Input
|
|
16
|
+
import org.gradle.api.tasks.Optional
|
|
17
|
+
import org.gradle.api.tasks.OutputFile
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A Task that will just expose an Exec-like task and that offers properties to configure the
|
|
21
|
+
* standard output and error.
|
|
22
|
+
*/
|
|
23
|
+
abstract class CustomExecTask : Exec() {
|
|
24
|
+
|
|
25
|
+
@get:OutputFile @get:Optional abstract val standardOutputFile: RegularFileProperty
|
|
26
|
+
|
|
27
|
+
@get:OutputFile @get:Optional abstract val errorOutputFile: RegularFileProperty
|
|
28
|
+
|
|
29
|
+
@get:Input @get:Optional abstract val onlyIfProvidedPathDoesNotExists: Property<String>
|
|
30
|
+
|
|
31
|
+
override fun exec() {
|
|
32
|
+
if (
|
|
33
|
+
onlyIfProvidedPathDoesNotExists.isPresent &&
|
|
34
|
+
File(onlyIfProvidedPathDoesNotExists.get()).exists()
|
|
35
|
+
) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
if (standardOutputFile.isPresent) {
|
|
39
|
+
standardOutput = FileOutputStream(standardOutputFile.get().asFile)
|
|
40
|
+
}
|
|
41
|
+
if (errorOutputFile.isPresent) {
|
|
42
|
+
errorOutput = FileOutputStream(errorOutputFile.get().asFile)
|
|
43
|
+
}
|
|
44
|
+
super.exec()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
package com.facebook.react.tasks.internal
|
|
9
9
|
|
|
10
10
|
import java.io.File
|
|
11
|
+
import javax.inject.Inject
|
|
11
12
|
import org.gradle.api.DefaultTask
|
|
12
13
|
import org.gradle.api.file.ConfigurableFileCollection
|
|
13
14
|
import org.gradle.api.file.DirectoryProperty
|
|
15
|
+
import org.gradle.api.file.FileSystemOperations
|
|
14
16
|
import org.gradle.api.provider.Property
|
|
15
17
|
import org.gradle.api.tasks.*
|
|
16
18
|
|
|
@@ -21,26 +23,30 @@ import org.gradle.api.tasks.*
|
|
|
21
23
|
abstract class PrepareBoostTask : DefaultTask() {
|
|
22
24
|
|
|
23
25
|
@get:InputFiles abstract val boostPath: ConfigurableFileCollection
|
|
26
|
+
@get:InputDirectory abstract val boostThirdPartyJniPath: DirectoryProperty
|
|
24
27
|
|
|
25
28
|
@get:Input abstract val boostVersion: Property<String>
|
|
26
29
|
|
|
27
30
|
@get:OutputDirectory abstract val outputDir: DirectoryProperty
|
|
28
31
|
|
|
32
|
+
@get:Inject abstract val fs: FileSystemOperations
|
|
33
|
+
|
|
29
34
|
@TaskAction
|
|
30
35
|
fun taskAction() {
|
|
31
|
-
|
|
36
|
+
fs.copy { it ->
|
|
32
37
|
it.from(boostPath)
|
|
33
|
-
it.from(
|
|
38
|
+
it.from(boostThirdPartyJniPath)
|
|
34
39
|
it.include(
|
|
35
40
|
"CMakeLists.txt",
|
|
36
41
|
"boost_${boostVersion.get()}/boost/**/*.hpp",
|
|
37
42
|
"boost/boost/**/*.hpp",
|
|
38
|
-
"asm/**/*.S"
|
|
43
|
+
"asm/**/*.S",
|
|
44
|
+
)
|
|
39
45
|
it.includeEmptyDirs = false
|
|
40
46
|
it.into(outputDir)
|
|
41
47
|
}
|
|
42
48
|
File(outputDir.asFile.get(), "boost").apply {
|
|
43
|
-
renameTo(File(
|
|
49
|
+
renameTo(File(parentFile, "boost_${boostVersion.get()}"))
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 javax.inject.Inject
|
|
11
|
+
import org.gradle.api.DefaultTask
|
|
12
|
+
import org.gradle.api.file.ConfigurableFileCollection
|
|
13
|
+
import org.gradle.api.file.CopySpec
|
|
14
|
+
import org.gradle.api.file.DirectoryProperty
|
|
15
|
+
import org.gradle.api.file.DuplicatesStrategy
|
|
16
|
+
import org.gradle.api.file.FileSystemOperations
|
|
17
|
+
import org.gradle.api.provider.Property
|
|
18
|
+
import org.gradle.api.tasks.*
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A task that takes care of extracting gflags from a source folder/zip and preparing it to be
|
|
22
|
+
* consumed by the NDK. This task will also take care of applying the mapping for gflags parameters.
|
|
23
|
+
*/
|
|
24
|
+
abstract class PrepareGflagsTask : DefaultTask() {
|
|
25
|
+
|
|
26
|
+
@get:InputFiles abstract val gflagsPath: ConfigurableFileCollection
|
|
27
|
+
@get:InputDirectory abstract val gflagsThirdPartyPath: DirectoryProperty
|
|
28
|
+
@get:Input abstract val gflagsVersion: Property<String>
|
|
29
|
+
|
|
30
|
+
@get:OutputDirectory abstract val outputDir: DirectoryProperty
|
|
31
|
+
|
|
32
|
+
@get:Inject abstract val fs: FileSystemOperations
|
|
33
|
+
|
|
34
|
+
@TaskAction
|
|
35
|
+
fun taskAction() {
|
|
36
|
+
val commonCopyConfig: (action: CopySpec) -> Unit = { action ->
|
|
37
|
+
action.from(gflagsPath)
|
|
38
|
+
action.from(gflagsThirdPartyPath)
|
|
39
|
+
action.duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
40
|
+
action.includeEmptyDirs = false
|
|
41
|
+
action.into(outputDir)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fs.copy { action ->
|
|
45
|
+
commonCopyConfig(action)
|
|
46
|
+
action.include(
|
|
47
|
+
"gflags-${gflagsVersion.get()}/src/*.h",
|
|
48
|
+
"gflags-${gflagsVersion.get()}/src/*.cc",
|
|
49
|
+
"CMakeLists.txt",
|
|
50
|
+
)
|
|
51
|
+
action.filesMatching("*/src/*") { matchedFile ->
|
|
52
|
+
matchedFile.path = "gflags/${matchedFile.name}"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fs.copy { action ->
|
|
57
|
+
commonCopyConfig(action)
|
|
58
|
+
action.include("gflags-${gflagsVersion.get()}/src/gflags_declare.h.in")
|
|
59
|
+
action.filesMatching("*/src/*") { matchedFile ->
|
|
60
|
+
matchedFile.filter { line ->
|
|
61
|
+
// Replace all placeholders with appropriate values
|
|
62
|
+
// see https://github.com/gflags/gflags/blob/v2.2.0/src/gflags_declare.h.in
|
|
63
|
+
line
|
|
64
|
+
.replace(Regex("@GFLAGS_NAMESPACE@"), "gflags")
|
|
65
|
+
.replace(
|
|
66
|
+
Regex(
|
|
67
|
+
"@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@"
|
|
68
|
+
),
|
|
69
|
+
"1",
|
|
70
|
+
)
|
|
71
|
+
.replace(Regex("@([A-Z0-9_]+)@"), "1")
|
|
72
|
+
}
|
|
73
|
+
matchedFile.path = "gflags/${matchedFile.name.removeSuffix(".in")}"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fs.copy { action ->
|
|
78
|
+
commonCopyConfig(action)
|
|
79
|
+
action.include("gflags-${gflagsVersion.get()}/src/config.h.in")
|
|
80
|
+
action.filesMatching("*/src/*") { matchedFile ->
|
|
81
|
+
matchedFile.filter { line -> line.replace(Regex("^#cmakedefine"), "//cmakedefine") }
|
|
82
|
+
matchedFile.path = "gflags/${matchedFile.name.removeSuffix(".in")}"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fs.copy { action ->
|
|
87
|
+
commonCopyConfig(action)
|
|
88
|
+
action.include("gflags-${gflagsVersion.get()}/src/gflags_ns.h.in")
|
|
89
|
+
action.filesMatching("*/src/*") { matchedFile ->
|
|
90
|
+
matchedFile.filter { line ->
|
|
91
|
+
line.replace(Regex("@ns@"), "google").replace(Regex("@NS@"), "google".uppercase())
|
|
92
|
+
}
|
|
93
|
+
matchedFile.path = "gflags/gflags_google.h"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fs.copy { action ->
|
|
98
|
+
commonCopyConfig(action)
|
|
99
|
+
action.include("gflags-${gflagsVersion.get()}/src/gflags.h.in")
|
|
100
|
+
action.filesMatching("*/src/*") { matchedFile ->
|
|
101
|
+
matchedFile.filter { line ->
|
|
102
|
+
line
|
|
103
|
+
.replace(Regex("@GFLAGS_ATTRIBUTE_UNUSED@"), "")
|
|
104
|
+
.replace(Regex("@INCLUDE_GFLAGS_NS_H@"), "#include \"gflags/gflags_google.h\"")
|
|
105
|
+
}
|
|
106
|
+
matchedFile.path = "gflags/${matchedFile.name.removeSuffix(".in")}"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fs.copy { action ->
|
|
111
|
+
commonCopyConfig(action)
|
|
112
|
+
action.include("gflags-${gflagsVersion.get()}/src/gflags_completions.h.in")
|
|
113
|
+
action.filesMatching("*/src/*") { matchedFile ->
|
|
114
|
+
matchedFile.filter { line -> line.replace(Regex("@GFLAGS_NAMESPACE@"), "gflags") }
|
|
115
|
+
matchedFile.path = "gflags/${matchedFile.name.removeSuffix(".in")}"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
package com.facebook.react.tasks.internal
|
|
9
9
|
|
|
10
10
|
import java.io.File
|
|
11
|
+
import javax.inject.Inject
|
|
11
12
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
12
13
|
import org.gradle.api.DefaultTask
|
|
13
14
|
import org.gradle.api.file.ConfigurableFileCollection
|
|
14
15
|
import org.gradle.api.file.DirectoryProperty
|
|
15
16
|
import org.gradle.api.file.DuplicatesStrategy
|
|
17
|
+
import org.gradle.api.file.FileSystemOperations
|
|
16
18
|
import org.gradle.api.provider.Property
|
|
17
19
|
import org.gradle.api.tasks.*
|
|
18
20
|
|
|
@@ -23,20 +25,22 @@ import org.gradle.api.tasks.*
|
|
|
23
25
|
abstract class PrepareGlogTask : DefaultTask() {
|
|
24
26
|
|
|
25
27
|
@get:InputFiles abstract val glogPath: ConfigurableFileCollection
|
|
26
|
-
|
|
28
|
+
@get:InputDirectory abstract val glogThirdPartyJniPath: DirectoryProperty
|
|
27
29
|
@get:Input abstract val glogVersion: Property<String>
|
|
28
30
|
|
|
29
31
|
@get:OutputDirectory abstract val outputDir: DirectoryProperty
|
|
30
32
|
|
|
33
|
+
@get:Inject abstract val fs: FileSystemOperations
|
|
34
|
+
|
|
31
35
|
@TaskAction
|
|
32
36
|
fun taskAction() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
fs.copy { action ->
|
|
38
|
+
action.from(glogPath)
|
|
39
|
+
action.from(glogThirdPartyJniPath)
|
|
40
|
+
action.include("glog-${glogVersion.get()}/src/**/*", "CMakeLists.txt", "config.h")
|
|
41
|
+
action.duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
42
|
+
action.includeEmptyDirs = false
|
|
43
|
+
action.filesMatching("**/*.h.in") { matchedFile ->
|
|
40
44
|
matchedFile.filter(
|
|
41
45
|
mapOf(
|
|
42
46
|
"tokens" to
|
|
@@ -56,24 +60,28 @@ abstract class PrepareGlogTask : DefaultTask() {
|
|
|
56
60
|
"ac_cv___attribute___noinline" to "__attribute__ ((noinline))",
|
|
57
61
|
"ac_cv___attribute___noreturn" to "__attribute__ ((noreturn))",
|
|
58
62
|
"ac_cv___attribute___printf_4_5" to
|
|
59
|
-
"__attribute__((__format__ (__printf__, 4, 5)))"
|
|
60
|
-
|
|
63
|
+
"__attribute__((__format__ (__printf__, 4, 5)))",
|
|
64
|
+
)
|
|
65
|
+
),
|
|
66
|
+
ReplaceTokens::class.java,
|
|
67
|
+
)
|
|
61
68
|
matchedFile.path = (matchedFile.name.removeSuffix(".in"))
|
|
62
69
|
}
|
|
63
|
-
|
|
70
|
+
action.into(outputDir)
|
|
64
71
|
}
|
|
65
72
|
val exportedDir = File(outputDir.asFile.get(), "exported/glog/").apply { mkdirs() }
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
fs.copy { action ->
|
|
74
|
+
action.from(outputDir)
|
|
75
|
+
action.include(
|
|
69
76
|
"stl_logging.h",
|
|
70
77
|
"logging.h",
|
|
71
78
|
"raw_logging.h",
|
|
72
79
|
"vlog_is_on.h",
|
|
73
|
-
"**/src/glog/log_severity.h"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
"**/src/glog/log_severity.h",
|
|
81
|
+
)
|
|
82
|
+
action.eachFile { file -> file.path = file.name }
|
|
83
|
+
action.includeEmptyDirs = false
|
|
84
|
+
action.into(exportedDir)
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
87
|
}
|
|
@@ -42,19 +42,35 @@ abstract class PreparePrefabHeadersTask : DefaultTask() {
|
|
|
42
42
|
input.get().forEach { (libraryName, pathToPrefixCouples) ->
|
|
43
43
|
val outputFolder: RegularFile = outputDir.file(libraryName).get()
|
|
44
44
|
pathToPrefixCouples.forEach { (headerPath, headerPrefix) ->
|
|
45
|
-
fs.copy {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
fs.copy { copySpec ->
|
|
46
|
+
copySpec.from(headerPath)
|
|
47
|
+
copySpec.include("**/*.h")
|
|
48
|
+
copySpec.exclude("**/*.cpp")
|
|
49
|
+
copySpec.exclude("**/*.txt")
|
|
50
50
|
// We don't want to copy all the boost headers as they are 250Mb+
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
copySpec.include("boost/config.hpp")
|
|
52
|
+
copySpec.include("boost/config/**/*.hpp")
|
|
53
|
+
copySpec.include("boost/core/*.hpp")
|
|
54
|
+
copySpec.include("boost/detail/workaround.hpp")
|
|
55
|
+
copySpec.include("boost/operators.hpp")
|
|
56
|
+
copySpec.include("boost/preprocessor/**/*.hpp")
|
|
57
|
+
// Headers needed for exposing rrc_text and rrc_textinput
|
|
58
|
+
copySpec.include("boost/container_hash/**/*.hpp")
|
|
59
|
+
copySpec.include("boost/detail/**/*.hpp")
|
|
60
|
+
copySpec.include("boost/intrusive/**/*.hpp")
|
|
61
|
+
copySpec.include("boost/iterator/**/*.hpp")
|
|
62
|
+
copySpec.include("boost/move/**/*.hpp")
|
|
63
|
+
copySpec.include("boost/mpl/**/*.hpp")
|
|
64
|
+
copySpec.include("boost/mp11/**/*.hpp")
|
|
65
|
+
copySpec.include("boost/describe/**/*.hpp")
|
|
66
|
+
copySpec.include("boost/type_traits/**/*.hpp")
|
|
67
|
+
copySpec.include("boost/utility/**/*.hpp")
|
|
68
|
+
copySpec.include("boost/assert.hpp")
|
|
69
|
+
copySpec.include("boost/static_assert.hpp")
|
|
70
|
+
copySpec.include("boost/cstdint.hpp")
|
|
71
|
+
copySpec.include("boost/utility.hpp")
|
|
72
|
+
copySpec.include("boost/version.hpp")
|
|
73
|
+
copySpec.into(File(outputFolder.asFile, headerPrefix))
|
|
58
74
|
}
|
|
59
75
|
}
|
|
60
76
|
}
|
|
@@ -11,10 +11,11 @@ import java.io.Serializable
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* This data class represents an entry that can be consumed by the [PreparePrefabHeadersTask].
|
|
14
|
+
*
|
|
14
15
|
* @param libraryName The name of the library that you're preparing for Prefab
|
|
15
16
|
* @param pathToPrefixCouples A list of pairs Path to Header prefix. You can use this list to supply
|
|
16
|
-
*
|
|
17
|
-
* that will be used by prefab to re-created the header layout.
|
|
17
|
+
* a list of paths that you want to be considered for prefab. Each path can specify an header
|
|
18
|
+
* prefix that will be used by prefab to re-created the header layout.
|
|
18
19
|
*/
|
|
19
20
|
data class PrefabPreprocessingEntry(
|
|
20
21
|
val libraryName: String,
|
|
@@ -22,6 +23,6 @@ data class PrefabPreprocessingEntry(
|
|
|
22
23
|
) : Serializable {
|
|
23
24
|
constructor(
|
|
24
25
|
libraryName: String,
|
|
25
|
-
pathToPrefixCouple: Pair<String, String
|
|
26
|
+
pathToPrefixCouple: Pair<String, String>,
|
|
26
27
|
) : this(libraryName, listOf(pathToPrefixCouple))
|
|
27
28
|
}
|