forked from libyal/libewf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
synclibs.ps1
67 lines (53 loc) · 2.6 KB
/
synclibs.ps1
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Script that synchronizes the local library dependencies
#
# Version: 20161110
$GitUrlPrefix = "https://github.com/libyal"
$LocalLibs = "libbfio libcaes libcdata libcdatetime libcerror libcfile libclocale libcnotify libcpath libcsplit libcthreads libfcache libfdata libfguid libfvalue libhmac libodraw libsmdev libsmraw libuna"
$LocalLibs = ${LocalLibs} -split " "
$Git = "git"
$WinFlex = "..\win_flex_bison\win_flex.exe"
$WinBison = "..\win_flex_bison\win_bison.exe"
ForEach (${LocalLib} in ${LocalLibs})
{
# PowerShell will raise NativeCommandError if git writes to stdout or stderr
# therefore 2>&1 is added and the output is stored in a variable.
$Output = Invoke-Expression -Command "${Git} clone ${GitUrlPrefix}/${LocalLib}.git ${LocalLib}-${pid} 2>&1"
Write-Host ${Output}
If (Test-Path ${LocalLib}-${pid})
{
$LocalLibVersion = Get-Content -Path ${LocalLib}-${pid}\configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" }
If (Test-Path ${LocalLib})
{
Remove-Item -Path ${LocalLib} -Force -Recurse
}
New-Item -ItemType directory -Path ${LocalLib} -Force | Out-Null
If (Test-Path ${LocalLib})
{
Copy-Item -Path ${LocalLib}-${pid}\${LocalLib}\*.[chly] -Destination ${LocalLib}\
Get-Content -Path ${LocalLib}-${pid}\${LocalLib}\${LocalLib}_definitions.h.in | % { $_ -Replace "@VERSION@",${LocalLibVersion} } > ${LocalLib}\${LocalLib}_definitions.h
}
Remove-Item -Path ${LocalLib}-${pid} -Force -Recurse
$NamePrefix = ""
ForEach (${DirectoryElement} in Get-ChildItem -Path "${LocalLib}\*.l")
{
$OutputFile = ${DirectoryElement} -Replace ".l$",".c"
$NamePrefix = Split-Path -path ${DirectoryElement} -leaf
$NamePrefix = ${NamePrefix} -Replace "^${LocalLib}_",""
$NamePrefix = ${NamePrefix} -Replace ".l$","_"
# PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr
# therefore 2>&1 is added and the output is stored in a variable.
$Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1"
Write-Host ${Output}
# Moving manually sicne win_flex -o <filename> does not provide the expected behavior.
Move-Item "lex.yy.c" ${OutputFile} -force
}
ForEach (${DirectoryElement} in Get-ChildItem -Path "${LocalLib}\*.y")
{
$OutputFile = ${DirectoryElement} -Replace ".y$",".c"
# PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr
# therefore 2>&1 is added and the output is stored in a variable.
$Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1"
Write-Host ${Output}
}
}
}