Skip to content

Commit

Permalink
Eyaml/Compiler Targets Stability (#64)
Browse files Browse the repository at this point in the history
Add a safety net for erroneous or non-compliant compiler eyaml descriptions that keeps the plugin still in a usable state. Also look for the new "EXE-Vars" keys under the old location as well.
  • Loading branch information
RobertBColton authored Jun 23, 2018
1 parent ccf1f47 commit 35ef11e
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions org/enigma/TargetHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ private TargetHandler()

static
{
load();
try
{
load();
}
catch (Throwable e)
{
// keep the plugin in a usable state even if this
// happens to fail to find any target compilers
EnigmaRunner.showDefaultExceptionHandler(e);
}
}

public static void load()
Expand Down Expand Up @@ -271,30 +280,46 @@ private static ArrayList<TargetSelection> findCompilers()
{
String ey = file.getName();
if (!ey.endsWith(".ey")) continue; //$NON-NLS-1$
TargetSelection ps = null;
try
{
YamlNode node = YamlParser.parse(file);
YamlNode exeVarsNode = (YamlNode) node.getM("EXE-Vars");

TargetSelection ps = new TargetSelection();
ps = new TargetSelection();
ps.id = ey.substring(0,ey.length() - 3);
ps.name = node.getMC("Name"); //$NON-NLS-1$
ps.desc = node.getMC("Description",null); //$NON-NLS-1$
ps.auth = node.getMC("Maintainer",null); //$NON-NLS-1$
ps.ext = exeVarsNode.getMC("Build-Extension",null); //$NON-NLS-1$
ps.outputexe = exeVarsNode.getMC("Run-output",null); //$NON-NLS-1$
ps.depends = new HashMap<String,Set<String>>();
Set<String> target = new HashSet<String>();
String targplat = node.getMC("Target-platform",null); //$NON-NLS-1$
if (target != null) targplat = normalize(targplat);
target.add(targplat);
ps.depends.put("target",target); //$NON-NLS-1$
if (node.getBool("Native",false)) defCompiler = ps; //$NON-NLS-1$
tCompilers.add(ps);
try
{
YamlNode exeVarsNode = (YamlNode) node.getM("EXE-Vars"); //$NON-NLS-1$
ps.ext = exeVarsNode.getMC("Build-Extension",null); //$NON-NLS-1$
ps.outputexe = exeVarsNode.getMC("Run-output",null); //$NON-NLS-1$
}
catch (IndexOutOfBoundsException e)
{
// there was no "EXE-Vars" key, which is optional
// but still check under the old location
ps.ext = node.getMC("Build-Extension",null); //$NON-NLS-1$
ps.outputexe = node.getMC("Run-output",null); //$NON-NLS-1$
}

// only add the target if there were no errors
if (ps != null) tCompilers.add(ps);
}
catch (FileNotFoundException e)
{
}
catch (Exception e)
{
EnigmaRunner.showDefaultExceptionHandler(e);
}
}
return tCompilers;
}
Expand Down

0 comments on commit 35ef11e

Please sign in to comment.