-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for running glass from gradle (#470)
* Add support for running glass from gradle Currently does not support installing. Needed to enable support for installing glass in the installer * Handle new cpp flag in tool json * Actually do something... * Fix glass classifier
- Loading branch information
Showing
11 changed files
with
114 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/groovy/edu/wpi/first/gradlerio/wpi/dependencies/tools/CppToolRunTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package edu.wpi.first.gradlerio.wpi.dependencies.tools | ||
|
||
import edu.wpi.first.gradlerio.SingletonTask | ||
import groovy.transform.CompileStatic | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.Internal | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.api.tasks.TaskProvider | ||
import org.gradle.internal.os.OperatingSystem | ||
import org.gradle.process.ExecSpec | ||
|
||
import javax.inject.Inject | ||
|
||
@CompileStatic | ||
class CppToolRunTask extends DefaultTask implements SingletonTask { | ||
@Internal | ||
String toolName | ||
|
||
@Inject | ||
CppToolRunTask(String name) { | ||
group = 'GradleRIO' | ||
description = "Run the tool $name" | ||
|
||
this.toolName = name | ||
} | ||
|
||
@TaskAction | ||
void runTool() { | ||
def isWindows = OperatingSystem.current().isWindows() | ||
if (isWindows) { | ||
runToolWindows() | ||
} else { | ||
runToolUnix() | ||
} | ||
} | ||
|
||
void runToolWindows() { | ||
def outputFile = new File(ToolInstallTask.toolsFolder, toolName + '.vbs') | ||
ProcessBuilder builder = new ProcessBuilder('wscript.exe', outputFile.absolutePath, 'silent') | ||
Process proc = builder.start() | ||
int result = proc.waitFor() | ||
if (result != 0) { | ||
def stdOut = proc.getInputStream().text; | ||
def stdErr = proc.getErrorStream().text; | ||
throw new ToolRunException(stdOut, stdErr) | ||
} | ||
} | ||
|
||
void runToolUnix() { | ||
def outputFile = new File(ToolInstallTask.toolsFolder, toolName + '.py') | ||
project.exec { ExecSpec spec -> | ||
spec.executable = outputFile.absolutePath | ||
} | ||
} | ||
|
||
@Override | ||
String singletonName() { | ||
return toolName | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/groovy/edu/wpi/first/gradlerio/wpi/dependencies/tools/WPICppTool.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package edu.wpi.first.gradlerio.wpi.dependencies.tools | ||
|
||
import edu.wpi.first.gradlerio.wpi.WPIExtension | ||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.TaskProvider | ||
|
||
@CompileStatic | ||
class WPICppTool { | ||
//TaskProvider<CppToolInstallTask> toolInstallTask | ||
TaskProvider<CppToolRunTask> toolRunTask | ||
|
||
String name | ||
|
||
String version | ||
|
||
WPICppTool(Project project, String name, String version, String artifactId) { | ||
def config = project.configurations.getByName('wpiCppTools') | ||
String toolsClassifier = project.extensions.getByType(WPIExtension).cppToolsClassifier | ||
artifactId += ":${toolsClassifier}@zip" | ||
def dependency = project.dependencies.add("wpiCppTools", artifactId) | ||
//toolInstallTask = project.tasks.register("${name}Install".toString(), CppToolInstallTask, name, config, dependency) | ||
toolRunTask = project.tasks.register(name, CppToolRunTask, name) | ||
this.name = name | ||
this.version = version | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters