From 8a5a6258d636521847dde5dabe1c2cc02132d969 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Tue, 23 Jul 2024 13:10:55 +0200 Subject: [PATCH 1/5] Add static compiler-flag --- src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets | 1 + src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets | 3 ++- src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets index f937f4ab57..2531c6268f 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets @@ -293,6 +293,7 @@ Value = b.ToString(); <_IkvmCompilerArgs Include="-sharedclassloader" Condition=" '$(SharedClassLoader)' == 'true' " /> <_IkvmCompilerArgs Include="-w$(WarningLevel)" /> <_IkvmCompilerArgs Include="-noparameterreflection" Condition=" '$(NoParameterReflection)' == 'true' " /> + <_IkvmCompilerArgs Include="-static" Condition=" '$(CompileStatically)' == 'true' " /> <_IkvmCompilerArgs Include="-exclude:$([System.IO.Path]::GetFullPath('$(_ExcludeFilePath)'))" Condition="Exists('$(_ExcludeFilePath)') And '@(ExcludeRegex)' != '' " /> <_IkvmCompilerArgs Include="@(_AssemblyAttributesClass->'-assemblyattributes:%(FullPath)')" /> <_IkvmCompilerReferencePath Remove="@(_IkvmCompilerReferencePath)" /> diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets index f0106ab7ba..205fc4e0b8 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets @@ -139,7 +139,8 @@ RemoveAssertions="$(RemoveAssertions)" Resources="@(_IkvmCompilerResource)" Remap="@(MapFile)" - Input="@(_Convert)" /> + Input="@(_Convert)" + Static="$(CompileStatically)" /> diff --git a/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props b/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props index e007dcb58a..57f2e9a742 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props +++ b/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props @@ -26,6 +26,7 @@ true true true + false From fb33deb97ec699bf1748ae3dcaa5a64463b4cdc6 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Tue, 23 Jul 2024 13:33:38 +0200 Subject: [PATCH 2/5] Typo --- src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props b/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props index 57f2e9a742..1c6c7c9685 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props +++ b/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props @@ -26,7 +26,7 @@ true true true - false + false From 34da4477f757d2eba9e8813a111b558d1cd03fa8 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Tue, 30 Jul 2024 10:14:37 +0200 Subject: [PATCH 3/5] Rename property after Review --- src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets | 2 +- src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets | 4 ++-- src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets index 2531c6268f..1f028d0d66 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.NoTasks.targets @@ -293,7 +293,7 @@ Value = b.ToString(); <_IkvmCompilerArgs Include="-sharedclassloader" Condition=" '$(SharedClassLoader)' == 'true' " /> <_IkvmCompilerArgs Include="-w$(WarningLevel)" /> <_IkvmCompilerArgs Include="-noparameterreflection" Condition=" '$(NoParameterReflection)' == 'true' " /> - <_IkvmCompilerArgs Include="-static" Condition=" '$(CompileStatically)' == 'true' " /> + <_IkvmCompilerArgs Include="-static" Condition=" '$(Static)' == 'true' " /> <_IkvmCompilerArgs Include="-exclude:$([System.IO.Path]::GetFullPath('$(_ExcludeFilePath)'))" Condition="Exists('$(_ExcludeFilePath)') And '@(ExcludeRegex)' != '' " /> <_IkvmCompilerArgs Include="@(_AssemblyAttributesClass->'-assemblyattributes:%(FullPath)')" /> <_IkvmCompilerReferencePath Remove="@(_IkvmCompilerReferencePath)" /> diff --git a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets index 205fc4e0b8..affb1f803e 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets +++ b/src/IKVM.NET.Sdk/targets/IKVM.Java.Core.Tasks.targets @@ -132,6 +132,7 @@ SharedClassLoader="$(SharedClassLoader)" NoStdLib="$(NoCompilerStandardLib)" NoParameterReflection="$(NoParameterReflection)" + Static="$(Static)" WarningLevel="$(WarningLevel)" References="@(_IkvmCompilerReferencePath)" StrictFinalFieldSemantics="$(StrictFinalFieldSemantics)" @@ -139,8 +140,7 @@ RemoveAssertions="$(RemoveAssertions)" Resources="@(_IkvmCompilerResource)" Remap="@(MapFile)" - Input="@(_Convert)" - Static="$(CompileStatically)" /> + Input="@(_Convert)" /> diff --git a/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props b/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props index 1c6c7c9685..eae6e88d56 100644 --- a/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props +++ b/src/IKVM.NET.Sdk/targets/IKVM.NET.Sdk.props @@ -26,7 +26,7 @@ true true true - false + false From 0439f51cdd3dd48957cbc7a4896b24fca1741ecf Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Wed, 31 Jul 2024 11:06:31 +0200 Subject: [PATCH 4/5] Support Static parameter on IkvmReference --- src/IKVM/buildTransitive/IKVM.IkvmReference.NoTasks.targets | 1 + src/IKVM/buildTransitive/IKVM.IkvmReference.Tasks.targets | 1 + src/IKVM/buildTransitive/IKVM.IkvmReference.props | 1 + 3 files changed, 3 insertions(+) diff --git a/src/IKVM/buildTransitive/IKVM.IkvmReference.NoTasks.targets b/src/IKVM/buildTransitive/IKVM.IkvmReference.NoTasks.targets index e13c617fe6..ac7d175f4a 100644 --- a/src/IKVM/buildTransitive/IKVM.IkvmReference.NoTasks.targets +++ b/src/IKVM/buildTransitive/IKVM.IkvmReference.NoTasks.targets @@ -41,6 +41,7 @@ <_IkvmCompilerArgs Include="-removeassertions" Condition=" '$(RemoveAssertions)' == 'true' " /> <_IkvmCompilerArgs Include="-target:library" /> <_IkvmCompilerArgs Include="-nostdlib" /> + <_IkvmCompilerArgs Include="-static" Condition=" '%(IkvmReferenceItem.Static)' == 'true' " /> <_IkvmCompilerArgs Include="-classloader:%(IkvmReferenceItem.ClassLoader)" Condition=" '%(IkvmReferenceItem.ClassLoader)' != '' " /> <_IkvmCompilerArgs Include="@(_IkvmCompilerReferencePath->'-reference:%(FullPath)')" /> <_IkvmCompilerArgs Include="-out:%(IkvmReferenceItem.StagePath)" /> diff --git a/src/IKVM/buildTransitive/IKVM.IkvmReference.Tasks.targets b/src/IKVM/buildTransitive/IKVM.IkvmReference.Tasks.targets index 752d54b7e4..b78ca0b968 100644 --- a/src/IKVM/buildTransitive/IKVM.IkvmReference.Tasks.targets +++ b/src/IKVM/buildTransitive/IKVM.IkvmReference.Tasks.targets @@ -44,6 +44,7 @@ CompressResources="true" ClassLoader="%(IkvmReferenceItem.ClassLoader)" NoStdLib="true" + Static="%(IkvmReferenceItem.Static)" References="@(_IkvmCompilerReferencePath->'%(FullPath)')" Input="%(IkvmReferenceItem.Compile)" Condition=" '%(IkvmReferenceItem.Compile)' != '' "/> diff --git a/src/IKVM/buildTransitive/IKVM.IkvmReference.props b/src/IKVM/buildTransitive/IKVM.IkvmReference.props index be41817347..db8211eb7a 100644 --- a/src/IKVM/buildTransitive/IKVM.IkvmReference.props +++ b/src/IKVM/buildTransitive/IKVM.IkvmReference.props @@ -23,6 +23,7 @@ true true true + false From 79e35e099c84139111afcff8889a494698d5527e Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Wed, 31 Jul 2024 13:43:26 +0200 Subject: [PATCH 5/5] Copy Static-property from IkvmReference to IkvmReferenceItem --- src/IKVM.MSBuild.Tasks/IkvmReferenceItem.cs | 7 +++++++ src/IKVM.MSBuild.Tasks/IkvmReferenceItemMetadata.cs | 1 + 2 files changed, 8 insertions(+) diff --git a/src/IKVM.MSBuild.Tasks/IkvmReferenceItem.cs b/src/IKVM.MSBuild.Tasks/IkvmReferenceItem.cs index f1e900a330..54facce0f3 100644 --- a/src/IKVM.MSBuild.Tasks/IkvmReferenceItem.cs +++ b/src/IKVM.MSBuild.Tasks/IkvmReferenceItem.cs @@ -72,6 +72,7 @@ public static IkvmReferenceItem[] Import(IEnumerable items) item.CacheSymbolsPath = item.Item.GetMetadata(IkvmReferenceItemMetadata.CacheSymbolsPath); item.StagePath = item.Item.GetMetadata(IkvmReferenceItemMetadata.StagePath); item.StageSymbolsPath = item.Item.GetMetadata(IkvmReferenceItemMetadata.StageSymbolsPath); + item.Static = string.Equals(item.Item.GetMetadata(IkvmReferenceItemMetadata.Static), "true", StringComparison.OrdinalIgnoreCase); item.Save(); } @@ -271,6 +272,11 @@ public IkvmReferenceItem(ITaskItem item) /// public List ResolvedReferences { get; set; } + /// + /// Whether Ikvmc should enable static-semantics. + /// + public bool Static { get; set; } = false; + /// /// Writes the metadata to the item. /// @@ -300,6 +306,7 @@ public void Save() Item.SetMetadata(IkvmReferenceItemMetadata.Private, Private ? "true" : "false"); Item.SetMetadata(IkvmReferenceItemMetadata.ReferenceOutputAssembly, ReferenceOutputAssembly ? "true" : "false"); Item.SetMetadata(IkvmReferenceItemMetadata.ResolvedReferences, string.Join(IkvmReferenceItemMetadata.PropertySeperatorString, ResolvedReferences)); + Item.SetMetadata(IkvmReferenceItemMetadata.Static, Static ? "true" : "false"); } /// diff --git a/src/IKVM.MSBuild.Tasks/IkvmReferenceItemMetadata.cs b/src/IKVM.MSBuild.Tasks/IkvmReferenceItemMetadata.cs index f9ef738f6a..72636a8f15 100644 --- a/src/IKVM.MSBuild.Tasks/IkvmReferenceItemMetadata.cs +++ b/src/IKVM.MSBuild.Tasks/IkvmReferenceItemMetadata.cs @@ -30,6 +30,7 @@ static class IkvmReferenceItemMetadata public static readonly string Aliases = "Aliases"; public static readonly string Private = "Private"; public static readonly string ReferenceOutputAssembly = "ReferenceOutputAssembly"; + public static readonly string Static = "Static"; }