-
Notifications
You must be signed in to change notification settings - Fork 3
/
recompile.bat
91 lines (78 loc) · 1.86 KB
/
recompile.bat
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
@echo off
:: Script created by Igor Santarek MIT 2018. Works only with cygwin or msys. Can be easly converted to pure batch script.
set bin_dir=./bin
set binary_name=bin
set main="./src/sample game/main.cpp"
set main_o=main.o
set main_remove=
set lib_src=./src/flow
set compiler=%main%
set linker=%main_o%
set remove=%main_remove%
if [%1] == [] (
goto :recompile
)
if [%1] == [-c] (
goto :clean
)
if [%1] == [-cx] (
goto :cleanx
)
if [%1] == [-t] (
goto :c_tests
)
if [%1] == [-ho] (
goto :c_header_only
)
echo recompile [-c] [-cx]
echo.
echo Script for recompiling and cleaning the project.
echo.
echo When runned without any argument, script just recompiles the project.
echo.
echo -c Cleans compile files without executable.
echo -cx Cleans compile files with executable.
echo -t Creates unit tests compiled executable and runs it.
echo -ho Creates only header in src directory.
exit /b
:recompile
wcpp %lib_src% flow >nul
cp flow.hpp "src/sample game"
mv flow.hpp src
g++ -c %compiler% -std=c++11
if %errorlevel% EQU 0 (
call :create_bin_dir
g++ -o ./%bin_dir%/%binary_name% %linker% -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer
)
exit /b
:clean
rm %remove% %linker%
exit /b
:cleanx
call :clean
rm ./%bin_dir%/%binary_name%.exe
exit /b
:c_tests
set test_binary_name=tests
set test_compiler="./src/tests/t_main.cpp"
set test_linker="t_main.o"
wcpp %lib_src% flow >nul
cp flow.hpp "src/tests"
mv flow.hpp src
wcpp ./src/tests/cases test_specifications >nul
mv cases.hpp src/tests/test_cases.hpp
g++ -c %test_compiler% -std=c++11
if %errorlevel% EQU 0 (
call :create_bin_dir
g++ -o ./%bin_dir%/%test_binary_name% %test_linker% -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer
.\bin\%test_binary_name%
)
rm %test_linker%
exit /b
:c_header_only
wcpp %lib_src% flow >nul
mv flow.hpp src
exit /b
:create_bin_dir
if NOT EXIST %bin_dir% mkdir %bin_dir%
exit /b