You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

54 lines
2.5 KiB

  1. # Script to generate the necessary files for a msvscpp build
  2. #
  3. # Version: 20161110
  4. $WinFlex = "..\win_flex_bison\win_flex.exe"
  5. $WinBison = "..\win_flex_bison\win_bison.exe"
  6. $Library = Get-Content -Path configure.ac | select -skip 3 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" }
  7. $Version = Get-Content -Path configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" }
  8. $Prefix = ${Library}.Substring(3)
  9. Get-Content -Path "include\${Library}.h.in" > "include\${Library}.h"
  10. Get-Content -Path "include\${Library}\definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } > "include\${Library}\definitions.h"
  11. Get-Content -Path "include\${Library}\features.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } > "include\${Library}\features.h"
  12. Get-Content -Path "include\${Library}\types.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } > "include\${Library}\types.h"
  13. Get-Content -Path "common\types.h.in" | % { $_ -Replace "@PACKAGE@","${Library}" } > "common\types.h"
  14. Get-Content -Path "${Library}\${Library}_definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } > "${Library}\${Library}_definitions.h"
  15. Get-Content -Path "${Library}\${Library}.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } > "${Library}\${Library}.rc"
  16. If (Test-Path "${Prefix}.net")
  17. {
  18. Get-Content -Path "${Prefix}.net\${Prefix}.net.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } > "${Prefix}.net\${Prefix}.net.rc"
  19. }
  20. $NamePrefix = ""
  21. ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.l")
  22. {
  23. $OutputFile = ${DirectoryElement} -Replace ".l$",".c"
  24. $NamePrefix = Split-Path -path ${DirectoryElement} -leaf
  25. $NamePrefix = ${NamePrefix} -Replace "^${Library}_",""
  26. $NamePrefix = ${NamePrefix} -Replace ".l$","_"
  27. # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr
  28. # therefore 2>&1 is added and the output is stored in a variable.
  29. $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1"
  30. Write-Host ${Output}
  31. # Moving manually since win_flex -o <filename> does not provide the expected behavior.
  32. Move-Item "lex.yy.c" ${OutputFile} -force
  33. }
  34. ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.y")
  35. {
  36. $OutputFile = ${DirectoryElement} -Replace ".y$",".c"
  37. # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr
  38. # therefore 2>&1 is added and the output is stored in a variable.
  39. $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1"
  40. Write-Host ${Output}
  41. }