Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Choreo #440

Merged
merged 16 commits into from
Oct 15, 2024
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
17 changes: 17 additions & 0 deletions gradleriobase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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:$choreoGitTag"
}

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

nativeUtils {
nativeDependencyContainer {
wpilibnewcommands(getNativeDependencyTypeClass('WPISharedMavenDependency')) {
spacey-sooty marked this conversation as resolved.
Show resolved Hide resolved
groupId = "choreo"
artifactId = "ChoreoLib-cpp"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = wpilibFoundVersion
spacey-sooty marked this conversation as resolved.
Show resolved Hide resolved
targetPlatforms.addAll(nativeUtils.wpi.platforms.allPlatforms)
}
}
}

nativeUtils {
nativeDependencyContainer {
xrpvendordep(getNativeDependencyTypeClass('WPISharedMavenDependency')) {
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
}
}
}
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

spacey-sooty marked this conversation as resolved.
Show resolved Hide resolved
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-3'

ext.frcYear = '2025'

ext.gradleWrapperVersion = '8.10.2'
Loading