Skip to content

Commit fab8797

Browse files
committed
Add support for build directory to handle LNK1170 error
1 parent e0a2a8b commit fab8797

File tree

6 files changed

+40
-6
lines changed

6 files changed

+40
-6
lines changed

.github/workflows/extension.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ on:
2323
description: 'Test runner to use'
2424
required: false
2525
default: 'run-tests.php'
26+
build-directory:
27+
description: 'Directory to build the extension in'
28+
required: false
2629
artifact-naming-scheme:
2730
description: 'Naming schema for the artifacts, pie or pecl'
2831
required: false
@@ -68,6 +71,7 @@ jobs:
6871
ts: ${{ matrix.ts }}
6972
args: ${{ inputs.args }}
7073
libs: ${{ inputs.libs }}
74+
build-directory: ${{ inputs.build-directory }}
7175
run-tests: ${{ inputs.run-tests }}
7276
test-runner: ${{ inputs.test-runner }}
7377

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Build a PHP extension for a specific version.
7575
- `ts` (required) - The thread safety to build the extension for.
7676
- `args` (optional) - Additional arguments to pass to the `configure` script.
7777
- `libs` (optional) - Libraries required for the extension.
78+
- `build-directory` (optional) - The directory to build the extension in, defaults to the user's temporary directory.
7879
- `run-tests` (optional) - Run the extension tests. Defaults to `true`.
7980
- `test-runner` (optional) - The test runner to use. Defaults to `run-tests.php`.
8081

extension/BuildPhpExtension/BuildPhpExtension.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
# NestedModules = @()
6161

6262
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
63-
FunctionsToExport = 'Invoke-PhpBuildExtension', 'Add-BuildRequirements', 'Add-Path', 'Get-PhpSdk', 'Add-Dependencies', 'Add-PhpDependencies', 'Get-VsVersion', 'Add-Extension', 'Get-Extension', 'Get-ExtensionSource', 'Add-ExtensionDependencies', 'Get-ExtensionConfig', 'Add-Extensions', 'Get-PhpBuild', 'Invoke-Build', 'Invoke-Tests', 'Add-Package', 'Get-PhpDevelBuild', 'Get-OlderVsVersion', 'Get-PeclLibraryZip'
63+
FunctionsToExport = 'Invoke-PhpBuildExtension', 'Add-BuildRequirements', 'Add-Path', 'Get-PhpSdk', 'Add-Dependencies', 'Add-PhpDependencies', 'Get-VsVersion', 'Add-Extension', 'Get-Extension', 'Get-BuildDirectory', 'Get-ExtensionSource', 'Add-ExtensionDependencies', 'Get-ExtensionConfig', 'Add-Extensions', 'Get-PhpBuild', 'Invoke-Build', 'Invoke-Tests', 'Add-Package', 'Get-PhpDevelBuild', 'Get-OlderVsVersion', 'Get-PeclLibraryZip'
6464

6565
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
6666
CmdletsToExport = '*'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Function Get-BuildDirectory {
2+
<#
3+
.SYNOPSIS
4+
Get the directory to build the extension.
5+
#>
6+
[OutputType()]
7+
param(
8+
)
9+
begin {
10+
}
11+
process {
12+
if ($null -ne $env:BUILD_DIRECTORY) {
13+
$parentBuildDirectory = $env:BUILD_DIRECTORY
14+
} else {
15+
$parentBuildDirectory = [System.IO.Path]::GetTempPath()
16+
}
17+
18+
$buildDirectory = [System.Guid]::NewGuid().ToString().substring(0, 8)
19+
20+
$buildDirectoryPath = [System.IO.Path]::Combine($parentBuildDirectory, $buildDirectory)
21+
22+
New-Item "$buildDirectoryPath" -ItemType "directory" -Force > $null 2>&1
23+
24+
return $buildDirectoryPath
25+
}
26+
end {
27+
}
28+
}

extension/BuildPhpExtension/public/Invoke-PhpBuildExtension.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ function Invoke-PhpBuildExtension {
4545

4646
$currentDirectory = (Get-Location).Path
4747

48-
$tempDirectory = [System.IO.Path]::GetTempPath()
49-
50-
$buildDirectory = [System.IO.Path]::Combine($tempDirectory, [System.Guid]::NewGuid().ToString())
51-
52-
New-Item "$buildDirectory" -ItemType "directory" -Force > $null 2>&1
48+
$buildDirectory = Get-BuildDirectory
5349

5450
Set-Location "$buildDirectory"
5551

extension/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ inputs:
3636
description: Test runner to use
3737
required: false
3838
default: 'run-tests.php'
39+
build-directory:
40+
description: Directory to build the extension in
41+
required: false
42+
default: 'build'
3943
artifact-naming-scheme:
4044
description: Naming schema for the artifacts, pie or pecl
4145
deprecationMessage: "This will be removed once pie is released"
@@ -56,6 +60,7 @@ runs:
5660
ARTIFACT_NAMING_SCHEME: ${{inputs.artifact-naming-scheme}}
5761
RUN_TESTS: ${{inputs.run-tests}}
5862
TEST_RUNNER: ${{inputs.test-runner}}
63+
BUILD_DIRECTORY: ${{inputs.build-directory}}
5964
run: |
6065
Import-Module ${{ github.action_path }}\BuildPhpExtension -Force
6166
Invoke-PhpBuildExtension -ExtensionUrl "${{inputs.extension-url}}" `

0 commit comments

Comments
 (0)