-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mono] new Sdk that selects mono runtime components (#54432)
* Work in progress: new Sdk that selects mono runtime components * Add props and targets description to the components doc * condition the _MonoRuntimeAvailableComponents by RuntimeIdentifier * [cmake] Write a component-manifest.props file during build If we're not building a mono aot cross compiler, generate a component-manifest.props file in artifacts/obj/mono/<host>/ that indicates if the host will use static or dynamic components, and a list of the available components, and the properties for constructing their names. * Build Microsoft.NETCore.App.Runtime.Mono.<RID>.Sdk shared framework nuget It seems to also generate a symbols nuget. And in the nuget there's a tools/mono-sdk-what-is-this.deps.json file from the SharedFrameworkHostFileNameOverride property. It would be nice to exclude that stuff. * put the compoonent-manifest.targets into the Sdk * delete WIP in mono/nuget/ * fixup static component names in component-manifest.targets * delete fixed fixme * add missing $ * fix whitespace * [cmake] switch to configure_file instead of file(CONFIGURE) * add missing trailing slashes in .props.in file * Add new Sdk packs to the workload manifest * rework component-manifest.targets to use ItemGroups; move to new SDK * Rename shared framework to Microsoft.NETCore.App.Runtime.Mono.<RID>.Props.Sdk And only include component-manifest.props, not the targets * Update manifest to include the new Props.Sdk and MonoTargets.Sdk * Move RuntimeConfigParserTask into Microsoft.NET.Runtime.MonoTargets.Sdk Consolidate all platform-independent tasks and targets into a single Sdk * Add iossimulator-x86 props * update components design doc * Fix typo * improve docs * Add _MonoRuntimeComponentDontLink target output * Drop component-manifest.props into runtime pack build/ directory Remove from the Microsoft.NETCore.App.Mono.Props.Sdk workload nuget * remove Microsoft.NETCore.App.Mono.Props.Sdk * Import component-manifest.props from the runtime pack Move the MonoTargets.Sdk import to each target platform that we support * Fix typos Co-authored-by: Rolf Bjarne Kvinge <[email protected]> * Apply suggestions from code review Co-authored-by: Ankit Jain <[email protected]> * Add JsonToItemsTaskFactory * fix whitespace * Do some validation earlier in _MonoComputeAvailableComponentDefinitions * Read component-manifest.json using the JsonToItemsTaskFactory and bundle it in Microsoft.NET.Runtime.MonoTargets.Sdk * remove ResolvedRuntimePack import from WorkloadManifest.targets it's too early, and we have the JsonToItemsTaskFactory now to read the manifest * Generate component-manifest.json in CMakeLists.txt * Fix some copy-paste nits * Use RuntimeFlavor==mono for runtime pack build directory instead of TargetsMobile. We want the build files (mono-components.json) in every mono runtime pack, not just on mobile targets * Apply suggestions from code review Co-authored-by: Ankit Jain <[email protected]> * rename component-manifest to RuntimeComponentManifest * fixup nullability annotations * fix whitespace * fix formatting * Misc fixes to JsonToItemsTaskFactory * Rename MonoRuntimeComponentManifestReadTask from MonoRuntimeComponentsReadManifestTask * undo nullability annotation Build doesn't like it for some reason (probably net472) * fix incorrect task parameter name * Remove Identity metadata from dictionary at json parsing time Also improve nullability a bit by making the properties immutable * Throw correct json deserializer exceptions * Catch JsonException in an async function We get nice error messages now like ``` src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets(8,5): error : Failed to deserialize json from file 'artifacts/bin/mono/iOSSimulator.x64.Release/build/RuntimeComponentManifest.json', JSON Path: $.items._MonoRuntimeAvailableComponents[2], Line: 14, Position: 1 [component-manifest.sample.proj] src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets(8,5): error : JsonException: The JSON value could not be converted to System.Collections.Generic.Dictionary`2[System.String,System.String]. Path: $.identity | LineNumber: 0 | BytePositionInLine: 16. Path: $.items._MonoRuntimeAvailableComponents[2] | LineNumber: 14 | BytePositionInLine: 1. [component-manifest.sample.proj] src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets(8,5): error : InvalidOperationException: Cannot get the value of a token type 'Number' as a string. [component-manifest.sample.proj] src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets(8,5): error : [component-manifest.sample.proj] ``` * fixup comments Co-authored-by: Rolf Bjarne Kvinge <[email protected]> Co-authored-by: Ankit Jain <[email protected]>
- Loading branch information
1 parent
30d770d
commit 893739f
Showing
21 changed files
with
858 additions
and
79 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"items": { | ||
"_MonoRuntimeComponentLinking": [ | ||
{ "identity": "${TemplateMonoRuntimeComponentLinking}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, | ||
], | ||
"_MonoRuntimeComponentSharedLibExt": [ | ||
{ "identity": "${TemplateMonoRuntimeComponentSharedLibExt}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, | ||
], | ||
"_MonoRuntimeComponentStaticLibExt": [ | ||
{ "identity": "${TemplateMonoRuntimeComponentStaticLibExt}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, | ||
], | ||
"_MonoRuntimeAvailableComponents": [ | ||
${TemplateMonoRuntimeAvailableComponents} | ||
], | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj
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,23 @@ | ||
<Project DefaultTargets="Build"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" /> | ||
|
||
<PropertyGroup> | ||
<PackageDescription>Provides the tasks+targets, for consumption by mono-based workloads</PackageDescription> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(RepoTasksDir)RuntimeConfigParser\RuntimeConfigParser.csproj" /> | ||
<ProjectReference Include="$(RepoTasksDir)JsonToItemsTaskFactory\JsonToItemsTaskFactory.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageFile Include="Sdk\Sdk.props" TargetPath="Sdk" /> | ||
<PackageFile Include="Sdk\Sdk.targets" TargetPath="Sdk" /> | ||
<PackageFile Include="build\$(MSBuildProjectName).props" TargetPath="build" /> | ||
<PackageFile Include="Sdk\RuntimeConfigParserTask.props" TargetPath="Sdk" /> | ||
<PackageFile Include="Sdk\RuntimeComponentManifest.props" TargetPath="Sdk" /> | ||
<PackageFile Include="Sdk\RuntimeComponentManifest.targets" TargetPath="Sdk" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" /> | ||
</Project> |
38 changes: 38 additions & 0 deletions
38
src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/README.md
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,38 @@ | ||
# Mono Runtime Host support targets | ||
|
||
This Sdk provides additional tasks and targets for workloads hosting the MonoVM .NET runtime. | ||
|
||
## component-manifest.targets | ||
|
||
See https://github.com/dotnet/runtime/blob/main/docs/design/mono/components.md | ||
|
||
## RuntimeConfigParserTask | ||
The `RuntimeConfigParserTask` task converts a json `runtimeconfig.json` to a binary blob for MonoVM's `monovm_runtimeconfig_initialize` API. | ||
To use the task in a project, reference the NuGet package, with the appropriate nuget source. | ||
|
||
### NuGet.config | ||
```xml | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" /> | ||
</packageSources> | ||
</configuration> | ||
``` | ||
|
||
### In the project file | ||
```xml | ||
<!-- Import the NuGet package into the project --> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Runtime.MonoTargets.Sdk" Version="<desired-dotnet-6-sdk-version>" /> | ||
</ItemGroup> | ||
|
||
<!-- Use the RuntimeConfigParser task in a target --> | ||
<Target> | ||
<RuntimeConfigParserTask | ||
RuntimeConfigFile="$(Path_to_runtimeconfig.json_file)" | ||
OutputFile="$(Path_to_generated_binary_file)" | ||
RuntimeConfigReservedProperties="@(runtime_properties_reserved_by_host)"> | ||
</RuntimeConfigParserTask> | ||
</Target> | ||
``` |
14 changes: 14 additions & 0 deletions
14
src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.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,14 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<JsonToItemsTaskFactoryTasksAssemblyPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tasks\net6.0\JsonToItemsTaskFactory.dll</JsonToItemsTaskFactoryTasksAssemblyPath> | ||
<JsonToItemsTaskFactoryTasksAssemblyPath Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\net472\JsonToItemsTaskFactory.dll</JsonToItemsTaskFactoryTasksAssemblyPath> | ||
</PropertyGroup> | ||
<UsingTask TaskName="MonoRuntimeComponentManifestReadTask" TaskFactory="JsonToItemsTaskFactory.JsonToItemsTaskFactory" AssemblyFile="$(JsonToItemsTaskFactoryTasksAssemblyPath)"> | ||
<ParameterGroup> | ||
<_MonoRuntimeComponentSharedLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> | ||
<_MonoRuntimeComponentStaticLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> | ||
<_MonoRuntimeComponentLinking ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> | ||
<_MonoRuntimeAvailableComponents ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> | ||
</ParameterGroup> | ||
</UsingTask> | ||
</Project> |
Oops, something went wrong.