1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // Multi-Phasic Applications: SquirrelJME
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
.multivm
.ident
.SourceTargetClassifier
;
13 import java
.nio
.file
.Path
;
14 import javax
.inject
.Inject
;
16 import org
.gradle
.api
.DefaultTask
;
17 import org
.gradle
.api
.provider
.Provider
;
20 * This task is used to generate a built-in RatufaCoat ROm.
24 public class RatufaCoatBuiltInTask
28 /** The classifier used. */
30 private final SourceTargetClassifier classifier
;
33 * Initializes the full suite task.
35 * @param __classifier The classifier used.
36 * @param __romTask The task used to create the ROM.
37 * @throws NullPointerException On null arguments.
41 public RatufaCoatBuiltInTask(SourceTargetClassifier __classifier
,
43 throws NullPointerException
45 if (__classifier
== null || __romTask
== null)
46 throw new NullPointerException("NARG");
48 this.classifier
= __classifier
;
50 // Set details of this task
51 this.setGroup("squirreljmeGeneral");
52 this.setDescription("Builds the combined ROM.");
54 // Depends on the ROM being built
55 this.dependsOn(__romTask
);
57 // The inputs are the ROM task's output
58 this.getInputs().file(this.inputPath(__romTask
));
60 // And the output is a primary single file for the ROM
61 this.getOutputs().file(this.outputPath());
63 // Actual running of everything
64 this.doLast(new RatufaCoatBuiltInTaskAction(__classifier
));
68 * Returns the input path to use for this task.
70 * @param __romTask The ROM task.
71 * @return The output of the task, used for input.
74 private Provider
<Path
> inputPath(VMRomTask __romTask
)
76 return this.getProject().provider(() -> __romTask
.getOutputs()
77 .getFiles().getSingleFile().toPath());
81 * Returns the output path of the C file.
83 * @return The output path.
86 public final Provider
<Path
> outputPath()
88 return this.getProject().provider(() -> this.getProject().getRootDir()
89 .toPath().resolve("ratufacoat").resolve("build")
90 .resolve(TaskInitialization
.task(
91 "builtin", this.classifier
) + ".c"));