Skip to content

Commit 550200c

Browse files
committed
Comments and planning
1 parent c55e286 commit 550200c

File tree

5 files changed

+42
-11
lines changed

5 files changed

+42
-11
lines changed

app/src/processing/app/gradle/Debugger.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Debugger {
2121
args["port"]?.setValue(port?.toString() ?: "5005")
2222

2323
// Try to attach the debugger, retrying if it fails
24+
// TODO: Stop retrying after the job has been cancelled / failed
2425
val start = TimeSource.Monotonic.markNow()
2526
while (start.elapsedNow() < 10.seconds) {
2627
try {

app/src/processing/app/gradle/Exceptions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class Exceptions (val vm: VirtualMachine, val editor: Editor?) {
5656
/*
5757
We have 6 lines by default within the editor to display more information about the exception.
5858
*/
59+
// TODO: Improve the display and clarity of the exception details
5960

6061
val message = """
6162
In Processing code:
@@ -91,7 +92,7 @@ class Exceptions (val vm: VirtualMachine, val editor: Editor?) {
9192
}
9293

9394
// TODO: Map to .pde file again, @see JavaBuild.placeException
94-
// BLOCKED: Because we don't run the JavaBuild code.prepocOffset is empty
95+
// TODO: This functionality should be provided by the mode
9596

9697
return this
9798
}

app/src/processing/app/gradle/GradleJob.kt

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ class GradleJob(
6363
private val cancel = GradleConnector.newCancellationTokenSource()
6464

6565

66-
// All the configuration for the gradle build
66+
/*
67+
Set up the gradle build launcher with the necessary configuration
68+
This includes setting the working directory, the tasks to run,
69+
and the arguments to pass to gradle.
70+
Create the necessary build files if they do not exist.
71+
*/
6772
private fun BuildLauncher.setupGradle(extraArguments: List<String> = listOf()) {
6873
val copy = sketch.isReadOnly || sketch.isUntitled
6974

@@ -195,6 +200,9 @@ class GradleJob(
195200
withCancellationToken(cancel.token())
196201
}
197202

203+
/*
204+
Start the gradle job and run the tasks
205+
*/
198206
fun start() {
199207
launchJob {
200208
handleExceptions {
@@ -234,18 +242,26 @@ class GradleJob(
234242
}
235243

236244

237-
245+
/*
246+
Cancel the gradle job and all the jobs that were launched in this scope
247+
*/
238248
fun cancel(){
239249
cancel.cancel()
240250
jobs.forEach(Job::cancel)
241251
}
242252

253+
/*
254+
Add a job to the scope and add it to the list of jobs so we can cancel it later
255+
*/
243256
private fun launchJob(block: suspend CoroutineScope.() -> Unit){
244257
val job = scope.launch { block() }
245258
jobs.add(job)
246259
}
247260

248-
// Handle exception thrown by Gradle
261+
262+
/*
263+
Handle exceptions that occur during the build process and inform the user about them
264+
*/
249265
private fun handleExceptions(action: () -> Unit){
250266
try{
251267
action()
@@ -282,7 +298,11 @@ class GradleJob(
282298
}
283299
}
284300

285-
// TODO: Move to separate file
301+
// TODO: Move to separate file?
302+
/*
303+
Add a progress listener to the build launcher
304+
to track the progress of the build and update the editor status accordingly
305+
*/
286306
private fun BuildLauncher.addStateListener(){
287307
addProgressListener(ProgressListener { event ->
288308
if(event is TaskStartEvent) {
@@ -328,6 +348,7 @@ class GradleJob(
328348
return@ProgressListener
329349
}
330350
// TODO: Show the error on the location if it is available
351+
// TODO: This functionality should be provided by the mode
331352
/*
332353
We have 6 lines to display the error in the editor.
333354
*/
@@ -348,6 +369,11 @@ class GradleJob(
348369
})
349370
}
350371

372+
/*
373+
Start log servers for the standard output and error streams
374+
This allows us to capture the output of Processing and display it in the editor
375+
Whilst keeping the gradle output separate
376+
*/
351377
fun BuildLauncher.addLogserver(){
352378
launchJob {
353379
startLogServer(logPort, System.out)
@@ -357,6 +383,10 @@ class GradleJob(
357383
}
358384
}
359385

386+
/*
387+
Connected a debugger to the gradle run task
388+
This allows us to debug the sketch while it is running
389+
*/
360390
fun BuildLauncher.addDebugging() {
361391
addProgressListener(ProgressListener { event ->
362392
if (event !is TaskStartEvent) return@ProgressListener

app/src/processing/app/gradle/GradleService.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@ import processing.app.Sketch
99
import processing.app.ui.Editor
1010
import kotlin.io.path.createTempDirectory
1111

12-
// TODO: Test offline mode, gradle seems to be included as not needed to be downloaded.
13-
// TODO: Test running examples
14-
// TODO: Report failures to the console
15-
// TODO: Highlight errors in the editor
12+
// TODO: Highlight errors in the editor in the right place
1613

1714
// TODO: ---- FUTURE ----
1815
// TODO: Improve progress tracking and show it in the UI
1916
// TODO: PoC new debugger/tweak mode
20-
// TODO: Allow for plugins to skip gradle entirely / new modes
21-
// TODO: Add background building
2217
// TODO: Track build speed (for analytics?)
18+
// TODO: Bundle Gradle with the app
2319

2420
/*
2521
* The gradle service runs the gradle tasks and manages the gradle connection

app/src/processing/app/gradle/api/Sketch.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package processing.app.gradle.api
33
import com.github.ajalt.clikt.command.SuspendingCliktCommand
44
import com.github.ajalt.clikt.core.Context
55
import com.github.ajalt.clikt.core.subcommands
6+
import com.github.ajalt.clikt.parameters.options.default
67
import com.github.ajalt.clikt.parameters.options.option
78
import com.github.ajalt.clikt.parameters.options.required
89
import processing.app.Base
@@ -31,6 +32,8 @@ class Sketch : SuspendingCliktCommand("sketch") {
3132
val sketch by option("--sketch", help = "The sketch to run")
3233
.required()
3334

35+
val mode by option("--mode", help = "The mode to use for running the sketch (only java is supported for now)")
36+
3437
override fun help(context: Context): String {
3538
return "Run the Processing sketch."
3639
}

0 commit comments

Comments
 (0)