Skip to content

Commit be44bac

Browse files
committed
fix line endings
1 parent 4fb6bed commit be44bac

File tree

3 files changed

+508
-508
lines changed

3 files changed

+508
-508
lines changed

scripts/build.ps1

Lines changed: 181 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1,181 +1,181 @@
1-
<#
2-
.Synopsis
3-
Build Cmder
4-
.DESCRIPTION
5-
Use this script to build your own edition of Cmder
6-
7-
This script builds dependencies from current vendor/sources.json file and unpacks them.
8-
9-
You will need to make this script executable by setting your Powershell Execution Policy to Remote signed
10-
Then unblock the script for execution with UnblockFile .\build.ps1
11-
.EXAMPLE
12-
.\build.ps1
13-
14-
Executes the default build for Cmder; ConEmu, clink. This is equivalent to the "minimum" style package in the releases
15-
.EXAMPLE
16-
.\build.ps1 -Compile
17-
18-
Recompile the launcher executable if you have the requisite build tools for C++ installed.
19-
.EXAMPLE
20-
.\build.ps1 -Compile -NoVendor
21-
22-
Skip all downloads and only build launcher.
23-
.EXAMPLE
24-
.\build -verbose
25-
26-
Execute the build and see what's going on.
27-
.EXAMPLE
28-
.\build.ps1 -SourcesPath '~/custom/vendors.json'
29-
30-
Build Cmder with your own packages. See vendor/sources.json for the syntax you need to copy.
31-
.NOTES
32-
AUTHORS
33-
Samuel Vasko, Jack Bennett
34-
Part of the Cmder project.
35-
.LINK
36-
http://cmder.app/ - Project Home
37-
#>
38-
[CmdletBinding(SupportsShouldProcess = $true)]
39-
Param(
40-
# CmdletBinding will give us;
41-
# -verbose switch to turn on logging and
42-
# -whatif switch to not actually make changes
43-
44-
# Path to the vendor configuration source file
45-
[string]$sourcesPath = "$PSScriptRoot\..\vendor\sources.json",
46-
47-
# Vendor folder location
48-
[string]$saveTo = "$PSScriptRoot\..\vendor\",
49-
50-
# Launcher folder location
51-
[string]$launcher = "$PSScriptRoot\..\launcher",
52-
53-
# Config folder location
54-
[string]$config = "$PSScriptRoot\..\config",
55-
56-
# Using this option will skip all downloads, if you only need to build launcher
57-
[switch]$noVendor,
58-
59-
# Build launcher if you have MSBuild tools installed
60-
[switch]$Compile
61-
)
62-
63-
# Get the scripts and Cmder root dirs we are building in.
64-
$cmder_root = Resolve-Path "$PSScriptRoot\.."
65-
66-
# Dot source util functions into this scope
67-
. "$PSScriptRoot\utils.ps1"
68-
$ErrorActionPreference = "Stop"
69-
70-
if ($Compile) {
71-
# Check for requirements
72-
Ensure-Executable "msbuild"
73-
74-
# Get the version string
75-
$version = Get-VersionStr
76-
77-
Push-Location -Path $launcher
78-
Create-RC $version ($launcher + '\src\version.rc2')
79-
80-
Write-Verbose "Building the launcher..."
81-
82-
# Reference: https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
83-
msbuild CmderLauncher.vcxproj /t:Clean,Build /p:configuration=Release /m
84-
85-
if ($LastExitCode -ne 0) {
86-
throw "MSBuild failed to build the launcher executable."
87-
}
88-
Pop-Location
89-
}
90-
91-
if (-not $noVendor) {
92-
# Check for requirements
93-
Ensure-Exists $sourcesPath
94-
Ensure-Executable "7z"
95-
96-
# Get the vendor sources
97-
$sources = Get-Content $sourcesPath | Out-String | ConvertFrom-Json
98-
99-
Push-Location -Path $saveTo
100-
New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null
101-
102-
$vend = $pwd
103-
104-
# Preserve modified (by user) ConEmu setting file
105-
if ($config -ne "") {
106-
$ConEmuXml = Join-Path $saveTo "conemu-maximus5\ConEmu.xml"
107-
if (Test-Path $ConEmuXml -pathType leaf) {
108-
$ConEmuXmlSave = Join-Path $config "ConEmu.xml"
109-
Write-Verbose "Backup '$ConEmuXml' to '$ConEmuXmlSave'"
110-
Copy-Item $ConEmuXml $ConEmuXmlSave
111-
}
112-
else { $ConEmuXml = "" }
113-
}
114-
else { $ConEmuXml = "" }
115-
116-
# Kill ssh-agent.exe if it is running from the $env:cmder_root we are building
117-
foreach ($ssh_agent in $(Get-Process ssh-agent -ErrorAction SilentlyContinue)) {
118-
if ([string]$($ssh_agent.path) -Match [string]$cmder_root.replace('\', '\\')) {
119-
Write-Verbose $("Stopping " + $ssh_agent.path + "!")
120-
Stop-Process $ssh_agent.id
121-
}
122-
}
123-
124-
foreach ($s in $sources) {
125-
Write-Verbose "Getting vendored $($s.name) $($s.version)..."
126-
127-
# We do not care about the extensions/type of archive
128-
$tempArchive = "tmp/$($s.name).tmp"
129-
Delete-Existing $tempArchive
130-
Delete-Existing $s.name
131-
132-
Download-File -Url $s.url -File $vend\$tempArchive -ErrorAction Stop
133-
Extract-Archive $tempArchive $s.name
134-
135-
if ((Get-ChildItem $s.name).Count -eq 1) {
136-
Flatten-Directory($s.name)
137-
}
138-
139-
# Write current version to .cmderver file, for later.
140-
"$($s.version)" | Out-File "$($s.name)/.cmderver"
141-
}
142-
143-
# Restore ConEmu user configuration
144-
if ($ConEmuXml -ne "") {
145-
Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'"
146-
Copy-Item $ConEmuXmlSave $ConEmuXml
147-
}
148-
149-
# Put vendor\cmder.sh in /etc/profile.d so it runs when we start bash or mintty
150-
if ( (Test-Path $($saveTo + "git-for-windows/etc/profile.d") ) ) {
151-
Write-Verbose "Adding cmder.sh /etc/profile.d"
152-
Copy-Item $($saveTo + "cmder.sh") $($saveTo + "git-for-windows/etc/profile.d/cmder.sh")
153-
}
154-
155-
# Replace /etc/profile.d/git-prompt.sh with cmder lambda prompt so it runs when we start bash or mintty
156-
if ( !(Test-Path $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") ) ) {
157-
Write-Verbose "Replacing /etc/profile.d/git-prompt.sh with our git-prompt.sh"
158-
Move-Item $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak")
159-
Copy-Item $($saveTo + "git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh")
160-
}
161-
162-
Pop-Location
163-
}
164-
165-
if (-not $Compile -or $noVendor) {
166-
Write-Warning "You are not building the full project, Use -Compile without -noVendor"
167-
Write-Warning "This cannot be a release. Test build only!"
168-
return
169-
}
170-
171-
Write-Verbose "Successfully built Cmder v$version!"
172-
173-
if ( $Env:APPVEYOR -eq 'True' ) {
174-
Add-AppveyorMessage -Message "Building Cmder v$version was successful." -Category Information
175-
}
176-
177-
if ( $Env:GITHUB_ACTIONS -eq 'true' ) {
178-
Write-Output "::notice title=Build Complete::Building Cmder v$version was successful."
179-
}
180-
181-
Write-Host -ForegroundColor green "All good and done!"
1+
<#
2+
.Synopsis
3+
Build Cmder
4+
.DESCRIPTION
5+
Use this script to build your own edition of Cmder
6+
7+
This script builds dependencies from current vendor/sources.json file and unpacks them.
8+
9+
You will need to make this script executable by setting your Powershell Execution Policy to Remote signed
10+
Then unblock the script for execution with UnblockFile .\build.ps1
11+
.EXAMPLE
12+
.\build.ps1
13+
14+
Executes the default build for Cmder; ConEmu, clink. This is equivalent to the "minimum" style package in the releases
15+
.EXAMPLE
16+
.\build.ps1 -Compile
17+
18+
Recompile the launcher executable if you have the requisite build tools for C++ installed.
19+
.EXAMPLE
20+
.\build.ps1 -Compile -NoVendor
21+
22+
Skip all downloads and only build launcher.
23+
.EXAMPLE
24+
.\build -verbose
25+
26+
Execute the build and see what's going on.
27+
.EXAMPLE
28+
.\build.ps1 -SourcesPath '~/custom/vendors.json'
29+
30+
Build Cmder with your own packages. See vendor/sources.json for the syntax you need to copy.
31+
.NOTES
32+
AUTHORS
33+
Samuel Vasko, Jack Bennett
34+
Part of the Cmder project.
35+
.LINK
36+
http://cmder.app/ - Project Home
37+
#>
38+
[CmdletBinding(SupportsShouldProcess = $true)]
39+
Param(
40+
# CmdletBinding will give us;
41+
# -verbose switch to turn on logging and
42+
# -whatif switch to not actually make changes
43+
44+
# Path to the vendor configuration source file
45+
[string]$sourcesPath = "$PSScriptRoot\..\vendor\sources.json",
46+
47+
# Vendor folder location
48+
[string]$saveTo = "$PSScriptRoot\..\vendor\",
49+
50+
# Launcher folder location
51+
[string]$launcher = "$PSScriptRoot\..\launcher",
52+
53+
# Config folder location
54+
[string]$config = "$PSScriptRoot\..\config",
55+
56+
# Using this option will skip all downloads, if you only need to build launcher
57+
[switch]$noVendor,
58+
59+
# Build launcher if you have MSBuild tools installed
60+
[switch]$Compile
61+
)
62+
63+
# Get the scripts and Cmder root dirs we are building in.
64+
$cmder_root = Resolve-Path "$PSScriptRoot\.."
65+
66+
# Dot source util functions into this scope
67+
. "$PSScriptRoot\utils.ps1"
68+
$ErrorActionPreference = "Stop"
69+
70+
if ($Compile) {
71+
# Check for requirements
72+
Ensure-Executable "msbuild"
73+
74+
# Get the version string
75+
$version = Get-VersionStr
76+
77+
Push-Location -Path $launcher
78+
Create-RC $version ($launcher + '\src\version.rc2')
79+
80+
Write-Verbose "Building the launcher..."
81+
82+
# Reference: https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
83+
msbuild CmderLauncher.vcxproj /t:Clean,Build /p:configuration=Release /m
84+
85+
if ($LastExitCode -ne 0) {
86+
throw "MSBuild failed to build the launcher executable."
87+
}
88+
Pop-Location
89+
}
90+
91+
if (-not $noVendor) {
92+
# Check for requirements
93+
Ensure-Exists $sourcesPath
94+
Ensure-Executable "7z"
95+
96+
# Get the vendor sources
97+
$sources = Get-Content $sourcesPath | Out-String | ConvertFrom-Json
98+
99+
Push-Location -Path $saveTo
100+
New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null
101+
102+
$vend = $pwd
103+
104+
# Preserve modified (by user) ConEmu setting file
105+
if ($config -ne "") {
106+
$ConEmuXml = Join-Path $saveTo "conemu-maximus5\ConEmu.xml"
107+
if (Test-Path $ConEmuXml -pathType leaf) {
108+
$ConEmuXmlSave = Join-Path $config "ConEmu.xml"
109+
Write-Verbose "Backup '$ConEmuXml' to '$ConEmuXmlSave'"
110+
Copy-Item $ConEmuXml $ConEmuXmlSave
111+
}
112+
else { $ConEmuXml = "" }
113+
}
114+
else { $ConEmuXml = "" }
115+
116+
# Kill ssh-agent.exe if it is running from the $env:cmder_root we are building
117+
foreach ($ssh_agent in $(Get-Process ssh-agent -ErrorAction SilentlyContinue)) {
118+
if ([string]$($ssh_agent.path) -Match [string]$cmder_root.replace('\', '\\')) {
119+
Write-Verbose $("Stopping " + $ssh_agent.path + "!")
120+
Stop-Process $ssh_agent.id
121+
}
122+
}
123+
124+
foreach ($s in $sources) {
125+
Write-Verbose "Getting vendored $($s.name) $($s.version)..."
126+
127+
# We do not care about the extensions/type of archive
128+
$tempArchive = "tmp/$($s.name).tmp"
129+
Delete-Existing $tempArchive
130+
Delete-Existing $s.name
131+
132+
Download-File -Url $s.url -File $vend\$tempArchive -ErrorAction Stop
133+
Extract-Archive $tempArchive $s.name
134+
135+
if ((Get-ChildItem $s.name).Count -eq 1) {
136+
Flatten-Directory($s.name)
137+
}
138+
139+
# Write current version to .cmderver file, for later.
140+
"$($s.version)" | Out-File "$($s.name)/.cmderver"
141+
}
142+
143+
# Restore ConEmu user configuration
144+
if ($ConEmuXml -ne "") {
145+
Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'"
146+
Copy-Item $ConEmuXmlSave $ConEmuXml
147+
}
148+
149+
# Put vendor\cmder.sh in /etc/profile.d so it runs when we start bash or mintty
150+
if ( (Test-Path $($saveTo + "git-for-windows/etc/profile.d") ) ) {
151+
Write-Verbose "Adding cmder.sh /etc/profile.d"
152+
Copy-Item $($saveTo + "cmder.sh") $($saveTo + "git-for-windows/etc/profile.d/cmder.sh")
153+
}
154+
155+
# Replace /etc/profile.d/git-prompt.sh with cmder lambda prompt so it runs when we start bash or mintty
156+
if ( !(Test-Path $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") ) ) {
157+
Write-Verbose "Replacing /etc/profile.d/git-prompt.sh with our git-prompt.sh"
158+
Move-Item $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak")
159+
Copy-Item $($saveTo + "git-prompt.sh") $($saveTo + "git-for-windows/etc/profile.d/git-prompt.sh")
160+
}
161+
162+
Pop-Location
163+
}
164+
165+
if (-not $Compile -or $noVendor) {
166+
Write-Warning "You are not building the full project, Use -Compile without -noVendor"
167+
Write-Warning "This cannot be a release. Test build only!"
168+
return
169+
}
170+
171+
Write-Verbose "Successfully built Cmder v$version!"
172+
173+
if ( $Env:APPVEYOR -eq 'True' ) {
174+
Add-AppveyorMessage -Message "Building Cmder v$version was successful." -Category Information
175+
}
176+
177+
if ( $Env:GITHUB_ACTIONS -eq 'true' ) {
178+
Write-Output "::notice title=Build Complete::Building Cmder v$version was successful."
179+
}
180+
181+
Write-Host -ForegroundColor green "All good and done!"

0 commit comments

Comments
 (0)