Added a better error message if ghdl is not installed.

This commit is contained in:
hneemann 2018-03-20 21:09:24 +01:00
parent eb620d1f57
commit 3e839a54ec
3 changed files with 25 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.extern.handler.ProcessInterface;
import de.neemann.digital.core.extern.handler.StdIOInterface;
import de.neemann.digital.gui.Settings;
import de.neemann.digital.lang.Lang;
import java.io.File;
import java.io.IOException;
@ -34,10 +35,22 @@ public class ApplicationGHDL extends ApplicationVHDLStdIO {
} catch (IOException e) {
if (file != null)
ProcessStarter.removeFolder(file.getParentFile());
if (ghdlNotFound(e))
throw new IOException(Lang.get("err_ghdlNotInstalled"));
else
throw e;
}
}
private boolean ghdlNotFound(Throwable e) {
while (e != null) {
if (e instanceof ProcessStarter.CouldNotStartProcessException)
return true;
e = e.getCause();
}
return false;
}
@Override
public boolean checkSupported() {
return true;
@ -53,6 +66,11 @@ public class ApplicationGHDL extends ApplicationVHDLStdIO {
String m1 = ProcessStarter.start(file.getParentFile(), ghdl, "-a", "--ieee=synopsys", file.getName());
String m2 = ProcessStarter.start(file.getParentFile(), ghdl, "-e", "--ieee=synopsys", "stdIOInterface");
return ProcessStarter.joinStrings(m1, m2);
} catch (IOException e) {
if (ghdlNotFound(e))
throw new IOException(Lang.get("err_ghdlNotInstalled"));
else
throw e;
} finally {
if (file != null)
ProcessStarter.removeFolder(file.getParentFile());

View File

@ -880,6 +880,9 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="err_ifExternalComponentIsUsedTwiceCodeMustBeIdentical">Wird eine externes Element mehrfach verwendet, muss der Code identisch sein!</string>
<string name="err_writingToStdOut_O">Konnte nicht auf stdOut schreiben:
{0}</string>
<string name="err_ghdlNotInstalled">
Der VHDL Simulator ghdl scheint nicht installiert zu sein. Installieren Sie ghdl (http://ghdl.free.fr/) und versuchen Sie es erneut. Sollte es immer noch Probleme geben, überprüfen Sie den Pfad zur ausfühbaren ghdl-Datei in den Digital-Einstellungen.
</string>
<string name="key_AddrBits">Adress-Bits</string><!-- ROM, RAMDualPort, RAMSinglePort, RAMSinglePortSel, EEPROM -->
<string name="key_AddrBits_tt">Anzahl der Adress-Bits, die verwendet werden.</string>

View File

@ -875,6 +875,9 @@
<string name="err_ifExternalComponentIsUsedTwiceCodeMustBeIdentical">If an external component is used multiple times, the code must be identical!</string>
<string name="err_writingToStdOut_O">Could not write to stdOut:
{0}</string>
<string name="err_ghdlNotInstalled">
The VHDL simulator ghdl does not seem to be installed. Install ghdl (http://ghdl.free.fr/) and try again. If there are still problems, check the path to the ghdl executable in the Digital settings.
</string>
<string name="key_AddrBits">Address Bits</string><!-- ROM, RAMDualPort, RAMSinglePort, RAMSinglePortSel, EEPROM -->
<string name="key_AddrBits_tt">Number of address bits used.</string>