Skip to content

Commit

Permalink
Add CommunityToolkit.Maui.BindingExtensions NuGet package (#22)
Browse files Browse the repository at this point in the history
Moves binding build targets and tasks into a NuGet package so that each
slim binding does not need to copy and build the eng (now src) folder.

Includes a handful of fixes for incremental builds and multi-targeting
builds running in parallel.
  • Loading branch information
pjcollins authored Jun 7, 2024
1 parent b6bdb35 commit ab96f71
Show file tree
Hide file tree
Showing 30 changed files with 302 additions and 192 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,37 @@ jobs:
- name: Create logs dir
run: mkdir -p ${{ runner.temp }}/logs/

- name: Create local nupkg dir
run: mkdir -p ./src/CommunityToolkit.Maui.BindingExtensions/bin/Release

- name: Build and test build tasks
working-directory: ./eng
working-directory: ./src
run: >-
dotnet test Microsoft.Maui.BindingExtensions.Build.Tasks.sln
dotnet test CommunityToolkit.Maui.BindingExtensions.sln
--logger trx --results-directory ${{ runner.temp }}/logs/TestResults-build-tasks
-bl:${{ runner.temp }}/logs/build-tasks.binlog
- name: Pack build tasks
working-directory: ./src/CommunityToolkit.Maui.BindingExtensions
run: dotnet pack CommunityToolkit.Maui.BindingExtensions.csproj -bl:${{ runner.temp }}/logs/build-tasks-pack.binlog

- name: Upload nupkg
uses: actions/upload-artifact@v4
with:
name: nupkg
path: ./src/CommunityToolkit.Maui.BindingExtensions/bin/Release/*.nupkg

- name: Build facebook
working-directory: ./facebook
run: dotnet build -m:1 -bl:${{ runner.temp }}/logs/facebook.binlog
run: dotnet build -bl:${{ runner.temp }}/logs/facebook.binlog

- name: Build firebase
working-directory: ./firebase/macios
run: dotnet build -m:1 -bl:${{ runner.temp }}/logs/firebase-macios.binlog
run: dotnet build -bl:${{ runner.temp }}/logs/firebase-macios.binlog

- name: Build googlecast
working-directory: ./googlecast/macios
run: dotnet build -m:1 -bl:${{ runner.temp }}/logs/googlecast-macios.binlog
run: dotnet build -bl:${{ runner.temp }}/logs/googlecast-macios.binlog

- name: Upload logs
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ FodyWeavers.xsd

xcuserdata/

build/
**/native/build/
.build/
*.xcframework
Pods/
Expand Down
3 changes: 2 additions & 1 deletion eng/Directory.Build.props → Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

<PropertyGroup>
<LangVersion>latest</LangVersion>
<MSBuildPackageReferenceVersion>17.9.5</MSBuildPackageReferenceVersion>
<MSBuildPackageVersion>17.9.5</MSBuildPackageVersion>
<BindingExtPackageVersion>0.0.1-pre1</BindingExtPackageVersion>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ Install prerequisites:

The goal is to have bindings and samples building 100% through normal MSBuild invocations.

Each .NET Binding project contains some additional MSBuild logic to help obtain and build the native SDK dependencies along with the native slim binding project. In some cases, the target may also download native SDKs if they are not already present. In this way, the expected native artefacts are available in the expected working directories.
Each .NET Binding project contains some additional MSBuild logic to help obtain and build the native SDK dependencies along with the native slim binding project. In some cases, the target may also download native SDKs if they are not already present. In this way, the expected native artifacts are available in the expected working directories.

In the [```eng/```](/eng/) folder you will find [```Common.android.targets```](/eng/Common.android.targets) and [```Common.macios.targets```](/eng/Common.macios.targets) files which contain some custom build targets to help with this, and are imported into the binding projects.
In the [```src/```](/src/) folder you will find a solution with custom build tasks/targets to help with this. These build extensions are available in a CommunityToolkit.Maui.BindingExtensions NuGet package that the binding projects reference.

Android binding projects generate the API definition automatically taking into account any optional manual modifications like those implemented via the [```Metadata.xml```](https://learn.microsoft.com/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-metadata#metadataxml-transform-file) transform file.

Expand Down
Binary file added build/nuget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 0 additions & 118 deletions eng/Common.macios.targets

This file was deleted.

19 changes: 0 additions & 19 deletions eng/Common.targets

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<AndroidGenerateResourceDesigner>false</AndroidGenerateResourceDesigner>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui.BindingExtensions" Version="$(BindingExtPackageVersion)" />
</ItemGroup>

<!-- Metadata applicable to @(AndroidLibrary) will be used if set -->
<ItemGroup>
<GradleProjectReference Include="../native" >
Expand All @@ -17,5 +21,4 @@
</GradleProjectReference>
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\..\eng\Common.android.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
</PropertyGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs"/>
<PackageReference Include="CommunityToolkit.Maui.BindingExtensions" Version="$(BindingExtPackageVersion)" />
</ItemGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs"/>
<XcodeProjectReference Include="../native/MauiFacebook.xcodeproj">
<SchemeName>MauiFacebook</SchemeName>
<SharpieNamespace>Facebook</SharpieNamespace>
Expand All @@ -21,5 +22,4 @@
</XcodeProjectReference>
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\..\eng\Common.macios.targets" />
</Project>
4 changes: 2 additions & 2 deletions facebook/macios/native/MauiFacebook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/facebook/facebook-ios-sdk";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 14.1.0;
kind = exactVersion;
version = 16.3.1;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/facebook/facebook-ios-sdk",
"state" : {
"revision" : "c19607d535864533523d1f437c84035e5fb101cf",
"version" : "14.1.0"
"revision" : "3fe31c168903759de1c5752d12856c5c437c6862",
"version" : "16.3.1"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
</PropertyGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs" />
<PackageReference Include="CommunityToolkit.Maui.BindingExtensions" Version="$(BindingExtPackageVersion)" />
</ItemGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs" />
<XcodeProjectReference Include="../native/MauiFirebase.xcodeproj">
<SchemeName>MauiFirebase</SchemeName>
<SharpieNamespace>Firebase</SharpieNamespace>
Expand All @@ -22,5 +23,4 @@
</XcodeProjectReference>
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\..\eng\Common.macios.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<ImplicitUsings>true</ImplicitUsings>
<IsBindingProject>true</IsBindingProject>

<XcodeBuildMacCatalyst>False</XcodeBuildMacCatalyst>
<BuildXcodeProjectsDependsOnTargets>$(BuildXcodeProjectsDependsOnTargets);NativeDependencies</BuildXcodeProjectsDependsOnTargets>
</PropertyGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs" />
<PackageReference Include="CommunityToolkit.Maui.BindingExtensions" Version="$(BindingExtPackageVersion)" />
</ItemGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs" />
<XcodeProjectReference Include="../native/MauiGoogleCast.xcodeproj">
<SchemeName>MauiGoogleCast</SchemeName>
<SharpieNamespace>GoogleCast</SharpieNamespace>
Expand All @@ -37,5 +37,4 @@
<Exec Command="unzip -q -o -d $([System.IO.Path]::GetFullPath($(MSBuildProjectDirectory)/../native/build/deps)) @(GoogleCastiOSSdkArchives)" />
</Target>

<Import Project="$(MSBuildThisFileDirectory)..\..\..\eng\Common.macios.targets" />
</Project>
7 changes: 7 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="maui-binding-extensions" value="https://pkgs.dev.azure.com/xamarin/public/_packaging/maui-binding-extensions/nuget/v3/index.json" />
<!--add key="local" value="src/CommunityToolkit.Maui.BindingExtensions/bin/Release/" /-->
</packageSources>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentAssertions;
using Microsoft.Maui.BindingExtensions.Build.Tasks;
using CommunityToolkit.Maui.BindingExtensions;
using NUnit.Framework;

namespace Microsoft.Maui.BindingExtensions.Build.Tests
namespace CommunityToolkit.Maui.BindingExtensions.Tests
{
[TestFixture]
public class BindingToolTaskTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.Build.Framework" Version="$(MSBuildPackageReferenceVersion)" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MSBuildPackageReferenceVersion)" />
<PackageReference Include="Microsoft.Build.Framework" Version="$(MSBuildPackageVersion)" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MSBuildPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Maui.BindingExtensions.Build.Tasks\Microsoft.Maui.BindingExtensions.Build.Tasks.csproj" />
<ProjectReference Include="..\CommunityToolkit.Maui.BindingExtensions\CommunityToolkit.Maui.BindingExtensions.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Build.Framework;
using NUnit.Framework;

namespace Microsoft.Maui.BindingExtensions.Build.Tests
namespace CommunityToolkit.Maui.BindingExtensions.Tests
{
public class MockBuildEngine : IBuildEngine4
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.34809.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Maui.BindingExtensions.Build.Tasks", "src\Microsoft.Maui.BindingExtensions.Build.Tasks\Microsoft.Maui.BindingExtensions.Build.Tasks.csproj", "{D1497B0B-A62D-49AD-833B-EFE4F87B1BEE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Maui.BindingExtensions", "CommunityToolkit.Maui.BindingExtensions\CommunityToolkit.Maui.BindingExtensions.csproj", "{D1497B0B-A62D-49AD-833B-EFE4F87B1BEE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Maui.BindingExtensions.Build.Tests", "test\Microsoft.Maui.BindingExtensions.Build.Tests\Microsoft.Maui.BindingExtensions.Build.Tests.csproj", "{7BF30708-BC47-4379-8DC0-E7093AC2FED6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Maui.BindingExtensions.Tests", "CommunityToolkit.Maui.BindingExtensions.Tests\CommunityToolkit.Maui.BindingExtensions.Tests.csproj", "{7BF30708-BC47-4379-8DC0-E7093AC2FED6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Loading

0 comments on commit ab96f71

Please sign in to comment.