Skip to content

Commit

Permalink
feat: add support for Linux ppc64le & riscv64
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi committed Nov 10, 2023
1 parent e0824f1 commit 4598479
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 14 deletions.
10 changes: 10 additions & 0 deletions client/routes/customize/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ function getInitialConfig(): BuildStore {
title: 'Linux arm32',
since: Version.LWJGL323,
},
[Native.LinuxPPC64LE]: {
id: Native.LinuxPPC64LE,
title: 'Linux ppc64le',
since: Version.LWJGL334,
},
[Native.LinuxRISCV64]: {
id: Native.LinuxRISCV64,
title: 'Linux riscv64',
since: Version.LWJGL334,
},
[Native.MacOS]: {
id: Native.MacOS,
title: 'macOS x64',
Expand Down
4 changes: 4 additions & 0 deletions client/routes/customize/lib/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ function pathToNative(folder: string): Native | null {
return Native.LinuxARM64;
case 'linux-arm32':
return Native.LinuxARM32;
case 'linux-ppc64le':
return Native.LinuxPPC64LE;
case 'linux-riscv64':
return Native.LinuxRISCV64;
case 'macos':
return Native.MacOS;
case 'macos-arm64':
Expand Down
2 changes: 2 additions & 0 deletions client/routes/customize/lib/getPlatformIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const getPlatformIcon = (platform: Native) => {
case Native.Linux:
case Native.LinuxARM64:
case Native.LinuxARM32:
case Native.LinuxPPC64LE:
case Native.LinuxRISCV64:
return <Icon aria-label="Linux" name="fa/brands/linux" key={`fa-${platform}`} />;
case Native.MacOS:
case Native.MacOSARM64:
Expand Down
28 changes: 21 additions & 7 deletions client/routes/customize/lib/gradle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ScriptState } from '../BuildScript';
import { Language, BuildType } from '../types';
import type { Addon, BindingDefinition, PlatformSelection } from '../types';
import { generateDependencies, getVersion, isNativeApplicableToAllPlatforms } from './script';
import {generateDependencies, getLinuxSuffix, getVersion, isNativeApplicableToAllPlatforms} from './script';
import { versionNum } from '../reducer';

export function generateGradle({
Expand Down Expand Up @@ -45,7 +45,12 @@ export function generateGradle({
script += '\n\n';
}
if (platformSingle === null) {
const linuxArches = +platform.linux + +platform['linux-arm64'] + +platform['linux-arm32'];
const linuxArches =
+platform.linux +
+platform['linux-arm64'] +
+platform['linux-arm32'] +
+platform['linux-ppc64le'] +
+platform['linux-riscv64'];
const macosArches = +platform.macos + +platform['macos-arm64'];
const windowsArches = +platform.windows + +platform['windows-x86'] + +platform['windows-arm64'];
if (language === Language.Groovy) {
Expand All @@ -55,14 +60,19 @@ export function generateGradle({
linuxArches == 1
? `
\tcase OperatingSystem.LINUX:
\t\tproject.ext.lwjglNatives = "natives-linux${platform.linux ? '' : platform['linux-arm64'] ? '-arm64' : '-arm32'}"
\t\tproject.ext.lwjglNatives = "natives-linux${getLinuxSuffix(platform)}"
\t\tbreak`
: `
\tcase OperatingSystem.LINUX:
\t\tproject.ext.lwjglNatives = "natives-linux"
\t\tdef osArch = System.getProperty("os.arch")
\t\tproject.ext.lwjglNatives = osArch.startsWith("arm") || osArch.startsWith("aarch64")
\t\t\t? "natives-linux-\${osArch.contains("64") || osArch.startsWith("armv8") ? "arm64" : "arm32"}"
\t\t\t: "natives-linux"
\t\tif (osArch.startsWith("arm") || osArch.startsWith("aarch64")) {
\t\t\tproject.ext.lwjglNatives += osArch.contains("64") || osArch.startsWith("armv8") ? "-arm64" : "-arm32"
\t\t} else if (osArch.startsWith("ppc")) {
\t\t\tproject.ext.lwjglNatives += "-ppc64le"
\t\t} else if (osArch.startsWith("riscv")) {
\t\t\tproject.ext.lwjglNatives += "-riscv64"
\t\t}
\t\tbreak`;
}
if (macosArches != 0) {
Expand Down Expand Up @@ -102,10 +112,14 @@ export function generateGradle({
script +=
linuxArches == 1
? `\n\t\tarrayOf("Linux", "FreeBSD", "SunOS", "Unit").any { name.startsWith(it) } ->
\t\t\t"natives-linux${platform.linux ? '' : platform['linux-arm64'] ? '-arm64' : '-arm32'}"`
\t\t\t"natives-linux${getLinuxSuffix(platform)}"`
: `\n\t\tarrayOf("Linux", "FreeBSD", "SunOS", "Unit").any { name.startsWith(it) } ->
\t\t\tif (arrayOf("arm", "aarch64").any { arch.startsWith(it) })
\t\t\t\t"natives-linux\${if (arch.contains("64") || arch.startsWith("armv8")) "-arm64" else "-arm32"}"
\t\t\telse if (arch.startsWith("ppc"))
\t\t\t\t"natives-linux-ppc64le"
\t\t\telse if (arch.startsWith("riscv"))
\t\t\t\t"natives-linux-riscv64"
\t\t\telse
\t\t\t\t"natives-linux"`;
}
Expand Down
35 changes: 28 additions & 7 deletions client/routes/customize/lib/ivy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ScriptState } from '../BuildScript';
import { BuildType } from '../types';
import {BuildType} from '../types';
import type { Addon } from '../types';
import { generateDependencies, getArtifactName, getVersion, isNativeApplicableToAllPlatforms } from './script';
import {generateDependencies, getArtifactName, getLinuxSuffix, getVersion, isNativeApplicableToAllPlatforms} from './script';

export function generateIvy({
build,
Expand Down Expand Up @@ -51,20 +51,23 @@ export function generateIvy({

if (platformSingle === null) {
script += `<!-- Add to build.xml -->`;
const linuxArches = +platform.linux + +platform['linux-arm64'] + +platform['linux-arm32'];
const linuxArches =
+platform.linux +
+platform['linux-arm64'] +
+platform['linux-arm32'] +
+platform['linux-ppc64le'] +
+platform['linux-riscv64'];
if (linuxArches !== 0) {
if (linuxArches === 1) {
script += `
<condition property="lwjgl.natives" value="natives-linux${
platform.linux ? '' : platform['linux-arm64'] ? '-arm64' : '-arm32'
}">${nl2}<os name="Linux"/>${nl1}</condition>`;
<condition property="lwjgl.natives" value="natives-linux${getLinuxSuffix(platform)}">${nl2}<os name="Linux"/>${nl1}</condition>`;
} else {
if (platform.linux) {
script += `
<condition property="lwjgl.natives" value="natives-linux">
\t<and>
\t\t<os name="Linux"/>
\t\t<not><matches string="\${os.arch}" pattern="^(arm|aarch64)"/></not>
\t\t<not><matches string="\${os.arch}" pattern="^(arm|aarch64|ppc|riscv)"/></not>
\t</and>
</condition>`;
}
Expand All @@ -86,6 +89,24 @@ export function generateIvy({
\t\t<matches string="\${os.arch}" pattern="^arm"/>
\t\t<not><matches string="\${os.arch}" pattern="64|^armv8"/></not>
\t</and>
</condition>`;
}
if (platform['linux-ppc64le']) {
script += `
<condition property="lwjgl.natives" value="natives-linux-ppc64le">
\t<and>
\t\t<os name="Linux"/>
\t\t<matches string="\${os.arch}" pattern="^ppc"/>
\t</and>
</condition>`;
}
if (platform['linux-riscv64']) {
script += `
<condition property="lwjgl.natives" value="natives-linux-riscv64">
\t<and>
\t\t<os name="Linux"/>
\t\t<matches string="\${os.arch}" pattern="^riscv"/>
\t</and>
</condition>`;
}
}
Expand Down
6 changes: 6 additions & 0 deletions client/routes/customize/lib/maven.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export function generateMaven({
script += generateProfile(Native.Linux, 'unix', 'arm', 'natives-linux-arm32');
script += generateProfile(Native.Linux, 'unix', 'arm32', 'natives-linux-arm32');
}
if (platform['linux-ppc64le']) {
script += generateProfile(Native.Linux, 'unix', 'ppc64le', 'natives-linux-ppc64le');
}
if (platform['linux-riscv64']) {
script += generateProfile(Native.Linux, 'unix', 'riscv64', 'natives-linux-riscv64');
}
if (platform.macos) {
script += generateProfile(Native.MacOS, 'mac', 'x86_64', 'natives-macos');
}
Expand Down
19 changes: 19 additions & 0 deletions client/routes/customize/lib/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ export function getSelectedPlatforms(natives: Array<Native>, platform: PlatformS
return result;
}

export function getLinuxSuffix(platform: PlatformSelection): string {
if (platform.linux) {
return '';
}
if (platform['linux-arm64']) {
return '-arm64';
}
if (platform['linux-arm32']) {
return '-arm64';
}
if (platform['linux-ppc64le']) {
return '-ppc64le';
}
if (platform['linux-riscv64']) {
return '-riscv64';
}
throw 'no linux platform selected';
}

export function generateScript(mode: Mode, state: ScriptState): string {
switch (mode) {
case Mode.Maven:
Expand Down

0 comments on commit 4598479

Please sign in to comment.