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