Commit Graph

21 Commits

Author SHA1 Message Date
Anandraj Govindan 9d08d55bbe Use NMake generator for Hermes build on Windows (#34790)
Summary:
CMake on Windows uses "Visual Studio **" generators are [multi-configuration](https://cgold.readthedocs.io/en/latest/glossary/multi-config.html),

which requires the hermes cli and hermes runtime build flavors to be compatible. Using the "MakeFile" generator will avoid the requirement and keeps the gradle script simpler. Please note that the "Makefile" generator is the default when only "Visual Studio Community edition" with default packages is available.

Use NMake generator for Hermes build on Windows

## Changelog
CMake on Windows uses "Visual Studio **" generators are [multi-configuration](https://cgold.readthedocs.io/en/latest/glossary/multi-config.html),

which requires the hermes cli and hermes runtime build flavors to be compatible. Using the "MakeFile" generator will avoid the requirement and keeps the gradle script simpler. Please note that the "Makefile" generator is the default when only "Visual Studio Community edition"  with default packages  is available.

[Android] [Fixed] - Use NMake generator for Hermes build on Windows

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

Test Plan: Verified that RN build on Windows with multiple SKUs of Visual studio.d

Reviewed By: cortinico

Differential Revision: D39889332

Pulled By: cortinico

fbshipit-source-id: f2d39d981e7c58c8cb93a4322155c844cb6bded3
2022-10-03 05:09:20 -07:00
Sim Sun 1237952d07 Bump SoLoader version to 0.10.4
Summary:
## Changelog

[Android] [Changed] - Bump Soloader to 0.10.4

Reviewed By: cortinico

Differential Revision: D37988583

fbshipit-source-id: 6d2a423f39c2c4077bad29406e8d9fd67141045b
2022-07-21 16:43:01 -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
Nicola Corti c11785b90d Update the hermesc output to be inside the $buildDir
Summary:
Currently, we build Hermes by specifying the Cmake flag `-B ./hermes`. That means
that the output out the build is going to be placed along side the source code.

This is fine, as long as the user doesn't use the `REACT_NATIVE_OVERRIDE_HERMES_DIR`,
which is used inside the Hermes CI. In that case, the source location of Hermes can be
changed, leading to scenarios where `hermesc` can't be found.

Here I'm changing the flag to be `-B $buildDir/hermes`. Therefore the build output
will always be located within the `./ReactAndroid/hermes-engine/build` folder.
This is a more robust solution as the build output will be encapsulated within the
`build/` folder.

Changelog:i
[Internal] [Changed] - Update the hermesc output to be inside the $buildDir

Reviewed By: cipolleschi

Differential Revision: D35964402

fbshipit-source-id: aa7e0775b282897d5a99c1c46265884d19c5f289
2022-04-27 09:41:11 -07:00
Nicola Corti c12423cbdc Use Android SDK version of CMake rather than an external one
Summary:
This diff updates the CMake command used for configuring the Hermes build
from `cmake` from $PATH to the `cmake` bundled with the Android SDK.
If not found, fallsback to the previous behavior.

This relaxes the requirement of having to ask our users to install CMake
in their CLIs.

Changelog:
[Internal] [Changed] - Use Android SDK version of CMake rather than an external one

Reviewed By: neildhar

Differential Revision: D35931306

fbshipit-source-id: 8d6c554e5e9040e3bd4fed5f72fbdb0eb61d745a
2022-04-26 07:19:00 -07:00
Nicola Corti 56fd85e371 Customize the Hermes version using the RN one
Summary:
This diff allows to customize the Hermes version exposed by the VM with
a version provided by React Native. This will make clearer that a specific
version of Hermes was built at a specific point of the RN release process.

Changelog:
[Internal] [Changed] - Customize the Hermes version using the RN one

Reviewed By: neildhar

Differential Revision: D35820268

fbshipit-source-id: 3e76db921c12a599743fb9312f52edd06d223bad
2022-04-22 07:52:27 -07:00
Nicola Corti c5babd993a Improve support for Android users on M1 machine
Summary:
This is a follow up to my previous diff. It applies the same customization for M1 users to the :ReactAndroid:hermes-engine build.

The two diffs are split so the first one can be cherry-picked into 0.68.1 if needed.

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

Reviewed By: mdvacca

Differential Revision: D35468658

fbshipit-source-id: c07822f6708f872456971378f44257f6c1e967ee
2022-04-07 10:55:32 -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
Neil Dhar 6f26a920a7 Enable ICF and LTO (#33560)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33560
X-link: https://github.com/facebook/hermes/pull/720

Turn on ICF for the build whenever it is available. This requires us to
link with LLD, which is only the default starting in NDK r23, so
manually specify LLD for the Android build.

Also turn on LTO for the CircleCI build, so we generate highly
optimised binaries for distribution.

Changelog: [Internal]

Reviewed By: jpporto

Differential Revision: D35344254

fbshipit-source-id: 64b37e6a7817a7b7826cc7480468367b95d63c61
2022-04-04 20:32:58 -07:00
Neil Dhar aefb17421b Always enable debugger by default
Summary:
We currently enable the debugger by default on all platforms except
Android. On Android, we then manually enable the debugger in debug
builds. Instead, change it so the debugger is manually disabled in
release builds, to simplify the setup.

Changelog: [Internal]

Reviewed By: jpporto

Differential Revision: D35347444

fbshipit-source-id: a97bba0c65c61c211cf9e361e7091343a2c6416f
2022-04-04 15:47:29 -07:00
Neil Dhar 68fd7de115 Directly invoke CMake when compiling Hermes
Summary:
Changelog: [Internal]

Working towards removing configure.py, switch to invoking CMake directly.

Note that with this change, ninja is no longer a requirement, since it will use the default build system on the host.

Reviewed By: cortinico, jpporto

Differential Revision: D35342731

fbshipit-source-id: f04a367bda9fb22642f17e7c2c5cf493e44013d3
2022-04-04 15:47:29 -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 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
Nicola Corti 10d2e4cf2e Fix a typo in the hermes-engine srcSet folder
Summary:
There is a typo in the hermes-engine resulting in hermes-engine not picking up the Intl
Java source code. I'm fixing it.

Changelog:
[Internal] [Changed] - Fix a typo in the hermes-engine srcSet folder

Reviewed By: motiz88

Differential Revision: D34922477

fbshipit-source-id: a144f7a2f75702bc8ddea73fa8b48c71d8fcd499
2022-03-16 04:59:47 -07:00
Nicola Corti 68fde3b35b Allow to override Hermes source location with REACT_NATIVE_OVERRIDE_HERMES_DIR
Summary:
This commit allows to specify a custom location for Hermes sources with the
`REACT_NATIVE_OVERRIDE_HERMES_DIR` environment variable.

This can be useful during local development if you wish to build against a local
clone of facebook/hermes.

Changelog:
[Internal] [Changed] - Allow to override Hermes source location with REACT_NATIVE_OVERRIDE_HERMES_DIR

Reviewed By: ShikaSD

Differential Revision: D34858893

fbshipit-source-id: 4fad3d1c8e99f1f1880b5633e596b67f5dfcc264
2022-03-15 06:29:25 -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
Nicola Corti a0511a1daa Attempt to fix CircleCI by bumping CMake to 3.18.1 (#33382)
Summary:
I accidentally broke CircleCI. This PR attempts to fix it by setting the requested CMake version to `3.18.1`.

We might have to bump the Docker image to fix this instead.

## Changelog

[Internal] - Attempt to fix CircleCI by bumping CMake to 3.18.1

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

Test Plan: Will rely on Green CircleCI

Reviewed By: motiz88

Differential Revision: D34679269

Pulled By: cortinico

fbshipit-source-id: 2addb0914d900c5e712e905cf14a54d6028cf417
2022-03-07 01:26:23 -08:00
Nicola Corti 350f8c5ed0 Setup publishing for the ReactAndroid/hermes-engine to the top level /android folder.
Summary:
This sets up the publishing of the `hermes-engine` to end up in the Maven Local repository
we have set up inside the ./android folder of the NPM package of `react-native`.
Artifacts from there will be picked up similarly to what it's happening for React Android

Changelog:
[Internal] [Changed] - Setup publishing for the `ReactAndroid/hermes-engine` to the top level `/android` folder.

Reviewed By: hramos

Differential Revision: D34213638

fbshipit-source-id: adbc0d1559ee815f9d7a711c9c77489ec92b76ff
2022-03-04 07:27:13 -08:00
Nicola Corti a211089b9b Setup an android library project inside ReactAndroid/hermes-engine
Summary:
This commits sets up an Android library by applying the plugin
and configuring all the necessary flags.

Flags have been adapted from:
https://github.com/facebook/hermes/blob/main/android/hermes/build.gradle
Removing the unnecesary ones and adapting the build to conform
to the React Native build system.

Changelog:
[Internal] [Changed] - Setup an android library project inside `ReactAndroid/hermes-engine`

Reviewed By: hramos

Differential Revision: D34213534

fbshipit-source-id: c2e7b810bf4c4b1831a764a6f76cb73722da2125
2022-03-04 07:27:13 -08:00
Nicola Corti d96cd6d285 Create a Gradle task to setup the Hermes Ninja build
Summary:
As the title says, we need to invoke:
```
./utils/build/configure.py ./ninja_build
cmake --build ./ninja_build --target hermesc
```
In order to build the Hermes compiler, otherwise the CMake build
will fail with a missing Cmake file.

Changelog:
[Internal] [Changed] - Create a Gradle task to setup the Hermes Ninja build

Reviewed By: hramos

Differential Revision: D34213468

fbshipit-source-id: 83f70bdb068f99ce17a44207b4282fde2d7420ca
2022-03-04 07:27:13 -08:00
Nicola Corti 191fc0f7cc Setup a Gradle build inside ReactAndroid/hermes-engine to download Hermes sources
Summary:
This Diff sets up a small Gradle build inside `ReactAndroid/hermes-engine`
The idea is to kickoff a small project where we can download Hermes sources and start a compilation of
the Hermes sources from there.

Specifically the used paths are:

- `/sdk/hermes` for the unzipping
- `/sdk/download/hermes.tar.gz` for the tarball location
- `/sdk/hermes/.hermesversion` for the hermes version.

allow-large-files

Changelog:
[Internal] [Changed] - Setup a Gradle build inside `hermes-engine` to download Hermes sources

Reviewed By: hramos

Differential Revision: D34210236

fbshipit-source-id: 97034f5608dfb3fcd1d74e9851944f7a60e52ea1
2022-03-04 07:27:13 -08:00