Skip to content

Commit 3037d36

Browse files
committed
Add support for build tools
1 parent 86da543 commit 3037d36

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Function Add-BuildTools {
2+
<#
3+
.SYNOPSIS
4+
Add build tools.
5+
.PARAMETER Config
6+
Configuration for the extension.
7+
#>
8+
[OutputType()]
9+
param(
10+
[Parameter(Mandatory = $true, Position=0, HelpMessage='Configuration for the extension')]
11+
[PSCustomObject] $Config
12+
)
13+
begin {
14+
}
15+
process {
16+
$Config.build_tools | ForEach-Object {
17+
if($null -eq (Get-Command $_ -ErrorAction SilentlyContinue)) {
18+
switch ($_)
19+
{
20+
nasm {
21+
choco install nasm -y --force
22+
Add-Path -Path "$env:ProgramFiles\NASM"
23+
}
24+
cmake {
25+
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=User' -y --force
26+
}
27+
cargo {
28+
choco install rust -y --force
29+
Add-Path -Path "$env:USERPROFILE\.cargo\bin"
30+
}
31+
git {
32+
choco install git.install --params "'/GitAndUnixToolsOnPath /WindowsTerminal /NoAutoCrlf'" -y --force
33+
}
34+
Default {
35+
$resultLines = (choco search $_ --limit-output) -split "\`r?\`n"
36+
if($resultLines | Where-Object { $_ -match "^$_\|" }) {
37+
choco install $_ -y --force
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
end {
45+
}
46+
}

extension/BuildPhpExtension/private/Add-Dependencies.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Function Add-Dependencies {
1919
process {
2020
Add-PhpDependencies -Config $Config
2121
Add-ExtensionDependencies -Config $Config
22+
Add-BuildTools -Config $Config
2223
Add-Extensions -Config $Config -Prefix $Prefix
2324
}
2425
end {

extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Function Get-ExtensionConfig {
7272
options = @()
7373
php_libraries = @()
7474
extension_libraries = @()
75+
build_tools = @()
7576
extensions = @()
7677
docs = @()
7778
build_directory = ""
@@ -162,6 +163,13 @@ Function Get-ExtensionConfig {
162163
}
163164
}
164165

166+
$configW32Content = [string](Get-Content -Path "config.w32")
167+
if($configW32Content.contains('PATH_PROG')) {
168+
[regex]::Matches($configW32Content, 'PATH_PROG\(([''"])([^''"]+)\1') | ForEach-Object {
169+
$config.build_tools += $_.Groups[2].Value
170+
}
171+
}
172+
165173
$config.build_directory = if ($Arch -eq "x64") { "x64\" } else { "" }
166174
$config.build_directory += "Release"
167175
if ($Ts -eq "ts") { $config.build_directory += "_TS" }

0 commit comments

Comments
 (0)