forked from WebKitForWindows/WebKitRequirements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackage-RequirementSource.ps1
107 lines (83 loc) · 3.26 KB
/
Package-RequirementSource.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<#
.Synopsis
Packages a release of the binaries of the libraries meeting the requirements of building WebKit.
.Details
Cleans up any unused files in
Downloads source code releases and stages them within the directory
structure. From there they can be built out.
.Parameter Root
The root directory to package the sources at. Defaults to current directory.
.Parameter Suffix
The suffix to apply to the bin and lib directories
#>
Param(
[string] $output = 'WinCairoRequirements.zip',
[string] $root = '.',
[string] $suffix = '64'
)
$binDirectory = Join-Path $root 'bin'
$libDirectory = Join-Path $root 'lib'
$docDirectory = Join-Path $root 'doc'
$shareDirectory = Join-Path $root 'share'
#----------------------------------------------------------------------
# Clean directory
#----------------------------------------------------------------------
Function Clean-Directory {
Param(
[Parameter(Mandatory)]
[string] $name,
[Parameter(Mandatory)]
[string] $extension
)
$directory = Join-Path $root $name;
Write-Host ('Cleaning {0} of any files that are not {1}s' -f $directory, $extension)
$files = Get-ChildItem -Path $directory
ForEach ($file in $files) {
if ($extension -ne $file.Extension) {
Write-Host ('Removing {0}' -f $file.FullName)
Remove-Item -Path $file.FullName -Recurse
}
}
}
#----------------------------------------------------------------------
# Remove unused directories
#----------------------------------------------------------------------
if (Test-Path $docDirectory) {
Write-Host ('Removing doc directory at {0}' -f $docDirectory)
Remove-Item -Path $docDirectory -Recurse
}
if (Test-Path $shareDirectory) {
Write-Host ('Removing share directory at {0}' -f $shareDirectory)
Remove-Item -Path $shareDirectory -Recurse
}
#----------------------------------------------------------------------
# Move dll files into bin
#
# Some libraries output dll into lib instead of bin
#----------------------------------------------------------------------
# Move any dlls into bin
Write-Host ('Moving dlls in {0}' -f $libDirectory)
$dlls = Get-ChildItem -Path $libDirectory -Filter '*.dll'
ForEach ($dll in $dlls) {
Write-Host ('Move {0} into bin directory' -f $dll.Name)
Move-Item $dll.FullName (Join-Path $binDirectory $dll.Name)
}
#----------------------------------------------------------------------
# Clean directories
#----------------------------------------------------------------------
Clean-Directory -Name 'bin' -Extension '.dll'
Clean-Directory -Name 'lib' -Extension '.lib'
#----------------------------------------------------------------------
# Rename the bin and lib directories to include the bits
#----------------------------------------------------------------------
$binRename = ('bin{0}' -f $suffix)
Write-Host ('Renaming {0} to {1}' -f $binDirectory, $binRename)
Rename-Item $binDirectory $binRename
$libRename = ('lib{0}' -f $suffix)
Write-Host ('Renaming {0} to {1}' -f $libDirectory, $libRename)
Rename-Item $libDirectory $libRename
#----------------------------------------------------------------------
# Zip files
#----------------------------------------------------------------------
Write-Host ('Creating archive at {0}' -f $output)
Compress-7Zip -ArchiveFileName $output -Path $root