Skip to content

Commit

Permalink
Merge branch 'main' into dev/mandel/rgen-init-project
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque authored Oct 13, 2024
2 parents 0203a6a + 57380a5 commit 5439d50
Show file tree
Hide file tree
Showing 34 changed files with 219 additions and 128 deletions.
27 changes: 1 addition & 26 deletions dotnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,6 @@ WINDOWS_PACKAGE_TARGETS += $(DOTNET_PKG_DIR)/Microsoft.$1.Windows.Bundle.$2.zip
endef
$(foreach platform,$(DOTNET_WINDOWS_PLATFORMS),$(eval $(call CreateWindowsBundle,$(platform),$($(platform)_NUGET_VERSION_NO_METADATA),$(shell echo $(platform) | tr A-Z a-z),$(shell echo $(platform) | tr a-z A-Z))))

define CreateMsi
$(TMP_PKG_DIR)/Microsoft.NET.Workload.$1.$2.wsx: ./generate-wix.csharp Makefile $(TMP_PKG_DIR)/Microsoft.$1.Windows.Bundle.$2.zip
$$(Q_GEN) ./generate-wix.csharp "$1" "$$@" "$(TMP_PKG_DIR)/Microsoft.$1.Windows.Bundle.$2.zip.tmpdir/dotnet" "$2"

$(TMP_PKG_DIR)/Microsoft.NET.Workload.$1.$2.msi: $(TMP_PKG_DIR)/Microsoft.NET.Workload.$1.$2.wsx .stamp-check-wixl
$$(Q_GEN) wixl -o "$$@" "$$<" -a x64

MSI_TARGETS += $(DOTNET_PKG_DIR)/Microsoft.NET.Workload.$1.$2.msi
endef
$(foreach platform,$(DOTNET_WINDOWS_PLATFORMS),$(eval $(call CreateMsi,$(platform),$($(platform)_NUGET_VERSION_NO_METADATA))))

NUGET_SOURCES:=$(shell grep https://pkgs.dev.azure.com $(TOP)/NuGet.config | sed -e 's/.*value="//' -e 's/".*//')
.stamp-install-workloads: Makefile $(WORKLOAD_TARGETS) $(RUNTIME_PACKS) $(REF_PACKS) $(SDK_PACKS) $(TEMPLATE_PACKS) $(WORKLOAD_PACKS)
$(Q) $(DOTNET) workload install --skip-manifest-update \
Expand All @@ -457,23 +446,9 @@ NUGET_SOURCES:=$(shell grep https://pkgs.dev.azure.com $(TOP)/NuGet.config | sed

TARGETS += .stamp-install-workloads

.stamp-check-wixl:
$(Q) if ! type wixl; then \
echo "Installing msitools to get wixl..."; \
if ! brew install msitools; then \
if ! type wixl; then \
echo "Failed to install wixl"; \
exit 1; \
fi; \
fi; \
echo "Installed msitools"; \
fi
$(Q) touch $@

TARGETS += $(WORKLOAD_TARGETS) $(WINDOWS_PACKAGE_TARGETS)

msi: $(MSI_TARGETS)
package: $(PACKAGE_TARGETS) $(MSI_TARGETS) $(WINDOWS_PACKAGE_TARGETS)
package: $(PACKAGE_TARGETS) $(WINDOWS_PACKAGE_TARGETS)

# Helper targets for templates
#
Expand Down
1 change: 1 addition & 0 deletions dotnet/generate-target-platforms.csharp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ using (TextWriter writer = new StreamWriter (outputPath)) {
writer.WriteLine ("\t</ItemGroup>");
writer.WriteLine ("\t<PropertyGroup>");
writer.WriteLine ($"\t\t<{platform}MinSupportedOSPlatformVersion>{minSdkVersionString}</{platform}MinSupportedOSPlatformVersion>");
writer.WriteLine ($"\t\t<MinSupportedOSPlatformVersion>$({platform}MinSupportedOSPlatformVersion)</MinSupportedOSPlatformVersion>");
writer.WriteLine ("\t</PropertyGroup>");
writer.WriteLine ("</Project>");
}
Expand Down
7 changes: 3 additions & 4 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@
<!-- 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>

<!-- Prevent .NET from resolving runtime identifier for NativeAOT builds when building universal apps. -->
<UseCurrentRuntimeIdentifier Condition="'$(_UseNativeAot)' == 'true' And '$(RuntimeIdentifiers)' != '' And '$(RuntimeIdentifier)' == ''">false</UseCurrentRuntimeIdentifier>

</PropertyGroup>

<!-- Set the default RuntimeIdentifier if not already specified. -->
Expand Down Expand Up @@ -142,6 +138,9 @@
</PropertyGroup>

<PropertyGroup>
<!-- Prevent .NET from resolving runtime identifier for NativeAOT builds when building universal apps. -->
<UseCurrentRuntimeIdentifier Condition="'$(_UseNativeAot)' == 'true' And '$(RuntimeIdentifiers)' != '' And '$(RuntimeIdentifier)' == ''">false</UseCurrentRuntimeIdentifier>

<!-- See Xamarin.Shared.Sdk.Trimming.props for an explanation why we use CustomAfterDirectoryBuildTargets to compute trimming options -->
<CustomAfterDirectoryBuildTargets>$(CustomAfterDirectoryBuildTargets);$(MSBuildThisFileDirectory)Xamarin.Shared.Sdk.Trimming.props</CustomAfterDirectoryBuildTargets>
</PropertyGroup>
Expand Down
13 changes: 13 additions & 0 deletions msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,19 @@
<comment>RuntimeIdentifier: don't translate (it's the name of a MSBuild property)</comment>
</data>

<data name="E7125" xml:space="preserve">
<value>Unable to parse the value '{0}' for the property '{1}.</value>
<comment>
{0}: user-provided value
{1}: name of an MSBuild property
</comment>
</data>

<data name="E7126" xml:space="preserve">
<value>The SupportedOSPlatformVersion value '{0}' in the project file is lower than the minimum value '{1}'.</value>
<comment>SupportedOSPlatformVersion: don't translate (it's the name of an MSBuild property)</comment>
</data>

<data name="XcodeBuild_CreateNativeRef" xml:space="preserve">
<value>Adding reference to Xcode project output: '{0}'. The '%(CreateNativeReference)' metadata can be set to 'false' to opt out of this behavior.</value>
<comment>
Expand Down
15 changes: 15 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileAppManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class CompileAppManifest : XamarinTask, ITaskCallback, ICancelableTask {

public bool IsWatchExtension { get; set; }

[Required]
public string MinSupportedOSPlatformVersion { get; set; } = string.Empty;

public ITaskItem [] PartialAppManifests { get; set; } = Array.Empty<ITaskItem> ();

[Required]
Expand Down Expand Up @@ -302,6 +305,18 @@ bool SetMinimumOSVersion (PDictionary plist)
minimumOSVersion = minimumOSVersionInManifest!;
}

// Verify that the value is not lower than the minimum
if (!Version.TryParse (MinSupportedOSPlatformVersion, out var minSupportedVersion)) {
Log.LogError (MSBStrings.E7125 /* Unable to parse the value '{0}' for the property '{1}. */, MinSupportedOSPlatformVersion, "MinSupportedOSPlatformVersion");
return false;
} else if (!Version.TryParse (SupportedOSPlatformVersion, out var supportedVersion)) {
Log.LogError (MSBStrings.E7125 /* Unable to parse the value '{0}' for the property '{1}. */, SupportedOSPlatformVersion, "SupportedOSPlatformVersion");
return false;
} else if (minSupportedVersion > supportedVersion) {
Log.LogError (MSBStrings.E7126 /* The SupportedOSPlatformVersion value '{0}' in the project file is lower than the minimum value '{1}'." */, SupportedOSPlatformVersion, MinSupportedOSPlatformVersion);
return false;
}

// Write out our value
plist [minimumVersionKey] = minimumOSVersion;

Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
IsWatchApp="$(IsWatchApp)"
IsWatchExtension="$(IsWatchExtension)"
IsXPCService="$(IsXPCService)"
MinSupportedOSPlatformVersion="$(MinSupportedOSPlatformVersion)"
PartialAppManifests="@(PartialAppManifest)"
ProjectDir="$(MSBuildProjectDirectory)"
ResourcePrefix="$(_ResourcePrefix)"
Expand Down
2 changes: 2 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ test.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/eng/Version.De
@printf "ENABLE_XAMARIN=$(ENABLE_XAMARIN)\n" >> $@
@printf "XCODE_IS_STABLE=$(XCODE_IS_STABLE)\n" >> $@
@printf "XCODE_VERSION=$(XCODE_VERSION)\n" >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),DOTNET_MIN_$(platform)_SDK_VERSION=$(DOTNET_MIN_$(platform)_SDK_VERSION)\\n)" | sed 's/^ //' >> $@

test-system.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/eng/Version.Details.xml
@rm -f $@
Expand Down Expand Up @@ -120,6 +121,7 @@ test-system.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/eng/Ver
@printf "ENABLE_XAMARIN=$(ENABLE_XAMARIN)\n" >> $@
@printf "XCODE_IS_STABLE=$(XCODE_IS_STABLE)\n" >> $@
@printf "XCODE_VERSION=$(XCODE_VERSION)\n" >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),DOTNET_MIN_$(platform)_SDK_VERSION=$(DOTNET_MIN_$(platform)_SDK_VERSION)\\n)" | sed 's/^ //' >> $@

clean-local::
$(Q) $(SYSTEM_XBUILD) /t:Clean /p:Platform=iPhoneSimulator /p:Configuration=$(CONFIG) $(XBUILD_VERBOSITY) tests.sln
Expand Down
29 changes: 28 additions & 1 deletion tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,7 @@ public void BuildMyNativeAotAppWithTrimAnalysisWarning (ApplePlatform platform,
[TestCase (ApplePlatform.MacOSX, "osx-x64", "Release")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64", "Debug")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64", "Release")]
[TestCase (ApplePlatform.MacOSX, "", "Release")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64", "Debug")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64", "Release")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64", "Debug")]
Expand Down Expand Up @@ -1861,7 +1862,7 @@ public void UnsupportedTargetPlatformVersion (ApplePlatform platform)
// Pick a target platform version that we don't really support,
// but don't show an error in .NET 8 because of backwards compat.
// The earliest target OS version should do.
var minSupportedOSVersion = GetSupportedTargetPlatformVersions (platform).First ();
var minSupportedOSVersion = GetMinSupportedOSPlatformVersion (platform);
var targetFrameworks = Configuration.DotNetTfm + "-" + platform.AsString ().ToLowerInvariant () + minSupportedOSVersion;
var supportedApiVersions = GetSupportedApiVersions (platform, isCompat: false);

Expand Down Expand Up @@ -1914,6 +1915,11 @@ string [] GetSupportedTargetPlatformVersions (ApplePlatform platform)
.ToArray ();
}

string GetMinSupportedOSPlatformVersion (ApplePlatform platform)
{
return Configuration.GetVariable ($"DOTNET_MIN_{platform.AsString ().ToUpperInvariant ()}_SDK_VERSION", "unknown MinSupportedOSPlatformVersion");
}

[Test]
[TestCase (ApplePlatform.MacCatalyst, "MtouchArch", "x86_64")]
[TestCase (ApplePlatform.iOS, "MtouchArch", "ARMv7s")]
Expand Down Expand Up @@ -2837,5 +2843,26 @@ static HashSet<string> GetLinkedWithFrameworks (string path)
}
return rv;
}

[Test]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "13.1")]
[TestCase (ApplePlatform.iOS, "ios-arm64", "10.0")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", "10.0")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64", "10.0")]
public void InvalidSupportedOSPlatformVersion (ApplePlatform platform, string runtimeIdentifiers, string version)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);

var minVersion = GetMinSupportedOSPlatformVersion (platform);
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["SupportedOSPlatformVersion"] = version;
var rv = DotNet.AssertBuildFailure (project_path, properties);
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
AssertErrorMessages (errors, $"The SupportedOSPlatformVersion value '{version}' in the project file is lower than the minimum value '{minVersion}'.");
}
}
}
6 changes: 5 additions & 1 deletion tests/monotouch-test/ObjCRuntime/RegistrarTestGenerated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class RegistrarTestGenerated {
void AssertIfIgnored ([CallerMemberName] string testCase = null)
{
switch (testCase) {
#if __MACCATALYST__
#if __MACCATALYST__ || __IOS__
case "NSNumberBindAs_Boolean_Array_Overrides":
case "NSNumberBindAs_Byte_Array_Overrides":
case "NSNumberBindAs_Double_Array_Overrides":
Expand All @@ -25,7 +25,11 @@ void AssertIfIgnored ([CallerMemberName] string testCase = null)
case "NSNumberBindAs_UInt32_Array_Overrides":
case "NSNumberBindAs_UInt64_Array_Overrides":
// https://github.com/xamarin/xamarin-macios/issues/19781
#if __MACCATALYST__
if (Runtime.IsARM64CallingConvention)
#elif __IOS__
if (Runtime.IsARM64CallingConvention && Runtime.Arch == Arch.SIMULATOR)
#endif
Assert.Ignore ("https://github.com/xamarin/xamarin-macios/issues/19781");
break;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,14 @@ CompileAppManifest CreateTask (string? tmpdir = null, ApplePlatform platform = A
task.AppBundleName = "AppBundleName";
task.CompiledAppManifest = new TaskItem (Path.Combine (tmpdir, "TemporaryAppManifest.plist"));
task.DefaultSdkVersion = Sdks.GetAppleSdk (platform).GetInstalledSdkVersions (false).First ().ToString ()!;
task.MinSupportedOSPlatformVersion = "10.0";
task.SupportedOSPlatformVersion = "15.0";
task.SdkVersion = task.DefaultSdkVersion ?? string.Empty;
task.TargetFrameworkMoniker = TargetFramework.GetTargetFramework (platform, true).ToString ();

return task;
}

[Test]
public void DefaultMinimumOSVersion ()
{
var dir = Cache.CreateTemporaryDirectory ();
var task = CreateTask (dir);

ExecuteTask (task);

var plist = PDictionary.FromFile (task.CompiledAppManifest!.ItemSpec)!;
Assert.AreEqual (task.SdkVersion, plist.GetMinimumOSVersion (), "MinimumOSVersion");
}

[Test]
public void MainMinimumOSVersions ()
{
Expand All @@ -52,6 +42,7 @@ public void MainMinimumOSVersions ()
main.Save (mainPath);

task.AppManifest = new TaskItem (mainPath);
task.SupportedOSPlatformVersion = "14.0";

ExecuteTask (task);

Expand All @@ -78,6 +69,7 @@ public void MultipleMinimumOSVersions ()

task.AppManifest = new TaskItem (mainPath);
task.PartialAppManifests = new [] { new TaskItem (partialPath) };
task.SupportedOSPlatformVersion = "14.0";

ExecuteTask (task);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ protected virtual void ConfigureTask (bool isDotNet)
Task.CompiledAppManifest = new TaskItem (Path.Combine (Cache.CreateTemporaryDirectory (), "AppBundlePath", "Info.plist"));
Task.AssemblyName = assemblyName;
Task.AppManifest = new TaskItem (CreateTempFile ("foo.plist"));
Task.MinSupportedOSPlatformVersion = "10.0";
Task.SupportedOSPlatformVersion = "15.0";
Task.SdkVersion = "10.0";

Plist = new PDictionary ();
Expand All @@ -70,7 +72,7 @@ public override void Setup ()

ConfigureTask (IsDotNet);

Task.Execute ();
ExecuteTask (Task);
CompiledPlist = PDictionary.FromFile (Task.CompiledAppManifest.ItemSpec);
}

Expand Down
6 changes: 6 additions & 0 deletions tools/common/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ public void ParseInterpreter (string value)
InterpretedAssemblies.AddRange (value.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries));
}

public void UnsetInterpreter ()
{
UseInterpreter = false;
InterpretedAssemblies.Clear ();
}

#if !NET
public void ParseI18nAssemblies (string i18n)
{
Expand Down
1 change: 0 additions & 1 deletion tools/devops/automation/run-post-ci-build-api-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ extends:
template: templates/pipelines/run-api-scan.yml
parameters:
isPR: false

20 changes: 19 additions & 1 deletion tools/devops/automation/scripts/bash/clean-bot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ df -h
# We don't care about errors in this section, we just want to clean as much as possible
set +e

# Clean workspace
(
REPO_PATH="SYSTEM_DEFAULTWORKINGDIRECTORY/$(basename "$BUILD_REPOSITORY_NAME")"
if test -d "$REPO_PATH"; then
cd "$REPO_PATH"
git clean -xfd
fi
)

# Delete all the simulator devices. These can take up a lot of space over time (I've seen 100+GB on the bots)
/Applications/Xcode.app/Contents/Developer/usr/bin/simctl delete all

Expand Down Expand Up @@ -118,14 +127,23 @@ XCODE_SELECT=$(xcode-select -p)

for oldXcode in "${oldXcodes[@]}"; do
if [ "$XCODE_SELECT" != "$oldXcode/Contents/Developer" ]; then
sudo rm -Rf "$oldXcode"
if test -d "$oldXcode"; then
sudo rm -Rf "$oldXcode"
fi
else
echo "Not removing $oldXcode because is the currently selected one."
fi
done

DIR="$(dirname "${BASH_SOURCE[0]}")"
"$DIR"/clean-simulator-runtime.sh
"$DIR"/kill-deadlocked-processes.sh

# Remove legacy Xamarin/MonoTouch stuff
sudo rm -Rf /Developer/MonoTouch
sudo rm -Rf /Library/Frameworks/Xamarin.iOS.framework
sudo rm -Rf /Library/Frameworks/Xamarin.Mac.framework
ls -R /Library/Frameworks

# Print disk status after cleaning
df -h
4 changes: 0 additions & 4 deletions tools/devops/automation/scripts/bash/clean-results-dir.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
set -o pipefail
IFS=$'\n\t'

# delete all watchOS simulators, we don't need them anymore
for i in $(xcrun simctl runtime list | grep "watchOS.*Ready" | sed -e 's/.* - //' -e 's/ .*//'); do
xcrun simctl runtime delete "$i"
done

xcrun simctl runtime list -j > simruntime.json
cat simruntime.json

Expand Down
6 changes: 0 additions & 6 deletions tools/devops/automation/scripts/bash/delete-library-dirs.sh

This file was deleted.

27 changes: 27 additions & 0 deletions tools/devops/automation/scripts/bash/kill-deadlocked-processes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -e

echo "Looking for processes that have been stuck for more than a day, and will try to kill them."

# Collect the list of processes for the current user, including the CPU time.
# We then split the CPU time into separate fields, so that it's easier to figure out the total number of minutes later on.
IFS=$'\n'
PROCESSES=()
while IFS='' read -r line; do PROCESSES+=("$line"); done < <(ps -o cputime=,pid=,user=,lstart=,args= -U "$USER" -w -w -w | sed -e 's/\([0-9]*\):\([0-9][0-9]\)\.\([0-9][0-9]\)/\1 m \2 s \3 ms/' | sort -nr)

IFS=' '
for process in "${PROCESSES[@]}"; do
IFS=" " read -r -a FIELDS <<< "$process"
minutes=${FIELDS[0]}
pid=${FIELDS[6]}

echo "$process"

# looking for processes that have spent more than a day using the CPU (24h * 60min = 1440min)
if (( minutes > 1440 )); then
echo " This process has been stuck for more than $minutes minutes, so assuming it's deadlocked and we'll try to kill it:"
echo " kill -9 $pid"
kill -9 "$pid" | sed 's/^/ /' || true
fi
done

echo "No (more) processes stuck for more than a day."
Loading

0 comments on commit 5439d50

Please sign in to comment.