Skip to content

Commit

Permalink
Add linux arm64 (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Jan 13, 2024
1 parent b31e0bc commit 54e6b08
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
- os: ubuntu-22.04
artifact-name: Linux
build-options: "-PlinuxBuild"
- os: ubuntu-22.04
artifact-name: LinuxArm64
build-options: "-PlinuxBuildArm64"
- os: macos-latest
artifact-name: macOS
build-options: "-PmacBuild"
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gradlew generateInstallers -PXmx3072m -PlinuxBuild -PjenkinsBuild
``-PlinuxBuild`` can be replaced with the OS of your choice to build.

- ``-PlinuxBuild``
- ``-PlinuxBuildArm64``
- ``-PmacBuild``
- ``-PmacBuildArm``
- ``-PwindowsBuild``
Expand Down
1 change: 1 addition & 0 deletions WPILibInstaller-Avalonia/Models/UpgradeConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class UpgradeConfig

public const string WindowsInstallerType = "Windows";
public const string LinuxInstallerType = "Linux";
public const string LinuxArm64InstallerType = "LinuxArm64";
public const string MacInstallerType = "Mac";
public const string MacArmInstallerType = "MacArm";

Expand Down
4 changes: 4 additions & 0 deletions WPILibInstaller-Avalonia/Models/VsCodeConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public class VsCodeConfig
public string VsCodeLinuxName { get; set; }
public string VsCodeLinuxHash { get; set; }

public string VsCodeLinuxArm64Url { get; set; }
public string VsCodeLinuxArm64Name { get; set; }
public string VsCodeLinuxArm64Hash { get; set; }

public string VsCodeVersion { get; set; }

[JsonProperty("wpilibExtension")]
Expand Down
5 changes: 5 additions & 0 deletions WPILibInstaller-Avalonia/Utils/PlatformUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public enum Platform
{
Win64,
Linux64,
LinuxArm64,
Mac64,
MacArm64,
Invalid
Expand All @@ -29,6 +30,10 @@ static PlatformUtils()
{
CurrentPlatform = Platform.Linux64;
}
else if (currentArch == Architecture.Arm64)
{
CurrentPlatform = Platform.LinuxArm64;
}
return;
}

Expand Down
55 changes: 35 additions & 20 deletions WPILibInstaller-Avalonia/ViewModels/InstallPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,25 @@ public override PageViewModelBase MoveNext()
private ValueTask<string> SetVsCodePortableMode()
{
string portableFolder = Path.Combine(configurationProvider.InstallDirectory, "vscode");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
portableFolder = Path.Combine(portableFolder, "VSCode-linux-x64", "data");
}
else if (OperatingSystem.IsMacOS())
{
portableFolder = Path.Combine(portableFolder, "code-portable-data");
}
else

var currentPlatform = PlatformUtils.CurrentPlatform;
switch (currentPlatform)
{
portableFolder = Path.Combine(portableFolder, "data");
case Platform.Win64:
portableFolder = Path.Combine(portableFolder, "data");
break;
case Platform.MacArm64:
case Platform.Mac64:
portableFolder = Path.Combine(portableFolder, "code-portable-data");
break;
case Platform.Linux64:
portableFolder = Path.Combine(portableFolder, "VSCode-linux-x64", "data");
break;
case Platform.LinuxArm64:
portableFolder = Path.Combine(portableFolder, "VSCode-linux-arm64", "data");
break;
default:
throw new PlatformNotSupportedException("Invalid platform");
}

try
Expand Down Expand Up @@ -657,17 +665,24 @@ private async Task RunVsCodeExtensionsSetup()

string codeExe;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
codeExe = Path.Combine(configurationProvider.InstallDirectory, "vscode", "bin", "code.cmd");
}
else if (OperatingSystem.IsMacOS())
var currentPlatform = PlatformUtils.CurrentPlatform;
switch (currentPlatform)
{
codeExe = Path.Combine(configurationProvider.InstallDirectory, "vscode", "Visual Studio Code.app", "Contents", "Resources", "app", "bin", "code");
}
else
{
codeExe = Path.Combine(configurationProvider.InstallDirectory, "vscode", "VSCode-linux-x64", "bin", "code");
case Platform.Win64:
codeExe = Path.Combine(configurationProvider.InstallDirectory, "vscode", "bin", "code.cmd");
break;
case Platform.MacArm64:
case Platform.Mac64:
codeExe = Path.Combine(configurationProvider.InstallDirectory, "vscode", "Visual Studio Code.app", "Contents", "Resources", "app", "bin", "code");
break;
case Platform.Linux64:
codeExe = Path.Combine(configurationProvider.InstallDirectory, "vscode", "VSCode-linux-x64", "bin", "code");
break;
case Platform.LinuxArm64:
codeExe = Path.Combine(configurationProvider.InstallDirectory, "vscode", "VSCode-linux-arm64", "bin", "code");
break;
default:
throw new PlatformNotSupportedException("Invalid platform");
}

// Load existing extensions
Expand Down
17 changes: 13 additions & 4 deletions WPILibInstaller-Avalonia/ViewModels/StartPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ private async Task<bool> SelectResourceFilesWithFile(string file)
}) ?? throw new InvalidOperationException("Not Valid");
}


entry = zipArchive.GetEntry("upgradeConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
Expand Down Expand Up @@ -256,7 +255,6 @@ private async Task<bool> SelectResourceFilesWithFile(string file)

private string? CheckInstallerType()
{
// TODO Handle Arm someday
if (OperatingSystem.IsWindows())
{
if (UpgradeConfig.InstallerType != UpgradeConfig.WindowsInstallerType)
Expand Down Expand Up @@ -284,9 +282,19 @@ private async Task<bool> SelectResourceFilesWithFile(string file)
}
else if (OperatingSystem.IsLinux())
{
if (UpgradeConfig.InstallerType != UpgradeConfig.LinuxInstallerType)
if (PlatformUtils.CurrentPlatform == Platform.LinuxArm64)
{
if (UpgradeConfig.InstallerType != UpgradeConfig.LinuxArm64InstallerType)
{
return UpgradeConfig.LinuxArm64InstallerType;
}
}
else
{
return UpgradeConfig.LinuxInstallerType;
if (UpgradeConfig.InstallerType != UpgradeConfig.LinuxInstallerType)
{
return UpgradeConfig.LinuxInstallerType;
}
}
}
else
Expand Down Expand Up @@ -364,6 +372,7 @@ public VsCodeModel VsCodeModel
VsCodeModel model = new VsCodeModel(VsCodeConfig.VsCodeVersion);
model.Platforms.Add(Utils.Platform.Win64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeWindowsUrl, VsCodeConfig.VsCodeWindowsName, VsCodeConfig.VsCodeWindowsHash));
model.Platforms.Add(Utils.Platform.Linux64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeLinuxUrl, VsCodeConfig.VsCodeLinuxName, VsCodeConfig.VsCodeLinuxHash));
model.Platforms.Add(Utils.Platform.LinuxArm64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeLinuxArm64Url, VsCodeConfig.VsCodeLinuxArm64Name, VsCodeConfig.VsCodeLinuxArm64Hash));
model.Platforms.Add(Utils.Platform.Mac64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeMacUrl, VsCodeConfig.VsCodeMacName, VsCodeConfig.VsCodeMacHash));
model.Platforms.Add(Utils.Platform.MacArm64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeMacUrl, VsCodeConfig.VsCodeMacName, VsCodeConfig.VsCodeMacHash));
return model;
Expand Down
14 changes: 12 additions & 2 deletions WPILibInstaller-Avalonia/ViewModels/VSCodePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public double ProgressBar3

private double progressBar3 = 0;

public double ProgressBar4
{
get => progressBar4;
set => this.RaiseAndSetIfChanged(ref progressBar4, value);
}

private double progressBar4 = 0;

public string DoneText
{
get => doneText;
Expand Down Expand Up @@ -267,14 +275,16 @@ private async Task DownloadVsCodeFunc()

var win64 = DownloadToMemoryStream(Platform.Win64, Model.Platforms[Platform.Win64].DownloadUrl, (d) => ProgressBar1 = d);
var linux64 = DownloadToMemoryStream(Platform.Linux64, Model.Platforms[Platform.Linux64].DownloadUrl, (d) => ProgressBar2 = d);
var mac64 = DownloadToMemoryStream(Platform.Mac64, Model.Platforms[Platform.Mac64].DownloadUrl, (d) => ProgressBar3 = d);
var linuxArm64 = DownloadToMemoryStream(Platform.LinuxArm64, Model.Platforms[Platform.LinuxArm64].DownloadUrl, (d) => ProgressBar3 = d);
var mac64 = DownloadToMemoryStream(Platform.Mac64, Model.Platforms[Platform.Mac64].DownloadUrl, (d) => ProgressBar4 = d);

var results = await Task.WhenAll(win64, linux64, mac64);
var results = await Task.WhenAll(win64, linux64, linuxArm64, mac64);

try
{
File.Delete(Path.Join(file, Model.Platforms[Platform.Win64].NameInZip));
File.Delete(Path.Join(file, Model.Platforms[Platform.Linux64].NameInZip));
File.Delete(Path.Join(file, Model.Platforms[Platform.LinuxArm64].NameInZip));
File.Delete(Path.Join(file, Model.Platforms[Platform.Mac64].NameInZip));
}
catch
Expand Down
1 change: 1 addition & 0 deletions WPILibInstaller-Avalonia/Views/VSCodePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ We strongly recommend using WPILib's VS Code instead of the system one or a sepa
<ProgressBar Value="{Binding ProgressBar1}" IsVisible="{Binding ProgressBar1Visible}" Margin="0,2,0,0" MinWidth="20" />
<ProgressBar Value="{Binding ProgressBar2}" IsVisible="{Binding ProgressBarAllVisible}" Margin="0,2,0,0" MinWidth="20" />
<ProgressBar Value="{Binding ProgressBar3}" IsVisible="{Binding ProgressBarAllVisible}" Margin="0,2,0,0" MinWidth="20" />
<ProgressBar Value="{Binding ProgressBar4}" IsVisible="{Binding ProgressBarAllVisible}" Margin="0,2,0,0" MinWidth="20" />
</StackPanel>
</Grid>
</Grid>
Expand Down
4 changes: 0 additions & 4 deletions apps/ToolsUpdater/src/main/java/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ private static void installJavaTool(ToolConfig tool, String toolsPath) {
}
}

private static final String arm32arch = "arm32";
private static final String arm64arch = "arm64";
private static final String x64arch = "x86-64";
private static final String x86arch = "x86";
Expand All @@ -50,9 +49,6 @@ private static String desktopArch() {
if (arch.equals("arm64") || arch.equals("aarch64")) {
return arm64arch;
}
if (arch.equals("arm32") || arch.equals("arm")) {
return arm32arch;
}
return (arch.equals("amd64") || arch.equals("x86_64")) ? x64arch : x86arch;
}

Expand Down
20 changes: 19 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ println pubVersion

project.ext.setProperty('toolchain-optional-roboRio', '')

if (OperatingSystem.current().isWindows()) {
project.ext.currentClassifier = 'windowsx86-64'
} else if (OperatingSystem.current().isMacOsX()) {
project.ext.currentClassifier = 'osxuniversal'
} else {
project.ext.currentClassifier = 'linuxx86-64'
}

if (project.hasProperty('linuxBuild')) {
project.ext.forcePlatform = 'linuxx86'
project.ext.forcePlatform = 'linuxx86-64'
project.ext.forceNativeClassifier = 'linuxx86-64'
project.ext.forceToolsClassifier = 'linuxx64'
project.ext.forceCppToolsClassifier = 'linuxx86-64'
Expand All @@ -43,6 +51,16 @@ if (project.hasProperty('linuxBuild')) {
project.ext.archiveType = Tar
project.ext.isUnix = true
project.ext.dotnetRuntime = 'linux-x64'
} else if (project.hasProperty('linuxBuildArm64')) {
project.ext.forcePlatform = 'linuxarm64'
project.ext.forceNativeClassifier = 'linuxarm64'
project.ext.forceToolsClassifier = 'linuxarm64'
project.ext.forceCppToolsClassifier = 'linuxarm64'
project.ext.buildClassifier = 'LinuxArm64'
offlineRepositoryRoot = "$buildDir/dependencies/linuxarm64"
project.ext.archiveType = Tar
project.ext.isUnix = true
project.ext.dotnetRuntime = 'linux-arm64'
} else if (project.hasProperty('macBuild')) {
project.ext.forcePlatform = 'osx'
project.ext.forceNativeClassifier = 'osxuniversal'
Expand Down
36 changes: 36 additions & 0 deletions scripts/jdk.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ def downloadLinuxJdk = tasks.register('downloadLinuxJdk', Download) {
overwrite false
}

def downloadLinuxArm64Jdk = tasks.register('downloadLinuxJdkArm64', Download) {
src "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$jdkVersionEscaped/OpenJDK17U-jdk_aarch64_linux_hotspot_${jdkVersionUnderscore}.tar.gz"
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite false
}

def downloadMacJdk = tasks.register('downloadMacJdk', Download) {
src "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$jdkVersionEscaped/OpenJDK17U-jdk_x64_mac_hotspot_${jdkVersionUnderscore}.tar.gz"
def fileName = file(src.file).name
Expand Down Expand Up @@ -151,6 +158,33 @@ ext.jdkZipSetupLinux = { AbstractArchiveTask zip->
}
}

ext.jdkZipSetupLinuxArm64 = { AbstractArchiveTask zip->
zip.dependsOn downloadLinuxArm64Jdk
zip.dependsOn jdkConfigFileTask

zip.inputs.files downloadLinuxArm64Jdk.get().outputFiles
zip.inputs.file jdkConfigFile

zip.from(project.tarTree(project.resources.gzip(downloadLinuxArm64Jdk.get().outputFiles.first()))) {
eachFile { f->
f.path = f.path.replace("jdk-${jdkVersion}/", 'jdk/')
}

exclude '**/bin/*.pdb'
exclude '**/bin/*.map'
exclude '**/bin/server/*.pdb'
exclude '**/bin/server/*.map'
exclude '**/demo/**'

includeEmptyDirs = false
}

zip.from(jdkConfigFile) {
into '/installUtils'
rename {'jdkConfig.json'}
}
}

ext.jdkZipSetupMac = { AbstractArchiveTask zip->
zip.dependsOn downloadMacJdk
zip.dependsOn jdkConfigFileTask
Expand Down Expand Up @@ -214,6 +248,8 @@ ext.jdkZipSetupMacArm = { AbstractArchiveTask zip->
ext.jdkZipSetup = { AbstractArchiveTask zip ->
if (project.hasProperty('linuxBuild')) {
jdkZipSetupLinux(zip)
} else if (project.hasProperty('linuxBuildArm64')) {
jdkZipSetupLinuxArm64(zip)
} else if (project.hasProperty('macBuild')) {
jdkZipSetupMac(zip)
} else if (project.hasProperty('macBuildArm')) {
Expand Down
11 changes: 6 additions & 5 deletions scripts/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def cppToolsArtifacts = [
'edu.wpi.first.tools:SysId'
]

def skipMacArmTools = [
def skipNewPlatformTools = [
'edu.wpi.first.tools:SmartDashboard'
]

Expand Down Expand Up @@ -64,8 +64,8 @@ def lazyEvaluator = tasks.register('lazyModelEvaluation') {
return
}

if (project.hasProperty('macBuildArm')) {
skipMacArmTools.each { tool->
if (project.hasProperty('macBuildArm') || project.hasProperty('linuxBuildArm64')) {
skipNewPlatformTools.each { tool->
if ("$dep.groupId:$dep.artifactId" == tool) {
def depString = "$dep.groupId:$dep.artifactId:$dep.version:$dep.classifier@$dep.extension"
println "Skipping because arm " + depString
Expand Down Expand Up @@ -120,8 +120,9 @@ def lazyEvaluator = tasks.register('lazyModelEvaluation') {
println dep
if (dep.classifier == null) {
offline "$dep.groupId:$dep.artifactId:$dep.version:@$dep.extension"
} else if (dep.classifier.startsWith(project.ext.forcePlatform)) {
offline "$dep.groupId:$dep.artifactId:$dep.version:$dep.classifier@$dep.extension"
} else if (dep.classifier.startsWith(project.ext.currentClassifier)) {
def newClassifier = dep.classifier.replace(project.ext.currentClassifier, project.ext.forceNativeClassifier)
offline "$dep.groupId:$dep.artifactId:$dep.version:$newClassifier@$dep.extension"
} else if (dep.classifier.contains('athena')) {
offline "$dep.groupId:$dep.artifactId:$dep.version:$dep.classifier@$dep.extension"
} else if (dep.classifier.contains('headers')) {
Expand Down
Loading

0 comments on commit 54e6b08

Please sign in to comment.