cmder/scripts/build.ps1
Dax T. Games cf15dcffc7 Added/enhanced bash with cmder.sh/user-cmder.sh, organized tasks menu
added personal files to .gitignore so they never get uploaded to the repo and added support for msys2 bash in the new git for windows

added autocreate of config/user-cmder.sh if iot does not exist and added it to the .gitignore

Added tasks: cmd::Cmder, cmd::Cmder as Admin, bash::bash, bash::bash as Admin, bash::mintty, bash::mintty as admin, powershell::powershell, powershell::powershell as Admin. Set default task to cmd::Cmder.  Cot rid of init.bat running before /bin/bash, fixes double exit requirement

Added running git for windows post-install.bat on first cmder launch

fixed file/path not found  errors when launching powershell as admin

fixed file/path not found errors when launching bash/mintty as admin

fixed PATH in vendor/cmder.sh

Added sourcing ~/.bashrc if it exists.

changed .gitignore to ignore anything with path of config/user-*

removed my personal files from .gitignore, left in config/user-*

Make sure $CMDER_ROOT does not have a trailing '/'

%CMDER_ROOT% does not have trailing '\'. allow user to specify a conemu.xml on the command line

Removed '\' from %CMDER_ROOT%
2015-11-14 12:07:56 -06:00

120 lines
3.6 KiB
PowerShell

<#
.Synopsis
Build Cmder
.DESCRIPTION
Use this script to build your own edition of Cmder
This script builds dependencies from current vendor/sources.json file and unpacks them.
You will need to make this script executable by setting your Powershell Execution Policy to Remote signed
Then unblock the script for execution with UnblockFile .\build.ps1
.EXAMPLE
.\build.ps1
Executes the default build for Cmder; Conemu, clink. This is equivalent to the "minimum" style package in the releases
.EXAMPLE
.\build.ps1 -Compile
Recompile the launcher executable if you have the requisite build tools for C++ installed.
.EXAMPLE
.\build -verbose
Execute the build and see what's going on.
.EXAMPLE
.\build.ps1 -SourcesPath '~/custom/vendors.json'
Build cmder with your own packages. See vendor/sources.json for the syntax you need to copy.
.NOTES
AUTHORS
Samuel Vasko, Jack Bennett
Part of the Cmder project.
.LINK
http://cmder.net/ - Project Home
#>
[CmdletBinding(SupportsShouldProcess=$true)]
Param(
# CmdletBinding will give us;
# -verbose switch to turn on logging and
# -whatif switch to not actually make changes
# Path to the vendor configuration source file
[string]$sourcesPath = "..\vendor\sources.json",
# Vendor folder location
[string]$saveTo = "..\vendor\",
# Launcher folder location
[string]$launcher = "..\launcher",
# Config folder location
[string]$config = "..\config",
# New launcher if you have MSBuild tools installed
[switch]$Compile
)
. "$PSScriptRoot\utils.ps1"
$ErrorActionPreference = "Stop"
Push-Location -Path $saveTo
$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json
# Check for requirements
Ensure-Exists $sourcesPath
Ensure-Executable "7z"
New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null
# Preserve modified (by user) ConEmu setting file
if ($config -ne "") {
$ConEmuXml = Join-Path $saveTo "conemu-maximus5\ConEmu.xml"
if (Test-Path $ConEmuXml -pathType leaf) {
$ConEmuXmlSave = Join-Path $config "ConEmu.xml"
Write-Verbose "Backup '$ConEmuXml' to '$ConEmuXmlSave'"
Copy-Item $ConEmuXml $ConEmuXmlSave
} else { $ConEmuXml = "" }
} else { $ConEmuXml = "" }
$vend = $pwd
foreach ($s in $sources) {
Write-Verbose "Getting $($s.name) from URL $($s.url)"
# We do not care about the extensions/type of archive
$tempArchive = "tmp/$($s.name).tmp"
Delete-Existing $tempArchive
Delete-Existing $s.name
Download-File -Url $s.url -File $vend\$tempArchive -ErrorAction Stop
Extract-Archive $tempArchive $s.name
if ((Get-Childitem $s.name).Count -eq 1) {
Flatten-Directory($s.name)
}
# Write current version to .cmderver file, for later.
"$($s.version)" | Out-File "$($s.name)/.cmderver"
}
# Restore user configuration
if ($ConEmuXml -ne "") {
Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'"
Copy-Item $ConEmuXmlSave $ConEmuXml
}
Pop-Location
if($Compile) {
Push-Location -Path $launcher
msbuild CmderLauncher.vcxproj /p:configuration=Release
Pop-Location
} else {
Write-Warning "You are not building a launcher, Use -Compile"
Write-Warning "This cannot be a release. Test build only!"
}
# Put vendor\cmder.sh in /etc/profile.d so it runs when we start bash or mintty
if ( (Test-Path $($SaveTo + "git-for-windows/etc/profile.d") ) ) {
write-verbose "Adding cmder.sh /etc/profile.d"
Copy-Item $($SaveTo + "cmder.sh") $($SaveTo + "git-for-windows/etc/profile.d/cmder.sh")
}
Write-Verbose "All good and done!"