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.
 
 
 
 
 
 

101 lines
3.3 KiB

  1. # Script that synchronizes the local library dependencies
  2. #
  3. # Version: 20180125
  4. Param (
  5. [switch]$UseHead = $false
  6. )
  7. $GitUrlPrefix = "https://github.com/libyal"
  8. $LocalLibs = "libbfio libcdata libcerror libcfile libclocale libcnotify libcpath libcsplit libcthreads libfcache libfdata libfdatetime libfguid libfmapi libfvalue libfwnt libuna"
  9. $LocalLibs = ${LocalLibs} -split " "
  10. $Git = "git"
  11. $WinFlex = "..\win_flex_bison\win_flex.exe"
  12. $WinBison = "..\win_flex_bison\win_bison.exe"
  13. ForEach (${LocalLib} in ${LocalLibs})
  14. {
  15. # Split will return an array of a single empty string when LocalLibs is empty.
  16. If (-Not (${LocalLib}))
  17. {
  18. Continue
  19. }
  20. $GitUrl = "${GitUrlPrefix}/${LocalLib}.git"
  21. # PowerShell will raise NativeCommandError if git writes to stdout or stderr
  22. # therefore 2>&1 is added and the output is stored in a variable.
  23. $Output = Invoke-Expression -Command "${Git} clone ${GitUrl} ${LocalLib}-${pid} 2>&1"
  24. Push-Location "${LocalLib}-${pid}"
  25. Try
  26. {
  27. $Output = Invoke-Expression -Command "${Git} fetch --quiet --all --tags --prune 2>&1"
  28. $LatestTag = Invoke-Expression -Command "${Git} describe --tags --abbrev=0 2>&1"
  29. If (${LatestTag} -and -not ${UseHead})
  30. {
  31. Write-Host "Synchronizing: ${LocalLib} from ${GitUrl} tag ${LatestTag}"
  32. $Output = Invoke-Expression -Command "${Git} checkout --quiet tags/${LatestTag} 2>&1"
  33. }
  34. Else
  35. {
  36. Write-Host "Synchronizing: ${LocalLib} from ${GitUrl} HEAD"
  37. }
  38. }
  39. Finally
  40. {
  41. Pop-Location
  42. }
  43. If (Test-Path ${LocalLib}-${pid})
  44. {
  45. $LocalLibVersion = Get-Content -Path ${LocalLib}-${pid}\configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" }
  46. If (Test-Path ${LocalLib})
  47. {
  48. Remove-Item -Path ${LocalLib} -Force -Recurse
  49. }
  50. New-Item -ItemType directory -Path ${LocalLib} -Force | Out-Null
  51. If (Test-Path ${LocalLib})
  52. {
  53. Copy-Item -Path ${LocalLib}-${pid}\${LocalLib}\*.[chly] -Destination ${LocalLib}\
  54. Get-Content -Path ${LocalLib}-${pid}\${LocalLib}\${LocalLib}_definitions.h.in | % { $_ -Replace "@VERSION@",${LocalLibVersion} } > ${LocalLib}\${LocalLib}_definitions.h
  55. }
  56. Remove-Item -Path ${LocalLib}-${pid} -Force -Recurse
  57. $NamePrefix = ""
  58. ForEach (${DirectoryElement} in Get-ChildItem -Path "${LocalLib}\*.l")
  59. {
  60. $OutputFile = ${DirectoryElement} -Replace ".l$",".c"
  61. $NamePrefix = Split-Path -path ${DirectoryElement} -leaf
  62. $NamePrefix = ${NamePrefix} -Replace "^${LocalLib}_",""
  63. $NamePrefix = ${NamePrefix} -Replace ".l$","_"
  64. # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr
  65. # therefore 2>&1 is added and the output is stored in a variable.
  66. $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1"
  67. Write-Host ${Output}
  68. # Moving manually sicne win_flex -o <filename> does not provide the expected behavior.
  69. Move-Item "lex.yy.c" ${OutputFile} -force
  70. }
  71. ForEach (${DirectoryElement} in Get-ChildItem -Path "${LocalLib}\*.y")
  72. {
  73. $OutputFile = ${DirectoryElement} -Replace ".y$",".c"
  74. # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr
  75. # therefore 2>&1 is added and the output is stored in a variable.
  76. $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1"
  77. Write-Host ${Output}
  78. }
  79. }
  80. }