Skip to content

Commit

Permalink
Add Choreo (#440)
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Veness <[email protected]>
  • Loading branch information
spacey-sooty and calcmogul authored Oct 15, 2024
1 parent 6b7fc6f commit 778914a
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 0 deletions.
2 changes: 2 additions & 0 deletions WPILibInstaller-Avalonia/Interfaces/IConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface IConfigurationProvider

AdvantageScopeConfig AdvantageScopeConfig { get; }

ChoreoConfig ChoreoConfig { get; }

VsCodeConfig VsCodeConfig { get; }

string InstallDirectory { get; }
Expand Down
14 changes: 14 additions & 0 deletions WPILibInstaller-Avalonia/Models/ChoreoConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#nullable disable

using Newtonsoft.Json;

namespace WPILibInstaller.Models
{
public class ChoreoConfig
{
[JsonProperty("zipFile")]
public string ZipFile { get; set; }
[JsonProperty("folder")]
public string Folder { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ await ExtractArchive(token, new[] {
configurationProvider.JdkConfig.Folder + "/",
configurationProvider.UpgradeConfig.Tools.Folder + "/",
configurationProvider.AdvantageScopeConfig.Folder + "/",
configurationProvider.ChoreoConfig.Folder + "/",
"installUtils/"});
}

Expand Down
13 changes: 13 additions & 0 deletions WPILibInstaller-Avalonia/ViewModels/StartPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ private async Task<bool> SelectResourceFilesWithFile(string file)
}) ?? throw new InvalidOperationException("Not Valid");
}

entry = zipArchive.GetEntry("choreoConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
{
var configStr = await reader.ReadToEndAsync();
ChoreoConfig = JsonConvert.DeserializeObject<ChoreoConfig>(configStr, new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Error
}) ?? throw new InvalidOperationException("Not Valid");
}

entry = zipArchive.GetEntry("fullConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
Expand Down Expand Up @@ -414,6 +425,8 @@ public override PageViewModelBase MoveNext()

public AdvantageScopeConfig AdvantageScopeConfig { get; private set; } = null!;

public ChoreoConfig ChoreoConfig { get; private set; } = null!;

public VsCodeConfig VsCodeConfig { get; private set; } = null!;

}
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ apply from: 'scripts/jdk.gradle'
apply from: 'scripts/maven.gradle'

apply from: 'scripts/advantagescope.gradle'
apply from: 'scripts/choreo.gradle'

// Tools must happen after maven
apply from: 'scripts/tools.gradle'
Expand Down Expand Up @@ -221,6 +222,7 @@ def generateFullResourcesTask = tasks.register('generateFullResources', project.
jdkZipSetup(it)

advantageScopeZipSetup(it)
choreoZipSetup(it)

if (OperatingSystem.current().isWindows()) {
def task = it
Expand Down Expand Up @@ -326,6 +328,7 @@ def generateConfigFiles = tasks.register('generateCommonResources', Zip) {
jdkConfigFileSetup(zip)

advantageScopeConfigFileSetup(zip)
choreoConfigFileSetup(zip)

vscodeConfigZipSetup(zip)
}
Expand Down
9 changes: 9 additions & 0 deletions files/Choreo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

SCRIPT_PATH="$(dirname "$(realpath "$0")")"
SCRIPT_NAME="$(basename "$(realpath "$0")")"
SCRIPT_BASE="$(basename -s .sh "$SCRIPT_NAME")"
OS_NAME="$(uname -s)"
CHOREO_PATH="$(realpath "$SCRIPT_PATH/../choreo")"

exec "$CHOREO_PATH/Choreo"
44 changes: 44 additions & 0 deletions files/Choreo.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'Create File System Object for working with directories
Set fso = WScript.CreateObject("Scripting.FileSystemObject")

'Get the folder of this script
toolsFolder = fso.GetParentFolderName(WScript.ScriptFullName)

'Get the Choreo folder
toolsFolder = fso.GetParentFolderName(WScript.ScriptFullName)
yearFolder = fso.GetParentFolderName(toolsFolder)
choreoFolder = fso.BuildPath(yearFolder, "choreo")

'Get the full path to the exe
fullExeName = fso.BuildPath(choreoFolder, "choreo.exe")

shellScript = fullExeName

'Create Shell Object
Set objShell = WScript.CreateObject( "WScript.Shell" )
Set objEnv = objShell.Environment("PROCESS")
dim runObject
' Allow us to catch a script run failure
On Error Resume Next
Set runObj = objShell.Exec(shellScript)
If Err.Number <> 0 Then
If WScript.Arguments.Count > 0 Then
If (WScript.Arguments(0) <> "silent") Then
WScript.Echo "Error Launching Tool" + vbCrLf + Err.Description
Else
WScript.StdOut.Write("Error Launching Tool")
WScript.StdOut.Write(Error.Description)
End If
Else
WScript.Echo "Error Launching Tool" + vbCrLf + Err.Description
End If
Set runObj = Nothing
Set objShell = Nothing
Set fso = Nothing
WScript.Quit(1)
End If

Set runObj = Nothing
Set objShell = Nothing
Set fso = Nothing
WScript.Quit(0)
27 changes: 27 additions & 0 deletions gradleriobase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ plugins {
id "edu.wpi.first.GradleRIO"
}

repositories {
mavenCentral()
maven {
url = uri("https://SleipnirGroup.github.io/ChoreoLib/dep")
}
}

deploy {
targets {
roborio(getTargetTypeClass('RoboRIO')) {
Expand Down Expand Up @@ -34,6 +41,8 @@ def deployCppArtifact = deploy.targets.roborio.artifacts.frcCpp

wpi.java.debugJni = false

def choreoVersion = "$choreoGitTag".substring(1)

dependencies {
annotationProcessor wpi.java.deps.wpilibAnnotations()
implementation wpi.java.deps.wpilib()
Expand Down Expand Up @@ -75,6 +84,9 @@ dependencies {
if (project(":").ext.buildClassifier == 'Windows') {
implementation "edu.wpi.first.msvc:runtime:${project(':gradleriobase').wpi.versions.wpilibVersion.get()}:x64@zip"
}

// choreo
implementation "choreo:ChoreoLib-java:$choreoVersion"
}

test {
Expand Down Expand Up @@ -113,6 +125,20 @@ nativeUtils {
}
}

nativeUtils {
nativeDependencyContainer {
choreo(getNativeDependencyTypeClass('WPISharedMavenDependency')) {
groupId = "choreo"
artifactId = "ChoreoLib-cpp"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = choreoVersion
targetPlatforms.addAll(nativeUtils.wpi.platforms.allPlatforms)
}
}
}

nativeUtils {
nativeDependencyContainer {
xrpvendordep(getNativeDependencyTypeClass('WPISharedMavenDependency')) {
Expand Down Expand Up @@ -155,6 +181,7 @@ model {
wpi.cpp.deps.googleTest(it)

wpi.cpp.deps.useLibrary(it, 'wpilibnewcommands')
wpi.cpp.deps.useLibrary(it, 'choreo')
wpi.cpp.deps.useLibrary(it, 'xrpvendordep')
wpi.cpp.deps.useLibrary(it, 'romivendordep')
}
Expand Down
121 changes: 121 additions & 0 deletions scripts/choreo.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
apply from: 'scripts/versions.gradle'

def baseUrl = "https://github.com/SleipnirGroup/Choreo/releases/download/$choreoGitTag/"

def fileNameWindows = "Choreo-$choreoGitTag-Windows-x86_64-standalone.zip"

def downloadUrlWindows = baseUrl + fileNameWindows

def fileNameMac = "Choreo-$choreoGitTag-macOS-x86_64-standalone.zip"

def downloadUrlMac = baseUrl + fileNameMac

def fileNameMacArm = "Choreo-$choreoGitTag-macOS-aarch64-standalone.zip"

def downloadUrlMacArm = baseUrl + fileNameMacArm

def fileNameLinux = "Choreo-$choreoGitTag-Linux-x86_64-standalone.zip"

def downloadUrlLinux = baseUrl + fileNameLinux


apply plugin: 'de.undercouch.download'

def downloadTaskWindows = tasks.register('downloadChoreoWindows', Download) {
src downloadUrlWindows
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite true
}

def downloadTaskMac = tasks.register('downloadChoreoMac', Download) {
src downloadUrlMac
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite true
}

def downloadTaskMacArm = tasks.register('downloadChoreoMacArm', Download) {
src downloadUrlMacArm
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite true
}

def downloadTaskLinux = tasks.register('downloadChoreoLinux', Download) {
src downloadUrlLinux
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite true
}

def choreoConfigFile = file("$buildDir/choreoConfig.json")

def choreoConfigFileTask = tasks.register("choreoConfigFile") {
it.outputs.file choreoConfigFile

doLast {

def config = [:]
config['folder'] = 'choreo'
config['zipFile'] = 'choreo.zip'

def gbuilder = getGsonBuilder()

gbuilder.setPrettyPrinting()
def json = gbuilder.create().toJson(config)

choreoConfigFile.parentFile.mkdirs()

choreoConfigFile.text = json
}
}

ext.choreoConfigFileSetup = { AbstractArchiveTask zip->
zip.dependsOn choreoConfigFileTask
zip.inputs.file choreoConfigFile

zip.from(choreoConfigFile) {
rename {'choreoConfig.json'}
}
}

ext.choreoZipSetup = { AbstractArchiveTask zip->
if (project.hasProperty('linuxBuild')) {
zip.dependsOn downloadTaskLinux

zip.inputs.files downloadTaskLinux.get().outputFiles

zip.from(project.zipTree(downloadTaskLinux.get().outputFiles.first())) {
into '/choreo'
includeEmptyDirs = false
}
} else if (project.hasProperty('macBuild')) {
zip.dependsOn downloadTaskMac

zip.inputs.files downloadTaskMac.get().outputFiles

zip.from(project.zipTree(downloadTaskMac.get().outputFiles.first())) {
into '/choreo'
includeEmptyDirs = false
}
} else if (project.hasProperty('macBuildArm')) {
zip.dependsOn downloadTaskMacArm

zip.inputs.files downloadTaskMacArm.get().outputFiles

zip.from(project.zipTree(downloadTaskMacArm.get().outputFiles.first())) {
into '/choreo'
includeEmptyDirs = false
}
} else {
zip.dependsOn downloadTaskWindows

zip.inputs.files downloadTaskWindows.get().outputFiles

zip.from(project.zipTree(downloadTaskWindows.get().outputFiles.first())) {
into '/choreo'
includeEmptyDirs = false
}
}
}
12 changes: 12 additions & 0 deletions scripts/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ def downloadNewCommands = tasks.register('downloadNewCommands', Download) {
overwrite false
}

def downloadChoreo = tasks.register('downloadChoreo', Download) {
src 'https://SleipnirGroup.github.io/ChoreoLib/dep/ChoreoLib2025Beta.json'
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite false
}

def downloadRomiVendor = tasks.register('downloadRomiVendor', Download) {
src 'https://raw.githubusercontent.com/wpilibsuite/allwpilib/main/romiVendordep/RomiVendordep.json'
def fileName = file(src.file).name
Expand All @@ -227,13 +234,18 @@ ext.mavenZipSetup = { AbstractArchiveTask zip->
}

zip.dependsOn downloadNewCommands
zip.dependsOn downloadChoreo
zip.dependsOn downloadReadTheDocs
zip.dependsOn downloadPythonAPI

zip.from(downloadNewCommands.get().outputFiles.first()) {
into '/vendordeps'
}

zip.from(downloadChoreo.get().outputFiles.first()) {
into '/vendordeps'
}

zip.from(downloadRomiVendor.get().outputFiles.first()) {
into '/vendordeps'
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/tools.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def toolsJsonTask = tasks.register('toolsJson', Task) {
advantageScopeItem['version'] = advantagescopeGitTag
config << advantageScopeItem

def choreoItem = [:]
choreoItem['name'] = "Choreo"
choreoItem['version'] = choreoGitTag
config << choreoItem

def gbuilder = getGsonBuilder()
gbuilder.setPrettyPrinting()
def json = gbuilder.create().toJson(config)
Expand Down
2 changes: 2 additions & 0 deletions scripts/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ ext.jdkVersion = '17.0.12+7'

ext.advantagescopeGitTag = 'v4.0.0-beta-1'

ext.choreoGitTag = 'v2025.0.0-beta-4'

ext.frcYear = '2025'

ext.gradleWrapperVersion = '8.10.2'

0 comments on commit 778914a

Please sign in to comment.