2014-02-25 00:33:14 +08:00
|
|
|
<#
|
2014-02-27 00:46:23 +08:00
|
|
|
.Synopsis
|
|
|
|
Build Cmder
|
|
|
|
.DESCRIPTION
|
|
|
|
Use this script to build your own edition of Cmder
|
2014-02-25 00:33:14 +08:00
|
|
|
|
2014-02-27 00:46:23 +08:00
|
|
|
This script builds dependencies from current vendor/sources.json file and unpacks them.
|
2014-02-25 00:33:14 +08:00
|
|
|
|
2014-02-27 00:46:23 +08:00
|
|
|
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
|
2014-02-25 00:33:14 +08:00
|
|
|
|
2015-08-24 02:21:45 +08:00
|
|
|
Executes the default build for Cmder; Conemu, clink. This is equivalent to the "minimum" style package in the releases
|
2015-02-25 21:58:11 +08:00
|
|
|
.EXAMPLE
|
2015-10-15 01:19:08 +08:00
|
|
|
.\build.ps1 -Compile
|
2015-02-25 21:58:11 +08:00
|
|
|
|
2015-10-15 01:19:08 +08:00
|
|
|
Recompile the launcher executable if you have the requisite build tools for C++ installed.
|
2014-02-27 00:46:23 +08:00
|
|
|
.EXAMPLE
|
|
|
|
.\build -verbose
|
2014-02-25 00:33:14 +08:00
|
|
|
|
2014-02-27 00:46:23 +08:00
|
|
|
Execute the build and see what's going on.
|
|
|
|
.EXAMPLE
|
|
|
|
.\build.ps1 -SourcesPath '~/custom/vendors.json'
|
2014-02-25 00:33:14 +08:00
|
|
|
|
2014-02-27 00:46:23 +08:00
|
|
|
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
|
2015-10-15 01:19:08 +08:00
|
|
|
http://cmder.net/ - Project Home
|
2014-02-27 00:46:23 +08:00
|
|
|
#>
|
|
|
|
[CmdletBinding(SupportsShouldProcess=$true)]
|
|
|
|
Param(
|
2014-03-03 05:00:04 +08:00
|
|
|
# CmdletBinding will give us;
|
2014-02-27 00:46:23 +08:00
|
|
|
# -verbose switch to turn on logging and
|
|
|
|
# -whatif switch to not actually make changes
|
2014-03-03 05:00:04 +08:00
|
|
|
|
2014-02-27 00:46:23 +08:00
|
|
|
# Path to the vendor configuration source file
|
2014-04-10 18:41:19 +08:00
|
|
|
[string]$sourcesPath = "..\vendor\sources.json",
|
2014-02-27 00:46:23 +08:00
|
|
|
|
2014-08-27 06:52:49 +08:00
|
|
|
# Vendor folder location
|
|
|
|
[string]$saveTo = "..\vendor\",
|
|
|
|
|
|
|
|
# Launcher folder location
|
2015-02-25 21:58:11 +08:00
|
|
|
[string]$launcher = "..\launcher",
|
|
|
|
|
2015-09-24 22:22:41 +08:00
|
|
|
# Config folder location
|
|
|
|
[string]$config = "..\config",
|
2015-09-02 01:05:57 +08:00
|
|
|
|
2015-10-14 19:59:20 +08:00
|
|
|
# New launcher if you have MSBuild tools installed
|
|
|
|
[switch]$Compile
|
2014-02-27 00:46:23 +08:00
|
|
|
)
|
2014-02-25 00:33:14 +08:00
|
|
|
|
2014-04-10 18:41:19 +08:00
|
|
|
. "$PSScriptRoot\utils.ps1"
|
2014-03-05 18:22:58 +08:00
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
2014-04-10 18:41:19 +08:00
|
|
|
Push-Location -Path $saveTo
|
|
|
|
$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json
|
|
|
|
|
2014-02-27 00:46:23 +08:00
|
|
|
# Check for requirements
|
|
|
|
Ensure-Exists $sourcesPath
|
|
|
|
Ensure-Executable "7z"
|
2015-03-18 21:21:43 +08:00
|
|
|
New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null
|
2014-02-27 00:46:23 +08:00
|
|
|
|
2015-09-02 01:05:57 +08:00
|
|
|
# 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 = "" }
|
|
|
|
|
2015-10-13 16:40:48 +08:00
|
|
|
$vend = $pwd
|
2014-02-27 00:46:23 +08:00
|
|
|
foreach ($s in $sources) {
|
2014-04-28 19:21:03 +08:00
|
|
|
Write-Verbose "Getting $($s.name) from URL $($s.url)"
|
2014-03-03 05:00:04 +08:00
|
|
|
|
|
|
|
# We do not care about the extensions/type of archive
|
2015-03-18 21:21:43 +08:00
|
|
|
$tempArchive = "tmp/$($s.name).tmp"
|
2014-03-03 05:00:04 +08:00
|
|
|
Delete-Existing $tempArchive
|
|
|
|
Delete-Existing $s.name
|
|
|
|
|
2015-10-13 16:40:48 +08:00
|
|
|
Download-File -Url $s.url -File $vend\$tempArchive -ErrorAction Stop
|
2014-03-05 21:31:01 +08:00
|
|
|
Extract-Archive $tempArchive $s.name
|
2014-03-03 05:00:04 +08:00
|
|
|
|
|
|
|
if ((Get-Childitem $s.name).Count -eq 1) {
|
2014-03-05 18:22:58 +08:00
|
|
|
Flatten-Directory($s.name)
|
2014-02-25 00:33:14 +08:00
|
|
|
}
|
2015-03-25 23:09:16 +08:00
|
|
|
# Write current version to .cmderver file, for later.
|
2015-05-18 05:13:04 +08:00
|
|
|
"$($s.version)" | Out-File "$($s.name)/.cmderver"
|
2014-02-27 00:46:23 +08:00
|
|
|
}
|
|
|
|
|
2015-09-02 01:05:57 +08:00
|
|
|
# Restore user configuration
|
|
|
|
if ($ConEmuXml -ne "") {
|
|
|
|
Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'"
|
|
|
|
Copy-Item $ConEmuXmlSave $ConEmuXml
|
|
|
|
}
|
|
|
|
|
2014-03-03 05:00:04 +08:00
|
|
|
Pop-Location
|
2014-08-27 06:52:49 +08:00
|
|
|
|
2015-10-14 19:59:20 +08:00
|
|
|
if($Compile) {
|
|
|
|
Push-Location -Path $launcher
|
|
|
|
msbuild CmderLauncher.vcxproj /p:configuration=Release
|
|
|
|
Pop-Location
|
|
|
|
} else {
|
2015-10-15 01:19:08 +08:00
|
|
|
Write-Warning "You are not building a launcher, Use -Compile"
|
2015-10-14 19:59:20 +08:00
|
|
|
Write-Warning "This cannot be a release. Test build only!"
|
|
|
|
}
|
2014-08-27 06:52:49 +08:00
|
|
|
|
|
|
|
Write-Verbose "All good and done!"
|