Skip to content

Commit

Permalink
Using a second copy of RAR to resolve IkvmFrameworkReference. This on…
Browse files Browse the repository at this point in the history
…e only includes IKVM related packages and Framework related stuff, and runs before compiling the IkvmReferences.
  • Loading branch information
wasabii committed Oct 9, 2023
1 parent 76c8af4 commit bce26db
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 86 deletions.
2 changes: 1 addition & 1 deletion src/IKVM.Image/buildTransitive/IKVM.Image.targets
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
</Task>
</UsingTask>

<Target Name="GetIkvmImageItemsOutputItems" DependsOnTargets="$(GetIkvmImageItemsOutputItemsDependsOn)" BeforeTargets="_GetPackageFiles;AssignLinkMetadata;AssignTargetPaths">
<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' " />
Expand Down
6 changes: 3 additions & 3 deletions src/IKVM.MSBuild.Tests/IKVM.MSBuild.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

<ItemGroup>
<Compile Remove="Project\**\*" />
<None Include="Project\**\*" CopyToOutputDirectory="Always" />
<None Include="Project\**\*" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\ext\helloworld\helloworld-2.0.jar" Link="Project\Lib\helloworld\helloworld-2.0-1\helloworld-2.0.jar">
<None Include="..\..\ext\helloworld\helloworld-2.0.jar" Link="Project\helloworld\helloworld-2.0-1\helloworld-2.0.jar">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\ext\helloworld\helloworld-2.0.jar" Link="Project\Lib\helloworld\helloworld-2.0-2\helloworld-2.0.jar">
<None Include="..\..\ext\helloworld\helloworld-2.0.jar" Link="Project\helloworld\helloworld-2.0-2\helloworld-2.0.jar">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions src/IKVM.MSBuild.Tests/Project/Exe/ProjectExe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,16 @@
<ProjectReference Include="..\Lib\ProjectLib.csproj" />
</ItemGroup>

<ItemGroup>
<IkvmReference Include="..\helloworld\helloworld-2.0-1\helloworld-2.0.jar">

</IkvmReference>
<IkvmReference Include="..\helloworld\helloworld-2.0-2\helloworld-2.0.jar">
<AssemblyName>helloworld-2</AssemblyName>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<Aliases>helloworld2</Aliases>
</IkvmReference>
</ItemGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
4 changes: 2 additions & 2 deletions src/IKVM.MSBuild.Tests/Project/Lib/ProjectLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
</ItemGroup>

<ItemGroup>
<IkvmReference Include="helloworld\helloworld-2.0-1\helloworld-2.0.jar">
<IkvmReference Include="..\helloworld\helloworld-2.0-1\helloworld-2.0.jar">

</IkvmReference>
<IkvmReference Include="helloworld\helloworld-2.0-2\helloworld-2.0.jar">
<IkvmReference Include="..\helloworld\helloworld-2.0-2\helloworld-2.0.jar">
<AssemblyName>helloworld-2</AssemblyName>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<Aliases>helloworld2</Aliases>
Expand Down
2 changes: 2 additions & 0 deletions src/IKVM.MSBuild.Tests/ProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ public void CanBuildTestProject(string tfm, string rid, string exe, string lib)
options.GlobalProperties["TargetFramework"] = tfm;
options.GlobalProperties["RuntimeIdentifier"] = rid;
options.TargetsToBuild.Clear();
options.TargetsToBuild.Add("Clean");
options.TargetsToBuild.Add("Build");
options.TargetsToBuild.Add("Publish");
options.Arguments.Add("/v:diag");
analyzer.Build(options).OverallSuccess.Should().Be(true);

var binDir = Path.Combine("Project", "Exe", "bin", "Release", tfm, rid);
Expand Down
19 changes: 0 additions & 19 deletions src/IKVM.MSBuild/buildTransitive/IKVM.MSBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,6 @@
<Error Text="Could not locate IKVM.Runtime.dll." Condition=" '$(IkvmRuntimeAssembly)' == '' " />
</Target>

<PropertyGroup>
<ResolveIkvmBaseAssemblyDependsOn>
$(ResolveIkvmBaseAssemblyDependsOn);
ResolvePackageDependenciesForBuild;
ResolveProjectReferences;
</ResolveIkvmBaseAssemblyDependsOn>
</PropertyGroup>

<!-- Locates the IKVM.Java assembly from among the current references of the project. -->
<Target Name="ResolveIkvmBaseAssembly" DependsOnTargets="$(ResolveIkvmBaseAssemblyDependsOn)">
<ItemGroup>
<_IkvmBaseAssembly Include="@(Reference);@(_ResolvedProjectReferencePaths)" Condition=" '%(Filename)%(Extension)' == 'IKVM.Java.dll' " />
</ItemGroup>
<PropertyGroup>
<IkvmBaseAssembly>@(_IkvmBaseAssembly)</IkvmBaseAssembly>
</PropertyGroup>
<Error Text="Could not locate IKVM.Java.dll." Condition=" '$(IkvmBaseAssembly)' == '' " />
</Target>

<!--
Optionally disable registration of tasks.
-->
Expand Down
86 changes: 59 additions & 27 deletions src/IKVM.NET.Sdk.Tests/ProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public override void Initialize(IEventSource eventSource)

public static string IkvmExportCachePath { get; set; }

public TestContext TestContext { get; set; }

[ClassInitialize]
public static void Init(TestContext context)
{
Expand Down Expand Up @@ -132,32 +130,34 @@ public static void ClassCleanup()
Directory.Delete(TempRoot, true);
}

public TestContext TestContext { get; set; }

[DataTestMethod]
[DataRow("net472", "win-x86")]
[DataRow("net472", "win-x64")]
[DataRow("net48", "win-x86")]
[DataRow("net48", "win-x64")]
[DataRow("net6.0", "win-x86")]
[DataRow("net6.0", "win-x64")]
[DataRow("net6.0", "linux-x64")]
[DataRow("net6.0", "linux-arm")]
[DataRow("net6.0", "linux-arm64")]
[DataRow("net6.0", "linux-musl-x64")]
[DataRow("net6.0", "linux-musl-arm")]
[DataRow("net6.0", "linux-musl-arm64")]
[DataRow("net6.0", "osx-x64")]
[DataRow("net6.0", "osx-arm64")]
[DataRow("net7.0", "win-x86")]
[DataRow("net7.0", "win-x64")]
[DataRow("net7.0", "linux-x64")]
[DataRow("net7.0", "linux-arm")]
[DataRow("net7.0", "linux-arm64")]
[DataRow("net7.0", "linux-musl-x64")]
[DataRow("net7.0", "linux-musl-arm")]
[DataRow("net7.0", "linux-musl-arm64")]
[DataRow("net7.0", "osx-x64")]
[DataRow("net7.0", "osx-arm64")]
public void CanBuildTestProject(string tfm, string rid)
[DataRow("net472", "win-x86", "{0}.exe", "{0}.dll")]
[DataRow("net472", "win-x64", "{0}.exe", "{0}.dll")]
[DataRow("net48", "win-x86", "{0}.exe", "{0}.dll")]
[DataRow("net48", "win-x64", "{0}.exe", "{0}.dll")]
[DataRow("net6.0", "win-x86", "{0}.exe", "{0}.dll")]
[DataRow("net6.0", "win-x64", "{0}.exe", "{0}.dll")]
[DataRow("net6.0", "linux-x64", "{0}", "lib{0}.so")]
[DataRow("net6.0", "linux-arm", "{0}", "lib{0}.so")]
[DataRow("net6.0", "linux-arm64", "{0}", "lib{0}.so")]
[DataRow("net6.0", "linux-musl-x64", "{0}", "lib{0}.so")]
[DataRow("net6.0", "linux-musl-arm", "{0}", "lib{0}.so")]
[DataRow("net6.0", "linux-musl-arm64", "{0}", "lib{0}.so")]
[DataRow("net6.0", "osx-x64", "{0}", "lib{0}.dylib")]
[DataRow("net6.0", "osx-arm64", "{0}", "lib{0}.dylib")]
[DataRow("net7.0", "win-x86", "{0}.exe", "{0}.dll")]
[DataRow("net7.0", "win-x64", "{0}.exe", "{0}.dll")]
[DataRow("net7.0", "linux-x64", "{0}", "lib{0}.so")]
[DataRow("net7.0", "linux-arm", "{0}", "lib{0}.so")]
[DataRow("net7.0", "linux-arm64", "{0}", "lib{0}.so")]
[DataRow("net7.0", "linux-musl-x64", "{0}", "lib{0}.so")]
[DataRow("net7.0", "linux-musl-arm", "{0}", "lib{0}.so")]
[DataRow("net7.0", "linux-musl-arm64", "{0}", "lib{0}.so")]
[DataRow("net7.0", "osx-x64", "{0}", "lib{0}.dylib")]
[DataRow("net7.0", "osx-arm64", "{0}", "lib{0}.dylib")]
public void CanBuildTestProject(string tfm, string rid, string exe, string lib)
{
// skip framework tests for non-Windows platforms
if (tfm == "net472" || tfm == "net48")
Expand Down Expand Up @@ -190,6 +190,38 @@ public void CanBuildTestProject(string tfm, string rid)
options.TargetsToBuild.Add("Build");
options.TargetsToBuild.Add("Publish");
analyzer.Build(options).OverallSuccess.Should().Be(true);

var binDir = Path.Combine("Project", "Exe", "bin", "Release", tfm, rid);

// check in build output and publish output
foreach (var i in new[] { "", "publish" })
{
var outDir = Path.Combine(binDir, i);

// main artifiacts generated by project
File.Exists(Path.Combine(outDir, string.Format(exe, "ProjectExe"))).Should().BeTrue();
File.Exists(Path.Combine(outDir, "ProjectLib.dll")).Should().BeTrue();

// ikvm libraries
File.Exists(Path.Combine(outDir, "IKVM.Runtime.dll")).Should().BeTrue();
File.Exists(Path.Combine(outDir, "IKVM.Java.dll")).Should().BeTrue();
File.Exists(Path.Combine(outDir, string.Format(lib, "ikvm"))).Should().BeTrue();

// ikvm image direcetories
Directory.Exists(Path.Combine(outDir, "ikvm")).Should().BeTrue();
Directory.Exists(Path.Combine(outDir, "ikvm", rid)).Should().BeTrue();
Directory.Exists(Path.Combine(outDir, "ikvm", rid, "bin")).Should().BeTrue();
File.Exists(Path.Combine(outDir, "ikvm", rid, "TRADEMARK")).Should().BeTrue();
File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "tzdb.dat")).Should().BeTrue();
File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "tzmappings")).Should().BeTrue();
File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "currency.data")).Should().BeTrue();
File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "security", "java.policy")).Should().BeTrue();
File.Exists(Path.Combine(outDir, "ikvm", rid, "lib", "security", "java.security")).Should().BeTrue();

// ikvm image native libraries
foreach (var libName in new[] { "awt", "fdlibm", "iava", "jvm", "management", "net", "nio", "sunec", "unpack", "verify" })
File.Exists(Path.Combine(outDir, "ikvm", rid, "bin", string.Format(lib, libName))).Should().BeTrue();
}
}

}
Expand Down
6 changes: 2 additions & 4 deletions src/IKVM/buildTransitive/IKVM.NoTasks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
-->

<!-- Builds the IkvmReferenceItem set into their output items within the cache. -->
<Target Name="_CompileIkvmReferences" DependsOnTargets="ResolveIkvmCompiler;ResolveIkvmRuntimeAssembly;ResolveIkvmBaseAssembly;ResolveIkvmFrameworkReferences" Inputs="$(IkvmCompilerPath);@(IkvmFrameworkReference);$(IkvmBaseAssembly);$(IkvmRuntimeAssembly);%(IkvmReferenceItem.Compile)" Outputs="%(IkvmReferenceItem.CachePath)">
<Target Name="_CompileIkvmReferences" DependsOnTargets="ResolveIkvmCompiler;ResolveIkvmRuntimeAssembly;ResolveIkvmFrameworkReferences" Inputs="$(IkvmCompilerPath);@(IkvmFrameworkReference);$(IkvmBaseAssembly);$(IkvmRuntimeAssembly);%(IkvmReferenceItem.Compile)" Outputs="%(IkvmReferenceItem.CachePath)">
<Error Text="Could not locate IKVM.Runtime assembly." Condition=" '$(IkvmRuntimeAssembly)' == '' " />
<Error Text="IKVM.Runtime.dll could not be located at '$(IkvmRuntimeAssembly)'." Condition="!Exists('$(IkvmRuntimeAssembly)')" />
<Error Text="Could not locate IKVM.Java assembly." Condition=" '$(IkvmBaseAssembly)' == '' " />
<Error Text="IKVM.Java.dll could not be located at '$(IkvmBaseAssembly)'." Condition="!Exists('$(IkvmBaseAssembly)')" />
<Error Text="Could not locate ikvmc executable." Condition=" '$(IkvmCompilerPath)' == '' " />
<Error Text="ikvmc could not be located at '$(IkvmCompilerPath)'." Condition="!Exists('$(IkvmCompilerPath)')" />

Expand All @@ -26,7 +24,7 @@
<_IkvmCompilerReferencePath Remove="@(_IkvmCompilerReferencePath)" />
<_IkvmReferenceItemResolvedReference Remove="@(_IkvmReferenceItemResolvedReference)" />
<_IkvmReferenceItemResolvedReference Include="%(IkvmReferenceItem.ResolvedReferences)" />
<_IkvmCompilerReferencePath Include="@(IkvmFrameworkReference);$(IkvmBaseAssembly);$(IkvmRuntimeAssembly);$(IkvmRuntimeJNIAssembly);@(_IkvmReferenceItemResolvedReference)" />
<_IkvmCompilerReferencePath Include="@(IkvmFrameworkReference);@(_IkvmReferenceItemResolvedReference)" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions src/IKVM/buildTransitive/IKVM.Tasks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<Target Name="_CompileIkvmReferences" DependsOnTargets="ResolveIkvmRuntimeAssembly;ResolveIkvmFrameworkReferences" Inputs="%(IkvmReferenceItem.Compile)" Outputs="%(IkvmReferenceItem.CachePath)">
<Error Text="Could not locate IKVM.Runtime assembly." Condition=" '$(IkvmRuntimeAssembly)' == '' " />
<Error Text="IKVM.Runtime.dll could not be located at '$(IkvmRuntimeAssembly)'." Condition="!Exists('$(IkvmRuntimeAssembly)')" />
<Error Text="Could not locate IKVM.Java assembly." Condition=" '$(IkvmBaseAssembly)' == '' " />
<Error Text="IKVM.Java.dll could not be located at '$(IkvmBaseAssembly)'." Condition="!Exists('$(IkvmBaseAssembly)')" />

<!-- Output to stage path then copy to cache path to be atomic. -->
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('%(IkvmReferenceItem.StagePath)'))" />
Expand All @@ -24,7 +22,7 @@
<_IkvmCompilerReferencePath Remove="@(_IkvmCompilerReferencePath)" />
<_IkvmReferenceItemResolvedReference Remove="@(_IkvmReferenceItemResolvedReference)" />
<_IkvmReferenceItemResolvedReference Include="%(IkvmReferenceItem.ResolvedReferences)" />
<_IkvmCompilerReferencePath Include="@(IkvmFrameworkReference);$(IkvmBaseAssembly);$(IkvmRuntimeAssembly);$(IkvmRuntimeJNIAssembly);@(_IkvmReferenceItemResolvedReference)" />
<_IkvmCompilerReferencePath Include="@(IkvmFrameworkReference);@(_IkvmReferenceItemResolvedReference)" />
</ItemGroup>

<Delete Files="%(IkvmReferenceItem.StagePath)" Condition="Exists('%(IkvmReferenceItem.StagePath)')" />
Expand Down
Loading

0 comments on commit bce26db

Please sign in to comment.