libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

gen_dll_res.ps1 (1619B)


      1 param ([string]$BasePath = ".\")
      2 
      3 $Host.SetShouldExit(111) # Set non-zero return code until task successfully finished
      4 $ErrorActionPreference = "Stop" # Stop on any error
      5 
      6 Remove-Variable MHD_ver,MHD_ver_major,MHD_ver_minor,MHD_ver_patchlev -ErrorAction:SilentlyContinue
      7 
      8 Write-Output "Processing: ${BasePath}..\..\configure.ac"
      9 foreach($line in Get-Content "${BasePath}..\..\configure.ac")
     10 {
     11     if ($line -match '^AC_INIT\(\[(?:GNU )?libmicrohttpd2\], *\[((\d+).(\d+).(\d+)) *\]') 
     12     {
     13         [string]$MHD_ver = $Matches[1].ToString()
     14         [string]$MHD_ver_major = $Matches[2].ToString()
     15         [string]$MHD_ver_minor = $Matches[3].ToString()
     16         [string]$MHD_ver_patchlev = $Matches[4].ToString()
     17         break 
     18     }
     19 }
     20 if ("$MHD_ver" -eq "" -or "$MHD_ver_major" -eq ""  -or "$MHD_ver_minor" -eq "" -or "$MHD_ver_patchlev" -eq "")
     21 {
     22     Write-Error -Message ("error MHDVSVER01 : Can't find MHD version")
     23     Throw ($MyInvocation.MyCommand.Name + " : error MHDVSVER01 : Can't find MHD version")
     24 }
     25 
     26 Write-Output "Detected MHD version: $MHD_ver"
     27 
     28 Write-Output "Generating ${BasePath}microhttpd2.rc"
     29 Get-Content "${BasePath}microhttpd2.rc.in" | ForEach-Object {
     30     $_  -replace '@PACKAGE_VERSION_MAJOR@',"$MHD_ver_major" `
     31         -replace '@PACKAGE_VERSION_MINOR@', "$MHD_ver_minor" `
     32         -replace '@PACKAGE_VERSION_SUBMINOR@', "$MHD_ver_patchlev" `
     33         -replace '@PACKAGE_VERSION@', "$MHD_ver"
     34 } | Out-File -FilePath "${BasePath}microhttpd2.rc" -Force
     35 
     36 $Host.SetShouldExit(0) # Reset return code
     37 
     38 Write-Output "${BasePath}microhttpd_dll_res_vc.rc was generated "
     39 exit 0 # Exit with success code