|
1 | 1 | # Script to generate the necessary files for a msvscpp build |
2 | 2 | # |
3 | | -# Version: 20260505 |
| 3 | +# Version: 20260608 |
4 | 4 |
|
5 | 5 | $WinFlex = "..\win_flex_bison\win_flex.exe" |
6 | 6 | $WinBison = "..\win_flex_bison\win_bison.exe" |
7 | 7 |
|
8 | | -$Library = Get-Content -Path configure.ac | select -skip 3 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } |
9 | | -$Version = Get-Content -Path configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } |
10 | | -$Prefix = ${Library}.Substring(3) |
| 8 | +$PackageName = Get-Content -Path configure.ac | |
| 9 | + select -skip 3 -first 1 | |
| 10 | + % { $_ -Replace " \[","" } | |
| 11 | + % { $_ -Replace "\],","" } |
| 12 | +$PackageVersion = Get-Content -Path configure.ac | |
| 13 | + select -skip 4 -first 1 | |
| 14 | + % { $_ -Replace " \[","" } | |
| 15 | + % { $_ -Replace "\],","" } |
11 | 16 |
|
12 | | -Get-Content -Path "include\${Library}.h.in" | Out-File -Encoding ascii "include\${Library}.h" |
13 | | -Get-Content -Path "include\${Library}\definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "include\${Library}\definitions.h" |
14 | | -Get-Content -Path "include\${Library}\features.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } | Out-File -Encoding ascii "include\${Library}\features.h" |
15 | | -Get-Content -Path "include\${Library}\types.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } | Out-File -Encoding ascii "include\${Library}\types.h" |
16 | | -Get-Content -Path "common\types.h.in" | % { $_ -Replace "@PACKAGE@","${Library}" } | Out-File -Encoding ascii "common\types.h" |
17 | | -Get-Content -Path "${Library}\${Library}_definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Library}\${Library}_definitions.h" |
18 | | -Get-Content -Path "${Library}\${Library}.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Library}\${Library}.rc" |
| 17 | +Get-Content -Path "common\types.h.in" | |
| 18 | + % { $_ -Replace "@PACKAGE@","${PackageName}" } | |
| 19 | + Out-File -Encoding ascii "common\types.h" |
19 | 20 |
|
| 21 | +If (Test-Path "include\${PackageName}.h.in") |
| 22 | +{ |
| 23 | + Get-Content -Path "include\${PackageName}.h.in" | |
| 24 | + Out-File -Encoding ascii "include\${PackageName}.h" |
| 25 | + Get-Content -Path "include\${PackageName}\definitions.h.in" | |
| 26 | + % { $_ -Replace "@VERSION@","${PackageVersion}" } | |
| 27 | + Out-File -Encoding ascii "include\${PackageName}\definitions.h" |
| 28 | + Get-Content -Path "include\${PackageName}\features.h.in" | |
| 29 | + % { $_ -Replace "@[A-Z0-9_]*@","0" } | |
| 30 | + Out-File -Encoding ascii "include\${PackageName}\features.h" |
| 31 | + Get-Content -Path "include\${PackageName}\types.h.in" | |
| 32 | + % { $_ -Replace "@[A-Z0-9_]*@","0" } | |
| 33 | + Out-File -Encoding ascii "include\${PackageName}\types.h" |
| 34 | +} |
| 35 | +If (Test-Path "${PackageName}\${PackageName}.c") |
| 36 | +{ |
| 37 | + Get-Content -Path "${PackageName}\${PackageName}_definitions.h.in" | |
| 38 | + % { $_ -Replace "@VERSION@","${PackageVersion}" } | |
| 39 | + Out-File -Encoding ascii "${PackageName}\${PackageName}_definitions.h" |
| 40 | + Get-Content -Path "${PackageName}\${PackageName}.rc.in" | |
| 41 | + % { $_ -Replace "@VERSION@","${PackageVersion}" } | |
| 42 | + Out-File -Encoding ascii "${PackageName}\${PackageName}.rc" |
| 43 | +} |
20 | 44 | If (Test-Path "pyproject.toml.in") |
21 | 45 | { |
22 | | - Get-Content -Path "pyproject.toml.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "pyproject.toml" |
| 46 | + Get-Content -Path "pyproject.toml.in" | |
| 47 | + % { $_ -Replace "@VERSION@","${PackageVersion}" } | |
| 48 | + Out-File -Encoding ascii "pyproject.toml" |
23 | 49 | } |
| 50 | +$PackagePrefix = ${PackageName}.Substring(3) |
24 | 51 |
|
25 | | -If (Test-Path "${Prefix}.net") |
| 52 | +If (Test-Path "${PackagePrefix}.net") |
26 | 53 | { |
27 | | - Get-Content -Path "${Prefix}.net\${Prefix}.net.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Prefix}.net\${Prefix}.net.rc" |
| 54 | + Get-Content -Path "${PackagePrefix}.net\${PackagePrefix}.net.rc.in" | |
| 55 | + % { $_ -Replace "@VERSION@","${PackageVersion}" } | |
| 56 | + Out-File -Encoding ascii "${PackagePrefix}.net\${PackagePrefix}.net.rc" |
28 | 57 | } |
29 | | - |
30 | | -$NamePrefix = "" |
31 | | - |
32 | | -ForEach (${Library} in Get-ChildItem -Directory -Path "lib*") |
| 58 | +ForEach (${PackageName} in Get-ChildItem -Directory -Path "lib*") |
33 | 59 | { |
34 | | - ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.l") |
| 60 | + $NamePrefix = "" |
| 61 | + |
| 62 | + ForEach (${DirectoryElement} in Get-ChildItem -Path "${PackageName}\*.l") |
35 | 63 | { |
36 | 64 | $OutputFile = ${DirectoryElement} -Replace ".l$",".c" |
37 | 65 |
|
38 | 66 | $NamePrefix = Split-Path -path ${DirectoryElement} -leaf |
39 | 67 | $NamePrefix = ${NamePrefix} -Replace ".l$","_" |
40 | 68 |
|
41 | | - Write-Host "Running: ${WinFlex} -Cf ${DirectoryElement}" |
| 69 | + $WinFlexArguments = @( |
| 70 | + "-Cf", |
| 71 | + "${DirectoryElement}" |
| 72 | + ) |
| 73 | + Write-Host "Running: ${WinFlex} $($WinFlexArguments -join ' ')" |
42 | 74 |
|
43 | 75 | # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr |
44 | 76 | # therefore 2>&1 is added and the output is stored in a variable. |
45 | | - $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1" |
| 77 | + $Output = Invoke-Expression -Command "& '${WinFlex}' $($WinFlexArguments -join ' ') 2>&1" | %{ "$_" } |
46 | 78 | Write-Host ${Output} |
47 | 79 |
|
48 | 80 | # Moving manually since `win_flex -o filename' does not provide the expected behavior. |
49 | 81 | Move-Item "lex.yy.c" ${OutputFile} -force |
50 | 82 | } |
51 | | - |
52 | | - ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.y") |
| 83 | + ForEach (${DirectoryElement} in Get-ChildItem -Path "${PackageName}\*.y") |
53 | 84 | { |
54 | 85 | $OutputFile = ${DirectoryElement} -Replace ".y$",".c" |
55 | 86 |
|
56 | | - Write-Host "Running: ${WinBison} -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement}" |
| 87 | + $WinBisonArguments = @( |
| 88 | + "-d" |
| 89 | + "-v" |
| 90 | + "-l" |
| 91 | + "-p", "${NamePrefix}" |
| 92 | + "-o", "${OutputFile}" |
| 93 | + "${DirectoryElement}" |
| 94 | + ) |
| 95 | + Write-Host "Running: ${WinBison} $($WinBisonArguments -join ' ')" |
57 | 96 |
|
58 | 97 | # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr |
59 | 98 | # therefore 2>&1 is added and the output is stored in a variable. |
60 | | - $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1" |
| 99 | + $Output = Invoke-Expression -Command "& '${WinBison}' $($WinBisonArguments -join ' ') 2>&1" | %{ "$_" } |
61 | 100 | Write-Host ${Output} |
62 | 101 | } |
63 | 102 | } |
64 | | - |
|
0 commit comments