Граф коммитов

239 Коммитов

Автор SHA1 Сообщение Дата
Sunbreak d0df6afe76 Remove Android.mk from internal Gradle task (#34687)
Summary:
`Android.mk`s are no longer used for internal Gradle tasks since [First Round of CMake files for React Android](b676ca560d) and [CMake setup for ReactAndroid](e3830ddffd)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Fixed] - Remove Android.mk from internal Gradle task

Pull Request resolved: https://github.com/facebook/react-native/pull/34687

Test Plan: None

Reviewed By: cipolleschi

Differential Revision: D39541322

Pulled By: cortinico

fbshipit-source-id: 421591effab2c1a82bcacff656360a2d02439a53
2022-09-15 06:32:49 -07:00
Nicola Corti e89bd4a375 Reduce the amount of C++ code in user space for RN-Tester
Summary:
This diff reduces the amount of C++ code in user space by:
- Moving all the C++ implementation of the .defaults package inside a `react_newarchdefaults` shared library
- Exposing only the entrypoint logic inside the RN-Tester's `OnLoad.cpp` file.

Changelog:
[Android] [Changed] - Reduce the amount of C++ code in user space for New Architecture

Reviewed By: cipolleschi

Differential Revision: D39381820

fbshipit-source-id: 9c4b5596b67b5a7ee58824319c80e325348ed06c
2022-09-12 12:48:43 -07:00
Nicola Corti 12ba077e16 Remove deprecated jni.srcDirs from ReactAndroid build file
Summary:
As the title says, android.sourceSets.main.jni is deprecated in AGP. We should not be accessing it. Here we were setting it to the empty array (the default value).

It will cause the build to break in a future AGP bump, hence I'm removing it.

Changelog:
[Internal] [Changed] - Remove deprecated jni.srcDirs from ReactAndroid build file

Created from CodeHub with https://fburl.com/edit-in-codehub

Reviewed By: cipolleschi

Differential Revision: D38655857

fbshipit-source-id: 2eb6897964554da462bde58937a6de708bc047dc
2022-08-15 02:23:13 -07:00
Muhammad Hur Ali be35c6dafb fix: react android kotlin plugin version conflict (#34255)
Summary:
Fixes https://github.com/facebook/react-native/issues/34229

Basically, the react android conflicts with the kotlin version that's defined in the top level build.gradle. To resolve it, the approach was to get the `kotlinVersion` defined in top level build.gradle and use it. If it's not defined, we use the default(1.6.10 as of now).

The reason behind not using the DSL is that it doesn't allow us to use the variables due to it's constrained syntax.
See [here](https://docs.gradle.org/current/userguide/plugins.html#sec:constrained_syntax)

So the idea was to use the build script to resolve the kotlin plugin and it works 👍 .

Kindly asking for review cortinico :)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Changed] - refactored usage of kotlin plugin

Pull Request resolved: https://github.com/facebook/react-native/pull/34255

Test Plan: Ran the node ./scripts/run-ci-e2e-tests.js --js --android --ios to verify it doesn't introduce any unexpected issues.

Reviewed By: dmitryrykun

Differential Revision: D38468567

Pulled By: cortinico

fbshipit-source-id: f9ab635fcf033f1d337ed90793ba1667957b8e01
2022-08-08 08:06:05 -07:00
Janic Duplessis ccbfdd7167 Improve OSS systrace (#34252)
Summary:
Implements most of systrace using androidx.tracing, this makes it usable using Android Studio profiler systrace.

## Changelog

[Android] [Added] - Improve OSS systrace

Pull Request resolved: https://github.com/facebook/react-native/pull/34252

Test Plan:
Run a systrace in Android Studio for RN Tester and make sure RN specific sections are there.

<img width="1263" alt="image" src="https://user-images.githubusercontent.com/2677334/180593493-fc087b4a-2253-43e1-b246-bed3e7bba7ac.png">

Reviewed By: NickGerleman

Differential Revision: D38116890

Pulled By: dmitryrykun

fbshipit-source-id: 744bedbf9ad4004488340a5b4e93d936d9a1e582
2022-07-27 10:54:35 -07:00
Nicola Corti d2bc02491a Cleanup some of the dependencies inside ReactAndroid (#34191)
Summary:
This cleans up a bit our dependency list inside `ReactAndroid`. I've re-sorted the lists, and exported everything I could in the `gradle.properties`.

I wish we could move to the Gradle Version Catalog for Android, but that's not possible at the moment (it will make impossible for users to build from source).

## Changelog

[Internal] - Cleanup some of the dependencies inside ReactAndroid

Pull Request resolved: https://github.com/facebook/react-native/pull/34191

Test Plan: Will rely on a Green CircleCI

Reviewed By: huntie

Differential Revision: D37828614

Pulled By: cortinico

fbshipit-source-id: f433d08d691db4145e0c72ca4dab2f0350e4101f
2022-07-14 06:19:49 -07:00
Nicola Corti f179d47fb1 Set root to be `..` for ReactAndroid
Summary:
I've accidentally broke the external CI.

The reason is that root is defaulted to `$rootProject/..`.
The Gradle Plugin assumes there is a package.json there, which is always the case for RN projects, given that root is configured properly.

This was green on internal CIs as it was actually hitting the file on `xplat/js/package.json`. Externally, there is no such file, therefore is failing.

The fix is to specify the root path and don't use the default for ReactAndroid

Changelog:
[Internal] [Fixed] - Set root to be `..` for ReactAndroid

Reviewed By: cipolleschi

Differential Revision: D36597308

fbshipit-source-id: 66638ee1014ef35c81195526e0b325f5cc008b82
2022-05-23 09:40:29 -07:00
Nicola Corti dadcfcae95 Disable Javadoc publishing as it's currently failing on CI
Summary:
I'm disabling the publishing of Javadoc as it's currently failing on CI.
The failure is happening due to a concurrency problem during the Kotlin
documentation generation.

As we don't have much Javadoc to export, I'm removing this for now.

Changelog:
[Internal] [Fixed] - Disable Javadoc publishing as it's currently failing on CI

Reviewed By: cipolleschi

Differential Revision: D36481215

fbshipit-source-id: 6f875932013f80779151f75e20d25ba3b71de074
2022-05-18 11:48:16 -07:00
Janic Duplessis 6ab7a99518 Pass react build dir to cmake (#33736)
Summary:
The ReactAndroid cmake build assumes that the build directory is ReactAndroid/build, but this is not always the case if gradle is configured with a different build location. Instead of assuming the build location in cmake, pass it from gradle.

## Changelog

[Android] [Fixed] - Pass react build dir to cmake

Pull Request resolved: https://github.com/facebook/react-native/pull/33736

Test Plan:
Tested in an app with a custom build dir that RN now builds properly after this change.

In build.gradle add:

```groovy
allprojects {
    buildDir = "${System.getProperty("user.home")}/.gradle/builds/${rootProject.name}/${project.name}"
}
```

Reviewed By: christophpurrer

Differential Revision: D36128556

Pulled By: cortinico

fbshipit-source-id: cdb8283c93ea7c384ec94cd3e24012220965b6dc
2022-05-06 01:56:33 -07:00
Nicola Corti bfc39353d1 Do not specify a Kotlin version in the RN rootProject (#33589)
Summary:
As we introduced KGP inside `ReactAndroid` (cc ShikaSD), we now need to specify a version for it (as users will consume that build on Android New Architecture.

Currently, the version is loaded in the RN `rootProject` which is not available on user's project. I'm cleaning this up.

## Changelog

[Internal] - Do not specify a Kotlin version in the RN rootProject

Pull Request resolved: https://github.com/facebook/react-native/pull/33589

Test Plan:
Tested on a nightly version with

```
npx react-native init RNNightly --version nightly
```

Reviewed By: mdvacca

Differential Revision: D35476777

Pulled By: cortinico

fbshipit-source-id: 5a819ef5fa9a6886d7b7b683f31d59cb05a49f29
2022-04-08 03:44:56 -07:00
Nicola Corti 4befd2a29c Improve support for Android users on M1 machine (#33588)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33588

Currently users on M1 machine can't use the New Architecture correctly as they will get build failures when building the native code.

This Diff fixes it by automatically recognizing the host architecture and switching to NDK 24 if user is runnign on `aarch64`

Changelog:
[Android] [Fixed] - Improve support for Android users on M1 machine

Reviewed By: mdvacca

Differential Revision: D35468252

fbshipit-source-id: b73f5262b9408f04f3ae4fd26458a4d17c1ec29a
2022-04-07 10:55:32 -07:00
Lorenzo Sciandra 5cd6367f0b Bump boost for Android to 1.76 to align with iOS + fix (#33565)
Summary:
The reason why I'm working on this is to reduce the delta between this and the react-native-macos fork, in particular with the android patch folder "Build": https://github.com/microsoft/react-native-macos/tree/main/android-patches/patches/Build (it's a long story)

While checking the changes in there, I noticed that one of them was a bump of boost. Looking back into main (here), I then noticed that there have been two bumps to boot in the repo so far:
* a combo update 5 years ago to 1.63:
  * 193afff926
  * 5c24a9110a
* and an update for the iOS side to 1.76 by Kudo last year: https://github.com/facebook/react-native/pull/31840

So this quickly turned into this: the PR wants to re-align the version of boost used in both iOS and Android.

I explored the option of bumping both to 1.78 (latest at the time of writing: https://www.boost.org/users/history/version_1_78_0.html) but then I noticed that there's a Flipper dependency, `Flipper-Boost-iOSX`, on the iOS pods side that has been released only once and it seems to imply that it's 1.76 only compatible https://github.com/priteshrnandgaonkar/Flipper-Boost-iOSX/releases/tag/1.76.0.1.11.

So going to 1.78 at least for now seems like a no-go, and I've settled for just aligning everything to 1.76 and just like iOS, move away from `boost-for-react-native` in favour of the original one.

While doing so, I also noticed that the `React/third-party.xcconfig` still had a reference to 1.68 instead of 1.76 which seems like a leftover from Kudo's PR... it's probably because it was not doing anything in the first place, so lmk if you want me to delete it.

## 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] [Changed] - Bump boost for Android to 1.76 to align with iOS

Pull Request resolved: https://github.com/facebook/react-native/pull/33565

Test Plan:
CI is green (aside an unrelated ios rntester job that is also broken on main) 
Locally both RNTester and new app work:
<img width="432" alt="Screenshot 2022-04-05 at 16 42 31" src="https://user-images.githubusercontent.com/16104054/161815444-0de63919-b90d-4a48-963a-872f0cc4ce79.png">

<img width="346" alt="Screenshot 2022-04-05 at 18 06 01" src="https://user-images.githubusercontent.com/16104054/161815438-b7b1c997-9dcd-47bd-acbe-732155941bb0.png">

Reviewed By: sshic

Differential Revision: D35433032

Pulled By: cortinico

fbshipit-source-id: 0d93f61f8c26eda1dd04127a8b20e799ab6828cb
2022-04-07 04:50:30 -07:00
Nicola Corti b2bc5aa5c9 Do not use `rootProject` directly in Gradle scripts
Summary:
While testing with the RN Nightly versions, I realized we pushed two changes
recently that are not working fine with the gradle setup of our users.

That's becuase we're referencing the `rootProject` directly.
`rootProject` should never be used directly as it resolves to:
- The root of the git repo of `react-native` when building the RN project (so
  `./ReactCommon` exists there).
- The /android folder of users' project when building an app that uses RN (so
  `./ReactCommon` does not exists there).

Changelog:
[Android] [Fixed] - Do not use `rootProject` directly in Gradle scripts

Reviewed By: sshic

Differential Revision: D35444967

fbshipit-source-id: be0508480a08224302168804b6feb52fd604d8db
2022-04-07 04:48:40 -07:00
Nicola Corti 1e51ac2b6c Setup multi-variant publishing for React Native Android (#33539)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33539

As we now provide `hermes-executor-debug` OR `hermes-executor-release` based on which version of RN we're building, we need to provide a variant aware AAR.

Changelog:
[Internal] [Changed] - Setup multi-variant publishing for React Native Android

Reviewed By: ShikaSD

Differential Revision: D35289444

fbshipit-source-id: ffccd2089dc2eb50ea8c08ed10d8fd9816f9efb7
2022-04-05 09:38:55 -07:00
Nicola Corti fca8c03b14 Reintroduce missing dependency between configureCMakeDebug and preBuild
Summary:
I've noticed that some builds are sporadically failing as `configureCMake*` is runnign before
`preBuild`. When this happens, some 3rd party library folder won't exist yet and the build will
essentially fail. This is introducing flakyiness that this commit is essentially reducing

Changelog:
[Internal] [Changed] - Reintroduce missing dependency between configureCMakeDebug and preBuild

Reviewed By: ShikaSD

Differential Revision: D35213932

fbshipit-source-id: bfb4173843349ca4c1699d584bf0c915ab7b35cf
2022-03-30 07:22:09 -07:00
Andrei Shikov e3830ddffd CMake setup for ReactAndroid (#33472)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33472

Changes native build of ReactAndroid to CMake instead of ndk-build. Removes a few workarounds around AGP issues with ndk-build which seems to be working with CMake by default.

Changelog: [Changed][Android] - Use CMake to build ReactAndroid module

Reviewed By: cortinico

Differential Revision: D35018803

fbshipit-source-id: af477937ed70a5ddfafef4e6260a397ee9911580
2022-03-23 11:18:54 -07:00
Nicola Corti 5b1ac6fb3b Use `findByName` instead of `named` when applying Gradle task dependencies
Summary:
When using Android Studio, an active ABI gets selected which is resulting in failing to open the project as some of the tasks can't be found. I'm fixing this.

Changelog:
[Internal] [Changed] - Use `findByName` instead of `named` when applying Gradle task dependencies

Reviewed By: ShikaSD

Differential Revision: D35044870

fbshipit-source-id: 44bfaee320bce84c992610325c13daf71934a38b
2022-03-22 04:48:52 -07:00
Nicola Corti c418bf4c8f Reduce flakyness of `configureNdkBuild*` tasks by setting an
Summary:
This is a follow up to
21dd646eca
The ABI specific tasks were not involved in this patch, and they're still
failing. I'm fixing them.

Changelog:
[Internal] [Changed] - Reduce flakyness of `configureNdkBuild*` tasks by setting an
explicit dependency on prefab - part 2

Reviewed By: ShikaSD

Differential Revision: D34960946

fbshipit-source-id: 3e4feb93aa59cbe47142dece1d0246117381179d
2022-03-17 05:56:37 -07:00
Nicola Corti 8200f91598 Disable prefab publishing if REACT_NATIVE_HERMES_SKIP_PREFAB is set. (#33439)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33439

This allows us to toggle the publishing of prefab if the `REACT_NATIVE_HERMES_SKIP_PREFAB`
env variable is set. With this we can control how big is the .aar of hermes-engine, reducing
the size from ~200Mb right now to 8Mb.

Changelog:
[Internal] [Changed] - Disable prefab publishing if REACT_NATIVE_HERMES_SKIP_PREFAB is set

Reviewed By: ShikaSD

Differential Revision: D34929265

fbshipit-source-id: eb710b72ee4e17ac04c2924ffdac7a542928e9f8
2022-03-16 12:24:55 -07:00
Andrei Shikov a6095d43cd Include CMakeLists.txt into third-party setup
Summary:
Includes `CMakeLists.txt` describing build of third-party libraries into "prepared" folders

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D34882968

fbshipit-source-id: 071cd9f2316b571c0ae007679ce85ba287904291
2022-03-15 20:23:51 -07:00
Nicola Corti 21dd646eca Reduce flakyness of `configureNdkBuild*` tasks by setting an explicit dependency on prefab.
Summary:
I've noticed that `test_android` and the Test Android Docker image jobs fails sometime with a missing
`libhermes.so` file. That is happening because the `configureNdkBuild*` tasks are executing
before the prefab for Hermes is ready. I'm adding an explicit dependency here that will prevent this
kind of situations from happening.

Changelog:
[Internal] [Changed] - Reduce flakyness of `configureNdkBuild*` tasks by setting an explicit dependency on prefab.

Reviewed By: ShikaSD

Differential Revision: D34859961

fbshipit-source-id: e4dc4b22c808359018ec952287b2d8a7094f0698
2022-03-15 06:39:40 -07:00
Nicola Corti a3d9892ed9 Build Hermes from Source (#33396)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33396

This commit fully unplugs the `ReactAndroid` from using hermes from the NPM package and plugs the usage of Hermes via the `packages/hermes-engine` Gradle build.

I've used prefab to share the .so between the two builds, so we don't need any extra machinery to make this possible.

Moreover, I've added a `buildHermesFromSource` property, which defaults to false when RN is imported, but is set to true when RN is opened for local development. This should allow us to distribute the `react-native` NPM package and users could potentially toggle which source to use (but see below).

Changelog:
[Android] [Changed] - Build Hermes from Source

Reviewed By: hramos

Differential Revision: D34389875

fbshipit-source-id: 107cbe3686daf7607a1f0f75202f24cd80ce64bb
2022-03-11 15:23:36 -08:00
Andrei Shikov b1a779392d Enable Kotlin build in OSS (#33160)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33160

Enables Kotlin build in RNAndroid, while adjusting the package structure to help with path/package inconsistency.

Moves `react/uimanager/interfaces` files into `react/uimanager` to make sure package name matches with file location and updates Buck configuration to still include it as a separate target.

Changelog: [Android][Changed] - Moved `com/react/facebook/uimanager/interfaces` files into `com/react/facebook/uimanager` to enable Kotlin build

Reviewed By: cortinico

Differential Revision: D34381179

fbshipit-source-id: 252588d9c7f62b8019bdfcce66197628d63e63a1
2022-02-22 10:22:52 -08:00
Gabriel Donadel Dall'Agnol 200488e87c build: Bump AGP to 7.1.1 and fix bundle inclusion in release mode (#33057)
Summary:
Upgrade Android Gradle to 7.1.0 on template and fix a bug where the bundle was not getting included when building the app in release mode

Closes https://github.com/facebook/react-native/issues/33002
Closes https://github.com/facebook/react-native/issues/33018
Closes https://github.com/facebook/react-native/issues/33046
Potentially fixes https://github.com/facebook/react-native/issues/33029

## Changelog

[Android] [Changed] - Bump AGP to 7.1.0 and fix bundle inclusion in release mode

Pull Request resolved: https://github.com/facebook/react-native/pull/33057

Test Plan:
1. Run `./scripts/test-manual-e2e.sh`
2. Select `A new RN app using the template` and `Android`
3. Test app on the emulator
4. Open Android studio build the app using release variant
4. Check the release apk using Android studio "Analyze APK" tool and ensure the bundle is included

![image](https://user-images.githubusercontent.com/11707729/152700410-3bcb80b0-35b6-4bdc-bf57-98a42a29e5a6.png)

Reviewed By: ShikaSD

Differential Revision: D34076884

Pulled By: cortinico

fbshipit-source-id: da4392af37e08e22dbcafba38476fd712141474a
2022-02-21 06:23:31 -08:00
Nicola Corti 8bc324fd34 Gradle: Deprecate `reactRoot` in favor of `root` and `reactNativeDir` (#33142)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33142

The `reactRoot` property was confusing as we were using it for both the root of the project
and the react-native NPM Package root. I'm deprecating it and splitting it in two.

I've added several warning in the codebase to tell the people how to migrate away from it.
Moreover this is specifying default values that are more user-friendly. Users won't have to
configure anything unless they are in a monorepo.

Changelog:
[Android] [Changed] - Gradle: Deprecate `reactRoot` in favor of `root` and `reactNativeDir`

Reviewed By: ShikaSD

Differential Revision: D34277050

fbshipit-source-id: fc7f45017452b086726516a9586cacd9a661c287
2022-02-18 04:32:40 -08:00
Gabriel Donadel Dall'Agnol 6b61995647 build(deps): Bump android Appcompat to 1.4.1 (#33072)
Summary:
Currently we are using Appcompat in version 1.0.2 which is almost 4 years old now, this PR updates it to version 1.4.1.

Using Appcompat 1.0.2 was also causing a crash on RNTester due to an error where FontFamily's method was not found (Related to https://github.com/facebook/react-native/issues/33065)

Closes https://github.com/facebook/react-native/issues/31620

## Changelog

[Android] [Changed] - Bump android Appcompat to 1.4.1

Pull Request resolved: https://github.com/facebook/react-native/pull/33072

Test Plan: Use `./scripts/test-manual-e2e.sh` to test both RNTester and a new app

Reviewed By: cortinico

Differential Revision: D34107105

Pulled By: ShikaSD

fbshipit-source-id: 966e4687b09ae50a88ee518622f073d72e8c6550
2022-02-10 09:52:59 -08:00
Nicola Corti fa85417179 Do not bundle libhermes.so or libjsc.so inside the React Native Android AAR (#33038)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33038

While rolling out RN 0.68.x we noticed that `libhermes.so` and `libjsc.so` were included
inside the final .aar we publish to NPM. This forced users (on both old or new arch) to
specify a `pickFirst` directive inside their packaging option (which is unpractical and
risky as the two .so might not be compatible each other if they're coming from
different Hermes/JSC versions).

Changelog:
[Android] [Fixed] - Do not bundle libhermes.so or libjsc.so inside the React Native Android AAR

Reviewed By: ShikaSD

Differential Revision: D33979107

fbshipit-source-id: 0b71d59f210b8bc9903cd0f30ed6e2120aab99e0
2022-02-03 08:44:53 -08:00
Kudo Chien 384e1a0c7b Add missing sources jar into published android artifacts (#32982)
Summary:
when migrated to `maven-publish` in https://github.com/facebook/react-native/issues/31611, the sources jar is not included by default from `maven-publish`. so react-native 0.66 / 0.67 doesn't include sources jar in npm published artifacts. it's not ideal for debug or tracing code.

this pr added the sources jar into the published artifact.

## Changelog

[Android] [Fixed] - Add missing sources jar into published android artifacts

Pull Request resolved: https://github.com/facebook/react-native/pull/32982

Test Plan:
make sure sources jar is included in artifact.

```
$ ./gradlew :ReactAndroid:installArchives
$ find android -name '*sources.jar*'
```

Reviewed By: ShikaSD

Differential Revision: D33842979

Pulled By: cortinico

fbshipit-source-id: f99ad46ce0cca0cfc2ab1d5c5a4fcb40a02683e7
2022-01-28 06:17:12 -08:00
Nicola Corti bd7caa64f5 Use side-by-side NDK for Android (#32848)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32848

If we leverage the side-by-side configuration of the NDK
(see https://developer.android.com/studio/projects/configure-agp-ndk#agp_version_41)
we will not have to specify the NDK Path or Version at all.

We will automatically pick the best NDK version selected by AGP.

Changelog:
[Android] [Changed] - Use side-by-side NDK for Android

Reviewed By: ShikaSD

Differential Revision: D33475818

fbshipit-source-id: 16aa4acfc44b94e2f92df89d71e104bf46d7f162
2022-01-11 10:00:54 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Andrei Shikov 8367fc3836 Replace fest with assertj (#32770)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32770

Fest is EOL and is replaced by assertj, originally a fork of Fest. This change replaces the usages in internal tests and removes the dependency.

Changelog:
[Internal][Android] Replace fest with assertj

Reviewed By: genkikondo

Differential Revision: D33143454

fbshipit-source-id: c1cbe5b064d007018f73858b2913806c11aa08af
2021-12-16 10:40:37 -08:00
Andrei Shikov 00ac034353 Bump OSS Android build to SDK 31 (#32606)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32606

Updates OSS builds for internals and template to target SDK 31, corresponding to Android 12.

Changelog:
[Updated][Android] - Bump Android compile and target SDK to 31

Reviewed By: cortinico

Differential Revision: D32107409

fbshipit-source-id: 57f219d33e884200ca4f49e1afe1bfd65b0d6315
2021-11-24 12:27:26 -08:00
Nicola Corti a5469f9d7f Update libruntimeexector to be a shared lib rather than a static lib
Summary:
AGP 7.x is changing the path where we can find
the precompiled static libraries. Therefore is getting complicated
to share prebuilt `.a` files. I'm updating `libruntimeexecutor` to be
a shared library instead so this will solve this issue for now.

Changelog:
[Internal] [Changed] - Update libruntimeexector to be a shared lib rather than a static lib

Reviewed By: ShikaSD

Differential Revision: D32646112

fbshipit-source-id: ce42e930076c1d3b5f54f3d8adcca1c38909d0fb
2021-11-24 10:58:54 -08:00
Dulmandakh 272cfe5d13 draft: bump AGP to 7 (#32589)
Summary:
Bump Android Gradle Plugin to 7.

## Changelog

[Android] [Changed] - Bump Android Gradle Plugin to 7.

This will make Java 11 a requirement for users that are either:
* Cloning react-native to contribute
* Using react-native while building from source.
* Creating new project from the template.

Pull Request resolved: https://github.com/facebook/react-native/pull/32589

Test Plan: CI is green

Reviewed By: ShikaSD

Differential Revision: D32427945

Pulled By: cortinico

fbshipit-source-id: c1ea464d87c3e397616c55154b3d8b1c3ea6c592
2021-11-24 10:58:54 -08:00
Nicola Corti 2162bce44b Adding a Custom Fabric Component to RNTester (#32640)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32640

This Diff shows how an application can provide a custom Fabric Components Registry.
The idea is to extend the CoreComponentsRegistry from rncore to provide the extra
components that are generated from RNTester.

Please note that this Diff can't be shipped as it is and should be rebased on top of:
- D32493605 (aa4da248c1) As the CLANGFORMAT is disabled for RNTester at the moment
- D32045059 (d29f3d2a6b) and D32128979 as they're effectively adding the sample component and the iOS code.

Changelog:
[Internal][Added] - Adding a Custom Fabric Component to RNTester

Reviewed By: ShikaSD

Differential Revision: D32498360

fbshipit-source-id: 1a737359498dddb571c8a445bec18e5dbcf53e04
2021-11-22 08:15:16 -08:00
Nicola Corti d70555ff0e Fix Release build of RNTester
Summary:
Currently the release build of RNTester is broken
as it's loading the debug native libraries. I had to create
separate tasks for the two variants as we can't benefit
of automatic variant matching between project (as of now till
we use prefabs or find another approach).

Changelog:
[Internal] [Fixed] - Fix Release build of RNTester

Reviewed By: ShikaSD

Differential Revision: D32203637

fbshipit-source-id: 5c260a365626e9b3c66e76166086711236a38264
2021-11-08 04:33:33 -08:00
Neil Dhar 43c38cdc8e Allow specifying an architecture in RNTester and release builds
Summary:
Setting `reactNativeDebugArchitectures` currently does not seem to work for RNTester, since it sets `abiFilters` which conflicts with the `splits` option we're already setting.

Gradle then complains:
```
neildhar@neildhar-mbp ~/f/x/j/react-native-github (default) >
./gradlew  -PreactNativeDebugArchitectures=x86_64 :packages:rn-tester:android:app:installJscDebug

> Configure project :ReactAndroid
Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version. Class name for the included build object: org.gradle.composite.internal.DefaultIncludedBuild$IncludedBuildImpl_Decorated.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':packages:rn-tester:android:app'.
> com.android.builder.errors.EvalIssueException: Conflicting configuration : 'x86_64' in ndk abiFilters cannot be present when splits abi filters are set : x86_64,x86,armeabi-v7a,arm64-v8a
```

Consolidate everything with the `splits` option.

In addition, it's convenient to also be able to control the native architecture for release builds.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D31834075

fbshipit-source-id: c6375d2a1e242981d0017f6e0a9d428b074a3fbd
2021-11-03 15:23:46 -07:00
Nicola Corti b0711f1d35 Update ReactAndroid to use the AGP NDK Apis (#32443)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32443

This diff removes all the custom Gradle machinery to build the native code and delegates to AGP
the triggering of the `ndk-build` command. This means that the native build will be now invoked
with the `:ReactAndroid:externalNativeBuild<Variant>` task.

An important thing to notice is that that task will always run, and will delegate to Make the
compilation avoidance. If you invoke the task twice, the second time it will be significantly faster.
On my machine this takes ~6/7 mins the first time, and 30 seconds the second time.

There are some gotchas that are worth noting:
* The native build will run on every build now. Given the complexity of our native build graph,
even with an up-to-date build, Make will still take ~30 seconds on my machine to analyse all the
targets and mention that there is no work to be done. I believe this could be impactful for local
development experience. The mitigation I found was to apply an `abiFilter` to build only the ABI
of the target device (e.g. arm64 for a real device and so on).
This reduces the native build to ~10 seconds.
* All the change to the `react-native-gradle-plugin` source will cause the Gradle tasks to be
considered invalid. Therefore they will re-extract the header files inside the folders that are
used by Make to compile, triggering a near-full rebuild. This can be a bit painful when building
 locally, if you plan to edit react-native-gradle-plugin and relaunch
 rn-tester (seems to be like an edge case scenario but worth pointing out). The mitigation here
 would be to invoke the tasks like

```
gw :packages:rn-tester:android:app:installHermesDebug -x prepareBoost -x prepareLibevent -x prepareGlog \
   -x prepareJSC -x extractNativeDependencies -x generateCodegenArtifactsFromSchema \
   -x generateCodegenSchemaFromJavaScript
```

Changelog:
[Internal] [Changed] - Refactor Extract Headers and JNI from AARs to an internal task

Reviewed By: ShikaSD

Differential Revision: D31683721

fbshipit-source-id: fa85793c567796f4e04751e10503717a88cb0620
2021-11-01 05:59:15 -07:00
Nicola Corti 30df66c648 Use explicit codegen path in ReactAndroid
Summary:
This Diff is adapting the codegen configuration for ReactAndroid
to specify a path for the codegen package. I've used the `findNodeModulePath`
so this will work for both:
* The top level OSS project as `node_modules` will be at the top level
* The scenario where ReactAndroid will be included and built from source (as `node_modules` is in the `..` folder).

Changelog:
[Internal] [Changed] - Use explicit codegen path in ReactAndroid

Reviewed By: mdvacca

Differential Revision: D31730920

fbshipit-source-id: 6637da5d0098114f4379bcaeb8a40e976c46f194
2021-10-20 09:34:06 -07:00
Nicola Corti e5ad0b403e useJavaGenerator output should override the react-native-codegen one
Summary:
Turns out that the Java generator is (as expected) outputting only Java code.
Therefore the C++ and the Markdown files are still generated by `react-native-codegen`.
I'm updating the logic to make sure the Java generator is not mutually exclusive and
overrides the output of `react-native-codegen`

Changelog:
[Internal] [Changed] - useJavaGenerator output should override the react-native-codegen one

Reviewed By: sshic

Differential Revision: D31754428

fbshipit-source-id: 3e6dae8212fbfebd28247ec17e88243871265808
2021-10-20 06:11:20 -07:00
Nicola Corti afc96ab126 Safely access the project NDK properties
Summary:
This diff is making sure that we're not failing the build
if either `ANDROID_NDK_PATH` or `ANDROID_NDK_VERSION` are missing.
Currently if any of the two is missing, a Gradle sync will fail.

This is problematic for the New Arch Rollout playbook as users will
import the `:ReactAndroid` project to build from source, and those
properties are instead defined at the `react-native` top level project.

Changelog:
[Internal] [Changed] - Safely access the project NDK properties

Reviewed By: sshic

Differential Revision: D31731291

fbshipit-source-id: ce4b762998ed545b3ec7ddcc07abbe4452602190
2021-10-20 06:07:15 -07:00
Nicola Corti bc93fefe13 Refactor Extract Headers and JNI from AARs to an internal task (#32426)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32426

This diff refactors the extractHeader and extractJni tasks to a single Gradle task in the `.internal` package.
The reason for this change is that those two tasks were always running, therefore invalidating the
whole native build cache.

Changelog:
[Internal] [Changed] - Refactor Extract Headers and JNI from AARs to an internal task

Reviewed By: mdvacca, ShikaSD

Differential Revision: D31682942

fbshipit-source-id: 191cc77902e82c0425949cee743d240ded790137
2021-10-18 04:34:43 -07:00
Nicola Corti 75b2e5cc97 Export prepareJSC to an internal task (#32427)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32427

This diff refactors the `prepareJSC` task to a separate Gradle task in the `.internal` package.

The reason for this change is that `prepareJSC` was just a plain `Task` and not a `Copy` task.
It was defining a top level `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the JSC headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareJSC to an internal task

Reviewed By: ShikaSD

Differential Revision: D31682293

fbshipit-source-id: 3d4cd9d9ce2fcd45e61f3c8c6685b69a622a1912
2021-10-18 04:34:43 -07:00
Nicola Corti 52b0cc0355 Export prepareBoost to an internal task (#32424)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32424

This diff refactors the `prepareBoost` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareBoost` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Boost headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareBoost to an internal task

Reviewed By: ShikaSD

Differential Revision: D31662120

fbshipit-source-id: 87ba82c634da832ee54c3d13561df45d3fd71381
2021-10-18 04:34:43 -07:00
Nicola Corti bb981b2055 Export prepareLibevent to an internal task (#32425)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32425

This diff refactors the `prepareLibevent` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareLibevent` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Libevent headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareLibevent to an internal task

Reviewed By: ShikaSD

Differential Revision: D31661988

fbshipit-source-id: e55c2179a187fa156f701c25bae3b48a796e2660
2021-10-18 04:34:43 -07:00
Nicola Corti c3e7ea0b5b Export prepareGlog to an internal task (#32421)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32421

This diff refactors the `prepareGlog` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareGlog` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Glog headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareGlog to an internal task

Reviewed By: ShikaSD

Differential Revision: D31661668

fbshipit-source-id: efcd5505a67d6c9f02fcab7a5c3255a160215661
2021-10-18 04:34:43 -07:00
Nicola Corti 85031d0166 Rename extension to just ReactExtension
Summary:
I'm cleaning up the extension to be just ReactExtension and not ReactAppExtension.
Similarly the name of the extension will be just `react` and not `reactApp`.

Changelog:
[Internal] [Changed] - Rename extension to just ReactExtension

Reviewed By: ShikaSD

Differential Revision: D30964793

fbshipit-source-id: 8a4207825d424e133e51495c34c21284c50363ae
2021-09-16 05:38:51 -07:00
Nicola Corti 022f188750 Merge CodegenPluginExtension inside ReactAppExtension
Summary:
This Diff is merging over all the properties from `CodegenPluginExtension` to
`ReactAppExtension`. Some of the properties were duplicate and generally having two
extensions is creating a lot of confusion for the users (e.g. don't know where to place a
specific property).

Therefore I'm merging the two to have only one. I've also updated the property to use the
Gradle Lazy Configuration API.

Changelog:
[Android] [Changed] - Gradle: Merge CodegenPluginExtension inside ReactAppExtension

Reviewed By: ShikaSD

Differential Revision: D30961343

fbshipit-source-id: 66be3157efef356392c0701aaef2283d058d3161
2021-09-15 09:23:23 -07:00
Nicola Corti c3ff336326 Merge the two Gradle Plugins (#32177)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32177

This diff merges the `react-native-gradle-plugin` and the `react-codegen/android` into a single plugin.
This will allow us to iterate faster on a single plugin, will create less confusion for our users (`react` vs `reactApp`)
and will help us avoid race conditions when the two plugins are applied together (as we will control the whole lifecycle of it).

Changelog:
[Internal] [Changed] - Merged the two Gradle Plugins

allow-large-files

Reviewed By: ShikaSD

Differential Revision: D30765147

fbshipit-source-id: fcb02a181c7d900daa514107c637d0ee0225976c
2021-09-15 03:21:23 -07:00
Nicola Corti 85249cafe8 Update project to build on Gradle 7.0.2 (#32073)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32073

This Diff bumps the version of Gradle used to build the project to
7.0.2. Ideally we could bump to 7.2.x directly, but I'll do one minor version
at a time to exclude potential build problems.

This diff is addressing all the extra build warnings that got raised by the new version.

Changelog:
[Android][Changed] - Bumped Gradle project version to 7.0.2

Reviewed By: ShikaSD

Differential Revision: D30486612

fbshipit-source-id: 70e0f7d18e547013ca7b1d12f8dd64a633df5870
2021-08-31 13:27:27 -07:00