Evaluate RunnerPaths.getDefaultRunnerAbsolutePath

This commit is contained in:
Peter Dell 2023-08-30 21:35:04 +02:00
parent 6472440284
commit 1febfd4b1f
3 changed files with 32 additions and 8 deletions

View File

@ -77,6 +77,7 @@ import com.wudsn.ide.lng.preferences.CompilerRunPreferences;
import com.wudsn.ide.lng.runner.Runner;
import com.wudsn.ide.lng.runner.RunnerDefinition;
import com.wudsn.ide.lng.runner.RunnerId;
import com.wudsn.ide.lng.runner.RunnerPaths.RunnerPath;
import com.wudsn.ide.lng.symbol.CompilerSymbolsView;
/**
@ -605,11 +606,15 @@ final class LanguageEditorCompileCommand {
}
}
}
// Execution type: pre-defined or USER_DEFINED_APPLICATION
// Execution type: predefined or USER_DEFINED_APPLICATION
else {
boolean error = false;
String runnerExecutablePath = compilerRunPreferences.getRunnerExecutablePath(runnerId);
if (StringUtility.isEmpty(runnerExecutablePath)) {
runnerExecutablePath = plugin.getRunnerPaths().getDefaultRunnerAbsolutePath(hardware, runnerId);
}
if (runnerCommandLine.contains(RunnerDefinition.RUNNER_EXECUTABLE_PATH)) {
if (StringUtility.isEmpty(runnerExecutablePath)) {
// ERROR: Path to application executable is not

View File

@ -43,6 +43,7 @@ import com.wudsn.ide.lng.Texts;
import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferences;
import com.wudsn.ide.lng.runner.RunnerDefinition;
import com.wudsn.ide.lng.runner.RunnerId;
import com.wudsn.ide.lng.runner.RunnerPaths.RunnerPath;
import com.wudsn.ide.lng.runner.RunnerRegistry;
/**
@ -52,8 +53,7 @@ import com.wudsn.ide.lng.runner.RunnerRegistry;
* @author Peter Dell
*
*/
public final class LanguageEditorCompileCommandDelegate
implements IActionDelegate2, IWorkbenchWindowPulldownDelegate2 {
public final class LanguageEditorCompileCommandDelegate implements IActionDelegate2, IWorkbenchWindowPulldownDelegate2 {
private IWorkbenchWindow window;
private Menu menu;
@ -110,7 +110,8 @@ public final class LanguageEditorCompileCommandDelegate
RunnerRegistry runnerRegistry = languagePlugin.getRunnerRegistry();
Hardware hardware = languageEditor.getHardware();
List<RunnerDefinition> runnerDefinitions = runnerRegistry.getDefinitions(hardware);
LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences = languageEditor.getLanguageHardwareCompilerPreferences();
LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences = languageEditor
.getLanguageHardwareCompilerPreferences();
Menu menu = new Menu(parent);
setMenu(menu);
@ -123,8 +124,15 @@ public final class LanguageEditorCompileCommandDelegate
String runnerName = runnerDefinition.getName();
// The system default application does not need an executable path.
if (!runnerId.equals(RunnerId.DEFAULT_APPLICATION)) {
if (StringUtility.isEmpty(languageHardwareCompilerDefinitionPreferences.getRunnerExecutablePath(runnerId))) {
continue;
// Explicit path configured?
if (StringUtility
.isEmpty(languageHardwareCompilerDefinitionPreferences.getRunnerExecutablePath(runnerId))) {
// Executable present in default path?
String executablePath = languagePlugin.getRunnerPaths().getDefaultRunnerAbsolutePath(hardware,
runnerId);
if (StringUtility.isEmpty(executablePath)) {
continue;
}
}
}

View File

@ -83,9 +83,9 @@ public final class RunnerPaths {
public RunnerPaths() {
runnerPaths = new TreeMap<String, RunnerPath>();
// See https://github.com/peterdell/wudsn-ide-tools
add(Hardware.ATARI8BIT, "altirra", Platform.OS_LINUX,Platform.ARCH_X86_64, "Altirra/Altirra.sh");
add(Hardware.ATARI8BIT, "altirra", Platform.OS_LINUX, Platform.ARCH_X86_64, "Altirra/Altirra.sh");
add(Hardware.ATARI8BIT, "altirra", Platform.OS_MACOSX, Platform.ARCH_X86_64, "Altirra/Altirra.sh");
add(Hardware.ATARI8BIT, "altirra", Platform.OS_WIN32,Platform.ARCH_X86, "Altirra/Altirra.exe");
add(Hardware.ATARI8BIT, "altirra", Platform.OS_WIN32, Platform.ARCH_X86, "Altirra/Altirra.exe");
add(Hardware.ATARI8BIT, "altirra", Platform.OS_WIN32, Platform.ARCH_X86_64, "Altirra/Altirra64.exe");
}
@ -114,6 +114,17 @@ public final class RunnerPaths {
return runnerPath;
}
public String getDefaultRunnerAbsolutePath(Hardware hardware, String runnerId) {
RunnerPath runnerPath = getDefaultRunnerPath(hardware, runnerId);
if (runnerPath != null) {
File file = runnerPath.getAbsoluteFile();
if (file != null && file.canExecute()) {
return file.getAbsolutePath();
}
}
return "";
}
public List<RunnerPath> getRunnerPaths() {
return Collections.unmodifiableList(new ArrayList<RunnerPath>(runnerPaths.values()));
}