-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
45 lines (37 loc) · 1.54 KB
/
build.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
# build.ps1
# Exit immediately if a command exits with a non-zero status
$ErrorActionPreference = "Stop"
try {
# Check if the "build" directory exists; if yes, clean it to avoid conflicts
if (Test-Path -Path "build") {
Write-Output "Cleaning 'build' directory to avoid generator conflicts..."
Remove-Item -Recurse -Force "build"
}
# Create a fresh "build" directory
Write-Output "Creating 'build' directory..."
New-Item -ItemType Directory -Path "build" | Out-Null
# Navigate into the "build" directory
Set-Location "build"
# Configure the project using CMake with MinGW Makefiles and specific compilers
Write-Output "Configuring project with CMake..."
cmake -G "MinGW Makefiles" -DBUILD_TESTING=ON `
-DCMAKE_C_COMPILER="C:/MinGW/mingw64/bin/gcc.exe" `
-DCMAKE_CXX_COMPILER="C:/MinGW/mingw64/bin/g++.exe" `
-DCMAKE_VERBOSE_MAKEFILE=ON ..
# Build the project using mingw32-make
Write-Output "Building the project..."
mingw32-make -j4
# Rename the executable to mnist.exe
if (Test-Path "./CTorch.exe") {
Write-Output "Renaming CTorch.exe to mnist.exe..."
Rename-Item -Path "./CTorch.exe" -NewName "mnist.exe" -Force
Write-Output "Executable has been renamed to mnist.exe in the 'build' directory."
} else {
Write-Error "Build succeeded, but CTorch.exe was not found in the build directory."
}
Write-Output "Build and rename completed successfully."
}
catch {
Write-Error "An error occurred: $_"
exit 1
}