aboutsummaryrefslogtreecommitdiff
path: root/w32/common/gen_dll_res.ps1
blob: da8e4c6e8d715949d50e02f1d8283a7c6bb17f54 (plain) (blame)
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
param ([string]$BasePath = ".\")

$Host.SetShouldExit(111) # Set non-zero return code until task successfully finished
$ErrorActionPreference = "Stop" # Stop on any error

Remove-Variable MHD_ver,MHD_ver_major,MHD_ver_minor,MHD_ver_patchlev -ErrorAction:SilentlyContinue

Write-Output "Processing: ${BasePath}..\..\configure.ac"
foreach($line in Get-Content "${BasePath}..\..\configure.ac")
{
    if ($line -match '^AC_INIT\(\[(?:GNU )?libmicrohttpd\],\[((\d+).(\d+).(\d+))\]') 
    {
        [string]$MHD_ver = $Matches[1].ToString()
        [string]$MHD_ver_major = $Matches[2].ToString()
        [string]$MHD_ver_minor = $Matches[3].ToString()
        [string]$MHD_ver_patchlev = $Matches[4].ToString()
        break 
    }
}
if ("$MHD_ver" -eq "" -or "$MHD_ver_major" -eq ""  -or "$MHD_ver_minor" -eq "" -or "$MHD_ver_patchlev" -eq "")
{
    Write-Error -Message ("error MHDVSVER01 : Can't find MHD version")
    Throw ($MyInvocation.MyCommand.Name + " : error MHDVSVER01 : Can't find MHD version")
}

Write-Output "Detected MHD version: $MHD_ver"

Write-Output "Generating ${BasePath}microhttpd_dll_res_vc.rc"
Get-Content "${BasePath}microhttpd_dll_res_vc.rc.in" | ForEach-Object {
    $_  -replace '@PACKAGE_VERSION_MAJOR@',"$MHD_ver_major" `
        -replace '@PACKAGE_VERSION_MINOR@', "$MHD_ver_minor" `
        -replace '@PACKAGE_VERSION_SUBMINOR@', "$MHD_ver_patchlev" `
        -replace '@PACKAGE_VERSION@', "$MHD_ver"
} | Out-File -FilePath "${BasePath}microhttpd_dll_res_vc.rc" -Force

$Host.SetShouldExit(0) # Reset return code

Write-Output "${BasePath}microhttpd_dll_res_vc.rc was generated "
exit 0 # Exit with success code