1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.plugin
.multivm
;
12 import cc
.squirreljme
.plugin
.util
.JavaExecSpecFiller
;
13 import java
.io
.IOException
;
14 import java
.io
.InputStream
;
15 import java
.io
.OutputStream
;
16 import java
.nio
.file
.Path
;
17 import java
.util
.List
;
20 import org
.gradle
.api
.Project
;
21 import org
.gradle
.api
.Task
;
22 import org
.gradle
.api
.tasks
.SourceSet
;
25 * Provider interface for the various virtual machines that are available.
27 * Note that source sets refer to {@link SourceSet#MAIN_SOURCE_SET_NAME}
28 * and {@link SourceSet#TEST_SOURCE_SET_NAME}.
32 @SuppressWarnings("InterfaceWithOnlyOneDirectInheritor")
33 public interface VMSpecifier
36 * Returns the supported target banglets.
38 * @return The supported banglets for this target.
41 Set
<BangletVariant
> banglets();
46 * @param __task The task running this, may be used to launch a VM.
47 * @param __isTest Is this a test run?
48 * @param __in The input data, this may be a JAR or otherwise.
49 * @param __out The destination output file.
50 * @throws IOException On read/write errors.
51 * @throws NullPointerException On null arguments.
54 void dumpLibrary(VMBaseTask __task
, boolean __isTest
, InputStream __in
,
56 throws IOException
, NullPointerException
;
61 * @return If this can be dumped.
67 * Is the emulator for this JIT capable, as in there does not need to be
68 * a library or ROM compilation before running?
70 * @return If this has a JIT.
73 boolean hasEmulatorJit();
76 * Is there a ROM task for the VM?
78 * @param __variant The variant used.
79 * @return If a ROM is available.
82 boolean hasRom(BangletVariant __variant
);
85 * Returns the name of the project that is used to run this using the
88 * @param __variant The variant used.
89 * @return The project used for running the emulator.
92 List
<String
> emulatorProjects(BangletVariant __variant
);
95 * Determines the name of the library that the provider uses for what is
96 * executed by the virtual machine and output by the virtual machine.
98 * @param __project The project to get from.
99 * @param __sourceSet The source set to determine the path for.
100 * @return The path to the source set's library.
101 * @throws NullPointerException On null arguments.
104 String
outputLibraryName(Project __project
, String __sourceSet
)
105 throws NullPointerException
;
108 * Determines the output ROM name.
110 * @param __sourceSet The source set used.
112 * @return The name the ROM should be.
113 * @throws NullPointerException On null arguments.
116 String
outputRomName(String __sourceSet
, BangletVariant __variant
)
117 throws NullPointerException
;
120 * Processes the library.
122 * @param __task The task running this, may be used to launch a VM.
123 * @param __isTest Is this a test run?
124 * @param __in The input data, this may be a JAR or otherwise.
125 * @param __out The destination output file.
126 * @throws IOException On read/write errors.
127 * @throws NullPointerException On null arguments.
130 void processLibrary(VMBaseTask __task
, boolean __isTest
, InputStream __in
,
132 throws IOException
, NullPointerException
;
135 * Returns the optional library dependencies needed to perform library
136 * processing, if any.
138 * @param __task The owning task.
140 * @return Iterable of dependent tasks.
141 * @throws NullPointerException On null arguments.
144 Iterable
<Task
> processLibraryDependencies(VMBaseTask __task
,
145 BangletVariant __variant
)
146 throws NullPointerException
;
149 * Processes the ROM file for linking.
151 * @param __task The task running under.
152 * @param __variant The variant used.
153 * @param __out The output of the given path.
154 * @param __build Build parameters for the ROM.
155 * @param __libs The libraries to link in.
156 * @throws IOException On read/write errors.
157 * @throws NullPointerException On null arguments.
160 void processRom(VMBaseTask __task
, BangletVariant __variant
,
162 RomBuildParameters __build
, List
<Path
> __libs
)
163 throws IOException
, NullPointerException
;
166 * Fills the execution spec with the arguments used to create the
169 * @param __task The task used as a latch to obtain the needed virtual
170 * machine and other details.
171 * @param __debugEligible Is this eligible for debug?
172 * @param __execSpec The execution spec to fill.
173 * @param __mainClass The main class to execute.
174 * @param __commonName The common name for the program.
175 * @param __sysProps The system properties to define.
176 * @param __libPath The library path to use for the virtual machine.
177 * @param __classPath The class path of the execution target.
178 * @param __args Arguments to the started program.
179 * @throws NullPointerException On null arguments.
182 void spawnJvmArguments(VMBaseTask __task
, boolean __debugEligible
,
183 JavaExecSpecFiller __execSpec
, String __mainClass
,
184 String __commonName
, Map
<String
, String
> __sysProps
, Path
[] __libPath
,
185 Path
[] __classPath
, String
... __args
)
186 throws NullPointerException
;
189 * Returns the virtual machine name using the given name format.
191 * @param __format The format of the name to use.
192 * @return The formatted name.
193 * @throws NullPointerException On null arguments.
196 String
vmName(VMNameFormat __format
)
197 throws NullPointerException
;
200 * Is this a golden standard for testing?
202 * @return If this is a golden standard for testing.
205 default boolean isGoldTest()