-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinitializer.ps1
More file actions
37 lines (30 loc) · 1.2 KB
/
initializer.ps1
File metadata and controls
37 lines (30 loc) · 1.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
$cpp_path = ""
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = 'stop'
try{if(Get-Command g++){$cpp_path = (Get-Command g++).Path}}
Catch {}
Finally {$ErrorActionPreference=$oldPreference}
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = 'stop'
try{if(Get-Command clang++){$cpp_path = (Get-Command clang++).Path}}
Catch {}
Finally {$ErrorActionPreference=$oldPreference}
if ( $cpp_path -eq "" ) {
$cpp_path= Read-Host -Prompt "Compiler could not be found. Please specify the path : "
} else {
$confirmation = Read-Host "Compiler that was found $cpp_path. Use it? [y/n]"
if ($confirmation -ne 'y') {
$cpp_path = Read-Host "Please specify the path : "
}
}
if (Test-Path -Path "cpm") {
Write-Output "./cpm already exist. Compilation..."
} else {
mkdir cpm > $null
}
& $cpp_path ./Compiler/src/main.cpp ./Compiler/AST/ast_nodes.cpp ./Compiler/helpers/char_source.cpp ./Compiler/src/lexer.cpp ./Compiler/src/parser.cpp ./Compiler/src/translator.cpp ./Compiler/src/compiler.cpp -lpthread -std=c++17 -o cpm/cpm > $null
if (Test-Path -Path "cpm/details") {
} else {
mkdir cpm/details > $null
}
Set-Content -Path cpm/details/cpp_compiler_path -Value $cpp_path