medfall

Log | Files | Refs

commit b093f5af9873393cc083c63d05261e4138645840
parent fdbfe8699ec8113f249518251c07bcbc03d76e3c
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue May  9 00:02:27 +0300

Use the new build system on Windows too

Diffstat:
build.bat | 77-----------------------------------------------------------------------------
libs/glfw.lua | 21+++++++++++++++++----
libs/imgui.lua | 2+-
libs/squish.lua | 3++-
make.lua | 40+++++++++++++++++++++++++++-------------
scripts/gen_makefile.lua | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
6 files changed, 127 insertions(+), 110 deletions(-)
diff --git a/build.bat b/build.bat @@ -1,77 +0,0 @@ -@ECHO off - -set VC=%PROGRAMFILES(X86)%\Microsoft Visual Studio 12.0\VC -set KIT=%PROGRAMFILES(X86)%\Windows Kits\8.1 -set DX=%PROGRAMFILES(X86)%\Microsoft DirectX SDK (June 2010) - -set INCLUDE=%VC%\include;%KIT%\Include\shared;%DX%\Include;%KIT%\Include\um;%KIT%\Include\winrt - -REM 64bit -REM set LIB=%VC%\lib\amd64;%KIT%\lib\winv6.3\um\x64 -REM set PATH=%VC%\bin\amd64\;%PATH% - -REM 32bit -set LIB=%VC%\LIB;%VC%\ATLMFC\LIB;%KIT%\lib\winv6.3\um\x86 -set PATH=%VC%\bin;%PATH% - -set FLAGS=-I include -Z7 -Zo -W4 -Oi -Gm- -GR- -EHa- -nologo -MTd -Od -wd4100 -wd4201 -wd4189 -wd4351 -wd4505 -wd4127 -wd4530 -wd4702 -D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -D_USE_MATH_DEFINES -DWIN32_LEAN_AND_MEAN -I . -set EXELIBS=glfw.lib user32.lib shell32.lib opengl32.lib gdi32.lib Ws2_32.lib -set EXEFLAGS=%EXELIBS% %FLAGS% -set COMMONOBJS=log.obj memory_arena.obj work_queue.obj stb_truetype.obj ggformat.obj strlcat.obj strlcpy.obj strtonum.obj profiler.obj stats.obj rng\well512.obj - -cl btt.cc -c %FLAGS% -cl heightmap.cc -c %FLAGS% -cl ggformat.cc -c %FLAGS% -cl gl.cc -c %FLAGS% -cl glad.cc -c %FLAGS% -cl gpubtt.cc -c %FLAGS% -cl http.cc -c %FLAGS% -cl hm.cc -c %FLAGS% -cl immediate.cc -c %FLAGS% -cl log.cc -c %FLAGS% -cl memory_arena.cc -c %FLAGS% -cl lz4.cc -c %FLAGS% -cl lz4hc.cc -c %FLAGS% -cl mixer.cc -c %FLAGS% -cl profiler.cc -c %FLAGS% -cl renderer.cc -c %FLAGS% -cl sha2.cc -c %FLAGS% -wd4244 -cl skybox.cc -c %FLAGS% -cl stats.cc -c %FLAGS% -cl -Tpstb_image.h -c %FLAGS% -DSTB_IMAGE_IMPLEMENTATION -wd4244 -cl -Tpstb_truetype.h -c %FLAGS% -DSTB_TRUETYPE_IMPLEMENTATION -cl strlcat.cc -c %FLAGS% -cl strlcpy.cc -c %FLAGS% -cl strtonum.cc -c %FLAGS% -cl terrain_manager.cc -c %FLAGS% -cl text_renderer.cc -c %FLAGS% -cl wave.cc -c %FLAGS% -cl win32_audio_output.cc -c %FLAGS% -cl work_queue.cc -c %FLAGS% -cl rng\well512.cc -c %FLAGS% -Forng\well512.obj - -cl libs\imgui\imgui.cc -c %FLAGS% -Folibs\imgui\imgui.obj -cl libs\imgui\imgui_draw.cc -c %FLAGS% -Folibs\imgui\imgui_draw.obj -cl libs\imgui\imgui_impl_glfw_gl3.cc -c %FLAGS% -Folibs\imgui\imgui_impl_glfw_gl3.obj -lib -OUT:imgui.lib libs\imgui\imgui.obj libs\imgui\imgui_draw.obj libs\imgui\imgui_impl_glfw_gl3.obj - -cl libs\glfw\src\context.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\context.obj -cl libs\glfw\src\init.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\init.obj -wd4152 -cl libs\glfw\src\input.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\input.obj -wd4152 -cl libs\glfw\src\monitor.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\monitor.obj -wd4152 -cl libs\glfw\src\vulkan.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\vulkan.obj -cl libs\glfw\src\window.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\window.obj -wd4152 -cl libs\glfw\src\win32_init.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\win32_init.obj -wd4244 -cl libs\glfw\src\win32_monitor.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\win32_monitor.obj -cl libs\glfw\src\win32_window.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\win32_window.obj -wd4204 -cl libs\glfw\src\win32_joystick.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\win32_joystick.obj -cl libs\glfw\src\win32_time.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\win32_time.obj -cl libs\glfw\src\win32_tls.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\win32_tls.obj -cl libs\glfw\src\wgl_context.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\wgl_context.obj -cl libs\glfw\src\egl_context.cc -c -D_GLFW_WIN32 -TC %FLAGS% -Folibs\glfw\src\egl_context.obj -lib -OUT:glfw.lib libs\glfw\src\context.obj libs\glfw\src\init.obj libs\glfw\src\input.obj libs\glfw\src\monitor.obj libs\glfw\src\vulkan.obj libs\glfw\src\window.obj libs\glfw\src\win32_init.obj libs\glfw\src\win32_monitor.obj libs\glfw\src\win32_window.obj libs\glfw\src\win32_joystick.obj libs\glfw\src\win32_time.obj libs\glfw\src\win32_tls.obj libs\glfw\src\wgl_context.obj libs\glfw\src\egl_context.obj - -cl main.cc gl.obj glad.obj renderer.obj immediate.obj text_renderer.obj hm.obj terrain_manager.obj heightmap.obj btt.obj gpubtt.obj lz4.obj skybox.obj http.obj -DSTATIC_GAME %COMMONOBJS% %EXEFLAGS% -Femedfall.exe -cl pp.cc heightmap.obj stb_image.obj lz4.obj lz4hc.obj %COMMONOBJS% %EXEFLAGS% -cl launcher\main.cc http.obj sha2.obj gl.obj glad.obj renderer.obj imgui.lib %COMMONOBJS% %EXEFLAGS% -Felauncher.exe -cl audio.cc win32_audio_output.obj mixer.obj wave.obj Ole32.lib %COMMONOBJS% %EXEFLAGS% -Feaudio.exe diff --git a/libs/glfw.lua b/libs/glfw.lua @@ -1,9 +1,22 @@ lib( "glfw", { "libs/glfw/src/context", "libs/glfw/src/init", "libs/glfw/src/input", "libs/glfw/src/monitor", "libs/glfw/src/vulkan", "libs/glfw/src/window", - "libs/glfw/src/x11_init", "libs/glfw/src/x11_monitor", "libs/glfw/src/x11_window", - "libs/glfw/src/xkb_unicode", "libs/glfw/src/linux_joystick", "libs/glfw/src/posix_time", - "libs/glfw/src/posix_tls", "libs/glfw/src/glx_context", "libs/glfw/src/egl_context", + "libs/glfw/src/egl_context", } ) -obj_replace_cxxflags( "libs/glfw/src/%", "-c -x c -O2 -D_GLFW_X11" ) +if OS == "windows" then + lib( "glfw", { + "libs/glfw/src/win32_init", "libs/glfw/src/win32_monitor", "libs/glfw/src/win32_window", + "libs/glfw/src/win32_joystick", "libs/glfw/src/win32_time", "libs/glfw/src/win32_tls", + "libs/glfw/src/wgl_context", + } ) +elseif OS == "linux" then + lib( "glfw", { + "libs/glfw/src/x11_init", "libs/glfw/src/x11_monitor", "libs/glfw/src/x11_window", + "libs/glfw/src/xkb_unicode", "libs/glfw/src/linux_joystick", "libs/glfw/src/posix_time", + "libs/glfw/src/posix_tls", "libs/glfw/src/glx_context", + } ) +end + +windows_obj_replace_cxxflags( "libs/glfw/src/%", "/c /O2 /TC /D_GLFW_WIN32" ) -- compile as c +linux_obj_replace_cxxflags( "libs/glfw/src/%", "-c -x c -O2 -D_GLFW_X11" ) diff --git a/libs/imgui.lua b/libs/imgui.lua @@ -1,2 +1,2 @@ lib( "imgui", { "libs/imgui/imgui", "libs/imgui/imgui_draw", "libs/imgui/imgui_impl_glfw_gl3" } ) -obj_cxxflags( "libs/imgui/imgui_draw", "-Wno-maybe-uninitialized" ) +linux_obj_cxxflags( "libs/imgui/imgui_draw", "-Wno-maybe-uninitialized" ) diff --git a/libs/squish.lua b/libs/squish.lua @@ -4,4 +4,5 @@ lib( "squish", { "libs/squish/colourblock", "libs/squish/maths", "libs/squish/squish", } ) -obj_cxxflags( "libs/squish/%", "-O3" ) +windows_obj_cxxflags( "libs/squish/%", "/O2" ) +linux_obj_cxxflags( "libs/squish/%", "-O3" ) diff --git a/make.lua b/make.lua @@ -5,10 +5,12 @@ local game_objs = { "work_queue", "renderer", "gl", "glad", "immediate", "text_r local game_libs = { "glfw", "tinyobjloader" } bin( "medfall", { "main", "hm", "heightmap", "terrain_manager", "lz4", "btt", "gpubtt", "skybox", "http", game_objs }, { game_libs } ) -bin_ldflags( "medfall", "-lX11 -lXrandr -lXinerama -lXcursor" ) +windows_bin_ldflags( "medfall", "opengl32.lib gdi32.lib Ws2_32.lib" ) +linux_bin_ldflags( "medfall", "-lX11 -lXrandr -lXinerama -lXcursor" ) bin( "launch", { "launcher/main", "http", "sha2", game_objs }, { "imgui", "monocypher", game_libs } ) -bin_ldflags( "launch", "-lX11 -lXrandr -lXinerama -lXcursor" ) +windows_bin_ldflags( "launch", "opengl32.lib gdi32.lib Ws2_32.lib" ) +linux_bin_ldflags( "launch", "-lX11 -lXrandr -lXinerama -lXcursor" ) require( "libs/imgui" ) require( "libs/glfw" ) @@ -16,10 +18,16 @@ require( "libs/monocypher" ) require( "libs/squish" ) require( "libs/tinyobjloader" ) -obj( "stb_image", "stb_image.h", "-DSTB_IMAGE_IMPLEMENTATION -Wno-shift-negative-value" ) +obj( "stb_image", "stb_image.h" ) +windows_obj_cxxflags( "stb_image", "/DSTB_IMAGE_IMPLEMENTATION -wd4244" ) +linux_obj_cxxflags( "stb_image", "-DSTB_IMAGE_IMPLEMENTATION -Wno-shift-negative-value" ) + -- obj( "stb_image_write", "stb_image_write.h", "-DSTB_IMAGE_WRITE_IMPLEMENTATION" ) -- obj( "stb_perlin", "stb_perlin.h", "-DSTB_PERLIN_IMPLEMENTATION" ) -obj( "stb_truetype", "stb_truetype.h", "-DSTB_TRUETYPE_IMPLEMENTATION" ) + +obj( "stb_truetype", "stb_truetype.h" ) +windows_obj_cxxflags( "stb_truetype", "-DSTB_TRUETYPE_IMPLEMENTATION" ) +linux_obj_cxxflags( "stb_truetype", "-DSTB_TRUETYPE_IMPLEMENTATION" ) if config == "release" then return @@ -30,21 +38,27 @@ bin( "bsp", { "main", "bsp", "bsp_renderer", game_objs }, { game_libs } ) -- bin( "btt", { "main", "mod_btt", "btt", "heightmap", "skybox", "stb_image", "lz4", game_objs }, { game_libs } ) bin( "sm", { "main", "shadow_map", game_objs }, { game_libs } ) -bin_ldflags( "bsp", "-lX11 -lXrandr -lXinerama -lXcursor" ) -bin_ldflags( "btt", "-lX11 -lXrandr -lXinerama -lXcursor" ) -bin_ldflags( "sm", "-lX11 -lXrandr -lXinerama -lXcursor" ) +windows_bin_ldflags( "bsp", "opengl32.lib gdi32.lib" ) +linux_bin_ldflags( "bsp", "-lX11 -lXrandr -lXinerama -lXcursor" ) +windows_bin_ldflags( "btt", "opengl32.lib gdi32.lib" ) +linux_bin_ldflags( "btt", "-lX11 -lXrandr -lXinerama -lXcursor" ) +windows_bin_ldflags( "sm", "opengl32.lib gdi32.lib" ) +linux_bin_ldflags( "sm", "-lX11 -lXrandr -lXinerama -lXcursor" ) bin( "sound", { "audio", "mixer", "wave", "platform_audio_output", common_objs } ) - -bin( "srv", { "server/main", common_objs } ) +windows_bin_ldflags( "sound", "ole32.lib" ) bin( "pp", { "pp", "lz4", "lz4hc", "heightmap", "stb_image", common_objs }, { "squish" } ) bin( "utils/genkeys/genkeys", { "utils/genkeys/genkeys", common_objs }, { "monocypher" } ) bin( "utils/genkeys/sign", { "utils/genkeys/sign", common_objs }, { "monocypher" } ) -obj_cxxflags( "lz4", "-O3 -g0" ) -obj_cxxflags( "lz4hc", "-O3 -g0" ) +linux_obj_cxxflags( "lz4", "-O3 -g0" ) +linux_obj_cxxflags( "lz4hc", "-O3 -g0" ) -bin( "test_lockfree", { "relacy" } ) -obj_cxxflags( "relacy", "-std=c++98 -fexceptions -frtti -Wno-shadow -Wno-missing-field-initializers" ) +if OS ~= "windows" then + bin( "srv", { "server/main", common_objs } ) + + bin( "test_lockfree", { "relacy" } ) + linux_obj_cxxflags( "relacy", "-std=c++98 -fexceptions -frtti -Wno-shadow -Wno-missing-field-initializers" ) +end diff --git a/scripts/gen_makefile.lua b/scripts/gen_makefile.lua @@ -7,10 +7,10 @@ local configs = { cxx = "...", lib = "...", - cxxflags = "/I . /Z7 /Zo /Oi /Gm- /GR- /EHa- /nologo /DNOMINMAX /D_USE_MATH_DEFINES /DWIN32_LEAN_AND_MEAN /DSTATIC_GAME", + cxxflags = "/I . /c /Z7 /Zo /Oi /Gm- /GR- /EHa- /nologo /DNOMINMAX /D_USE_MATH_DEFINES /DWIN32_LEAN_AND_MEAN /DSTATIC_GAME", -- ldflags = "user32.lib shell32.lib opengl32.lib gdi32.lib Ws2_32.lib", - ldflags = "user32.lib shell32.lib", - warnings = "/W4 /wd4100 /wd4201 /wd4189 /wd4351 /wd4505 /wd4127 /wd4350 /wd4702 /D_CRT_SECURE_NO_WARNINGS", + ldflags = "user32.lib shell32.lib dbghelp.lib", + warnings = "/W4 /wd4100 /wd4201 /wd4189 /wd4351 /wd4505 /wd4127 /wd4530 /wd4702 /D_CRT_SECURE_NO_WARNINGS", }, [ "windows-32" ] = { }, @@ -138,11 +138,10 @@ function bin( bin_name, objs, libs ) printf( "clean::\n\trm -f %s", bin_path ) end -function obj( obj_name, source, cxxflags ) +function obj( obj_name, source ) local obj_path = ( "%s/%s%s" ):format( dir, obj_name, obj_suffix ) printh( "OBJS += %s", obj_path ) printf( "%s: %s", obj_path, source ) - printf( "%s: CXXFLAGS += %s", obj_path, cxxflags ) end function lib( lib_name, objs ) @@ -150,17 +149,43 @@ function lib( lib_name, objs ) printf( "%s/%s%s%s: %s", dir, lib_prefix, lib_name, lib_suffix, join( objs, obj_suffix ) ) end -function bin_ldflags( bin_name, ldflags ) - local bin_path = ( "%s%s%s" ):format( bin_prefix, bin_name, bin_suffix ) - printf( "%s: LDFLAGS += %s", bin_path, ldflags ) +-- TODO: this should be split by windows/linux and also by msvc/gcc +function linux_bin_ldflags( bin_name, ldflags ) + if OS == "linux" then + local bin_path = ( "%s%s%s" ):format( bin_prefix, bin_name, bin_suffix ) + printf( "%s: LDFLAGS += %s", bin_path, ldflags ) + end +end + +function linux_obj_cxxflags( obj_name, cxxflags ) + if OS == "linux" then + printf( "%s/%s%s: CXXFLAGS += %s", dir, obj_name, obj_suffix, cxxflags ) + end +end + +function linux_obj_replace_cxxflags( obj_name, cxxflags ) + if OS == "linux" then + printf( "%s/%s%s: CXXFLAGS := %s", dir, obj_name, obj_suffix, cxxflags ) + end end -function obj_cxxflags( obj_name, cxxflags ) - printf( "%s/%s%s: CXXFLAGS += %s", dir, obj_name, obj_suffix, cxxflags ) +function windows_bin_ldflags( bin_name, ldflags ) + if OS == "windows" then + local bin_path = ( "%s%s%s" ):format( bin_prefix, bin_name, bin_suffix ) + printf( "%s: LDFLAGS += %s", bin_path, ldflags ) + end end -function obj_replace_cxxflags( obj_name, cxxflags ) - printf( "%s/%s%s: CXXFLAGS := %s", dir, obj_name, obj_suffix, cxxflags ) +function windows_obj_cxxflags( obj_name, cxxflags ) + if OS == "windows" then + printf( "%s/%s%s: CXXFLAGS += %s", dir, obj_name, obj_suffix, cxxflags ) + end +end + +function windows_obj_replace_cxxflags( obj_name, cxxflags ) + if OS == "windows" then + printf( "%s/%s%s: CXXFLAGS := %s", dir, obj_name, obj_suffix, cxxflags ) + end end printf( "CXXFLAGS := %s", cxxflags ) @@ -171,6 +196,45 @@ printf( "" ) printf( "all: $(BINS)" ) printf( "" ) +if OS == "windows" then + +printf( [[ +VC = ${ProgramFiles(x86)}\Microsoft Visual Studio 12.0\VC +KIT = ${ProgramFiles(x86)}\Windows Kits\8.1 +DX = ${ProgramFiles(x86)}\Microsoft DirectX SDK (June 2010) + +export INCLUDE := $(VC)\include;$(KIT)\Include\shared;$(DX)\Include;$(KIT)\Include\um;$(KIT)\Include\winrt +export LIB := $(VC)\lib\amd64;$(KIT)\lib\winv6.3\um\x64 +export PATH := /cygdrive/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/:$(PATH) +]] ) + +printf( [[ +$(BINS): %%: + @printf "\e[1;31mbuilding $@\e[0m\n" + @mkdir -p "$(@D)" + cl -Fe$@ $^ $(LDFLAGS) +]] ) +printf( [[ +%s/%%%s: %%.cc + @printf "\e[1;32mbuilding $<\e[0m\n" + @mkdir -p "$(@D)" + cl $(CXXFLAGS) -Fo$@ $^ +]], dir, obj_suffix ) +printf( [[ +$(OBJS): %%: + @printf "\e[1;32mbuilding $<\e[0m\n" + @mkdir -p "$(@D)" + cl $(CXXFLAGS) -Fo$@ -Tp$< +]] ) +printf( [[ +%%%s: + @printf "\e[1;35mbuilding $@\e[0m\n" + @mkdir -p "$(@D)" + lib -OUT:$@ $^ +]], lib_suffix ) + +else + printf( [[ $(BINS): %%: @printf "\e[1;31mbuilding $@\e[0m\n" @@ -196,10 +260,12 @@ printf( [[ @$(AR) rs $@ $^ ]], lib_suffix ) -printf( "clean::\n\trm -rf build release" ) - printf( "include %s/**.d", dir ) +end + +printf( "clean::\n\trm -rf build release" ) + automatically_print_output_at_exit = setmetatable( { }, { __gc = function() print( table.concat( output, "\n" ) )