Skip to content

Commit

Permalink
fix: ensure platform tests are working
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielku15 committed Aug 11, 2024
1 parent e5bef39 commit ffab19f
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 10 deletions.
11 changes: 11 additions & 0 deletions build/Build.DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,24 @@ void DotNetWriteVersionInfoProps()
.Requires(() => Framework)
.Executes(() =>
{
Log.Information($"Running DotNet tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (OS fonts)");
DotNetTasks.DotNetRun(_ => _
.SetProcessWorkingDirectory(RootDirectory / "test" / "dotnet" / "AlphaSkia.Test")
.SetRuntime(TargetOperatingSystem.Current.DotNetRid + "-" +
(Architecture ?? Architecture.Current))
.SetFramework(Framework)
.AddProcessEnvironmentVariable("NUGET_PACKAGES", TemporaryDirectory / "packages")
);
Log.Information($"Running DotNet tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (FreeType fonts)");
DotNetTasks.DotNetRun(_ => _
.SetProcessWorkingDirectory(RootDirectory / "test" / "dotnet" / "AlphaSkia.Test")
.SetRuntime(TargetOperatingSystem.Current.DotNetRid + "-" +
(Architecture ?? Architecture.Current))
.SetFramework(Framework)
.AddProcessEnvironmentVariable("NUGET_PACKAGES", TemporaryDirectory / "packages")
.SetApplicationArguments("--freetype")
);
});

[Parameter] [Secret] readonly string NugetApiKey = GetVariable<string>("NUGET_API_KEY");
Expand Down
12 changes: 11 additions & 1 deletion build/Build.Java.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,24 @@ void JavaBuildInternal()
.DependsOn(PrepareGitHubArtifacts)
.Executes(() =>
{
Log.Debug("Testing with Java at {JavaHome} and version {AlphaSkiaTestVersion}", JavaHome, JavaVersion);
Log.Information("Testing with Java at {JavaHome} and version {AlphaSkiaTestVersion} (OS fonts)", JavaHome, JavaVersion);
GradlewTool("run",
environmentVariables: Variables
.ToDictionary(x => x.Key, x => x.Value)
.SetKeyValue("JAVA_HOME", JavaHome)
.SetKeyValue("ALPHASKIA_TEST_VERSION", JavaVersion)
.AsReadOnly(),
workingDirectory: RootDirectory / "test" / "java");
Log.Information("Testing with Java at {JavaHome} and version {AlphaSkiaTestVersion} (FreeType fonts)", JavaHome, JavaVersion);
GradlewTool("run --args=--freetype",
environmentVariables: Variables
.ToDictionary(x => x.Key, x => x.Value)
.SetKeyValue("JAVA_HOME", JavaHome)
.SetKeyValue("ALPHASKIA_TEST_VERSION", JavaVersion)
.AsReadOnly(),
workingDirectory: RootDirectory / "test" / "java");
});

void JavaWriteVersionInfoProperties()
Expand Down
8 changes: 8 additions & 0 deletions build/Build.Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,17 @@ void NodeWritePackageJson()
NpmTasks.NpmInstall(_ => _
.SetProcessWorkingDirectory(RootDirectory / "test" / "node")
.SetForce(true));
Log.Information("Testing with Node with (OS fonts)", JavaHome, JavaVersion);
NpmTasks.NpmRun(_ => _
.SetProcessWorkingDirectory(RootDirectory / "test" / "node")
.SetCommand("start"));
Log.Information("Testing with Node with (FreeType fonts)", JavaHome, JavaVersion);
NpmTasks.NpmRun(_ => _
.SetProcessWorkingDirectory(RootDirectory / "test" / "node")
.SetCommand("start")
.SetArguments("--freetype"));
});

void CopyNodeAddonsToPackages()
Expand Down
8 changes: 4 additions & 4 deletions lib/java/jni/include/alphaTab_alphaSkia_AlphaSkiaCanvas.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/java/jni/src/AlphaSkiaCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ extern "C"
return static_cast<jint>(alphaskia_get_color_type());
}

JNIEXPORT jint JNICALL Java_alphaTab_alphaSkia_AlphaSkiaCanvas_switchToFreeTypeFonts(JNIEnv *, jclass) {
JNIEXPORT void JNICALL Java_alphaTab_alphaSkia_AlphaSkiaCanvas_switchToFreeTypeFonts(JNIEnv *, jclass) {
alphaskia_switch_to_freetype_fonts();
}

JNIEXPORT jint JNICALL Java_alphaTab_alphaSkia_AlphaSkiaCanvas_switchToOperatingSystemFonts(JNIEnv *, jclass) {
JNIEXPORT void JNICALL Java_alphaTab_alphaSkia_AlphaSkiaCanvas_switchToOperatingSystemFonts(JNIEnv *, jclass) {
alphaskia_switch_to_operating_system_fonts();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ public native void fillText(String text, AlphaSkiaTypeface typeface, float fontS
* This results in a platform specific display of any rendered texts and allows using of any
* fonts installed on the system.
*/
public static native int switchToFreeTypeFonts();
public static native void switchToFreeTypeFonts();

/**
* Switches the rendering to use the FreeType font manager and font rendering.
* This results in a platform independent display of any rendered texts achieving consistent rendering.
* Operating system fonts cannot be used in this mode.
*/
public static native int switchToOperatingSystemFonts();
public static native void switchToOperatingSystemFonts();
}
2 changes: 1 addition & 1 deletion lib/node/alphaskia/src/AlphaSkiaCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class AlphaSkiaCanvas extends AlphaSkiaNative<AlphaSkiaCanvasHandle> {
* This results in a platform independent display of any rendered texts achieving consistent rendering.
* Operating system fonts cannot be used in this mode.
*/
public static SwitchToFreeTypeFonts(): void {
public static switchToFreeTypeFonts(): void {
loadAddon().alphaskia_switch_to_freetype_fonts();
}

Expand Down
1 change: 1 addition & 0 deletions test/dotnet/NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<add key="repositoryPath" value="../../.nuke/temp/packages" />
</config>
<packageSources>
<clear />
<add key="local" value="../../dist/nupkgs" />
</packageSources>
</configuration>
4 changes: 4 additions & 0 deletions test/java/src/main/java/alphaTab/alphaSkia/test/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import java.nio.file.Path;
import java.nio.file.Paths;

import java.util.*;
import java.util.stream.*;


public class Main {
private static Path findRepositoryRoot(Path current) {
if (current.resolve(".nuke").toFile().exists()) {
Expand Down

0 comments on commit ffab19f

Please sign in to comment.