-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
99 lines (90 loc) · 4.2 KB
/
setup.ps1
File metadata and controls
99 lines (90 loc) · 4.2 KB
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
Write-Host "Setting up project..."
$sfml = Read-Host "Please insert SFML folder path: "
$sfml = $sfml.Replace('/', '\')
if(-not($sfml.EndsWith('\'))){
$sfml = $sfml+"\"
}
function Get-File-Exists {
param (
[Parameter(Mandatory=$true, Position=0)]
[string] $FilePath,
[Parameter(Mandatory=$true, Position=1)]
[bool] $isFile
)
if($isFile) {
if(-not(Test-Path -Path ($sfml+$FilePath) -PathType Leaf)) {
Write-Host "File '$FilePath' doesn't exist!`nPress any key to continue..."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit
} else {
Write-Host "'$FilePath' OK"
}
} else {
if(-not(Test-Path -Path ($sfml+$FilePath))) {
Write-Host "Directory '$FilePath' doesn't exist!`nPress any key to continue..."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit
} else {
Write-Host "'$FilePath' OK"
}
}
}
Write-Host "`nChecking path.."
Get-File-Exists "include" $false
Get-File-Exists "lib/sfml-audio.lib" $true
Get-File-Exists "lib/sfml-graphics.lib" $true
Get-File-Exists "lib/sfml-window.lib" $true
Get-File-Exists "lib/sfml-system.lib" $true
Get-File-Exists "lib/sfml-audio-d.lib" $true
Get-File-Exists "lib/sfml-graphics-d.lib" $true
Get-File-Exists "lib/sfml-window-d.lib" $true
Get-File-Exists "lib/sfml-system-d.lib" $true
Get-File-Exists "bin/openal32.dll" $true
Get-File-Exists "bin/sfml-audio-d-2.dll" $true
Get-File-Exists "bin/sfml-graphics-d-2.dll" $true
Get-File-Exists "bin/sfml-window-d-2.dll" $true
Get-File-Exists "bin/sfml-system-d-2.dll" $true
$sfml = $sfml.Substring(0, $sfml.Length-1)
if(Test-Path -Path "./sfml-file" -PathType Leaf) {
Write-Host "`nRemoving old files.."
Remove-Item "./sfml-file"
}
Write-Host "`nSaving sfml path..."
$sfml = $sfml.Replace('\', '\\')
$sfml | Set-Content "./sfml-file"
$sfml = $sfml.Replace('\\', '\')
Write-Host "`nSetting up project file..."
(Get-Content ".\RoguelikeGame.Main\RoguelikeGame.Main.vcxproj") -replace '{SFML_PATH}', $sfml | Out-File -encoding ASCII ".\RoguelikeGame.Main\RoguelikeGame.Main.vcxproj"
$sfml = $sfml + "\"
Write-Host "`nCopying files..."
Copy-Item ($sfml+"bin\openal32.dll") -Destination ".\RoguelikeGame.Main\"
Copy-Item ($sfml+"bin\sfml-audio-d-2.dll") -Destination ".\RoguelikeGame.Main\"
Copy-Item ($sfml+"bin\sfml-graphics-d-2.dll") -Destination ".\RoguelikeGame.Main\"
Copy-Item ($sfml+"bin\sfml-window-d-2.dll") -Destination ".\RoguelikeGame.Main\"
Copy-Item ($sfml+"bin\sfml-system-d-2.dll") -Destination ".\RoguelikeGame.Main\"
Write-Host "`nCreating Git Hooks..."
Write-Host " - Pre-commit"
Set-Content ".\.git\hooks\pre-commit" '#!/bin/sh'
Add-Content ".\.git\hooks\pre-commit" 'if [ -f "sfml-file" ] '
Add-Content ".\.git\hooks\pre-commit" 'then'
Add-Content ".\.git\hooks\pre-commit" 'search=`cat sfml-file`'
Add-Content ".\.git\hooks\pre-commit" 'replace="{SFML_PATH}"'
Add-Content ".\.git\hooks\pre-commit" 'sed -i ''s#''$search''#''$replace''#g'' ./RoguelikeGame.Main/RoguelikeGame.Main.vcxproj'
Add-Content ".\.git\hooks\pre-commit" 'unix2dos ./RoguelikeGame.Main/RoguelikeGame.Main.vcxproj'
Add-Content ".\.git\hooks\pre-commit" 'git add ./RoguelikeGame.Main/RoguelikeGame.Main.vcxproj'
Add-Content ".\.git\hooks\pre-commit" 'fi'
Write-Host " - Post-commit"
Set-Content ".\.git\hooks\post-commit" '#!/bin/sh'
Add-Content ".\.git\hooks\post-commit" 'if [ -f "sfml-file" ] '
Add-Content ".\.git\hooks\post-commit" 'then'
Add-Content ".\.git\hooks\post-commit" 'replace=`cat sfml-file`'
Add-Content ".\.git\hooks\post-commit" 'search="{SFML_PATH}"'
Add-Content ".\.git\hooks\post-commit" 'sed -i ''s#''$search''#''$replace''#g'' ./RoguelikeGame.Main/RoguelikeGame.Main.vcxproj'
Add-Content ".\.git\hooks\post-commit" 'unix2dos ./RoguelikeGame.Main/RoguelikeGame.Main.vcxproj'
Add-Content ".\.git\hooks\post-commit" 'echo "----- INFO -----"'
Add-Content ".\.git\hooks\post-commit" 'echo "SFML values changed in commit, please ignore vcxproj modified flag!"'
Add-Content ".\.git\hooks\post-commit" 'echo "----------------"'
Add-Content ".\.git\hooks\post-commit" 'fi'
Write-Host "`nDone`nPress any key to continue..."
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
exit