Skip to content

Commit

Permalink
Ensure libextension-dotnet.a is built for MacCatalyst, and we have th…
Browse files Browse the repository at this point in the history
…e right targets in place.
  • Loading branch information
enclave-alistair committed Feb 15, 2023
1 parent d49549e commit 3d36e8a
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ global using nfloat = global::System.Runtime.InteropServices.NFloat%3B
<Import Project="$(_TargetsDirectory)Xamarin.Mac.ObjCBinding.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'macOSBindingProject' " />

<Import Project="$(_TargetsDirectory)Xamarin.MacCatalyst.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'MacCatalystExecutableProject' Or '$(_ProjectType)' == 'MacCatalystClassLibrary' " />
<Import Project="$(_TargetsDirectory)Xamarin.MacCatalyst.AppExtension.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'MacCatalystSAppExtensionProject' " />
<Import Project="$(_TargetsDirectory)Xamarin.MacCatalyst.AppExtension.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'MacCatalystAppExtensionProject' " />
<Import Project="$(_TargetsDirectory)Xamarin.MacCatalyst.ObjCBinding.$(_ProjectLanguage).targets" Condition="'$(_ProjectType)' == 'MacCatalystBindingProject' " />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!--
***********************************************************************************************
Xamarin.MacCatalyst.AppExtension.CSharp.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file imports the version- and platform-specific targets for the project importing
this file. This file also defines targets to produce an error if the specified targets
file does not exist, but the project is built anyway (command-line or IDE build).
Copyright (C) 2014-2016 Xamarin. All rights reserved.
***********************************************************************************************
-->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets')"/>

<PropertyGroup>
<!-- Version/fx properties -->
<TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">Xamarin.MacCatalyst</TargetFrameworkIdentifier>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v1.0</TargetFrameworkVersion>

<!-- This must be set before importing Microsoft.CSharp.targets -->
<!--
In Xamarin.iOS.Common.targets, just before the _CompileToNative target, we modify the
mtouch references to ensure that we get the lib assemblies for nugets, and not the ref references:
https://github.com/xamarin/xamarin-macios/blob/9e31d07ecc08a64372dd562e843c3d8950d24985/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets#L784-L791
This logic removes nuget references, and then re-adds any copy-local dll references.
This works fine in executable projects, but not in library projects (aka extensions), because nugets aren't copied for library projects:
https://github.com/NuGet/NuGet.BuildTasks/blob/cf4b0a12cf1f75e0654f28c2a9020251c41d126a/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.targets#L86
So we need to set the CopyNuGetImplementations variable to 'true' for our library projects.
-->
<CopyNuGetImplementations Condition="'$(CopyNuGetImplementations)' == ''">true</CopyNuGetImplementations>

<!-- Enable nuget package conflict resolution -->
<!-- This must be set before importing Microsoft.CSharp.targets -->
<ResolveAssemblyConflicts>true</ResolveAssemblyConflicts>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" Condition="'$(UsingAppleNETSdk)' != 'true'" />
<Import Project="Xamarin.MacCatalyst.AppExtension.Common.targets" />

<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets')"/>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
***********************************************************************************************
Xamarin.MacCatalyst.AppExtension.Common.props
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file defines default properties for iOS App Extension projects.
Copyright (C) 2014-2016 Xamarin. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.props"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.props')"/>

<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.props"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.props')"/>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--
***********************************************************************************************
Xamarin.MacCatalyst.AppExtension.Common.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file imports the version- and platform-specific targets for the project importing
this file. This file also defines targets to produce an error if the specified targets
file does not exist, but the project is built anyway (command-line or IDE build).
Copyright (C) 2014-2016 Xamarin. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsAppExtension>True</IsAppExtension>
<IsWatchExtension>False</IsWatchExtension>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)Xamarin.MacCatalyst.Common.Targets" />

<Import Project="$(MSBuildThisFileDirectory)Xamarin.MacCatalyst.AppExtension.Common.props" />

<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets')"/>

<!-- Override GetTargetPath, Build, and Rebuild -->
<Target Name="GetBundleTargetPath" DependsOnTargets="_GenerateBundleName;$(GetTargetPathDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
<Target Name="Build" Condition="'$(_InvalidConfigurationWarning)' != 'true'" DependsOnTargets="_GenerateBundleName;$(BuildDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
<Target Name="Rebuild" Condition="'$(_InvalidConfigurationWarning)' != 'true'" DependsOnTargets="_GenerateBundleName;$(RebuildDependsOn)" Outputs="@(_AppExtensionBundlePath)" />

<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets')"/>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!--
***********************************************************************************************
Xamarin.MacCatalyst.AppExtension.FSharp.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file imports the version- and platform-specific targets for the project importing
this file. This file also defines targets to produce an error if the specified targets
file does not exist, but the project is built anyway (command-line or IDE build).
Copyright (C) 2014-2016 Xamarin. All rights reserved.
***********************************************************************************************
-->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets')"/>

<PropertyGroup>
<!-- Version/fx properties -->
<TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">Xamarin.MacCatalyst</TargetFrameworkIdentifier>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v1.0</TargetFrameworkVersion>

<!-- This must be set before importing Microsoft.FSharp.targets -->
<!-- See Xamarin.MacCatalyst.AppExtension.CSharp.targets for a detailed explanation of this variable -->
<CopyNuGetImplementations Condition="'$(CopyNuGetImplementations)' == ''">true</CopyNuGetImplementations>

<!-- This should be done in the F# target files, but _DebugFileExt is not an upstream
msbuild feature yet, so F# doesn't have this. Once, upstream F# adds it, we can
remove this -->
<_DebugFileExt Condition="'$(FscDebugFileExt)' != ''">$(FscDebugFileExt)</_DebugFileExt>
<_DebugFileExt Condition="'$(_DebugFileExt)' == ''">.mdb</_DebugFileExt>

<!-- Enable nuget package conflict resolution -->
<!-- This must be set before importing Microsoft.CSharp.targets -->
<ResolveAssemblyConflicts>true</ResolveAssemblyConflicts>
</PropertyGroup>

<!-- xbuild searches multiple MSBuildExtensionsPath32, but only in the Import element so we can't determine this with a variable -->
<Import
Condition="'$(Language)' != 'F#' And Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')"
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets" />
<Import
Condition="'$(Language)' != 'F#' And Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets')"
Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets" />
<Import
Condition="'$(Language)' != 'F#' And Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets')"
Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets" />

<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets')"/>

<Import Project="Xamarin.MacCatalyst.AppExtension.Common.targets" />

</Project>
2 changes: 1 addition & 1 deletion runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ endif
DOTNET_iOS_LIBRARIES = libextension-dotnet.a
DOTNET_tvOS_LIBRARIES = libtvextension-dotnet.a
DOTNET_macOS_LIBRARIES = libextension-dotnet-coreclr.a
DOTNET_MacCatalyst_LIBRARIES =
DOTNET_MacCatalyst_LIBRARIES = libextension-dotnet.a

define DotNetLibTemplate
DOTNET_TARGETS += \
Expand Down

0 comments on commit 3d36e8a

Please sign in to comment.