mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5dc15222b2
Summary: Running `.\gradlew installArchives` is currently broken on Windows. This is because .sh scripts were added in the codegen module, which cannot be run by the Command Prompt on Windows. It can be worked around by installing eg. Git Bash., which can be then leveraged using the code modifications in this PR, which include sanitizing mixed Linux-Windows relative paths, and other minor Windows-specific adjustments. It's required that the user adds a Windows Environment variable storing the path to their bash binary named `REACT_WINDOWS_BASH`. Pair-programmed with davinci26 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Android] [Fix] - Fix building React Android on Windows. Fixes https://github.com/facebook/react-native/issues/30271 Pull Request resolved: https://github.com/facebook/react-native/pull/30535 Reviewed By: ShikaSD Differential Revision: D25909760 Pulled By: appden fbshipit-source-id: ea0e6e7c161a5e4a937d46e8e6972ce142fead4e
67 lines
2.0 KiB
Groovy
67 lines
2.0 KiB
Groovy
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
buildscript {
|
|
repositories {
|
|
mavenLocal()
|
|
google()
|
|
jcenter()
|
|
}
|
|
dependencies {
|
|
classpath("com.android.tools.build:gradle:4.1.0")
|
|
}
|
|
}
|
|
|
|
allprojects {
|
|
repositories {
|
|
mavenLocal()
|
|
google()
|
|
jcenter()
|
|
}
|
|
}
|
|
|
|
// This task is required when using react-native-codegen from source, instead of npm.
|
|
task('buildCodegenCLI', type: Exec) {
|
|
def codegenRoot = "$projectDir/.."
|
|
|
|
inputs.files(
|
|
file("$codegenRoot/scripts"),
|
|
file("$codegenRoot/src"),
|
|
file("$codegenRoot/package.json"),
|
|
file("$codegenRoot/.babelrc"),
|
|
file("$codegenRoot/.prettierrc"),
|
|
)
|
|
|
|
def libDir = file("$codegenRoot/lib")
|
|
libDir.mkdirs()
|
|
def nodeModulesDir = file("$codegenRoot/node_modules")
|
|
nodeModulesDir.mkdirs();
|
|
outputs.dirs(libDir, nodeModulesDir)
|
|
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
// Convert path to Linux format: use canonical path to strip it off relative elements in the middle of the string.
|
|
// Then replace baskslashes with slashes, remove leading colon, add leading slash.
|
|
// Eg. D:\path1\sub2/.. -> /D/path1/path2
|
|
String canonicalPath = new File(codegenRoot).getCanonicalPath()
|
|
String linuxPath = canonicalPath.replace('\\', '/');
|
|
linuxPath = linuxPath.replace(':', '')
|
|
linuxPath = '/' + linuxPath
|
|
|
|
// Get the location of bash in the system; assume environment variable created to store it.
|
|
String bashHome = "$System.env.REACT_WINDOWS_BASH"
|
|
if (bashHome == null) {
|
|
throw new GradleException("REACT_WINDOWS_BASH is not defined.")
|
|
}
|
|
commandLine(bashHome, "-c", "$linuxPath/scripts/oss/build.sh")
|
|
}
|
|
else {
|
|
commandLine("$codegenRoot/scripts/oss/build.sh")
|
|
}
|
|
}
|