-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
73 lines (61 loc) · 2.52 KB
/
Copy pathbuild.bat
File metadata and controls
73 lines (61 loc) · 2.52 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
@echo off
REM Designed for Microsoft Visual C++ Compiler (cl.exe)
setlocal enabledelayedexpansion
echo [*] kamos v1.0 Build System
echo [*] Checking for Visual C++ compiler...
REM check for environment variables
if defined VCINSTALLDIR goto :compile
if exist "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" (
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
goto :compile
) else if exist "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat" (
call "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64
goto :compile
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
goto :compile
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64
goto :compile
)
echo [!] Visual Studio not found. Attempting direct cl.exe invocation...
where cl.exe >nul 2>nul
if %errorlevel% neq 0 (
echo [!] ERROR: cl.exe not found. Please install Visual Studio C++ Build Tools.
exit /b 1
)
:compile
echo [+] Compiler found. Starting compilation...
REM
if not exist "obj" mkdir obj
echo.
echo [*] Compiling Source Files...
REM Compilation flags:
REM /O2 : Optimize for speed
REM /EHsc: Exception handling
REM /W4 : Warning level 4
REM /Fo : Output directory for object files
REM /Fe : Name of the executable
REM /std:c++17 : Use C++17 standard (optional but good practice)
set SOURCE_FILES=cpps\\main.cpp cpps\\utils.cpp cpps\\modules.cpp
set LIBS=ws2_32.lib iphlpapi.lib advapi32.lib shlwapi.lib netapi32.lib shell32.lib
REM Use /MT to statically link the C/C++ runtime into the EXE (no MSVCRT DLL dependency)
cl.exe /nologo /O2 /MT /EHsc /W4 /MP /I"headers" ^
/Fo".\\obj\\" ^
/Fe"kamos.exe" ^
%SOURCE_FILES% ^
/link %LIBS% /SUBSYSTEM:CONSOLE /MACHINE:X64
if %errorlevel% equ 0 (
echo.
echo [+] Compilation successful!
echo [+] Output: kamos.exe
echo.
REM
echo [*] Cleaning up object files...
del /Q .\obj\*.*
rmdir .\obj
exit /b 0
) else (
echo.
echo [!] Compilation failed!
exit /b 1)