Repository navigation
Expand file tree
/
Copy pathbuild.bat
More file actions
152 lines (129 loc) · 5.16 KB
/
Copy pathbuild.bat
File metadata and controls
152 lines (129 loc) · 5.16 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@echo off
setlocal EnableExtensions
set "OUT_DIR=%~dp0build"
set "BUILD_MODE=%~1"
set "GENERATE_COMPCMDS=0"
if /I "%~2"=="-compile-commands" set "GENERATE_COMPCMDS=1"
if /I "%~1"=="-compile-commands" set "GENERATE_COMPCMDS=1"
if /I "%GENERATE_COMPCMDS%"=="1" (
goto compile_commands
)
if "%BUILD_MODE%"=="" set "BUILD_MODE=debug"
if /I not "%BUILD_MODE%"=="debug" if /I not "%BUILD_MODE%"=="release" (
echo [vsbuild] Usage: %~nx0 [debug^|release] [-compile-commands]
exit /b 1
)
where cl.exe >nul 2>nul && goto ready
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" (
echo [vsbuild] MSVC and vswhere.exe not found. Install Visual Studio Build Tools.
exit /b 1
)
set "VCVARS="
for /f "usebackq delims=" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set "VCVARS=%%i\VC\Auxiliary\Build\vcvars64.bat"
)
if not defined VCVARS (
echo [vsbuild] Visual Studio with the C++ workload not found. Install "Desktop development with C++".
exit /b 1
)
call "%VCVARS%" >nul
if not defined VCToolsInstallDir (
echo [vsbuild] Failed to initialize MSVC x64 environment.
exit /b 1
)
:ready
:: BUILDING FREETYPE
:: --------------------------------------------------
set "FT_DIR=%~dp0vendor\freetype"
set "FT_FLAGS=/nologo /c /TC /I"%FT_DIR%\include" /DFT2_BUILD_LIBRARY /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS"
if /I "%BUILD_MODE%"=="debug" set "FT_FLAGS=%FT_FLAGS% /Od /Zi /MTd"
if /I "%BUILD_MODE%"=="release" set "FT_FLAGS=%FT_FLAGS% /O2 /MT"
if not exist "%OUT_DIR%\freetype" mkdir "%OUT_DIR%\freetype"
cl %FT_FLAGS% ^
"%FT_DIR%\src\autofit\autofit.c" ^
"%FT_DIR%\src\base\ftbase.c" ^
"%FT_DIR%\src\base\ftbbox.c" ^
"%FT_DIR%\src\base\ftbitmap.c" ^
"%FT_DIR%\src\base\ftglyph.c" ^
"%FT_DIR%\src\base\ftinit.c" ^
"%FT_DIR%\src\base\ftmm.c" ^
"%FT_DIR%\src\base\ftsynth.c" ^
"%FT_DIR%\src\bdf\bdf.c" ^
"%FT_DIR%\src\cff\cff.c" ^
"%FT_DIR%\src\cid\type1cid.c" ^
"%FT_DIR%\src\gzip\ftgzip.c" ^
"%FT_DIR%\src\lzw\ftlzw.c" ^
"%FT_DIR%\src\pcf\pcf.c" ^
"%FT_DIR%\src\pfr\pfr.c" ^
"%FT_DIR%\src\psaux\psaux.c" ^
"%FT_DIR%\src\pshinter\pshinter.c" ^
"%FT_DIR%\src\psnames\psnames.c" ^
"%FT_DIR%\src\raster\raster.c" ^
"%FT_DIR%\src\sfnt\sfnt.c" ^
"%FT_DIR%\src\sdf\sdf.c" ^
"%FT_DIR%\src\smooth\smooth.c" ^
"%FT_DIR%\src\svg\svg.c" ^
"%FT_DIR%\src\type1\type1.c" ^
"%FT_DIR%\src\type42\type42.c" ^
"%FT_DIR%\src\truetype\truetype.c" ^
"%FT_DIR%\src\winfonts\winfnt.c" ^
"%FT_DIR%\builds\windows\ftsystem.c" ^
"%FT_DIR%\builds\windows\ftdebug.c" ^
/Fo"%OUT_DIR%\freetype\\" || exit /b 1
lib /nologo ^
/out:"%OUT_DIR%\freetype.lib" ^
"%OUT_DIR%\freetype\*.obj" || exit /b 1
:: --------------------------------------------------
:: END FREETYPE
:: Shader compilation goes first
fxc /nologo /T vs_5_0 /E vs_main /Fh src/shader/foxui_vs.h /Vn foxui_vs src/shader/foxui_shader.hlsl
fxc /nologo /T ps_5_0 /E ps_main /Fh src/shader/foxui_ps.h /Vn foxui_ps src/shader/foxui_shader.hlsl
set "CL_FLAGS_COMMON=/nologo /std:c++20 /utf-8 /W4 /WX /EHsc- /GR- /DUNICODE /D_UNICODE /Isrc /external:Ivendor /external:Ivendor\freetype\include /external:W0"
set "LIBRARIES=user32.lib gdi32.lib ole32.lib imm32.lib d3d11.lib dxgi.lib dwrite.lib windowscodecs.lib shell32.lib dwmapi.lib dcomp.lib"
if /I "%BUILD_MODE%"=="debug" set "CL_FLAGS=%CL_FLAGS_COMMON% /Od /Zi /MTd /DFOXUI_DEBUG"
if /I "%BUILD_MODE%"=="release" set "CL_FLAGS=%CL_FLAGS_COMMON% /O2 /MT /DNDEBUG"
if not exist "%OUT_DIR%" mkdir "%OUT_DIR%"
:: Building just the Library here
cl %CL_FLAGS% ^
/c src\windows\foxui_win32.cpp ^
/Fo"%OUT_DIR%\foxui.obj" /Fd"%OUT_DIR%\foxui.pdb" || exit /b 1
lib ^
/nologo ^
/out:"%OUT_DIR%\foxui.lib" ^
"%OUT_DIR%\foxui.obj" ^
"%OUT_DIR%\freetype.lib" || exit /b 1
:: Building the example here...
cl %CL_FLAGS% ^
example\calc.cpp "%OUT_DIR%\foxui.lib" ^
/Fo"%OUT_DIR%\foxui_calc.obj" /Fd"%OUT_DIR%\foxui_calc.pdb" ^
/Fe"%OUT_DIR%\foxui_calc.exe" ^
/link /pdb:"%OUT_DIR%\foxui_calc.pdb" /incremental:no ^
/subsystem:windows /entry:mainCRTStartup %LIBRARIES% || exit /b 1
echo [build] Foxui %BUILD_MODE% build complete.
exit /b 0
:: Generate compile-commands.json
:compile_commands
echo [clangd] Generating compile_commands.json...
set "CLANGD_FLAGS=/std:c++20 /utf-8 /EHsc- /GR- /DUNICODE /D_UNICODE /Isrc /Ivendor /Ivendor\freetype\include"
if /I "%BUILD_MODE%"=="debug" set "CLANGD_FLAGS=%CLANGD_FLAGS% /DFOXUI_DEBUG"
if /I "%BUILD_MODE%"=="release" set "CLANGD_FLAGS=%CLANGD_FLAGS% /DNDEBUG"
set "ROOT=%~dp0"
set "ROOT=%ROOT:\=/%"
if "%GENERATE_COMPCMDS%"=="1" (
(
echo [
echo {
echo "directory": "%ROOT%",
echo "file": "%ROOT%src/windows/foxui_win32.cpp",
echo "command": "clang-cl.exe %CLANGD_FLAGS% /c %ROOT%src/windows/foxui_win32.cpp"
echo },
echo {
echo "directory": "%ROOT%",
echo "file": "%ROOT%example/calc.cpp",
echo "command": "clang-cl.exe %CLANGD_FLAGS% /c %ROOT%example/calc.cpp"
echo }
echo ]
) > "%~dp0compile_commands.json"
echo [clangd] Generated compile_commands.json
)