Skip to content

Commit

Permalink
Generate ikvm.properties instead of copying it.
Browse files Browse the repository at this point in the history
Add some properties to configure generation.
  • Loading branch information
wasabii committed Jan 3, 2025
1 parent 064be94 commit 2775c09
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/IKVM.Image/IKVM.Image.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<None Include="README.md" Pack="true" PackagePath="." />
<None Include="buildTransitive\**\*" Pack="true" PackagePath="buildTransitive\%(RecursiveDir)%(Filename)%(Extension)" />
<None Include="lib\**\*" Pack="true" PackagePath="lib\%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="ikvm.properties" Pack="true" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<Import Sdk="Microsoft.Build.NoTargets" Project="Sdk.targets" />
Expand Down
50 changes: 35 additions & 15 deletions src/IKVM.Image/buildTransitive/IKVM.Image.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
<IkvmImageAvailableRuntimeIdentifiers Include="win-x64;win-x86;win-arm64;linux-x64;linux-arm;linux-arm64;linux-musl-x64;linux-musl-arm;linux-musl-arm64;osx-x64;osx-arm64;android-arm64" />
</ItemGroup>

<PropertyGroup>
<IkvmImageTargetPath Condition=" '$(IkvmImageTargetPath)' == '' ">ikvm</IkvmImageTargetPath>
<IkvmPropertiesFileName Condition=" '$(IkvmPropertiesFileName)' == '' ">ikvm.properties</IkvmPropertiesFileName>
<CopyIkvmImageItemToOutputDirectory Condition=" '$(CopyIkvmImageItemToOutputDirectory)' == '' ">PreserveNewest</CopyIkvmImageItemToOutputDirectory>
<CopyIkvmImageItemToPublishDirectory Condition=" '$(CopyIkvmImageItemToPublishDirectory)' == '' "></CopyIkvmImageItemToPublishDirectory>
<CopyIkvmPropertiesFileToOutputDirectory Condition=" '$(CopyIkvmImageItemToOutputDirectory)' == '' ">PreserveNewest</CopyIkvmPropertiesFileToOutputDirectory>
<CopyIkvmPropertiesFileToPublishDirectory Condition=" '$(CopyIkvmPropertiesFileToPublishDirectory)' == '' "></CopyIkvmPropertiesFileToPublishDirectory>
</PropertyGroup>

<Choose>
<When Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net461'))">
<PropertyGroup>
Expand Down Expand Up @@ -102,9 +111,10 @@
</_ExpandIkvmImageItems>
<ItemGroup>
<_IkvmImageItemExpanded Update="@(_IkvmImageItemExpanded)">
<TargetPath>ikvm\%(_IkvmImageItemExpanded.RuntimeIdentifier)\%(_IkvmImageItemExpanded.ImagePath)</TargetPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>ikvm\%(_IkvmImageItemExpanded.RuntimeIdentifier)\%(_IkvmImageItemExpanded.ImagePath)</Link>
<TargetPath>$(IkvmImageTargetPath)\%(_IkvmImageItemExpanded.RuntimeIdentifier)\%(_IkvmImageItemExpanded.ImagePath)</TargetPath>
<CopyToOutputDirectory>$(CopyIkvmImageItemToOutputDirectory)</CopyToOutputDirectory>
<CopyToPublishDirectory>$(CopyIkvmImageItemToPublishDirectory)</CopyToPublishDirectory>
<Link>$(IkvmImageTargetPath)\%(_IkvmImageItemExpanded.RuntimeIdentifier)\%(_IkvmImageItemExpanded.ImagePath)</Link>
<Pack Condition=" '%(_IkvmImageItemExpanded.Pack)' == '' ">false</Pack>
</_IkvmImageItemExpanded>
</ItemGroup>
Expand Down Expand Up @@ -138,12 +148,13 @@

<Target Name="GetIkvmImageItemsOutputItems" BeforeTargets="_GetPackageFiles;AssignLinkMetadata;AssignTargetPaths" DependsOnTargets="$(GetIkvmImageItemsOutputItemsDependsOn)">
<_FilterIkvmImageItems Items="@(_IkvmImageItemExpanded)">
<Output TaskParameter="Items" ItemName="_SourceItemsToCopyToOutputDirectory" Condition=" '$(IkvmImageItemToNone)' != 'true' " />
<Output TaskParameter="Items" ItemName="_SourceItemsToCopyToPublishDirectory" Condition=" '$(IkvmImageItemToNone)' != 'true' " />
<Output TaskParameter="Items" ItemName="None" Condition=" '$(IkvmImageItemToNone)' == 'true' " />
<Output TaskParameter="Items" ItemName="_IkvmImageItemFiltered" />
</_FilterIkvmImageItems>
<ItemGroup>
<_IkvmImageItemExpanded Remove="@(_IkvmImageItemExpanded)" />
<_SourceItemsToCopyToOutputDirectory Include="@(_IkvmImageItemFiltered)" Condition=" '$(IkvmImageItemToNone)' != 'true' " />
<_SourceItemsToCopyToPublishDirectory Include="@(_IkvmImageItemFiltered)" Condition=" '$(IkvmImageItemToNone)' != 'true' " />
<None Include="@(_IkvmImageItemFiltered)" ItemName="None" Condition=" '$(IkvmImageItemToNone)' == 'true' " />
</ItemGroup>
</Target>

Expand All @@ -154,18 +165,22 @@
</GetIkvmImageItemsOutputItemsDependsOn>
</PropertyGroup>

<Target Name="GetDefaultIkvmPropertiesFile" BeforeTargets="_GetPackageFiles;AssignLinkMetadata;AssignTargetPaths">
<Target Name="WriteIkvmPropertiesFile">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\content\ikvm.properties" Condition="Exists('$(MSBuildThisFileDirectory)..\content\ikvm.properties')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>ikvm.properties</TargetPath>
<Link>ikvm.properties</Link>
</None>
<_IkvmPropertiesFileLine Include="ikvm.home.root=$(IkvmImageTargetPath)" />
</ItemGroup>
<WriteLinesToFile Lines="@(_IkvmPropertiesFileLine)" File="$(IntermediateOutputPath)$(IkvmPropertiesFileName)" WriteOnlyWhenDifferent="true" />
</Target>

<Target Name="CollectIkvmImageItemsOutputItems" BeforeTargets="_GetPackageFiles;AssignLinkMetadata;AssignTargetPaths" DependsOnTargets="$(CollectIkvmImageItemsOutputItemsDependsOn)">

<Target Name="IncludeIkvmPropertiesFile" DependsOnTargets="WriteIkvmPropertiesFile" BeforeTargets="_GetPackageFiles;AssignLinkMetadata;AssignTargetPaths">
<ItemGroup>
<None Include="$(IntermediateOutputPath)$(IkvmPropertiesFileName)" Condition="Exists('$(IntermediateOutputPath)$(IkvmPropertiesFileName)')">
<CopyToOutputDirectory>$(CopyIkvmPropertiesFileToOutputDirectory)</CopyToOutputDirectory>
<CopyToPublishDirectory>$(CopyIkvmPropertiesFileToPublishDirectory)</CopyToPublishDirectory>
<TargetPath>$(IkvmPropertiesFileName)</TargetPath>
<Link>$(IkvmPropertiesFileName)</Link>
</None>
</ItemGroup>
</Target>

<PropertyGroup>
Expand All @@ -176,10 +191,15 @@
</CollectIkvmImageItemsOutputItemsDependsOn>
</PropertyGroup>

<Target Name="CollectIkvmImageItemsOutputItems" BeforeTargets="_GetPackageFiles;AssignLinkMetadata;AssignTargetPaths" DependsOnTargets="$(CollectIkvmImageItemsOutputItemsDependsOn)">

</Target>

<PropertyGroup>
<AssignTargetPathsDependsOn>
CollectIkvmImageItemsOutputItems;
GetDefaultIkvmPropertiesFile;
WriteIkvmPropertiesFile;
IncludeIkvmPropertiesFile;
$(AssignTargetPathsDependsOn);
</AssignTargetPathsDependsOn>
</PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion src/IKVM.Image/ikvm.properties

This file was deleted.

2 changes: 1 addition & 1 deletion src/IKVM/buildTransitive/IKVM.IkvmReference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<Target Name="ResolveIkvmFrameworkReferences" DependsOnTargets="$(ResolveIkvmFrameworkReferencesDependsOn);$(ResolveAssemblyReferencesDependsOn)">
<ItemGroup>
<_IkvmFrameworkAssemblyReference Include="@(Reference)" Condition=" '%(Reference.NuGetIsFrameworkReference)' == 'true' Or '%(Reference.FrameworkFile)' == 'true' Or '%(Reference.ResolvedFrom)' == '{TargetFrameworkDirectory}' Or '%(Reference.IsImplicitlyDefined)' == 'true' Or '%(Reference.FrameworkReferenceName)' != '' Or '%(Reference.FrameworkReferenceVersion)' != '' Or '%(Reference.Identity)' == 'mscorlib' "/>
<_IkvmFrameworkAssemblyReference Include="@(Reference)" Condition=" '%(Reference.NuGetIsFrameworkReference)' == 'true' Or '%(Reference.FrameworkFile)' == 'true' Or '%(Reference.ResolvedFrom)' == '{TargetFrameworkDirectory}' Or '%(Reference.IsImplicitlyDefined)' == 'true' Or '%(Reference.FrameworkReferenceName)' != '' Or '%(Reference.FrameworkReferenceVersion)' != '' Or '%(Reference.Identity)' == 'mscorlib' Or '%(Reference.Identity)' == 'System' Or $([System.String]::new('%(Reference.Identity)').StartsWith('System.')) "/>
<_IkvmFrameworkAssemblyReference Include="@(Reference)" Condition=" '%(Reference.Identity)' == 'IKVM.Runtime' Or '%(Reference.Filename)%(Reference.Extension)' == 'IKVM.Runtime.dll' " />
<_IkvmFrameworkAssemblyReference Include="@(Reference)" Condition=" '%(Reference.Identity)' == 'IKVM.Java' Or '%(Reference.Filename)%(Reference.Extension)' == 'IKVM.Java.dll' " />
<_IkvmReferenceInstalledAssemblyDirectory Include="$(TargetFrameworkDirectory)" />
Expand Down

0 comments on commit 2775c09

Please sign in to comment.