File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ @ echo off
2
+ :: Compiler and flags
3
+ set CXX = g++
4
+ set CXXFLAGS = -std=c++17 -Iinclude -Wall -Wextra -Werror
5
+
6
+ :: Directories
7
+ set SRC_DIR = src
8
+ set INCLUDE_DIR = include
9
+ set BUILD_DIR = build
10
+ set OUTPUT_DIR = output
11
+
12
+ :: Target executable
13
+ set TARGET = scanner.exe
14
+
15
+ :: Create necessary directories if they don't exist
16
+ if not exist " %BUILD_DIR% " mkdir " %BUILD_DIR% "
17
+ if not exist " %OUTPUT_DIR% " mkdir " %OUTPUT_DIR% "
18
+
19
+ :: Compile source files to object files
20
+ echo Compiling source files...
21
+ for %%f in (%SRC_DIR% \*.cpp) do (
22
+ echo Compiling %%f ...
23
+ %CXX% %CXXFLAGS% -c %%f -o " %BUILD_DIR% \%%~nf .o"
24
+ )
25
+
26
+ :: Link object files into the target executable
27
+ echo Linking object files...
28
+ set OBJS =
29
+ for %%f in (%BUILD_DIR% \*.o) do (
30
+ set OBJS = !OBJS! %%f
31
+ )
32
+ %CXX% %CXXFLAGS% -o %TARGET% %OBJS%
33
+
34
+ if errorlevel 1 (
35
+ echo Build failed.
36
+ exit /b 1
37
+ ) else (
38
+ echo Build succeeded.
39
+ )
40
+
41
+ :: Run the scanner with example input and output
42
+ if " %1 " == " run" (
43
+ echo Running %TARGET% with examples/example1.txt...
44
+ %TARGET% examples/example1.txt %OUTPUT_DIR% \output.txt
45
+ type %OUTPUT_DIR% \output.txt
46
+ )
47
+
48
+ :: Clean up build files and executable
49
+ if " %1 " == " clean" (
50
+ echo Cleaning up...
51
+ rmdir /s /q " %BUILD_DIR% "
52
+ del " %TARGET% "
53
+ exit /b 0
54
+ )
55
+
56
+
You can’t perform that action at this time.
0 commit comments