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

31 Коммитов

Автор SHA1 Сообщение Дата
Riccardo Cipolleschi cb9eaa6db0 Refactor hermes logic to make it branch agnostic (#35709)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35709

This change refactors the logic to choose which version of hermes we have to pick

## Changelog:
[iOS][Changed] - Refactor hermes choosing logic

Reviewed By: cortinico, dmytrorykun

Differential Revision: D42211405

fbshipit-source-id: d19c0f2c523c5596d18a1f904e3b26d96ea1a77a
2023-01-05 06:58:38 -08:00
Dmitry Rykun 234486068e Prepare dummy hermes.xcframework before pod install
Summary:
This diff adds prepare command to hermes-engine.podspec. That command creates dummy `universal/hermes.xcframework` and `maocosx/hermes.framework`. This allow us to utilise CocoaPods auto-linking, and remove manual linking/cleanup code.
Also we now do not pollute user project with "Copy Hermes Framework" script phase. Which was quite bad on its own, and also caused annoying bugs on the CI.
allow-large-files

Changelog:
[iOS][Changed] - Prepare dummy hermes.xcframework before pod install.

Reviewed By: cipolleschi

Differential Revision: D41533994

fbshipit-source-id: d7d098ba5e882ac2d036335c23d7cda447d75b8d
2022-12-13 08:42:09 -08:00
Dmitry Rykun a5c77115ae Build hermesc in Xcode run script phase
Summary:
Build hermesc in Xcode run script phase, so it ends up inside `Pods/hermes-engine/buld_host_hermesc`. All the the housekeeping is now done by CocoaPods and Xcode, and we can get rid of all the setup/cleanup code.

Changelog:
[iOS][Changed] - Build hermesc in Xcode run script phase.

Reviewed By: cipolleschi

Differential Revision: D41521987

fbshipit-source-id: 336854fa23582255cba6d161acf2cc791cac9d00
2022-11-24 10:22:40 -08:00
Dmitry Rykun af6c9e2183 Do not add "Copy Hermes Framework" script phase to hermes-engine target
Summary:
This script phase is added to the main target of the user project.
Adding it to the hermes-engine target is redundant and does nothing useful.

Changelog:
[iOS][Changed] - Do not add "Copy Hermes Framework" script phase to hermes-engine target.

Reviewed By: cipolleschi

Differential Revision: D41521276

fbshipit-source-id: a024fa33f7ec1605d1d6021f436d3d397871a50c
2022-11-24 08:43:21 -08:00
Riccardo Cipolleschi 138af74e3f Remove `HERMES_BUILD_FROM_SOURCE` flag (#35397)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35397

This Diff removes the `HERMES_BUILD_FROM_SOURCE` that was not always propagated to the original script. This lead to some cases where hermesC was built during `pod install` and then removed by the `react_native_post_install`'s `else` branch.

Basically, when the Pods are installed the first time, everything run smoothly. Subsequent invocations of `pod install`, to install other dependencies, for example, will incur in this problem because:
1. Cocoapods will see that hermes-engine is already installed
2. the podspec is not executed, given that the pod has been fetched from the cache
3. The env var is not set (given that the podspec is not executed)
4. the main script sees the env var as not set, `ENV['HERMES_BUILD_FROM_SOURCE'] == "1"` return false
5. The `else` branch is executed, and it removes the `hermesc_build_dir` and the `copy Hermes framework` script phase.

## Changelog:
[iOS][Changed] - Remove `HERMES_BUILD_FROM_SOURCE` flag

Reviewed By: cortinico, dmytrorykun

Differential Revision: D41373439

fbshipit-source-id: ea4aafd187c0ca3ff5c0d79f8aeaaa46ad50f499
2022-11-21 05:21:39 -08:00
Dmitry Rykun 27e7295ca7 Abort pod install if bad HERMES_ENGINE_TARBALL_PATH is set
Summary:
Changelog:
[iOS][Changed] - Abort pod install if bad HERMES_ENGINE_TARBALL_PATH is set.

Reviewed By: cipolleschi

Differential Revision: D41341471

fbshipit-source-id: 34a3ac154b0a3f795d07dcd10f92361cb9bb4ad6
2022-11-21 03:06:15 -08:00
Lorenzo Sciandra c540ff7bd1 fix(local-e2e-script): add logic to handle maven local for iOS and Android accordingly (#35104)
Summary:
This PR is a follow up of https://github.com/facebook/react-native/pull/35075 and 1546666a6d to ensure that even in the local e2e testing scenario the new maven approach is followed - without this, RNTestProject on Android won't work, like so:
<img width="1905" alt="Screenshot 2022-10-27 at 12 15 38" src="https://user-images.githubusercontent.com/16104054/198334105-30fb2037-4e7c-4814-8c3f-2412ba0bd49f.png">

And iOS will always build everything from source every time.

This PR addresses both by generating the artifacts locally, and passing them to RNTestProject as if they were coming from a url (mimicking as closely as possible the behaviour for the final user)

In doing so, there's been some refactoring to prep the ground for follow up work.
* refactor CI to rely less on scripts directly in the CircleCI config, but invoke .js ones
* we should be able to trigger more the "manual" artifacts generation so that it will only happen once between RNTester and RNTestProject, and we can pass existing artifacts to the other flows.
* once all of this in place, a very good improvement would be to be able to download the maven artifacts kind of like nightlies and stables do. This will only be viable by checking that there's no local changes, after which there needs to be logic to pull down from CircleCI the artifacts based on git commit <-> circleCI job references.
 ---

While at it, I've also fixed the hermes-engine podspec logic for detecting if it's on CI: basically the local e2e script needs to align with the changes done here: 4b51207735

but as you can see there, the condition was actually inconsistent across the various files, so realigned to `CI === 'true'`. We probably didn't catch that so far 'cause the other condition in the hermes podspect (existence of `hermestag_file`) is only true on release branches and this new logic has not been in any release branches yet.

## 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
-->

[Internal] [Fixed] - add logic to local e2e script to handle maven local for iOS and Android accordingly

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

Test Plan:
Run ` yarn test-e2e-local -t RNTestProject -p Android` successfully.

Run ` yarn test-e2e-local -t RNTestProject -p iOS` successfully. On the pod install stage, you will see `[Hermes] Using pre-built Hermes binaries from local path.`

Reviewed By: dmytrorykun

Differential Revision: D40893239

Pulled By: cipolleschi

fbshipit-source-id: a31217ec4f177383c62292d00fabc4cbe4391cfd
2022-11-02 08:23:50 -07:00
Dmitry Rykun 6b8e13f53c Integrate Hermes with the Xcode build process
Summary:
## Context
If React Native is built from *main* of any non-stable commit, then Hermes is built from source. The build is performed by `build-ios-framework.sh` and `build-mac-framework.sh` scripts in `hermes-engine.podspec` `prepare_command` stage. Since those scripts have no access build target information, they build all possible architectures and platforms just in case. That takes ages.
## Solution
The idea is to integrate build script into Xcode *run script* phase, and use build target information to build Hermes for active architecture only.
## Implementation
- Existing behaviour remains unchanged for local tarball and remote prebuild cases.
- `build-hermesc-xcode.sh` builds Hermesc as `hermes-engine.podspec` `prepare_command`. Default build location is `react-native/sdks/hermes-engine/build_host_hermesc`.
- `build-hermes-xcode.sh` builds Hermes in 'Build Hermes' Xcode script phase. It uses `$PLATFORM_NAME`, `$CONFIGURATION`, `$ARCHS`, `$IPHONEOS_DEPLOYMENT_TARGET` and `$MACOSX_DEPLOYMENT_TARGET` environment variables to configure cmake project so it builds only active architecture. The script also gets RN version, *cmake* path and *hermesc* path from the podspec.
- `copy-hermes-xcode.sh` copies Hermes.framework inside the app bundle. This script phase is added to the user app target in a `post_install` hook, after pods are integrated in a user project.
- `OTHER_LDFLAGS -framework "hermes"` added to the user project to enable linking against Hermes.framework.
- If `HERMES_OVERRIDE_HERMESC_PATH` is set, then Hermesc building is skipped, and `HERMES_OVERRIDE_HERMESC_PATH` is used for `build-hermes-xcode.sh`.
- `HERMES_CLI_PATH` is injected into user project config to enable Hermes source maps in `react-native-xcode.sh`.
## Things that didn't work
- *Running build-hermesc-xcode.sh in Xcode run script phase*. This doesn't work because Hermesc is supposed to be built for macos, and if build target is ios, then Xcode configures environment in such a way that Hermesc build fails.
- *Installing Hermesc into CocoaPods download folder*. So it then ends up in `Pods/hermes-engine/build_host_hermesc`, and all the housekeeping is handled by CocoaPods. This doesn't work because cmake uses absolute paths in a configured project. If configured project is moved to a different location, nothing builds.
- *Installing Hermesc directly into Pods/hermes-engine*. This doesn't work because CocoaPods runs prepare_command before Pods folder clean up, and everything gets wiped.
## Known issue
-  If `Pods/hermes-engine` is manually removed, then `sdks/hermes-engine/build_host_hermesc` must also be removed before running `pod install`. Otherwise cmake will complain about stale cache:
```
CMake Error: The source "<CocoaPodsCache>/hermes-engine/<hash2>/CMakeLists.txt" does not match the source
"<CocoaPodsCache>/hermes-engine/<has1>/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.
```
## Benchmark
MacBook M1 2021 32 GB.
```
export REACT_NATIVE_PATH=~/fbsource/xplat/js/react-native-github
cd $REACT_NATIVE_PATH/packages/rn-tester
pod install
rm -rf $REACT_NATIVE_PATH/sdks/hermes-engine/build_host_hermesc
cd $REACT_NATIVE_PATH/packages/rn-tester/Pods/hermes-engine
echo 't1=$(date +%s); $@; t2=$(date +%s); diff=$(echo "$t2 - $t1" | bc); echo Operation took $diff seconds.' > /tmp/benchmark.sh
```
```
# Before
export BUILD_TYPE=Debug
export JSI_PATH=$REACT_NATIVE_PATH/ReactCommon/jsi
export RELEASE_VERSION=1000.0
export IOS_DEPLOYMENT_TARGET=iphonesimulator
export MAC_DEPLOYMENT_TARGET=12.6
cd $REACT_NATIVE_PATH/packages/rn-tester/Pods/hermes-engine
. /tmp/benchmark.sh $REACT_NATIVE_PATH/sdks/hermes-engine/utils/build-ios-framework.sh
# Operation took 252 seconds
. /tmp/benchmark.sh $REACT_NATIVE_PATH/sdks/hermes-engine/utils/build-mac-framework.sh
# Operation took 179 seconds
```
```
# After
. /tmp/benchmark.sh source $REACT_NATIVE_PATH/sdks/hermes-engine/utils/build-hermesc-xcode.sh $REACT_NATIVE_PATH/sdks/hermes-engine/build_host_hermesc
# Operation took 59 seconds.
. /tmp/benchmark.sh xcodebuild -workspace $REACT_NATIVE_PATH/packages/rn-tester/RNTesterPods.xcworkspace -scheme hermes-engine
# Operation took 106 seconds.
```
|Before|||After|||
|--|
|iOS framework (s)|Mac framework (s)|Total (s)|Hermesc (s)|Target-specific framework (s)|Total (s)|
|252|179|431|59|106|**165 (-266) (-61%)**|
The performance win is fixed, and does not depend on the project size and structure.
As an example, this is how these changes affect build time of RNTester.
|Before||||After|||
|--|
||Pod install (s)|Xcode build (s)|Total (s)|Pod install (s)|Xcode build (s)|Total (s)|
|Clean build|1219|132|1352|734 (-485)|249(+117)|**983 (-369)**|
|Incremental build|82|30|112|105 (+23)|**34 (+4)**|139 (+27)|
The most important values here are the total clean build time and the incremental Xcode build time. The first one went down by 369 seconds, the second one went up by 4 seconds. I consider it a reasonable tradeoff.
The extra 4 seconds in  the incremental Xcode build time can potentially be mitigated by setting up output file lists for the new script phases.

allow-large-files

Changelog:
[iOS][Changed] - Hermes is integrated into Xcode build.

Reviewed By: hramos

Differential Revision: D40063686

fbshipit-source-id: e6993d62225789377db769244bc07786cc978a27
2022-11-01 11:55:41 -07:00
Riccardo Cipolleschi 44e8462a03 Consume Hermes from Maven in release (#35116)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35116

This diff let release versions of React Native to consume the Hermes tarball from Maven.

It is already setup to download proper debug/release version

## Changelog
[iOS][Added] - Download Hermes from Maven while for -stables

Reviewed By: cortinico

Differential Revision: D40794707

fbshipit-source-id: b6fa44a272ca044e1c4057a08accecb2009ad312
2022-10-28 07:17:19 -07:00
Héctor Ramos a68c418082 Do not build JSI in React-jsi when Hermes is enabled, resolve JSI ODR violation (#35038)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35038

React-jsi provides JSI to allow React Native to interface with JavaScriptCore.
The hermes-engine Pod provides a second copy of JSI, as Hermes is built and linked statically with JSI.
This second copy of JSI would lead to an [ODR Violation](https://en.cppreference.com/w/cpp/language/definition).

To resolve this, when Hermes is enabled:
- React-hermes and hermes-engine are installed.
- React-jsc is not installed.
- React-jsi continues to be installed.
- React-jsi will not build JSI.
- React-jsi will declare a dependency on hermes-engine.

The result is that the JSI dependency for React Native is satisfied by hermes-engine, and there is no duplicate JSI library in the project.

When Hermes is disabled:
- React-jsi and React-jsc are installed.
- React-hermes and hermes-engine are not installed.
- React-jsi will build JSI.

Changelog:
[iOS][Changed] Resolve JSI ODR violation, make hermes-engine the JSI provider when Hermes is enabled

Reviewed By: cipolleschi

Differential Revision: D40334913

fbshipit-source-id: 409407a193a35cbd21b0e8778537b3627e4c54a2
2022-10-20 14:14:23 -07:00
Riccardo Cipolleschi 1546666a6d Consume Tarball from Maven (#35034)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35034

Currently, when creating an app using the command:
`npx react-native init MyApp --version nightly`
iOS fails to install the dependencies because it does not find a proper tarball to run Hermes.

This diff solve the problem by fetching the Hermes tarball that is created by the CI while building the nightly.

## Changelog:
[iOS][Fixed] - Make the nightly work with the  proper Hermes tarball

Reviewed By: cortinico

Differential Revision: D40512418

fbshipit-source-id: f510f84be9f19807236091687df5e13961103318
2022-10-20 10:43:31 -07:00
Héctor Ramos 2a21d5a28e Exclude Hermes debugger in release builds
Summary:
Fixes Xcode release builds when Hermes is enabled.

The Hermes debugger is loaded by the Hermes executor only if HERMES_ENABLE_DEBUGGER is defined. The hermes-engine Pod would set `HERMES_ENABLE_DEBUGGER=0` in release builds, but of course this would satisfy the HERMES_ENABLE_DEBUGGER ifdef check, leading to build time issues due to missing `hermes::debugger` symbols.

Now, both the `hermes-engine` and `React-hermes` pods only set `HERMES_ENABLE_DEBUGGER=1` in debug builds. No gcc preprocessor definition is added by these pods in release builds.

Changelog:
[iOS] [Changed] - Do not load Hermes inspector in release builds

Reviewed By: cipolleschi

Differential Revision: D40077503

fbshipit-source-id: dd9ce148e8521fc4e43e47e90f29ba8f7c9b7e4a
2022-10-05 09:19:05 -07:00
Lorenzo Sciandra 8486b4c5ee chore: re-add fixes from Kudo's PR 34846 (#34861)
Summary:
I'm not sure why, but my commit 97f5ef05e6 landed despite the PR still having a couple of merge conflicts from after Kudo's PR https://github.com/facebook/react-native/issues/34846 being merged.

What happened is that basically it just "overwrote" those chances, so this PR is just a fix for that.

## 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
-->

[Internal] [Changed] - re-adding Kudo's fix for nightly build

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

Test Plan: N/A

Reviewed By: cipolleschi

Differential Revision: D40059290

Pulled By: cortinico

fbshipit-source-id: 38e495a0dbecd39e836d15aa2a1a30e7354d9813
2022-10-04 09:06:01 -07:00
Lorenzo Sciandra 97f5ef05e6 infra(e2e): rework local E2E script (#34513)
Summary:
This is a long time coming effort to improve the situation around the local e2e script that in the release crew: the current bash-based script is quirky at best, and what you end up generating as a sample project is not really a true sample project. This is where this PR comes in: it migrates the flow from `./scripts/test-manual-e2e.sh` to `yarn test-e2e-local <options>`.

Here's the current shape of the options:

```sh
Options:
  --help          Show help                                            [boolean]
  --version       Show version number                                  [boolean]
  -t, --target      [choices: "RNTester", "RNTestProject"] [default: "RNTester"]
  -p, --platform                    [choices: "iOS", "Android"] [default: "iOS"]
  -h, --hermes                                         [boolean] [default: true]
```

The idea is to change it so that you can just run the script, and it will do that one specific thing "well", without the tester needing to do anything aside from actually testing the app once it's open.

Some of the key changes:
* tries to stick to the patterns of the other established *.js based scripts, in terms of tooling and approach (and even refactor parts that can be shared with other scripts) - like the android artifacts generation
* no need to start the android emulator on the side
* no need to start Metro on the side
* RNTester iOS will open up on the simulator (no Xcode open that then you need to press)

Things that still need work:
* see the #fixme and #todo in comments
* because we rely on exec, the output sent back is not formatted/shaped correctly so it's a bit more noisy/chaotic - but can't handle it right now because the package we use doesn't allow it - see https://github.com/shelljs/shelljs/issues/86

## 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
-->

[Internal] [Changed] - Migrate bash E2E local testing script to new JS based command

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

Test Plan:
To test the script, you can run it passing the options showed above; this is the current situation:
* RNTester iOS Hermes 
* RNTester Android Hermes 
* RNTester iOS JSC 
* RNTester Android JSC 
* RNTestProject Android Hermes 
* RNTestProject iOS Hermes 
* RNTestProject Android JSC 
* RNTestProject iOS JSC 

Reviewed By: cortinico

Differential Revision: D39814692

Pulled By: cortinico

fbshipit-source-id: d4791798aaad764c6a3757269b7636f847ccf2ca
2022-10-04 04:56:44 -07:00
Kudo Chien 93c3effc72 Fix issues for nightly build (#34846)
Summary:
There are two issues from nightly builds.

#### 1. `VERSION_NAME=1000.0.0-main` in  _ReactAndroid/gradle.properties_

the solution is to remove unused _ReactAndroid/gradle.properties_  git revert when publishing package.

#### 2. `pod install` error from downloading hermes, e.g. the url is unavailable. `https://github.com/facebook/react-native/releases/download/v0.0.0-20221002-2027-2319f75c8/hermes-runtime-darwin-debug-v0.0.0-20221002-2027-2319f75c8.tar.gz`

fix _hermes-engine.podspec_ to support nightly build and build hermes from main branch.

## Changelog

[General] [Fixed] - Fix nightly build issues

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

Test Plan:
1. i cannot fully test publish-npm.js workflow and it stops at `npm publish`. i can just check at this moment, the _ReactAndroid/gradle.properties_ is right.
2. create a `npx react-native init` project and `yarn add react-native@nightly`. patch `node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec` and try `pod install`

Reviewed By: cipolleschi

Differential Revision: D40021649

Pulled By: cortinico

fbshipit-source-id: c9e2701e524f4b16eab6f2c72b5cfa34883082c3
2022-10-03 08:16:16 -07:00
Lorenzo Sciandra cc13b0273f fix(hermes): change logic in build scripts for Apple to use the right version (#34710)
Summary:
Within the `hermes-engine.podspec` contained in the RN repo (at `react-native/main/sdks/hermes-engine/`), there's a bit of logic that triggers `./utils/build-ios-framework.sh` and `./utils/build-mac-framework.sh` .

The issue is that we all thought that that  `./utils/build-ios-framework.sh` would invoke the React native version of the scripts (since the podspec file lives right next to the `utils` folder) but, in reality, it doesn't. It just so happens that the Hermes repo has a root level `utils` folder which is (you guessed it) where the Hermes variation of those build scripts live.
So, when running the pod install command in a react-native project (build from source), it will go and download the hermes source code (since the `source[:git]` gets set) but then it will use the **hermes** variation of the `build-*.sh` scripts.

[Read more here](https://github.com/facebook/react-native/pull/34513#issuecomment-1248286691).

This PR is taking kudo's proposed [patch here](https://github.com/reactwg/react-native-new-architecture/discussions/68#discussioncomment-3654191) - props for the fix go to him.

## 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
-->

[iOS] [Fixed] -  Change hermes logic in build scripts for Apple to use the correct files

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

Test Plan: Tested by kudo in his work, and in my PR locally - [see here](https://github.com/facebook/react-native/pull/34513#issuecomment-1249431302).

Reviewed By: cortinico

Differential Revision: D39647057

Pulled By: cipolleschi

fbshipit-source-id: 6520e248801a307ca2f8886a3853dd1ff4af193d
2022-09-26 02:02:32 -07:00
Héctor Ramos c557f25648 Use PRODUCTION envvar directly in hermes-engine Pod to determine build type (#34776)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34776

CocoaPods is not used when Hermes is built in Circle CI, so we cannot rely on the React Native CocoaPods scripts to be loaded.
The get_hermes_build_type function is removed from the RN CocoaPods scripts and in its place, the ENV['PRODUCTION'] envvar is accessed directly.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D39778190

fbshipit-source-id: 12083b7b4533b4ad7bb7a08612883983a0583616
2022-09-23 13:08:15 -07:00
Héctor Ramos 2fc44ac8e1 Use debug/release tarballs in hermes-engine Pod (#34761)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34761

Separate debug and release tarballs are built in CI. Use the appropriate Hermes artifacts tarball when building hermes-engine.

Add hermes.rb tests.

Changelog:
[iOS] [Changed] - Remove debugger from Hermes when building for release

Reviewed By: cipolleschi

Differential Revision: D39698499

fbshipit-source-id: e6b10d34c7f94c2f86fc47d8b97466011aaa75cc
2022-09-23 09:40:24 -07:00
Héctor Ramos 3046ce2421 Clean up hermes-engine Pod
Summary:
Aside from the log output, these changes do not change the behavior of the hermes-engine Pod.

Removed unused git branch checks.
Use react_native_path var to build filepaths.
Edit Hermes build from source log message to be consistent with other logs.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D39699165

fbshipit-source-id: 7e389eb5315fc5a2510b84eddac2f499a3e65157
2022-09-22 13:41:51 -07:00
Héctor Ramos ce4aa93173 Build separate tarballs for Hermes with and without debugger (#34704)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34704

Create separate hermes-engine tarballs for release and debug builds, and only include the debugger in debug builds.
Changes the hermes-engine podspec to use a debug Hermes build by default in order to preserve the inclusion of the debugger.

Upcoming changes should split the hermes-engine Pod to allow Xcode to use release and debug builds as needed.

Changelog:
[iOS][Changed] - Use debug Hermes builds by default

Reviewed By: cipolleschi

Differential Revision: D39326467

fbshipit-source-id: 94c5fe7db80194d22fced6717c5efc7accd36d48
2022-09-22 13:41:51 -07:00
Riccardo Cipolleschi 4b51207735 Simplify logic to choose if we need to build hermes from source or not. (#34232)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34232

This diff simplify the logic to decide whether we want to build hermes from source or not.

The requirement we have is that we don't want our users to build hermes.
So, we don't want to build hermes when there is a precompiled tarball available, while we want to build hermes in CI.

## Changelog

[General][Changed] - Build hermes when in CI and not when there is a tarball

Reviewed By: cortinico

Differential Revision: D37999748

fbshipit-source-id: 7d9cab51c37fb47db216055c057a22081e10df07
2022-07-22 02:13:47 -07:00
Lorenzo Sciandra 46a9edc854 Hermes pod: change logic to use the hermes tag to set the pod source correctly (#34221)
Summary:
This fix is necessarly to ensure that when working on the codebase in the `0.XX-stable` branches (ex. when you are working on a release) the Hermes podfile is correctly set against the right commit for that branch, and not latest commit from main branch of Hermes repo.

I didn't add a check to verify that the file `.hermesversion` exists because I think it's safe to assume that the file and the tag correctly exists when this step (doing a pod install on the `0.XX-stable` branch).

Once this is merged, we need to cherry pick it on both the 0.69 and 0.70 branches

## Changelog

[iOS] [Fixed] - Hermes pod: change logic to use the hermes tag to set the pod source correctly

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

Test Plan:
* git clone the repo
* checkout 0.69-stable branch
* follow https://reactnative.dev/contributing/release-testing
* without this commit, when testing RNTester + iOS + Hermes the app will insta-crash on opening
* with it, the app gets build successfully

Reviewed By: cortinico

Differential Revision: D37957660

Pulled By: cipolleschi

fbshipit-source-id: 4e50099ed712b1ad8e6439822e3f530142982c1b
2022-07-19 07:34:18 -07:00
Héctor Ramos 6154cb7512 Hermes: Use arbitrary path to hermes-runtime-darwin if ENV set
Summary:
Allow an arbitrary path to hermes-runtime-darwin-vX.Y.Z.tgz to be specified. This can be used in CI or in local e2e tests to test with Hermes enabled without having a matching GitHub release.

Usage:

```
HERMES_ENGINE_TARBALL_PATH=~/Downloads/hermes- runtime-darwin-v0.69.0.tar.gz \
  USE_HERMES=1 \
  pod install
```

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D36985477

fbshipit-source-id: 853829c89e6f0ac3f63781c7f290cf3994b8e0cd
2022-06-09 11:18:30 -07:00
Nicola Corti bffad4351c Backports fixes on the 0.69 release branch to main (#33938)
Summary:
This PR includes a set of changes that landed only on the 0.69-stable release branch and need to be backported to main:

- a72d1960ff
- 659b693fcd
- 2a6832a7e3
- 0ca6e41059
- f50936bef2

Most of the fixes are working around the assumption that
`version != 1000.0.0 => Build Hermes From Source`.

That is not true in the release branch as the version is named (e.g. 0.69.0-rc4) and we need to build Hermes there.

## Changelog

[Internal] - Backports fixes on the 0.69 release branch to main

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

Test Plan: Tested that those commits are working fine on the release branch.

Reviewed By: hramos

Differential Revision: D36776291

Pulled By: cortinico

fbshipit-source-id: 66e28232d80054fab4a2a97c8d2de12e3c1cf392
2022-05-31 10:37:12 -07:00
LeoTM f56d701e56 Bump iOS from 11.0 to 12.4 in Hermes eng podspec (#33939)
Summary:
Deprecate iOS/tvOS SDK 11.0 support now that 12.4+ is required

Context: https://github.com/facebook/react-native/pull/33935#issuecomment-1142253352

## Changelog

[iOS] [Fixed] - Deprecate iOS/tvOS SDK 11.0 support now that 12.4+ is required

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

Reviewed By: hramos

Differential Revision: D36780553

Pulled By: cortinico

fbshipit-source-id: 64dd12742d1f9f949a89306dd3353ea24a31983d
2022-05-31 10:29:08 -07:00
fortmarek 91452fc1ed Fix downloading prebuilt hermes from the Github release (#33935)
Summary:
This:
```ruby
source[:http] = `https://github.com/facebook/react-native/releases/download/v#{version}/hermes-runtime-darwin-v#{version}.tar.gz`
```
currently fails with the following error:
```
[!] Failed to load 'hermes-engine' podspec:
[!] Invalid `hermes-engine.podspec` file: No such file or directory - https://github.com/facebook/react-native/releases/download/v0.69.0-rc.4/hermes-runtime-darwin-v0.69.0-rc.4.tar.gz.
```

For some reasons, the string with backticks is treated differently than with double quotes since this works:
```ruby
source[:http] = "https://github.com/facebook/react-native/releases/download/v#{version}/hermes-runtime-darwin-v#{version}.tar.gz"
```

## 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
-->

[Internal] - Fix downloading prebuilt hermes from the Github release

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

Test Plan:
- `npx react-native init RN069RC4 --version 0.69.0-rc.4`
- in the created project, run `pod install` with hermes enabled
- run `git init && git add . && git commit -m "Initial commit" && git remote add origin https://github.com/fortmarek/some-fake-repository` (this is necessary due to an unrelated bug in the RC4)
- observe error
- update `node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec` with the change from this commit
- run `pod install`
- 🎉

Reviewed By: dmitryrykun

Differential Revision: D36775047

Pulled By: cortinico

fbshipit-source-id: 3772adca32fe9898cde33c187d19b7b181af3677
2022-05-31 04:43:00 -07:00
Héctor Ramos 38b70653b2 Hermes: Use pre-built artifacts in hermes-engine
Summary:
Update `hermes-engine.podspec` to use pre-built Hermes artifacts from the corresponding React Native GitHub Release when targeting a specific React Native release.
Otherwise, fallback to building Hermes from source.

Changelog: [Internal]

Reviewed By: cortinico, cipolleschi

Differential Revision: D36609257

fbshipit-source-id: 6179c9e255558c7eaf1417ff46a2e7db120295f0
2022-05-25 03:30:57 -07:00
Héctor Ramos c6fb89a0e8 Hermes: Use pre-built hermes-engine if hermes-artifact-url is set
Summary:
Introduces option to use pre-built Hermes binaries.

Requires a `hermes-engine` pod release to have been published in the following manner:

```
env hermes-artifact-url='https://github.com/facebook/react-native/releases/download/vX.Y.Z/hermes-runtime-darwin-vX.Y.Z.tar.gz' pod trunk push hermes-engine.podspec
```
...where "vX.Y.Z" corresponds to a published React Native release on GitHub where the `hermes-runtime-darwin-vX.Y.Z.tar.gz` binary was generated and/or uploaded as part of the release process.

Changelog: [Internal]

Reviewed By: cortinico, cipolleschi

Differential Revision: D36532561

fbshipit-source-id: 73bc107158387ff2db359e1b6a973db6ee85995c
2022-05-23 12:14:29 -07:00
Héctor Ramos 644fe430fd iOS: Use pre-built hermesc if available (#33827)
Summary:
Use pre-built hermesc if available by generating a ImportHermesc.cmake file that points to the hermesc binary. Recent `react-native` releases should have hermesc available in sdks/hermesc.

Hermes build scripts have been updated to support a `HERMES_OVERRIDE_HERMESC_PATH` envvar which can point to this generated ImportHermesc.cmake file.

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

Changelog:
[iOS] [Changed] - Use pre-built HermesC if available in current React Native release

Reviewed By: cortinico

Differential Revision: D36024615

fbshipit-source-id: 476569f73309f9bd142f28cb02d1f7d57b6cbc6a
2022-05-13 14:43:14 -07:00
Héctor Ramos e49e7c7ac5 Remove Pod::UI undefined symbol warning during Hermes build
Summary:
The `utils/build-apple-framework.sh` script uses the ruby runtime to load `hermes-engine.podspec`, and in the process it will load the Core CocoaPods gem to parse the podspec file.

Since the podspec file uses Pod::UI to print logs, and the CoreUI gem is not loaded when `build-apple-framework.sh` accesses `hermes-engine.podspec`, we would get a warning due to Pod::UI not being defined.

This change will only use Pod::UI when it is defined, therefore limiting it to only executing when `hermes-engine.podspec` is loaded as part of the normal `pod install` build process.

Changelog: [Internal]

Reviewed By: cortinico, neildhar

Differential Revision: D36297856

fbshipit-source-id: ac1ab021f74f9dcaa7be2a2358482c73b827b756
2022-05-11 15:49:48 -07:00
Héctor Ramos ae28880fbc Hermes: Copy build scripts to RN
Summary:
Copy Hermes build scripts to React Native repository for greater control over the build pipeline when used in RN.

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D36295406

fbshipit-source-id: 54bf4173b6c75db35de828378e6f5782a248ed2e
2022-05-11 15:49:48 -07:00