-
Notifications
You must be signed in to change notification settings - Fork 7
/
compile.bat
115 lines (96 loc) · 3.63 KB
/
compile.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@echo off
setlocal
set MARE_BUILD_DIR="build/Debug/mare"
set MARE_OUTPUT_DIR="build/Debug/mare"
set MARE_SOURCE_DIR="src"
set MARE_SOURCE_FILES=mare/Generator.cpp mare/CMake.cpp mare/CodeBlocks.cpp mare/CodeLite.cpp mare/JsonDb.cpp mare/Main.cpp mare/Make.cpp mare/Mare.cpp mare/NetBeans.cpp mare/Vcproj.cpp mare/Vcxproj.cpp mare/Tools/md5.cpp mare/Tools/Win32/getopt.cpp libmare/Engine.cpp libmare/Namespace.cpp libmare/Parser.cpp libmare/Statement.cpp libmare/Tools/Directory.cpp libmare/Tools/Error.cpp libmare/Tools/File.cpp libmare/Tools/Process.cpp libmare/Tools/Scope.cpp libmare/Tools/String.cpp libmare/Tools/Word.cpp
:main
goto get_args
:get_args_return
goto find_visual_studio
:find_visual_studio_return
goto build
:build_return
goto end
:get_args
if "%1" == "--buildDir" (
set MARE_BUILD_DIR="%2"
shift /1
shift /1
goto get_args
)
if "%1" == "--outputDir" (
set MARE_OUTPUT_DIR="%2"
shift /1
shift /1
goto get_args
)
if "%1" == "--sourceDir" (
set MARE_SOURCE_DIR="%2"
shift /1
shift /1
goto get_args
)
if "%1" == "" goto get_args_return
goto usage
:usage
echo Usage: %0 [^-^-buildDir=^<dir^>] [^-^-outputDir=^<dir^>] [^-^-sourceDir=^<dir^>]
goto end
:find_visual_studio
if not "%VCINSTALLDIR%"=="" goto find_visual_studio_return
FOR /F "usebackq tokens=*" %%A IN (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) DO (
if exist "%%A" (
call "%%A\VC\Auxiliary\Build\vcvars32.bat"
goto find_visual_studio_return
)
)
FOR /F "usebackq skip=2 tokens=2*" %%A IN (`reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7 /v 15.0 2^>nul`) DO (
if exist "%%B" (
call "%%B\VC\Auxiliary\Build\vcvars32.bat"
goto find_visual_studio_return
)
)
if not "%VS140COMNTOOLS%"=="" (
call "%VS140COMNTOOLS%vsvars32.bat"
goto find_visual_studio_return
)
if not "%VS120COMNTOOLS%"=="" (
call "%VS120COMNTOOLS%vsvars32.bat"
goto find_visual_studio_return
)
if not "%VS110COMNTOOLS%"=="" (
call "%VS110COMNTOOLS%vsvars32.bat"
goto find_visual_studio_return
)
if not "%VS100COMNTOOLS%"=="" (
call "%VS100COMNTOOLS%vsvars32.bat"
goto find_visual_studio_return
)
echo "error: Could not find Visual Studio installation."
goto end
:build
if not exist %MARE_SOURCE_DIR:"=%/mare/Main.cpp (
echo "error: Could not find source files."
goto end
)
setlocal enableextensions
if not exist %MARE_BUILD_DIR% mkdir %MARE_BUILD_DIR%
if not exist %MARE_OUTPUT_DIR% mkdir %MARE_OUTPUT_DIR%
endlocal
setlocal
set DEL_FILE=%MARE_OUTPUT_DIR:"=%/mare.exe
del %DEL_FILE:/=\% 2>NUL
endlocal
for %%f in (%MARE_SOURCE_FILES%) do (
cl /I"%MARE_SOURCE_DIR:"=%/libmare" /Zi /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fd"%MARE_BUILD_DIR:"=%/" /Fo"%MARE_BUILD_DIR:"=%/" /Gd /analyze- /c "%MARE_SOURCE_DIR:"=%/%%f"
)
set MARE_OBJECTS=
for %%f in (%MARE_BUILD_DIR:"=%/*.obj) do (
call set MARE_OBJECTS=%%MARE_OBJECTS%% %MARE_BUILD_DIR:"=%/%%f
)
echo ^-^> %MARE_BUILD_DIR:"=%/mare.exe
link /OUT:"%MARE_OUTPUT_DIR:"=%/mare.exe" /NOLOGO "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 %MARE_OBJECTS%
rem if exist %MARE_OUTPUT_DIR:"=%/mare.exe (echo done) else echo failed
goto build_return
:end
endlocal