gen_dll_res.ps1 1.6 KB

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