Skip to content

Commit ecd7369

Browse files
committed
Rewrite batch to powershell
1 parent 5f4f0eb commit ecd7369

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

.ci/lemon-parser.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Write-Output "-- Compiling Lemon parser..."
2+
$LemonSrc = Join-Path -Path './parser' -ChildPath 'lemon.c'
3+
$LemonBin = Join-Path -Path './parser' -ChildPath 'lemon.exe'
4+
5+
if ($IsWindows) {
6+
& cl /Fe${LemonExe} ${LemonSrc}
7+
}
8+
else {
9+
$LemonBin = Join-Path -Path './parser' -ChildPath 'lemon'
10+
& gcc ${LemonSrc} -o ${LemonBin}
11+
}
12+
& ${LemonBin} -x
13+
14+
Write-Output "-- Cleanup initial file state..."
15+
16+
$AutoFiles = "./parser/zephir.c",
17+
"./parser/zephir.h",
18+
"./parser/parser.c",
19+
"./parser/scanner.c"
20+
21+
foreach ($GeneratedFile in $AutoFiles) {
22+
if (Test-Path -Path $GeneratedFile) {
23+
Remove-Item $GeneratedFile
24+
}
25+
}
26+
27+
Write-Output "-- Run re2c..."
28+
& re2c -o (Join-Path -Path './parser' -ChildPath 'scanner.c') (Join-Path -Path './parser' -ChildPath 'scanner.re')
29+
30+
Write-Output "-- Generating zephir.c file with lemon parser..."
31+
& ${LemonBin} -s (Join-Path -Path './parser' -ChildPath 'zephir.lemon')
32+
33+
Write-Output "-- Generating parser.c file..."
34+
$ParserC = Join-Path -Path './parser' -ChildPath 'parser.c'
35+
$ZephirC = Join-Path -Path './parser' -ChildPath 'zephir.c'
36+
$BaseC = Join-Path -Path './parser' -ChildPath 'base.c'
37+
Set-Content -Path ${ParserC} -Value '#include <php.h>'
38+
Get-Content ${ParserC}, ${ZephirC}, ${BaseC} | Set-Content ${ParserC}

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
shell: cmd
118118
run: |
119119
call C:\tools\php-sdk\bin\phpsdk_setvars.bat
120-
call .\.ci\build-win32.bat
120+
powershell.exe -File .\.ci\lemon-parser.ps1
121121
# CD parser
122122
# DEL zephir.c zephir.h parser.c scanner.c
123123
# re2c -o scanner.c scanner.re

0 commit comments

Comments
 (0)