Last active
November 29, 2021 21:53
-
-
Save revoice1/cfa0681b4babc436d8aa56fa89d9c983 to your computer and use it in GitHub Desktop.
Code to pull repos and locally build/transfer development MiSTer cores
This file contains hidden or 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
# Script to pull git repos for MiSTer cores, build locally, and transfer to MiSTer if online and registered in DNS | |
# Transfer to the MiSTer requires SMB to be enabled and working, with auth working | |
# i.e. before running the script connect to SMB ("\\mister\") and authenticate, saving the creds. | |
# Requires git to be installed locally in some form | |
# Requires a local install of Quartus 17.0 lite with Cyclone V support installed | |
# More info on Quartus https://fpgasoftware.intel.com/17.0/?edition=lite&platform=windows | |
$ProjectRoot = "Q:\Scripts" # Local path where you would like to store the repo | |
$quartus_sh = "C:\intelFPGA_lite\17.0\quartus\bin64\quartus_sh" # Default path to the quartus_sh file | |
$MiSTerDNSName = "MiSTer" | |
# List of projects to clone and build from | |
$Projects = @{ | |
PlayStation = @{ | |
Repo = "https://github.com/RobertPeip/PlayStation_MiSTer.git" | |
Type = "Console" | |
} | |
X68000 = @{ | |
Repo = "https://github.com/MiSTer-devel/X68000_MiSTer.git" | |
Type = "Computer" | |
} | |
} | |
# Check is mister in online and SMBis open | |
$MisterOnline = $(Test-NetConnection -ComputerName $MiSTerDNSName -CommonTCPPort SMB).TcpTestSucceeded | |
Foreach ($Project in $Projects.Keys) { | |
$RepoName = $Projects[$Project].Repo -replace ".*/(.*).git", '$1' | |
$LocalRepoLocation = "$($ProjectRoot)\$($RepoName)" | |
$RepoExists = Test-Path $LocalRepoLocation | |
if (!$RepoExists) { | |
Set-Location $ProjectRoot | |
git clone $Projects[$Project].Repo | |
} | |
Set-Location $LocalRepoLocation | |
$LocalCorePath = ".\output_files\$($Project).rbf" | |
$pull = git pull | |
$rbfExists = Test-Path $LocalCorePath | |
if (!$rbfExists -or ($pull -ne "Already up to date.")) { | |
Write-Verbose -Verbose "Running $Project core build" | |
&$quartus_sh --flow compile $($Project) | |
} | |
else { | |
Write-Verbose -Verbose "No new $Project repo updates, skipping build" | |
} | |
if ($MisterOnline) { | |
Write-Verbose -Verbose "MiSTer online, checking if core needs to be updated" | |
$MiSTerFilePath = "\\$MiSTerDNSName\sdcard\_$($Projects[$Project].Type)\$($Project)_dev.rbf" | |
$CoreExistsOnMiSTer = Test-Path $MiSTerFilePath | |
if ($CoreExistsOnMiSTer) { | |
$LocalCoreHash = (Get-FileHash $LocalCorePath).hash | |
$CoreOnMiSTer = Get-Item $MiSTerFilePath | |
$CoreOnMiSTerHash = (Get-FileHash $CoreOnMiSTer).hash | |
# Compare the file hashes and store result for transfer logic | |
$HashesMatch = $LocalCoreHash -eq $CoreOnMiSTerHash | |
} | |
# If the core does not exist on the MiSTer or the hash doesn't match, transfer | |
if (!$CoreExistsOnMiSTer -or !$HashesMatch) { | |
Write-Verbose -Verbose "MiSTer needs $($Project) core update, copying" | |
Write-Verbose -Verbose "Copying $($Project) rbf to MiSTer" | |
Copy-Item $LocalCorePath $MiSTerFilePath | |
} | |
else { | |
Write-Verbose -Verbose "MiSTer $($Project) core already up to date" | |
} | |
} | |
else { | |
Write-Verbose -Verbose "MiSTer not reachable, skipping copy" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment