Skip to content

Commit

Permalink
fix linux
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Mar 10, 2024
1 parent bae3dbe commit 8e0d1ea
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/OneWare.Quartus/QuartusModule.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reactive.Linq;
using System.Runtime.InteropServices;
using CommunityToolkit.Mvvm.Input;
using Microsoft.CodeAnalysis;
Expand Down Expand Up @@ -31,14 +32,22 @@ public void OnInitialized(IContainerProvider containerProvider)
containerProvider.Resolve<FpgaService>().RegisterToolchain<QuartusToolchain>();
containerProvider.Resolve<FpgaService>().RegisterLoader<QuartusLoader>();

settingsService.RegisterTitledPath("Tools", "Quartus", "Quartus_Path", "Quartus Path",
"Sets the path for Quartus", Path.Combine(Path.GetPathRoot(Environment.SystemDirectory) ?? "",
var defaultQuartusPath = PlatformHelper.Platform switch
{
PlatformId.LinuxX64 or PlatformId.LinuxArm64 => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"intelFPGA_lite", "18.1",
"quartus"), null, null, IsQuartusPathValid);
"quartus"),
_ => Path.Combine(Path.GetPathRoot(Environment.SystemDirectory) ?? "",
"intelFPGA_lite", "18.1",
"quartus")
};

settingsService.RegisterTitledPath("Tools", "Quartus", "Quartus_Path", "Quartus Path",
"Sets the path for Quartus", defaultQuartusPath, null, null, IsQuartusPathValid);

string? environmentPathSetting;

settingsService.GetSettingObservable<string>("Quartus_Path").Subscribe(x =>
settingsService.GetSettingObservable<string>("Quartus_Path").Skip(1).Subscribe(x =>
{
if (string.IsNullOrEmpty(x)) return;
Expand All @@ -48,11 +57,12 @@ public void OnInitialized(IContainerProvider containerProvider)
return;
}
var binPath = Path.Combine(x, "bin64");
var binPath = Path.Combine(x, "bin");
var bin64Path = Path.Combine(x, "bin64");
environmentPathSetting = PlatformHelper.Platform switch
{
PlatformId.WinX64 or PlatformId.WinArm64 => $";{binPath};",
PlatformId.WinX64 or PlatformId.WinArm64 => $";{bin64Path};",
_ => $":{binPath}:"
};
Expand All @@ -65,7 +75,8 @@ public void OnInitialized(IContainerProvider containerProvider)
private static bool IsQuartusPathValid(string path)
{
if (!Directory.Exists(path)) return false;
if (!File.Exists(Path.Combine(path, "bin64", $"quartus_pgm{PlatformHelper.ExecutableExtension}"))) return false;
if (!File.Exists(Path.Combine(path, "bin64", $"quartus_pgm{PlatformHelper.ExecutableExtension}"))
&& !File.Exists(Path.Combine(path, "bin", $"quartus_pgm{PlatformHelper.ExecutableExtension}"))) return false;
return true;
}
}

0 comments on commit 8e0d1ea

Please sign in to comment.