Skip to content

Commit

Permalink
Added mac arm build and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Oct 16, 2024
1 parent 8adfe77 commit 1f2a5e3
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def generateFullResourcesTask = tasks.register('generateFullResources', project.

advantageScopeZipSetup(it)
choreoZipSetup(it)
elasticZipSetup(it)

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

advantageScopeConfigFileSetup(zip)
choreoConfigFileSetup(zip)
elasticConfigFileSetup(zip)

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

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

if [ "$OS_NAME" = "Linux" ]; then
exec "$ELASTIC_PATH/elastic_dashboard"
elif [ "$OS_NAME" = "Darwin" ]; then
open "$ELASTIC_PATH/elastic_dashboard.app"
else
exec "$ELASTIC_PATH/elastic_dashboard"
fi
44 changes: 44 additions & 0 deletions files/Elastic.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 Elastic folder
toolsFolder = fso.GetParentFolderName(WScript.ScriptFullName)
yearFolder = fso.GetParentFolderName(toolsFolder)
elasticFolder = fso.BuildPath(yearFolder, "elastic")

'Get the full path to the exe
fullExeName = fso.BuildPath(elasticFolder, "elastic_dashboard.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)
20 changes: 20 additions & 0 deletions scripts/elastic.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def fileNameMac = 'Elastic-WPILib-macOS.zip'

def downloadUrlMac = baseUrl + fileNameMac

def fineNameMacArm = 'Elastic-WPILib-macOS.zip'

def downloadUrlMacArm = baseUrl + fileNameMacArm

def fileNameLinux = 'Elastic-WPILib-Linux'

def downloadUrlLinux = baseUrl + fileNameLinux
Expand All @@ -30,6 +34,13 @@ def downloadTaskMac = tasks.register('downloadElasticMac', Download) {
overwrite true
}

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

def downloadTaskLinux = tasks.register('downloadElasticLinux', Download) {
src downloadUrlLinux
def fileName = file(src.file).name
Expand Down Expand Up @@ -86,6 +97,15 @@ ext.elasticZipSetup = { AbstractArchiveTask zip->
into '/elastic'
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 '/elastic'
includeEmptyDirs = false
}
} else {
zip.dependsOn downloadTaskWindows

Expand Down
17 changes: 17 additions & 0 deletions scripts/tools.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def advantageScopeScriptUnixFile = file("files/AdvantageScope.sh")
def choreoScriptFile = file("files/Choreo.vbs")
def choreoScriptUnixFile = file("files/Choreo.sh")

def elasticScriptFile = file("files/Elastic.vbs")
def elasticScriptUnixFile = file("files/Elastic.sh")

def toolsJsonTask = tasks.register('toolsJson', Task) {

dependsOn tasks.named('lazyModelEvaluation')
Expand Down Expand Up @@ -64,6 +67,11 @@ def toolsJsonTask = tasks.register('toolsJson', Task) {
choreoItem['version'] = choreoGitTag
config << choreoItem

def elasticItem = [:]
elasticItem['name'] = "Elastic"
elasticItem['version'] = elasticGitTag
config << elasticItem

def gbuilder = getGsonBuilder()
gbuilder.setPrettyPrinting()
def json = gbuilder.create().toJson(config)
Expand Down Expand Up @@ -112,6 +120,10 @@ ext.toolsSetup = { AbstractArchiveTask zip->
zip.from (choreoScriptFile) {
into '/tools'
}

zip.from (elasticScriptFile) {
into '/tools'
}
} else {
zip.from (scriptBaseUnixFile) {
into '/tools'
Expand Down Expand Up @@ -147,6 +159,11 @@ ext.toolsSetup = { AbstractArchiveTask zip->
into '/tools'
fileMode 0755
}

zip.from (elasticScriptUnixFile) {
into '/tools'
fileMode 0755
}
}

}

0 comments on commit 1f2a5e3

Please sign in to comment.