The Wayback Machine - https://web.archive.org/web/20201221014848/https://github.com/microsoft/react-native-windows/pull/3871
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add React Native Source Patching Infrastructure #3871

Merged
merged 6 commits into from Jan 14, 2020

Conversation

@NickGerleman
Copy link
Contributor

@NickGerleman NickGerleman commented Jan 14, 2020

As part of the efforts to move off of microsoft/react-native, we're aiming to
consume facebook/react-native directly and then apply a set of Windows specific
patches. This change gives us a mechanism to do this patching.

We opt to fully modify React Native sources instead of manipulating
files/includes with build logic. This helps with header resolution and keeps
the rest of the build mostly unaware of the patching. Patching is done in the
projects intermediate output directory. This has a number of benefits but has
the unfortunate property that we will do patching separately for each vcxproj,
and have copies of patched react native for each. Some of this overhead is
mitigated by only copying C++ source files. Avoiding this would likely mean
outputting to a non-build directory or making larger changes to build
structure.

We move jsireact header logic here as well, so we can remove the root
WorkingHeaders directory.

Validated that files in DeforkingPatches will overwrite source and that we
still compile files including jsireact after removing an existing
WorkingHeaders directory. Tested that changing patches leads to a correct
imcremental rebuild.

Microsoft Reviewers: Open in CodeFlow
As part of the efforts to move off of microsoft/react-native, we're aiming to
consume facebook/react-native directly and then apply a set of Windows specific
patches. This change gives us a mechanism to do this patching.

We opt to fully modify React Native sources instead of manipulating
files/includes with build logic. This helps with header resolution and keeps
the rest of the build mostly unaware of the patching. Patching is done in the
projects intermediate output directory. This has a number of benefits but has
the unfortunate property that we will do patching separately for each vcxproj,
and have copies of patched react native for each. Some of this overhead is
mitigated by only copying C++ source files. Avoiding this would likely mean
outputting to a non-build directory or making dramatic changes to build
structure.

We move jsireact header logic here as well, so we can remove the root
WorkingHeaders directory.

Validated that files in DeforkingPatches will overwrite source and that we
still compile files including jsireact after removing an existing
WorkingHeaders directory. Tested that changing patches leads to a correct
imcremental rebuild.
@NickGerleman NickGerleman requested a review from microsoft/react-native-windows-write as a code owner Jan 14, 2020
@NickGerleman NickGerleman requested review from acoates-ms and vmoroz Jan 14, 2020
<!--
Visual Studio has its own incremental build logic for simple cases that
falls over here. Force use of MSBuild logic here. This has a minimal impact
on build time (~10s total to build a noop change on a six core machine).

This comment has been minimized.

@NickGerleman

NickGerleman Jan 14, 2020
Author Contributor

I kind of hate this, but it feels good to enable this anyway since we could have silently been getting flaky incremental builds before. Given the time to compile actual changes (especially without a PCH in most projects), this isn't too much overhead.

@NickGerleman NickGerleman requested a review from kmelmon Jan 14, 2020
<Warning Text="Folly required to build without microsoft/react-native. - Downloading folly..." Condition="!Exists('$(FollyDir)..\.follyzip\folly-2019.09.30.00.zip')" />
<DownloadFile Condition="!Exists('$(FollyDir)..\.follyzip\folly-2019.09.30.00.zip')" SourceUrl="https://github.com/facebook/folly/archive/v2019.09.30.00.zip" DestinationFolder="$(FollyDir)..\.follyzip" />
</Target>
<Target Name="UnzipFollyIfNotUseMicrosoftReactNative" BeforeTargets="PrepareForBuild" DependsOnTargets="DownloadFollyIfNotUseMicrosoftReactNative">

This comment has been minimized.

@NickGerleman

NickGerleman Jan 14, 2020
Author Contributor

Updating this since from what I can tell we never populate folly from npm, even when using microsoft/react-native.

…nput since we enumerate before other patching.
@NickGerleman
Copy link
Contributor Author

@NickGerleman NickGerleman commented Jan 14, 2020

@acoates-ms I'm interested in some of the comments you made earlier about potential issues around developers consuming RNW and how we publish the non-Nuget version of the project. Is there an area I should look, or any immediate concerns that come to mind?

<ReactSourceDestinationFiles Include="@(ReactSourceFiles->'$(ReactNativeDir)\%(RecursiveDir)%(Filename)%(Extension)')" />

<DeforkingPatchFiles Include="$(ReactNativeWindowsDir)\DeforkingPatches\**" />
<DeforkingPatchDesintationFiles Include="@(DeforkingPatchFiles->'$(ReactNativeDir)\%(RecursiveDir)%(Filename)%(Extension)')" />

This comment has been minimized.

@NickGerleman

NickGerleman Jan 14, 2020
Author Contributor

nit: spelling

@msftbot
Copy link
Contributor

@msftbot msftbot bot commented Jan 14, 2020

Hello @NickGerleman!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.
@NickGerleman
Copy link
Contributor Author

@NickGerleman NickGerleman commented Jan 14, 2020

@msftbot require 2 sign offs.

@msftbot
Copy link
Contributor

@msftbot msftbot bot commented Jan 14, 2020

Hello @NickGerleman!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it has at least 2 approvals

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@vmoroz
vmoroz approved these changes Jan 14, 2020
Copy link
Contributor

@vmoroz vmoroz left a comment

:shipit:

@msftbot msftbot bot merged commit 026b176 into microsoft:master Jan 14, 2020
22 checks passed
22 checks passed
PR Build #20200114..6 succeeded
Details
PR (Build and Pack Nuget) Build and Pack Nuget succeeded
Details
PR (Current (C#) PR ArmDebug) Current (C#) PR ArmDebug succeeded
Details
PR (Current (C#) PR X64DebugBundle) Current (C#) PR X64DebugBundle succeeded
Details
PR (Current (C#) PR X86Debug) Current (C#) PR X86Debug succeeded
Details
PR (Desktop PR X64Debug) Desktop PR X64Debug succeeded
Details
PR (Desktop PR X64Release) Desktop PR X64Release succeeded
Details
PR (Desktop PR X86Debug) Desktop PR X86Debug succeeded
Details
PR (Desktop PR X86Release) Desktop PR X86Release succeeded
Details
PR (E2E Test) E2E Test succeeded
Details
PR (Setup) Setup succeeded
Details
PR (Universal Other Projects PR X64Release) Universal Other Projects PR X64Release succeeded
Details
PR (Universal Other Projects PR X86Debug) Universal Other Projects PR X86Debug succeeded
Details
PR (Universal PR ArmRelease) Universal PR ArmRelease succeeded
Details
PR (Universal PR PublicRNX86Debug) Universal PR PublicRNX86Debug succeeded
Details
PR (Universal PR X86Release) Universal PR X86Release succeeded
Details
PR (Verify change files + lint) Verify change files + lint succeeded
Details
PR (Verify react-native init DebugCpp) Verify react-native init DebugCpp succeeded
Details
PR (Verify react-native init DebugCs) Verify react-native init DebugCs succeeded
Details
PR (Verify react-native init ReleaseCpp) Verify react-native init ReleaseCpp succeeded
Details
PR (Verify react-native init ReleaseCs) Verify react-native init ReleaseCs succeeded
Details
license/cla All CLA requirements met.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.