Skip to content

Commit

Permalink
Add Xcsync tool to workload package (#20931)
Browse files Browse the repository at this point in the history
Co-authored-by: Haritha Mohan <[email protected]>
Co-authored-by: Alex Soto <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
  • Loading branch information
4 people authored Aug 5, 2024
1 parent 2c7fce4 commit 6aca25a
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 4 deletions.
3 changes: 3 additions & 0 deletions dotnet/Microsoft.MacCatalyst.Sdk/data/UnixFilePermissions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
<!-- bgen -->
<File Path="tools/bin/bgen" Permission="755" />
<File Path="tools/lib/bgen/bgen" Permission="755" />
<!-- xcsync -->
<File Path="tools/bin/xcsync" Permission="755" />
<File Path="tools/lib/xcsync" Permission="755" />
</FileList>
3 changes: 3 additions & 0 deletions dotnet/Microsoft.iOS.Sdk/data/UnixFilePermissions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
<!-- mlaunch -->
<File Path="tools/bin/mlaunch" Permission="755" />
<File Path="tools/lib/mlaunch/mlaunch.app/Contents/MacOS/mlaunch" Permission="755" />
<!-- xcsync -->
<File Path="tools/bin/xcsync" Permission="755" />
<File Path="tools/lib/xcsync" Permission="755" />
</FileList>
3 changes: 3 additions & 0 deletions dotnet/Microsoft.macOS.Sdk/data/UnixFilePermissions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
<!-- bgen -->
<File Path="tools/bin/bgen" Permission="755" />
<File Path="tools/lib/bgen/bgen" Permission="755" />
<!-- xcsync -->
<File Path="tools/bin/xcsync" Permission="755" />
<File Path="tools/lib/xcsync" Permission="755" />
</FileList>
3 changes: 3 additions & 0 deletions dotnet/Microsoft.tvOS.Sdk/data/UnixFilePermissions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
<!-- mlaunch -->
<File Path="tools/bin/mlaunch" Permission="755" />
<File Path="tools/lib/mlaunch/mlaunch.app/Contents/MacOS/mlaunch" Permission="755" />
<!-- xcsync -->
<File Path="tools/bin/xcsync" Permission="755" />
<File Path="tools/lib/xcsync" Permission="755" />
</FileList>
2 changes: 2 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
<!-- Tell .NET to skip sanity checks that trigger too eagerly for builds with multiple RuntimeIdentifiers -->
<AllowPublishAotWithoutRuntimeIdentifier Condition="'$(AllowPublishAotWithoutRuntimeIdentifier)' == '' And '$(_UseNativeAot)' == 'true'">true</AllowPublishAotWithoutRuntimeIdentifier>
<AllowSelfContainedWithoutRuntimeIdentifier Condition="'$(AllowSelfContainedWithoutRuntimeIdentifier)' == ''">true</AllowSelfContainedWithoutRuntimeIdentifier>

<XcsyncPath Condition="'$(XcsyncPath)' == ''">$(_XamarinSdkRootDirectoryOnMac)tools/bin</XcsyncPath>
</PropertyGroup>

<!-- Set the default RuntimeIdentifier if not already specified. -->
Expand Down
35 changes: 35 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,41 @@ global using nfloat = global::System.Runtime.InteropServices.NFloat%3B
</ItemGroup>
</Target>

<Target Name="ComputeXcsyncArguments">
<PropertyGroup>
<xcSyncExecute>PATH=$(XcsyncPath):$PATH $(DOTNET_HOST_PATH) xcsync</xcSyncExecute>
<xcSyncProjectFile Condition="'$(xcSyncProjectFile)' == ''">$(MSBuildProjectFullPath)</xcSyncProjectFile>
<xcSyncXcodeFolder Condition="'$(xcSyncXcodeFolder)' == ''">$(IntermediateOutputPath)xcode</xcSyncXcodeFolder>
<xcSyncTargetFrameworkMoniker Condition="'$(xcSyncTargetFrameworkMoniker)' == ''">$(TargetFramework)</xcSyncTargetFrameworkMoniker>
<xcSyncVerbosity Condition="'$(xcSyncVerbosity)' == ''">Diagnostic</xcSyncVerbosity>


<XcsyncCommonArguments Condition="'$(xcSyncProjectFile)' != ''">$(XcsyncCommonArguments) -p "$(xcSyncProjectFile)"</XcsyncCommonArguments>
<XcsyncCommonArguments Condition="'$(xcSyncXcodeFolder)' != ''">$(XcsyncCommonArguments) -t "$(xcSyncXcodeFolder)"</XcsyncCommonArguments>
<XcsyncCommonArguments Condition="'$(xcSyncTargetFrameworkMoniker)' != ''">$(XcsyncCommonArguments) -tfm $(xcSyncTargetFrameworkMoniker)</XcsyncCommonArguments>
<XcsyncCommonArguments Condition="'$(xcSyncVerbosity)' != ''">$(XcsyncCommonArguments) -v $(xcSyncVerbosity)</XcsyncCommonArguments>
<XcsyncCommonArguments>$(XcsyncCommonArguments) --dotnet-path "$([System.IO.Path]::GetDirectoryName($(DOTNET_HOST_PATH)))"</XcsyncCommonArguments>

<XcsyncGenerateArguments>$(XcsyncCommonArguments) --force</XcsyncGenerateArguments>

<XcsyncSyncArguments>$(XcsyncCommonArguments)</XcsyncSyncArguments>
</PropertyGroup>
</Target>

<Target Name="xcsync-generate" DependsOnTargets="ComputeXcsyncArguments">
<Message Importance="Normal" Text="Add $(XcsyncPath) to your path to invoke xcSync directly from the commandline." />
<Message Importance="Low" Text="Executing xcSync using: $(xcSyncExecute) generate $(XcsyncGenerateArguments)" />

<Exec SessionId="$(BuildSessionId)" Command="$(xcSyncExecute) generate $(XcsyncGenerateArguments)" />
</Target>

<Target Name="xcsync-sync" DependsOnTargets="ComputeXcsyncArguments">
<Message Importance="Normal" Text="Add $(XcsyncPath) to your path to invoke xcSync directly from the commandline." />
<Message Importance="Low" Text="Executing xcSync using: $(xcSyncExecute) sync $(XcsyncSyncArguments)" />

<Exec SessionId="$(BuildSessionId)" Command="$(xcSyncExecute) sync $(XcsyncSyncArguments)" />
</Target>

<!-- Import existing targets -->

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions mk/xamarin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ endif

# Available versions can be seen here:
# https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-eng/NuGet/Microsoft.Tools.Mlaunch/versions
# https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-eng/NuGet/Microsoft.Tools.xcsync/versions
MLAUNCH_NUGET_VERSION=1.0.142
XCSYNC_NUGET_VERSION=1.0.86

define CheckVersionTemplate
check-$(1)::
Expand Down
2 changes: 1 addition & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ifdef INCLUDE_MTOUCH
SUBDIRS += mtouch
endif

SUBDIRS+=mlaunch siminstaller
SUBDIRS+=mlaunch siminstaller xcsync

ifdef ENABLE_DOTNET
ifdef INCLUDE_XAMARIN_LEGACY
Expand Down
4 changes: 2 additions & 2 deletions tools/devops/governance/CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -850,11 +850,11 @@
"_justification": "External repo dependency, mono."
},
{
"file": "maccore\\tools\\provisioning-profiles\\certificates-and-profiles\\developer-id-application-luis-aguilera-aug-2024.p12",
"file": "maccore\\tools\\provisioning-profiles\\certificates-and-profiles\\developer-id-application-luis-aguilera-jul-2029.p12",
"_justification": "Testing certificate."
},
{
"file": "maccore\\tools\\provisioning-profiles\\certificates-and-profiles\\developer-id-installer-luis-aguilera-aug-2024.p12",
"file": "maccore\\tools\\provisioning-profiles\\certificates-and-profiles\\developer-id-installer-luis-aguilera-jul-2029.p12",
"_justification": "Testing certificate."
},
{
Expand Down
2 changes: 1 addition & 1 deletion tools/mlaunch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ endif
TARGETS += $(foreach platform,$(DOTNET_PLATFORMS_MOBILE),$(DOTNET_DESTDIR)/Microsoft.$(platform).Sdk/tools/bin/mlaunch)

$(DOWNLOAD_STAMP_FILE):
$(Q) $(DOTNET) restore download-mlaunch.csproj /bl:$@.binlog $(NSBUILD_VERBOSITY) /p:MlaunchNuGetVersion=$(MLAUNCH_NUGET_VERSION)
$(Q) $(DOTNET) restore download-mlaunch.csproj /bl:$@.binlog $(MSBUILD_VERBOSITY) /p:MlaunchNuGetVersion=$(MLAUNCH_NUGET_VERSION)
$(Q) touch $@

$(IOS_DESTDIR)/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch: $(DOWNLOAD_STAMP_FILE)
Expand Down
2 changes: 2 additions & 0 deletions tools/xcsync/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.stamp

37 changes: 37 additions & 0 deletions tools/xcsync/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
TOP=../..

include $(TOP)/Make.config
include $(TOP)/mk/xamarin.mk

DOWNLOAD_STAMP_FILE=.download-$(XCSYNC_NUGET_VERSION).stamp

TARGETS += $(foreach platform,$(DOTNET_PLATFORMS),$(DOTNET_DESTDIR)/Microsoft.$(platform).Sdk/tools/bin/xcsync)

$(DOWNLOAD_STAMP_FILE):
$(Q) $(DOTNET) restore download-xcsync.csproj /bl:$@.binlog $(MSBUILD_VERBOSITY) /p:XcsyncNuGetVersion=$(XCSYNC_NUGET_VERSION)
$(Q) touch $@

define DotNetInstall
$$(DOTNET_DESTDIR)/Microsoft.$(1).Sdk/tools/bin/xcsync: $$(DOWNLOAD_STAMP_FILE)
$$(Q) rm -rf $$(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/tools/bin/xcsync
$$(Q) rm -rf $$(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/tools/lib/xcsync
$$(Q) mkdir -p $$(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/tools/bin
$$(Q) mkdir -p $$(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/tools/lib/xcsync
$$(Q) $$(CP) -R $(TOP)/packages/microsoft.tools.xcsync/$$(XCSYNC_NUGET_VERSION)/bin/dotnet-xcsync $$(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/tools/bin/xcsync
$$(Q) $$(CP) -R $(TOP)/packages/microsoft.tools.xcsync/$$(XCSYNC_NUGET_VERSION)/lib/. $$(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/tools/lib/xcsync
$$(Q) chmod a+x $$(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/tools/bin/xcsync
$$(Q) chmod a+x $$(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME)/tools/lib/xcsync/xcsync
endef

$(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call DotNetInstall,$(platform))))

clean-local::
ifdef ENABLE_DOTNET
$(Q) rm -rf $(foreach platform,$(DOTNET_PLATFORMS),$(DOTNET_DESTDIR)/$($(platform)_NUGET_SDK_NAME)/tools/bin/xcsync)
$(Q) rm -rf $(foreach platform,$(DOTNET_PLATFORMS),$(DOTNET_DESTDIR)/$($(platform)_NUGET_SDK_NAME)/tools/lib/xcsync)
endif
$(Q) rm -rf .*.stamp obj .*.binlog

all-local:: $(TARGETS)
install-local:: $(TARGETS)
download: $(DOWNLOAD_STAMP_FILE)
15 changes: 15 additions & 0 deletions tools/xcsync/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
xcsync
-------

xcsync is a closed source tool used to interact with Xcode.

We'll build this tool from souce if the xamarin build is enabled (configured
with --enable-xamarin).

Otherwise we'll get a binary version from the macios-binaries repository. This
version may be somewhat out of date, but should work at least for running
tests.

To update the binary version of xcsync in macios-binaries execute `make publish`
in this directory (when the xamarin build is enabled, so that xcsync
is built from source).
13 changes: 13 additions & 0 deletions tools/xcsync/download-xcsync.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)</TargetFramework>
</PropertyGroup>

<Import Project="../../eng/Versions.props" />

<ItemGroup>
<PackageDownload Include="Microsoft.Tools.xcsync" Version="[$(XcsyncNuGetVersion)]" />
</ItemGroup>

<Target Name="Download" />
</Project>

6 comments on commit 6aca25a

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire

Pipeline on Agent
Hash: 6aca25ad5d44bc0a27a79d0a0bff4802f6ee597a [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 6aca25ad5d44bc0a27a79d0a0bff4802f6ee597a [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 6aca25ad5d44bc0a27a79d0a0bff4802f6ee597a [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 6aca25ad5d44bc0a27a79d0a0bff4802f6ee597a [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: 6aca25ad5d44bc0a27a79d0a0bff4802f6ee597a [CI build]

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.