-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new arch module template: cpp-lib (#12481)
## Description Adds a new `cpp-lib` template designed to be applied on top of the new projects created by the (now recommended) `create-react-native-library` script. Also updates the `cpp-app` template to be able to autolink and run these new libraries. ### Type of Change - New feature (non-breaking change which adds functionality) - This change requires a documentation update ### Why Devs need to add windows support to native modules in a way which can be consumed by the new arch RNW apps (i.e. the `cpp-app` template). Resolves #12480 ### What Create a new `cpp-lib` template which can be applied on top of the template created by `npx create-react-native-library`, adding Windows support for a turbo module. It will also automatically apply the `cpp-app` template to the example project if it exists. ## Screenshots <img width="441" alt="image" src="https://github.com/microsoft/react-native-windows/assets/10852185/f5f31727-a233-419c-8afe-ad91f797abb2"> ## Testing Verified the new template could be applied to a fresh library created by `create-react-native-library` and that example app autolinks, builds, and runs correctly. ## Changelog Should this change be included in the release notes: yes Created a new arch module template: cpp-lib
- Loading branch information
1 parent
e2ee456
commit 6164875
Showing
35 changed files
with
1,275 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-f2a1a001-7c49-48af-8a21-a5947fbec507.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Create new arch module template: cpp-lib", | ||
"packageName": "react-native-windows", | ||
"email": "jthysell@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
vnext/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT License. | ||
This file will be consumed by ALL C++ Win32 module projects (both inside | ||
and outside of this repo) that build on top of Microsoft.ReactNative. | ||
Do not make any changes here unless it applies to ALL such projects. | ||
--> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<!-- | ||
Define SkipAddPriPayloadFilesToCopyToOutputDirectoryItems=true and GenerateLibraryLayout=false to avoid | ||
conflicts with copying Microsoft.ReactNative XBF files by the native module DLLs and by Microsoft.ReactNative. | ||
--> | ||
<SkipAddPriPayloadFilesToCopyToOutputDirectoryItems>true</SkipAddPriPayloadFilesToCopyToOutputDirectoryItems> | ||
<GenerateLibraryLayout>false</GenerateLibraryLayout> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.Composition.Common.props" /> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Codegen.props" /> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\NuGet.Cpp.props" /> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\WinUI.props" /> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\PackageVersionDefinitions.props" /> | ||
</Project> |
20 changes: 20 additions & 0 deletions
20
vnext/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT License. | ||
This file will be consumed by C++ ALL Win32 module projects (both inside | ||
and outside of this repo) that build on top of Microsoft.ReactNative. | ||
Do not make any changes here unless it applies to ALL such projects. | ||
--> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<!-- Starting with the base of the UWP Cpp targets for now (until we need to start differentiating). --> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets" /> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Codegen.targets" /> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="boost" Version="1.76.0.0" /> | ||
<PackageReference Include="Microsoft.VCRTForwarders.140" Version="1.0.2-rc" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
vnext/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// AutolinkedNativeModules.g.cpp contents generated by "react-native autolink-windows" | ||
// clang-format off | ||
#include "pch.h" | ||
#include "AutolinkedNativeModules.g.h"{{ &autolinkCppIncludes }} | ||
|
||
namespace winrt::Microsoft::ReactNative | ||
{ | ||
|
||
void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::ReactNative::IReactPackageProvider> const& packageProviders) | ||
{ {{ &autolinkCppPackageProviders }} | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
vnext/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// AutolinkedNativeModules.g.h contents generated by "react-native autolink-windows" | ||
// clang-format off | ||
#pragma once | ||
|
||
namespace winrt::Microsoft::ReactNative | ||
{ | ||
|
||
void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::ReactNative::IReactPackageProvider> const& packageProviders); | ||
|
||
} |
Oops, something went wrong.