Skip to content

Instantly share code, notes, and snippets.

@thereverand
Last active January 1, 2020 04:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thereverand/cfb10fc01946e3068b2f290225257823 to your computer and use it in GitHub Desktop.
Save thereverand/cfb10fc01946e3068b2f290225257823 to your computer and use it in GitHub Desktop.
Building cc65 on Windows
[cmdletbinding()]
param(
[string]$MinGWPath = "C:\MinGW"
)
$ErrorActionPreference = 'Stop';
<#
You will need to install:
- MinGW : https://osdn.net/frs/redir.php?m=pumath&f=mingw%2F68260%2Fmingw-get-setup.exe
- Install packages
- mingw32-base-bin
- msys-base-bin
Drop this into your cc65 source folder.
This will ensure the PATH contains all the needed paths
- MinGW bin
- MSYS bin
- cc65 bin
Create a global function called 'make' which will run mingw32-make
Clean any previous builds THEN
It builds it :)
#>
$paths = @{
"$MinGWPath\bin"=$true
"$MinGWPath\msys\1.0\bin\"=$true
"$PSScriptRoot\bin"=$false
};
function Set-EnvPath {
[cmdletbinding()]
param(
[string]$Path,
[bool]$MustExist
)
if ($MustExist.IsPresent -and ![System.IO.File]::Exists($Path)) {
Write-Error "Path '$Path' must exist.";
return;
}
if ($ENV:Path -notlike "*${Path}*") {
Write-Verbose "Adding '$Path' to PATH";
$newPath = @($ENV:Path,$Path) -join ";";
[System.Environment]::SetEnvironmentVariable("PATH", $newPath, [System.EnvironmentVariableTarget]::User);
$ENV:Path = $newPath;
}
}
function global:make {
[cmdletbinding()]
param(
[Parameter(ValueFromRemainingArguments=$true)]
[string]$Arguments
)
Invoke-Expression "mingw32-make $Arguments";
}
foreach ($path in $paths.Keys) {
Write-Verbose "Checking path '$path'"
Set-EnvPath -Path $path -MustExist $paths[$path];
}
make clean
make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment