Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Mar 12, 2024
2 parents c41bfb7 + 8e0d1ea commit 1ba5711
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 @@ -34,14 +35,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 @@ -51,11 +60,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 @@ -68,7 +78,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 1ba5711

Please sign in to comment.