Skip to content

Commit

Permalink
Merge pull request #1323 from rasaha91/cherry-pick-ndk-fixes
Browse files Browse the repository at this point in the history
Cherry pick ndk fixes
  • Loading branch information
rasaha91 authored Aug 4, 2022
2 parents e6482e0 + c83c522 commit e960741
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 80 deletions.
2 changes: 2 additions & 0 deletions .ado/android-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
persistCredentials: false # set to 'true' to leave the OAuth token in the Git config after the initial fetch

- template: templates/android-build-office-setup.yml

- template: templates/android-build-office.yml

- template: templates/download-android-dependencies.yml
Expand Down
4 changes: 3 additions & 1 deletion .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch

- template: templates/android-build-office.yml
- template: templates/android-build-office-setup.yml

- task: CmdLine@2
displayName: Bump package version
Expand All @@ -208,6 +208,8 @@ jobs:
inputs:
script: node .ado/removeWorkspaceConfig.js

- template: templates/android-build-office.yml

# Enumerate and download all dependencies ..
- template: templates/download-android-dependencies.yml
parameters:
Expand Down
62 changes: 62 additions & 0 deletions .ado/templates/android-build-office-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
steps:
- task: UseNode@1
inputs:
version: '16.x'

- template: apple-droid-node-patching.yml
parameters:
apply_office_patches: true

# Install NuGet
- task: CmdLine@2
displayName: Install NuGet
inputs:
script: curl -o $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe --create-dirs https://dist.nuget.org/win-x86-commandline/latest/nuget.exe

- task: CmdLine@2
displayName: "Rename package to react-native"
inputs:
script: node .ado/renamePackageForOffice.js

- task: CmdLine@2
displayName: yarn install
inputs:
script: yarn install --frozen-lockfile

# scripts/set-rn-version.js
#
# update the following files to the commit id.
# package.json (-> npm package version)
# gradle.properties (-> aar version)
# gradle.properties (-> aar version)
#
# The following files are updated for runtime version checking.
# ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java
# React/Base/RCTVersion.m
# ReactCommon/cxxreact/ReactNativeVersion.h
# Libraries/Core/ReactNativeVersion.js
#
# --nightly --autogenerateVersionNumber => version = `0.0.0-${currentCommit.slice(0, 9)}`;
# When on main branch or non-stable branch.
- task: CmdLine@2
displayName: Set canary package version
inputs:
script: node scripts/set-rn-version.js --nightly --autogenerateVersionNumber --skipUpdateRuby # TODO(macOS GH#1148): Remove --skipUpdateRuby flag once we clean up version update scripts
condition: or(eq(variables['Build.SourceBranchName'], 'main'), not(contains(variables['Build.SourceBranchName'], '-stable')))

# TODO: We don't seem to be running set-rn-version.js for stable branches, hence we would end up publishing using the values in the repository.

- task: CmdLine@2
displayName: nuget restore
inputs:
script: mono $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe restore $(System.DefaultWorkingDirectory)/ReactAndroid/packages.config -PackagesDirectory $(System.DefaultWorkingDirectory)/ReactAndroid/packages/ -Verbosity Detailed -NonInteractive

- task: CmdLine@2
displayName: Setup Build Dependencies
inputs:
script: chmod +x .ado/setup_droid_deps.sh && .ado/setup_droid_deps.sh

- task: CmdLine@2
displayName: Remove RNTesterApp.android.bundle
inputs:
script: rm -f ./packages/rn-tester/js/RNTesterApp.android.bundle
62 changes: 0 additions & 62 deletions .ado/templates/android-build-office.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,4 @@
steps:
- task: UseNode@1
inputs:
version: '16.x'

- template: apple-droid-node-patching.yml
parameters:
apply_office_patches: true

# Install NuGet
- task: CmdLine@2
displayName: Install NuGet
inputs:
script: curl -o $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe --create-dirs https://dist.nuget.org/win-x86-commandline/latest/nuget.exe

- task: CmdLine@2
displayName: "Rename package to react-native"
inputs:
script: node .ado/renamePackageForOffice.js

- task: CmdLine@2
displayName: yarn install
inputs:
script: yarn install --frozen-lockfile

# scripts/set-rn-version.js
#
# update the following files to the commit id.
# package.json (-> npm package version)
# gradle.properties (-> aar version)
# gradle.properties (-> aar version)
#
# The following files are updated for runtime version checking.
# ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java
# React/Base/RCTVersion.m
# ReactCommon/cxxreact/ReactNativeVersion.h
# Libraries/Core/ReactNativeVersion.js
#
# --nightly --autogenerateVersionNumber => version = `0.0.0-${currentCommit.slice(0, 9)}`;
# When on main branch or non-stable branch.
- task: CmdLine@2
displayName: Set canary package version
inputs:
script: node scripts/set-rn-version.js --nightly --autogenerateVersionNumber --skipUpdateRuby # TODO(macOS GH#1148): Remove --skipUpdateRuby flag once we clean up version update scripts
condition: or(eq(variables['Build.SourceBranchName'], 'main'), not(contains(variables['Build.SourceBranchName'], '-stable')))

# TODO: We don't seem to be running set-rn-version.js for stable branches, hence we would end up publishing using the values in the repository.

- task: CmdLine@2
displayName: nuget restore
inputs:
script: mono $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe restore $(System.DefaultWorkingDirectory)/ReactAndroid/packages.config -PackagesDirectory $(System.DefaultWorkingDirectory)/ReactAndroid/packages/ -Verbosity Detailed -NonInteractive

- task: CmdLine@2
displayName: Setup Build Dependencies
inputs:
script: chmod +x .ado/setup_droid_deps.sh && .ado/setup_droid_deps.sh

- task: CmdLine@2
displayName: Remove RNTesterApp.android.bundle
inputs:
script: rm -f ./packages/rn-tester/js/RNTesterApp.android.bundle

- task: CmdLine@2
displayName: Create RNTester bundle
inputs:
Expand Down
2 changes: 1 addition & 1 deletion .ado/templates/android-nuget-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ steps:
- task: CmdLine@2
displayName: 'NuGet pack'
inputs:
script: NDK=ndk`cat ${ANDROID_SDK_ROOT}/ndk-bundle/source.properties 2>&1 | grep Pkg.Revision | awk '{ print $3}' | awk -F. '{ print $1 }'`; mono $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe pack $(System.DefaultWorkingDirectory)/ReactAndroid/ReactAndroid.nuspec -OutputDirectory $(Build.StagingDirectory)/final -Properties buildNumber=$(buildNumber)-$NDK\;commitId=$(Build.SourceVersion)
script: NDK=ndk`$(System.DefaultWorkingDirectory)/gradlew -q ReactAndroid:properties | grep ndkVersion | awk '{print $2}' | awk -F. '{print $1}'`; mono $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe pack $(System.DefaultWorkingDirectory)/ReactAndroid/ReactAndroid.nuspec -OutputDirectory $(Build.StagingDirectory)/final -Properties buildNumber=$(buildNumber)-$NDK\;commitId=$(Build.SourceVersion)
9 changes: 0 additions & 9 deletions .ado/templates/prep-android-nuget.yml

This file was deleted.

27 changes: 20 additions & 7 deletions android-patches/patches/Build/ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
--- ./ReactAndroid/build.gradle 2022-01-11 17:41:28.000000000 -0800
+++ /var/folders/vs/8_b205053dddbcv7btj0w0v80000gn/T/update-1h8V3n/merge/Build/ReactAndroid/build.gradle 2022-01-12 15:51:37.000000000 -0800
@@ -41,6 +41,8 @@
diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle
index 3c23c6a84b4..183bffe7164 100644
--- a/ReactAndroid/build.gradle
+++ b/ReactAndroid/build.gradle
@@ -12,6 +12,10 @@ plugins {
id("de.undercouch.download")
}

+rootProject.ext {
+ ndkVersion="21.4.7075529"
+}
+
import com.facebook.react.tasks.internal.*

import java.nio.file.Paths
@@ -41,6 +45,8 @@ def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES")
// and the build will use that.
def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH")

Expand All @@ -9,7 +22,7 @@
// Setup build type for NDK, supported values: {debug, release}
def nativeBuildType = System.getenv("NATIVE_BUILD_TYPE") ?: "release"

@@ -86,11 +88,22 @@
@@ -86,11 +92,22 @@ task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) {
dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
}

Expand All @@ -32,7 +45,7 @@
includeEmptyDirs = false
into("$thirdPartyNdkDir/folly")
}
@@ -144,6 +157,14 @@
@@ -144,6 +161,14 @@ task prepareHermes(dependsOn: createNativeDepsDirectories, type: Copy) {
into "$thirdPartyNdkDir/hermes"
}

Expand All @@ -47,15 +60,15 @@
task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
onlyIfNewer(true)
@@ -292,6 +313,7 @@
@@ -315,6 +340,7 @@ android {
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
"REACT_GENERATED_SRC_DIR=$buildDir/generated/source",
"REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react",
+ "V8_NUGET_DIR=$projectDir/$V8Path",
"-j${ndkBuildJobs()}"

if (Os.isFamily(Os.FAMILY_MAC)) {
@@ -311,7 +333,7 @@
@@ -339,7 +365,7 @@ android {
}
}

Expand Down
14 changes: 14 additions & 0 deletions android-patches/patches/Build/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/build.gradle.kts b/build.gradle.kts
index 4725963eae0..7c71d628832 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,9 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

-val ndkPath by extra(System.getenv("ANDROID_NDK"))
-val ndkVersion by extra(System.getenv("ANDROID_NDK_VERSION"))
-
buildscript {
repositories {
google()

0 comments on commit e960741

Please sign in to comment.