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

91 Коммитов

Автор SHA1 Сообщение Дата
Zihan Chen (MSFT) 9bb71650c9 Add `@react-native/codegen-typescript-test` to verify .d.ts files in `@react-native/codegen` (1) (#36562)
Summary:
- Add a typescript project to test `CodegenSchema.d.ts`. More tests for other .d.ts files will be added in future pull requests.
- The build script scans all snapshots from `react-native/codegen`'s typescript frontend and generates .ts files for each snapshot, but they are .gitignore-ed.
- `npm run build` will build these .ts files against `CodegenSchema.d.ts` after generating them.
- A failed jest case is included to ensure CI catch it, it will be removed before merged.

bypass-github-export-checks

## Changelog:

[General] [Added] - Add react-native/codegen-typescript-test to verify .d.ts files in react-native/codegen (1)

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

Test Plan:
`npm run build` in `packages/react-native-codegen-typescript-test` and see all test files appear in `__generated__`.

## Screenshot

![Untitled](https://user-images.githubusercontent.com/53799235/226757755-cab4cb29-7d22-46a1-9ecb-d6732122ed38.png)

Reviewed By: rshest

Differential Revision: D44292277

Pulled By: cipolleschi

fbshipit-source-id: 8d79fe913f9563d64c92aae7c4f4e97a24ae9a21
2023-04-05 07:38:25 -07:00
Ruslan Lesiutin 714b502b0c | RN Monorepo | Migrate to package (#36434)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36434

Changelog: [Internal]

This is a squashed stack of 18 commits, starting from D43202126

allow-large-files

Reviewed By: cortinico

Differential Revision: D43977381

fbshipit-source-id: 0da552ddb85f2f61a0be0ef071915b35f3f8555c
2023-03-17 05:03:25 -07:00
Riccardo Cipolleschi e57b6d11fa Remove .ruby-version and update Gemfile to support multiple versions of Ruby (#36281)
Summary:
This Change remove the need to have a specific version of Ruby installed. We are now supporting a wider range of Ruby versions, starting from Ruby 2.6.10 (the ruby installed on MacOS by default).
We are still using a Gemfile to control the version of cocoapods that needs to be installed.

## Changelog

[IOS] [CHANGED] - Remove `.ruby-version` and update Gemfile to support a wider range of Ruby versions

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

Test Plan:
- Tested locally on RNTester and an app from template, switch across different versions of Ruby
- CircleCI is green on the commit

Reviewed By: cortinico

Differential Revision: D43567660

Pulled By: cipolleschi

fbshipit-source-id: e7edfe5806a898a83ba39cb58b1318ebde56a57c
2023-02-26 09:32:28 -08:00
Riccardo Cipolleschi e7becb06c1 Update RCTFabric to generate headers in the `React` folder when using Frameworks
Summary:
By leveraging the `PUBLIC_HEADERS_FOLDER_PATH` build settings of Xcode, we can instruct cocoapods to generate the frameworks Headers in a specific folder, for example the `React` folder.
This allows us to maintain the `#include`/`#import` structure, even if the framework has a different name.
However, we need to update the search paths to take into account this extra folder.

## Changelog:
[iOS][Changed] - Generate RCTFabric framework's headers in the React folder

Reviewed By: sammy-SC, dmytrorykun

Differential Revision: D43425677

fbshipit-source-id: 94a4f3a3c7de86341b3ce3457704e6b8fb9a588e
2023-02-20 11:50:10 -08:00
Pranav Yadav 363a6d253d chore: untrack stack dumps; `*.stackdump` (#35530)
Summary:
- Untracking StackDump files through `.gitignore`
- Most of the programs like shell (bash) **_crashes_** it generates **_StackDump_**; `*.stackdump` file(s)
- Such files are only for low level debugging purpose and _shouldn't be tracked_
- PS: When using integrated terminals on IDEs it's common to have these files especially on Win m/c :)

## Changelog

[Internal] [Changed] - Untracking Stack Dumps; `*.stackdump` files

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

Test Plan: - [NO-CODE] Diff

Reviewed By: rshest

Differential Revision: D41653070

Pulled By: cortinico

fbshipit-source-id: 0727feb66daa286d077743a451643970555e9c20
2022-12-02 04:04:51 -08:00
Nicola Corti f0972cb101 RNGP - Various improvements needed for 3rd party libs (#35496)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35496

This commit includes a series of fixes needed for better integration with libraries for 0.71:
- I've added an `android/README.md` file as some libraries were failing the build if the folder was missing
- RNGP now applies dep substitution on app and all the libraries project
- RNGP now adds repositories on app and all the libraries project
- I've removed the maven local repo to the `/android` folder as now is empty
- I've fixed the path for the JSC repo for Windows users
- I've added a bit of backward compat by re-adding an empty `project.react.ext` block that libraries might read from.
- I've removed `codegenDir` from the `GenerateCodegenArtifactsTask` which was unused.

Changelog:
[Internal] [Changed] - RNGP - Various improvements needed for 3rd party libs

Reviewed By: cipolleschi

Differential Revision: D41549489

fbshipit-source-id: 2252da0180ac24fd3fe5a55300527da6781f0f8c
2022-11-29 02:56:35 -08:00
shivenmian b7a85b59b5 chore: renamed react-native-codegen to @react-native/codegen (#34804)
Summary:
Renamed react-native-codegen package to react-native/codegen and updated references, without changing the folder name; part of RFC480 (https://github.com/facebook/react-native/issues/34692). Follow-up from https://github.com/facebook/react-native/pull/34578

## Changelog

[General] [Changed] - Renamed react-native-codegen package to react-native/codegen and updated references

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

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

Reviewed By: cortinico

Differential Revision: D39883584

Pulled By: hoxyq

fbshipit-source-id: 0ef384b75c6edd248b31e37b8f05f64b4d39ca6f
2022-11-28 08:28:51 -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
Pranav Yadav 0ba1127c15 untrack test reports generated by test libraries (reporters) (#35187)
Summary:
- Untrack Test Reports generated by test libraries (reporters E.g. `jest-junit`)
- E.g. `/reports/junit/js-test-results.xml` report is generated; when we exec `yarn test-ci`, which is **_shouldn't_ be tracked**

### NOTE: Used `[skip ci]` to avoid wastage of compute resources �🌏
- Feel free to init tests manually if you find it necessary

## 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] [CHANGED] - Untrack Test Reports generated by test libraries (reporters E.g. `jest-junit`)

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

Test Plan:
`yarn test-ci`
![image](https://user-images.githubusercontent.com/55224033/199709131-240d844c-a98a-419b-a370-cafe8e927de4.png)

Reviewed By: cipolleschi

Differential Revision: D40993282

Pulled By: sshic

fbshipit-source-id: 3fe150d3e8bd45cec56b50f2dc071002412e475e
2022-11-18 05:58:04 -08: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
Moti Zilberman 19715cf4fb Add .metro-health-check to .gitignore
Summary:
Changelog:
[General][Changed] - Add Metro health check files to the template's `.gitignore`

We're adding an opt-in watcher health check to Metro, which can occasionally leave files named `.metro-health-check*` in the project. To ensure this doesn't clutter people's repos accidentally if enabled, we preemptively add this as a pattern to `.gitignore` in the new project template. We also add it to the React Native repo's `.gitignore` file just in case.

Reviewed By: arushikesarwani94

Differential Revision: D40352040

fbshipit-source-id: 261803b684d79292c014205084e61d5e4f7aeb3d
2022-10-14 06:51:52 -07:00
Nicola Corti 0e2f090631 Setup publishing for Snapshot and Stable on Maven (#34967)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34967

This diff is a preparatory work for publishing artifacts on Maven Central.
What it does is:
1. It sets up all the 3 modules (react-native, hermes-engine, external-artifacts) for publishg
2. Adds coordinates to publish on the Snapshot repository
3. Adds support for appendign -SNAPSHOT version if invoked with `-PisNightly=true`
4. Configures GPG signing of artifacts.

I haven't touched the CircleCI and JS code yet. I'll do it in another diff.

Changelog:
[General] [Changed] - Setup publishing for Snapshot and Stable on Maven

Reviewed By: mdvacca, cipolleschi

Differential Revision: D40146212

fbshipit-source-id: 9321e16f6c18b35bc3ae785749d613085c56e7bc
2022-10-13 03:08:22 -07:00
Héctor Ramos 1b30df10c6 Remove old __offline_mirrors__ from gitignore
Summary:
Remove old `__offline_mirrors__` from `.gitignore`.
This directory is not synced to GitHub.

Changelog: [Internal]

Reviewed By: fbmal7

Differential Revision: D40245262

fbshipit-source-id: ccc93ea4cb5729432f590f78e463b14ba6e78b22
2022-10-12 15:34:55 -07:00
Héctor Ramos 041ccf31df Add offline mirrors to .gitignore
Summary:
Add internal CocoaPods offline mirrors paths to .gitignore.

Changelog: [Internal]

Reviewed By: fbmal7

Differential Revision: D40241900

fbshipit-source-id: 712059f6d8f16bbd1964e13d49b257adad8aa8a2
2022-10-12 15:34:55 -07:00
Luna Wei dc56eb99f1 Fix missing renames from bots to react-native-bots (#34713)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34713

Changelog: [Internal] - Fix up missing bots usage after we moved everything to packages/react-native-bots in 767f8e0249

Reviewed By: NickGerleman

Differential Revision: D39583230

fbshipit-source-id: 6cc6b7923e67139dc3c81dfe0c39005dde905248
2022-09-16 12:41:06 -07:00
Riccardo Cipolleschi 00458c9410 Make react-native-codegen tests run in OSS (#34594)
Summary:
During the CoreContributor summit, we discovered that the `react-native-codegen` tests cannot be executed in the OSS due to this [issue with Jest](https://github.com/facebook/jest/issues/2567).

This PR moves the required variables inside the proper closure so that we can run tests in the OSS.

## Changelog

[General] [Fixed] - Enable the `react-native-codegen` tests in the OSS.

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

Test Plan:
1. Run `yarn install` in the `react-native-codegen` folder.
2. Run `yarn jest`, see the test fail.
3. Apply the changes in this diff.
4. Run `yarn jest`, see the test pass.

Reviewed By: cortinico

Differential Revision: D39259164

Pulled By: cipolleschi

fbshipit-source-id: 7c4c0a7baa3c9b5e90a7ef75a37a0ec9d1b89db0
2022-09-06 10:24:22 -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
Nicola Corti 4ea593b756 Fix release infrastructure failures discovered during .69 release
Summary:
During the release of .69, we (fortmarek and me) discovered a couple of bits that needed
some intervention.
- `sdks/.hermesversion` was gitignored, so we could not commit that.
- `scripts/bump-hermes-version.js` was not executable, so we had to chmod +x to
  make it runnable.

Here I'm fixing it.

Changelog:
[Internal] [Changed] - Fix release infrastructure failures discovered during .69 release

Reviewed By: cipolleschi

Differential Revision: D36003808

fbshipit-source-id: c4d82ed5e2c63988699035ac84b0e87ed8894540
2022-04-28 07:48:40 -07:00
Riccardo Cipolleschi 0480f56c5b Introduce .xcode.env configuration file to source `node` (#33546)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33546

This Diff does 2 things:
1. Removes all the remnant of the `find-node.sh` script. This allows React Native to stay agnostic from any other node manager
2. Introduces a way for the developers to specify which `node` executable they want to use, through a simple `.env` file.

## Changelog
[iOS][Changed] - This PR removes the `find-node.sh` scripts and replaces it with an `.xcode.env` file that is sourced by the script phases that needs it. The `.xcode.env` file is versioned: to customize a local environment, an unversioned `.xcode.local.env` can be used.

Reviewed By: cortinico

Differential Revision: D35317070

fbshipit-source-id: 4b400ba56aa2d574db563fa67b2008e1ddde1c59
2022-04-11 02:50:57 -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
Héctor Ramos 889578a142 Download Hermes tarball during pod install
Summary:
Downloads a tarball of the Hermes source code when `pod install` is run.

If the current release is pinned to a Hermes tag, it will use that specific tag, otherwise the latest Hermes commit will be used.

# Changelog:
[Internal]

Reviewed By: cortinico

Differential Revision: D34629595

fbshipit-source-id: 5f36af4a43bc2d137dfd702082558ab9d0191140
2022-03-10 11:24:48 -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
Héctor Ramos 5928105d9d Bundle Hermes source code in react-native npm package
Summary:
If `--include-hermes` flag is set, the Hermes source code will be downloaded and included in the `react-native` npm package as part of the release.

Hermes will be available at `node_modules/react-native/third-party-podspecs/hermes`.

# Changelog

[Internal] Update build scripts to provide option to bundle Hermes source code

Reviewed By: cortinico

Differential Revision: D34255926

fbshipit-source-id: 76c1e9811a05a4a827ceba13e572d0ea756ac724
2022-02-22 12:23:49 -08:00
Sota Ogo eb4ace865b Add /template/ios/build/ to gitignore
Summary: Changelog: [internal] Add /template/ios/build to gitignore. The folder is auto generated for ios.

Reviewed By: cortinico

Differential Revision: D33051582

fbshipit-source-id: ccf84fa0594d1fbbf224d92004dd05987c9deae7
2021-12-13 10:49:00 -08: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
Gustavo Sverzut Barbieri 57aa70c06c Introduce Gemfile, ruby-version (#32303)
Summary:
Implement par of the discussion https://github.com/react-native-community/discussions-and-proposals/discussions/411, except the `.nvmrc` part, this includes:
 - Setting `.ruby-version` in the main project and also `template/`
 - Fixing the CocoaPods version with a project-level `Gemfile` and also `template/Gemfile`
 - Using all `pod` executions from `bundle exec pod`, using the determined version
 - Script to manage and update the ruby version

## Changelog

[iOS] [Added] - Gemfile with CocoaPods 1.11 and ruby-version (2.7.4)

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

Test Plan: Build for iOS and run all CircleCI tests to see if nothing changed

Reviewed By: RSNara

Differential Revision: D31344686

Pulled By: fkgozali

fbshipit-source-id: 25c63131ca9b16d3cf6341019548e0d63bdcaefe
2021-10-01 21:22:26 -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
Héctor Ramos ef6ad1f2d6 Codegen: Remove generate-specs.sh
Summary:
First part of the codegen script cleanup effort. Everything that was done in generate-specs.sh is now part of the CocoaPods recipe (e.g. codegen method in `react_native_pods.rb`).

Now that `generate-specs.sh` has been removed, the codegen may still be invoked manually for test purposes like so:

```
cd react-native

# Generate Schema - do this whenever your JS specs change
node packages/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js <output_file_schema_json> <javascript_sources_dir>

# Generate native interfaces for iOS (use schema.json generated by previous step)
node scripts/generate-specs-cli.js ios <output_file_schema_json> <output_dir> <library_name>
```

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D30648067

fbshipit-source-id: 29688e0aac5496886657db82becb05bc8da076c9
2021-09-10 17:28:55 -07:00
Héctor Ramos 6651d8c346 Enable codegen in RNTester's NativeModuleExample
Summary:
Create a ScreenshotManager.podspec (codegen recipe included) and add ScreenshotManager Pod to the Podfile.

Changelog:
[Internal]

Reviewed By: fkgozali

Differential Revision: D30623054

fbshipit-source-id: be20880a53ba8a08f8b42b8d81c868c8a21960e1
2021-08-31 16:26:52 -07:00
Nicola Corti 13107fa3d0 Import template/android/ as part of the top level build (#32124)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32124

This Diff adds `template/android/` as part of the top level build as an included
build. This means that the Android template will be loaded inside Android studio and it
will be easier to invoke tasks directly there.

I'm also bumping Gradle to 7.0.2 for the template.

Please note that the template relies on the `template/node_modules` folder to
work correctly, as the Gradle build is loading a file from there.
Therefore I've added a check to verify that we import the build only if `node_modules`
is available.

Changelog:
[Internal] [Changed] - Load template/android/ inside the build.

Reviewed By: ShikaSD

Differential Revision: D30672845

fbshipit-source-id: 7253296b54e1fde7448e0e170d59b244ed9ec8fb
2021-08-31 13:27:27 -07:00
Nicola Corti 1f8c5607b2 Flatten the `react-native-codegen` included build. (#32007)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32007

This Diff simplifies the codegen Gradle build.
Previously the build used to have a 2-level nesting of included build.

Turns out that the `react-native-codegen/android/build.gradle` build
is just providing a task and including an inner build that contains the codegen
Gradle plugin. I've moved such plugin to the outer build.

This will also make sure that the Gradle plugin files are properly index by the
IDE when opening the build (as nested included build are not yet supported).

Changelog:
Internal - Flatten the `react-native-codegen` Gradle included build

Reviewed By: fkgozali, ShikaSD

Differential Revision: D30227784

fbshipit-source-id: af304afeeba1926f8b7b5b47cf69889d3f808f5f
2021-08-12 05:14:58 -07:00
Andrei Shikov dbbc1c1624 Add react build app plugin and extension
Summary:
Changelog:
[Android][Added] - Basic definition for react gradle plugin

Adds plugin and build configuration + copies config from react.gradle to extension.
Copies internals of react.gradle to the plugin. Will be refactored in the next commits.

Reviewed By: mdvacca

Differential Revision: D25693008

fbshipit-source-id: b0feaa02cee8a1ee94d032426d19c501ff3b2534
2021-02-22 08:16:51 -08:00
Janic Duplessis 12fccdeea3 Make codegen more reliable on iOS (#30792)
Summary:
This addesses a few issues I noticed while migrating my app to the new build-time codegen on iOS.

1. I noticed random failures because of codegen on iOS. This is mostly due to the fact the codegen output files are not specified in the xcode script. The only reason it works relatively fine currently is because the codegen output is inside the input files directory. This has the side effect of causing files to be regenerated every build, then causes all core modules to be recompiled which adds up a significant amount of time to rebuilds. To fix this I added the generated files to the script phase output and moved the FBReactNativeSpec dir outside of the codegen source (Libraries). I moved it to the React directory as this seemed to make sense and is where a lot of iOS files are as well as the core modules. Note this might require internal changes. This removes the circular dependency between our build phase input and output so consecutive builds can be cached properly.

2. Add `set -o pipefail` to the xcode script, this helped propagate errors properly to xcode because of the `| tee` pipe so it fails at the script phase and not later with a header not found error. Also add `2>&1` to pipe stderr to stdout so errors are also captured in the log file.

3. Add the `-l` flag to the bash invocation to help finding the yarn binary. With my setup yarn is added to the system PATH in my user .profile. Adding this file will cause bash to source the user environment which xcode scripts does not by default. I think this will help with most setups.

4. If yarn is not found the `command -v yarn` would make the script exit without any output because of the -e flag. I made a change to ignore the return code and check later if YARN_BINARY is set and have an explicit error message if not.

## Changelog

[iOS] [Fixed] - Make codegen more reliable on iOS

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

Test Plan:
Tested various project states to make sure the build always succeeds in RN tester:

- Simulate fresh clone, remove all ignored files, install pods, build
- Build, delete FBReactNativeSpec generated files, build again
- Build, build again, make sure FBReactNativeSpec is cached and not rebuilt
- Make the script fail and check that xcode shows the script error logs properly

![image](https://user-images.githubusercontent.com/2677334/105891571-c8badd00-5fde-11eb-839c-259d8e448523.png)

Note: Did not test fabric

Reviewed By: fkgozali

Differential Revision: D26104213

Pulled By: hramos

fbshipit-source-id: e18d9a0b9ada7c0c2e608d29ffe88087f04605b4
2021-02-01 14:39:25 -08:00
empyrical f312e5ba84 Update iOS Fabric-related files to compile on OSS (#29810)
Summary:
Original PR contents:

This pull request updates the Podspecs and associated build scripts, and some source files so they build on OSS. RNTester now compiles with `fabric_enabled` again.

The following changes have been made:

 * Various spots that were pointing to the old `ReactCommon/fabric` location have now been updated to `ReactCommon/react/renderer`
 * Files that were attempting to use internal FB header `FBRCTFabricComponentsPlugins.h` were changed to use `RCTFabricComponentsPlugins.h`
 * `RCTFabricComponentsPlugins` in OSS was updated to include the `Image` fabric component (thanks tsapeta)
 * Replaced old `generate-rncore.sh` build script with new `generate-rncore.js` script which does not require `flow-node` and uses the `react-native-codegen` API directly, so there is no longer any need for an interim `schema-rncore.json` file.
 * Updated Yoga podspec which wasn't fully synced with changes from the main Yoga repo
 * Updated Fabric podspec with additional needed subspecs

Additions to PR by hramos:
* Replaced use of generate-rncore scripts with the original generate-native-modules-specs.sh script, which is now generate-specs.sh and supports both codegen for Native Modules and Components now (TurboModules/Fabric).
* Codegen now runs at build time as part of the Xcode build pipeline instead of as part of `pod install`. The build script is injected by the FBReactNativeSpec pod, as the pod is part of both Fabric and non-Fabric builds.

## Changelog

[General] [Fixed] - RNTester compiles with `fabric_enabled` again

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

Test Plan:
RNTester now compiles and runs in the simulator again when `fabric_enabled` is set to `true`.

```
cd xplat/js/react-native-github/packages/rn-tester
USE_FABRIC=1 pod install
open RNTesterPods.xcworkspace
# Build and run
```

Reviewed By: fkgozali

Differential Revision: D24058507

Pulled By: hramos

fbshipit-source-id: 8b2ea3694e6cb9aa23f83f087e2995fd4320e2bb
2020-12-22 08:36:22 -08:00
Héctor Ramos c901c1fbce Integrate Native Module codegen into Xcode build pipeline (#30449)
Summary:
Move the codegen invocation out of Podfiles and into the FBReactNativeSpec Pod itself. With this change, developers do not need to modify their existing project's Podfiles, and yet the codegen will be integrated into their projects automatically by way of the FBReactNativeSpec Pod.

This is accomplished in part by injecting a script build phase into the Pods Xcode project that is generated by CocoaPods. The build phase will save the output of the codegen script to a log in the derived files directory. The codegen will be executed if the codegen log file is not present, or if the contents of the Libraries directory has changed.

The codegen will thus be invoked in these situations:

**RNTester:**
* When `packages/rn-tester/RNTesterPods.xcworkspace` is built, if the codegen output logfile is not present or if the input files have changed.

**OSS React Native apps:**
* When `ios/AwesomeProject.xcworkspace` is built, if the codegen output file is not present or if the input files have changed. Normally, this should not happen, as we do not expect folks to update the contents of `node_modules/react-native/Libraries`.

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

Changelog: [Internal] - Moved codegen invocation out of Podfile and into FBReactNativeSpec Pod

Reviewed By: fkgozali

Differential Revision: D25138896

fbshipit-source-id: 4779f822459cea2c30fd544eee19a49e8d80153d
2020-12-02 14:27:50 -08:00
Héctor Ramos 9218e0c2e6 iOS: Generate FBReactNativeSpec ObjC++ files at build time
Summary:
Removes the generated FBReactNativeSpec files from source control.

## Generating FBReactNativeSpec files

The files will be generated automatically by CocoaPods when the `RNTesterPods` Xcode workspace is generated:

```
cd packages/rn-tester
pod install
```

The spec files can be re-generated by invoking the script directly:
```
./scripts/generate-native-modules-specs.sh
```

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D24261167

fbshipit-source-id: acb7ac856e5e519932e4f587f79e24f49cd84a91
2020-10-21 20:47:09 -07:00
Kevin Gozali c3ab2a2541 RNTester Android: Add stub C++ for TurboModule provider (#30014)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/30014

This is the base setup to compile C++ as part of RNTester app. There is no dependencies on ReactAndroidNdk lib yet, just a bunch of ndkBuild setup in Gradle. Note: this is using Gradle's `nkdBuild` support instead of calling `ndk-build` manually like in ReactAndroid/build.gradle.

Reference: https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ExternalNativeNdkBuildOptions.html

Note that `ANDROID_NDK` env var is honored to pick the right NDK version.

For now, this is gated behind `USE_CODEGEN` env variable.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23887058

fbshipit-source-id: 7a962649461d15af46999a15b900464543e5b05c
2020-09-23 16:52:48 -07:00
Kevin Gozali 0351c57e6a Codegen: Generate module C++ lookup function for JNI next to the spec classes
Summary:
The TurboModule system requires a lookup function to map the spec name (name used in JS) to the C++ TurboModule subclass. This is a pure C function. For now, generate one lookup function per set of modules found in the codegen schema.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23618281

fbshipit-source-id: 889e07bdd4f2e5e93c4d14e60225f5b0c6683917
2020-09-11 01:14:17 -07:00
Martin Sherburn 549563e8ab Allow Hermes to be built as a DLL on Windows
Summary:
On windows it is required to explicitly specify what symbols need to be exported from a DLL to make them accessible (using `__declspec(dllexport)`). I have added and expanded on existing macros to do this and added exports that were previously missing.

Changelog:
[Internal][Changed] - Allow Hermes to be compiled to a single DLL on windows

Reviewed By: mhorowitz

Differential Revision: D23084343

fbshipit-source-id: 832cb17b9e637e4c04dad479aae6c1fc190f968e
2020-08-24 06:07:19 -07:00
stealthanthrax 63992c0b96 Migrating RNTester to Packages Directory (#29567)
Summary:
## 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
-->
This PR aims to migrate the RNTester App to `packages` directory. But is currently, open to inspect the CI issues and resolve the merge conflicts.

Currently done
 - Working on iOS
 - Working on Android
 - Detox Tests working on iOS

Need to work on
 - Errors generated by the CI builds

[General] [Changed] - Migrated the RNTester App to the packages directory.

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

Test Plan: It runs on both ios and android for now and the detox iOS builds are working.

Reviewed By: cpojer

Differential Revision: D23034761

Pulled By: rickhanlonii

fbshipit-source-id: e04bb06e1c7ef15d340206090d1575a871b9e6f5
2020-08-19 17:57:08 -07:00
empyrical c67e1fe42f Codegen: Add prepublish script to build Flow files (#28827)
Summary:
*This is a follow-up to https://github.com/facebook/react-native/issues/28645, redone using a build script based off of Metro's build script instead of using `flow-remove-types` and `flow-copy-source`.*

This pull request adds a build step to `react-native-codegen` that builds the Flow-annotated JS files so that users of the NPM module `react-native-codegen` do not need to use require hooks to be able to import it.

A new build script, `scripts/build.js` is added that builds every JS file in `src/` into a `lib/` folder, and also copies over the original Flow annotated files to `lib/` with a `.js.flow` extension, so users of `react-native-codegen` can still typecheck against it using Flow. The shell scripts in `src` are also copied over. It is based off of the [build script from Metro](00867816eb/scripts/build.js)

## Changelog

[General] [Added] - Codegen: Add prepublish script to build Flow files
Pull Request resolved: https://github.com/facebook/react-native/pull/28827

Test Plan:
I am able to make use of the Codegen scripts without needing to use the `flow-node` CLI or the `flow-remove-types/register`
require hook.

Reviewed By: cpojer

Differential Revision: D21412173

Pulled By: hramos

fbshipit-source-id: 26ae67cdd04652ca4700a069a234a25558773cb1
2020-05-08 15:41:35 -07:00
Enes 69ce9c21d4 Update .gitignore (#28789)
Summary:
When you profile your heap and memory allocations with Memory Profiler, files with *.hprof extension are created in /android folder that has big sizes (up to 600 MB for each). These files may be needed to add to gitignore.

## 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] [Added] - Add *.hprof files to gitignore
Pull Request resolved: https://github.com/facebook/react-native/pull/28789

Differential Revision: D21432927

Pulled By: hramos

fbshipit-source-id: a20f12645de5ca0874c9130094e2f97fe16b2203
2020-05-08 15:36:15 -07:00
Héctor Ramos 91a49d8827 Add script to generate native modules specs with react-native-codegen
Summary:
Adds a script that uses `react-native-codegen` to generate FBReactNativeSpec.
The generated output should not be considered ready for production use at this time.
The goal of adding this script at this time is to demonstrate the current status of native modules specs code generation in open source.

For example, the generated output may be used in RNTester, with some modifications due to some naming differences in react-native-codegen's output when compared to the FBReactNativeSpec files generated by the old codegen.

Usage:

```
./scripts/generate-native-modules-specs.sh ./codegen-out
```

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D21471004

fbshipit-source-id: 5ff3c57807d9ba2c91dc7fe32d227d218732b059
2020-05-08 12:23:35 -07:00
Jason Safaiyeh d59f7d07bf Update .gitignore to ignore ReactAndroid generated Gradle files (#28014)
Summary:
When building RNAndroid, Gradle files are generated. Added them to `.gitignore`. If it is ideal to have them in the repo I can commit them.

## Changelog

[Internal] [Fixed] - Added ReactAndroid generated Gradle files to .gitignore
Pull Request resolved: https://github.com/facebook/react-native/pull/28014

Test Plan: Build ReactAndroid, generated Gradle files no longer show up in git changes.

Differential Revision: D19873998

Pulled By: mdvacca

fbshipit-source-id: 29af7612df611bba1e83f4afac8692e1aa6df515
2020-02-12 23:21:32 -08:00
Jason Safaiyeh fa8b4f5aa0 Add Android dot files to .gitignore (#27589)
Summary:
Added dot files to `.gitignore` these got generated opening the project in Android Studio or running Gradle scripts.

<img width="570" alt="Screen Shot 2019-12-21 at 4 05 36 PM" src="https://user-images.githubusercontent.com/8675043/71315203-48ee3680-240c-11ea-9600-218e11b194b5.png">

## Changelog

[Internal] [Added] - Added Android Studio dot files to gitignore
Pull Request resolved: https://github.com/facebook/react-native/pull/27589

Differential Revision: D19235583

Pulled By: cpojer

fbshipit-source-id: eb265d516e125aeb64807efe42832b80d7977b18
2019-12-26 21:33:34 -08:00
Dulmandakh 19bf2027d1 gitignore ReactAndroid prebuilt libs (#27487)
Summary:
This PR changes gitignore to ignore prebuilt libs in ReactAndroid as a whole, because we added 64 bit platforms and their files are showing up as changes.

## Changelog

[GENERAL] [Changed] - gitignore ReactAndroid prebuilt libs
Pull Request resolved: https://github.com/facebook/react-native/pull/27487

Test Plan: After ReactAndroid build, you won't see prebuilt lib changes in git.

Differential Revision: D18992774

Pulled By: hramos

fbshipit-source-id: 33d3e01f59945dbc18ae4d9e3e3ac4b0e5b5e764
2019-12-12 18:18:19 -08:00
Nick Gerleman 1796bc5927 Add Visual Studio and VSCode files to .gitignore (#27132)
Summary:
These files are currently seen by Git if opening the project in Visual Studio or VSCode.

## Changelog
[Internal] [Fixed] - Add Visual Studio files to .gitignore
Pull Request resolved: https://github.com/facebook/react-native/pull/27132

Differential Revision: D18346486

Pulled By: cpojer

fbshipit-source-id: e1ff752790d46455e85b13f2508cd0286d6bdde2
2019-11-06 03:26:59 -08:00
Kevin Gozali 4856494d32 iOS Pods: use tar.gz offline mirrors instead of pods replica
Summary: Tweaking things to allow proper offline caching for FB internal builds.

Reviewed By: PeteTheHeat

Differential Revision: D17491386

fbshipit-source-id: 77295588c121190628d38ef95d5416cba06c121e
2019-09-20 16:20:16 -07:00
Kevin Gozali 058404f11c iOS Pods: introduced fb-only __generated__ dir
Summary:
To help cache Pods artifacts for Sandcastle test run, create a `__generated__` dir under RNTester/Pods, which will contain the normally-top-level files produced by `pod install`. The files will then be symlinked by the script.

allow-large-files

Reviewed By: axe-fb

Differential Revision: D17470686

fbshipit-source-id: 50e4c57e913e2884eed27db94c50181fe4632133
2019-09-19 00:03:44 -07:00
Kevin Gozali de76e7c887 RNTester Pods top-level subdirs
Summary: These subdirs are generated by CocoaPods, they shouldn't be checked in normally. Note that this must be explicitly listed for FB-CI compatibility.

Reviewed By: axe-fb

Differential Revision: D17469656

fbshipit-source-id: 05b023d3f0fa72ddd7cb301cdaf03eabd4f9a4d8
2019-09-18 20:30:40 -07:00