Commit e85f4f1d authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Allow the build system to launch binaries which have no source code.

parent da4faf55
......@@ -210,6 +210,67 @@ public final class ProjectManager
return bin.<Binary>toArray(new Binary[bin.size()]);
}
/**
* Returns the class path for the given projects.
*
* @param __p The projects to lookup.
* @return The class path for the projects.
* @throws NullPointerException On null arguments.
* @since 2019/05/05
*/
public final Binary[] classPath(String... __p)
throws NullPointerException
{
return this.classPath(this.deftimespace, __p);
}
/**
* Returns the class path for the given projects in the given timespace.
*
* @param __t The timespace to use.
* @param __p The projects to lookup.
* @return The class path for the projects.
* @throws NullPointerException On null arguments.
* @since 2019/05/05
*/
public final Binary[] classPath(TimeSpaceType __t, String... __p)
throws NullPointerException
{
if (__t == null || __p == null)
throw new NullPointerException("NARG");
// Need the binary manager to get the class path for these
BinaryManager bm;
try
{
bm = this.binaryManager(__t);
}
// {@squirreljme.error AU9g Could not obtain the binary manager.}
catch (IOException e)
{
throw new RuntimeException("AU9g", e);
}
// Get binaries
int n = __p.length;
Binary[] bins = new Binary[n];
for (int i = 0; i < n; i++)
bins[i] = bm.get(__p[i]);
// Do not return duplicate binaries
Set<Binary> rv = new LinkedHashSet<>();
// Compile all of the project and return required class path for
// it to operate
for (Binary i : bins)
for (Binary b : bm.classPath(i))
rv.add(b);
// Return the completed set
return rv.<Binary>toArray(new Binary[rv.size()]);
}
/**
* Opens the given root file from the source tree. This also handles MIME
* encoded files if they exist and decodes them accordingly.
......
......@@ -13,6 +13,7 @@ package cc.squirreljme.builder.support.vm;
import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.builder.support.BinaryManager;
import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.NoSourceAvailableException;
import cc.squirreljme.builder.support.Source;
import cc.squirreljme.builder.support.TimeSpaceType;
import cc.squirreljme.vm.VMClassLibrary;
......@@ -113,12 +114,40 @@ public final class BuildSuiteManager
return rv;
// Build the binaries for this finding the matching one
for (Binary b : this.manager.build(__s))
if (__s.equals(b.name().toString()))
try
{
for (Binary b : this.manager.build(__s))
if (__s.equals(b.name().toString()))
{
rv = new BuildClassLibrary(b);
break;
}
}
// If no source exists then just use it directly
catch (NoSourceAvailableException e)
{
try
{
rv = new BuildClassLibrary(this.manager.binaryManager().
get(__s));
}
// {@squirreljme.error AU9h Could not load the binary manager.}
catch (IOException x)
{
libraries.put(__s, (rv = new BuildClassLibrary(b)));
return rv;
RuntimeException t = new RuntimeException("AU9h", x);
t.addSuppressed(e);
throw t;
}
}
// Library was found?
if (rv != null)
{
libraries.put(__s, rv);
return rv;
}
// {@squirreljme.error AU1b No such library exists. (The requested
// library)}
......
......@@ -11,6 +11,7 @@
package cc.squirreljme.builder.support.vm;
import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.builder.support.NoSourceAvailableException;
import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.TimeSpaceType;
import cc.squirreljme.vm.VirtualMachine;
......@@ -118,7 +119,17 @@ public class VMMain
// Get the project and all of its dependencies built which forms
// the class path
Set<Binary> xclasspath = new LinkedHashSet<>();
Binary[] vclasspath = __pm.build(project);
Binary[] vclasspath;
try
{
vclasspath = __pm.build(project);
}
// If there is no source for this, just use the classpath then
catch (NoSourceAvailableException e)
{
vclasspath = __pm.classPath(project);
}
// The boot entry always must be last
Binary bootp = vclasspath[vclasspath.length - 1];
......
......@@ -19,6 +19,8 @@ More detailed changes:
* Build system
* Builder
* Allow the build system to launch binaries in a VM even if they have no
source code.
* Handle cases during compilation if a dependency has no source code.
* If an attempt is made to compile a binary with no source code, throw a
new exception type indicating this rather than the generic failure
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment