-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.bat
More file actions
109 lines (98 loc) · 3.77 KB
/
script.bat
File metadata and controls
109 lines (98 loc) · 3.77 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
100
101
102
103
104
105
106
107
108
109
@echo off
setlocal
set CPP_STANDARD=c++20
set SAFETY_FLAGS=-Wall -Wextra -pedantic
set HEADERS_DIR=headers
set BUILD_DIR=build
set BINARIES_DIR=%BUILD_DIR%/binaries
set COMPILE_FLAGS=-std=%CPP_STANDARD% %SAFETY_FLAGS% -Os -s -c -I%HEADERS_DIR%/
set BUILD_FLAGS=-std=%CPP_STANDARD% %SAFETY_FLAGS% -O3 -s
echo.
for %%a in (%*) do (
if %%a == init (
call :init
) else if %%a == compile (
call :compile
) else if %%a == build (
call :build
) else if %%a == link (
call :link
) else if %%a == clean (
call :clean
) else (
echo Invalid option! Available options: 'init', 'compile', 'build', 'link' and 'clean'.
exit /b 1
)
echo.
)
exit /b 0
:init
echo "==========="
echo "Phase: init"
echo "==========="
echo.
echo "[CREATE] 'build/' directory"
mkdir build\binaries\workspace
mkdir build\test_binaries\unit_tests
exit /b 0
:compile
echo "=============="
echo "Phase: compile"
echo "=============="
echo.
echo "[COMPILE] src/gnu_toolchain.cpp" && g++ %COMPILE_FLAGS% src/gnu_toolchain.cpp -o %BINARIES_DIR%/gnu_toolchain.o
echo "[COMPILE] src/workspace/dependencies_manager.cpp" && g++ %COMPILE_FLAGS% src/workspace/dependencies_manager.cpp -o %BINARIES_DIR%/workspace/dependencies_manager.o
echo "[COMPILE] src/workspace/env_manager.cpp" && g++ %COMPILE_FLAGS% src/workspace/env_manager.cpp -o %BINARIES_DIR%/workspace/env_manager.o
echo "[COMPILE] src/workspace/modification_identifier.cpp" && g++ %COMPILE_FLAGS% src/workspace/modification_identifier.cpp -o %BINARIES_DIR%/workspace/modification_identifier.o
echo "[COMPILE] src/workspace/project_config.cpp" && g++ %COMPILE_FLAGS% src/workspace/project_config.cpp -o %BINARIES_DIR%/workspace/project_config.o
echo "[COMPILE] src/workspace/scaffold.cpp" && g++ %COMPILE_FLAGS% src/workspace/scaffold.cpp -o %BINARIES_DIR%/workspace/scaffold.o
echo "[COMPILE] src/workspace/util.cpp" && g++ %COMPILE_FLAGS% src/workspace/util.cpp -o %BINARIES_DIR%/workspace/util.o
echo "[COMPILE] src/commands.cpp" && g++ %COMPILE_FLAGS% src/commands.cpp -o %BINARIES_DIR%/commands.o
echo "[COMPILE] src/main.cpp" && g++ %COMPILE_FLAGS% src/main.cpp -o %BINARIES_DIR%/main.o
exit /b 0
:build
echo "============"
echo "Phase: build"
echo "============"
echo.
echo "[BUILD] build/cbt.exe" && g++ %BUILD_FLAGS% %BINARIES_DIR%/*.o %BINARIES_DIR%/workspace/*.o -o build/cbt.exe
echo "[HASH] build/cbt.exe" && certutil -hashfile build\cbt.exe SHA256 > build\Windows.sha256.checksum.txt
exit /b 0
:link
echo "==========="
echo "Phase: link"
echo "==========="
echo.
if not exist "build\cbt.exe" (
echo "[ACTION] Compile and build project first"
exit /b 1
)
if not exist "C:\cbt" (
mkdir "C:\cbt"
echo "[DIR] Create 'C:\cbt'"
)
copy /Y "build\cbt.exe" "C:\cbt\cbt.exe" >nul
echo "[COPY] 'cbt.exe' updated"
set "CURRENT_PATH=%PATH%"
echo %CURRENT_PATH% | find /I "C:\cbt" >nul
if errorlevel 1 (
echo "[ACTION] Add 'C:\cbt' to PATH via System Environment GUI"
echo "[ACTION] Open 'Start' > 'Run' > Type 'sysdm.cpl' > Hit 'OK'"
echo "[ACTION] Go to 'Advanced' > 'Environment Variables'"
echo "[ACTION] Under 'User variables' > Double click 'Path' > Hit 'Add' > Type 'C:\cbt' > Hit 'OK'"
echo "[ACTION] Re-open terminal"
) else (
echo "[INFO] 'cbt' available globally"
)
exit /b 0
:clean
echo "============"
echo "Phase: clean"
echo "============"
echo.
rmdir /s /q build
echo "[DELETE] sample application (if present)" && rmdir /s /q my_application
echo "[DELETE] sample library (if present)" && rmdir /s /q my_library
echo.
call :init
exit /b 0