Skip to content

Commit bb79ad5

Browse files
committed
fix: improve build script
1 parent f52de08 commit bb79ad5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

scanner/build.bat

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
@echo off
2+
setlocal enabledelayedexpansion
3+
24
:: Compiler and flags
35
set CXX=g++
4-
set CXXFLAGS=-std=c++17 -Iinclude -Wall -Wextra -Werror
6+
set CXXFLAGS=-std=c++17 -Iinclude -Wall -Wextra -Werror -mthreads
57

68
:: Directories
79
set SRC_DIR=src
@@ -12,6 +14,11 @@ set OUTPUT_DIR=output
1214
:: Target executable
1315
set TARGET=scanner.exe
1416

17+
:: Clean old build files
18+
if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
19+
if exist "%TARGET%" del "%TARGET%"
20+
mkdir "%BUILD_DIR%"
21+
1522
:: Create necessary directories if they don't exist
1623
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
1724
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"
@@ -21,6 +28,10 @@ echo Compiling source files...
2128
for %%f in (%SRC_DIR%\*.cpp) do (
2229
echo Compiling %%f...
2330
%CXX% %CXXFLAGS% -c %%f -o "%BUILD_DIR%\%%~nf.o"
31+
if errorlevel 1 (
32+
echo Failed to compile %%f.
33+
exit /b 1
34+
)
2435
)
2536

2637
:: Link object files into the target executable
@@ -29,7 +40,8 @@ set OBJS=
2940
for %%f in (%BUILD_DIR%\*.o) do (
3041
set OBJS=!OBJS! %%f
3142
)
32-
%CXX% %CXXFLAGS% -o %TARGET% %OBJS%
43+
echo Object files: !OBJS!
44+
%CXX% %CXXFLAGS% -static -static-libgcc -static-libstdc++ -o %TARGET% !OBJS!
3345

3446
if errorlevel 1 (
3547
echo Build failed.
File renamed without changes.

0 commit comments

Comments
 (0)