From fc659200520639296db79de85406a0a17d88edf4 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 3 Oct 2021 18:31:26 -0400 Subject: windows build --- .gitignore | 2 +- README.md | 6 +++++- make.bat | 16 +++++++++++++--- vlib.h | 19 +++++++++++-------- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index bade9a7..1c26f4f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ TAGS *.exe *.ilk *.pdb -./*.obj +*.obj *.dll *.lib SDL2 diff --git a/README.md b/README.md index c49cf01..874ed5d 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,11 @@ sudo apt install libsdl2-dev or equivalent, then run `make release`. On Windows, download Visual Studio, [the VC development libraries for SDL2](https://libsdl.org/release/SDL2-devel-2.0.16-VC.zip), -add `vcvarsall.bat` to your PATH, then run `make.bat release`. +extract it, rename the folder to `SDL2`, and place it in the same folder +as the source code. +Then add `vcvarsall.bat` to your PATH, and run `make.bat release`. +Finally you'll need to copy `SDL2\lib\x64\SDL2.dll` to the same folder as +`sandbox.exe`. Alternatively, you can just compile `main.c` with any C compiler, making sure that `SDL.h` is in your include path (and you're linking with SDL2). diff --git a/make.bat b/make.bat index 91a4280..b28c532 100644 --- a/make.bat +++ b/make.bat @@ -1,11 +1,21 @@ @echo off if "%_VCVARS%" == "" ( set "_VCVARS=1" - vcvarsall x64 + call vcvarsall x64 ) if "%1" == "" ( - cl /nologo /W4 /wd4706 /wd4996 /wd4100 /Zi /Od /DEBUG /DDEBUG=1 main.c SDL2\lib\x64\SDL2.lib SDL2\lib\x64\SDL2main.lib /Fe:sandbox shell32.lib + cl /nologo /W4 /wd4706 /wd4996 /wd4100 /wd4204 /Zi /Od /DEBUG /DDEBUG=1 main.c /I SDL2\include SDL2\lib\x64\SDL2.lib SDL2\lib\x64\SDL2main.lib /Fe:sandbox shell32.lib ) if "%1" == "release" ( - cl /nologo /W4 /wd4706 /wd4996 /wd4100 /O2 main.c SDL2\lib\x64\SDL2.lib SDL2\lib\x64\SDL2main.lib /Fe:sandbox shell32.lib + cl /nologo /W4 /wd4706 /wd4996 /wd4100 /wd4204 /O2 main.c /I SDL2\include SDL2\lib\x64\SDL2.lib SDL2\lib\x64\SDL2main.lib /Fe:sandbox shell32.lib + rd /s/q FunctionSandbox + mkdir FunctionSandbox + mkdir FunctionSandbox\sandboxes + copy sandbox.exe FunctionSandbox + copy sandboxes\*.txt FunctionSandbox\sandboxes + copy example.png FunctionSandbox + copy SDL2.dll FunctionSandbox + del sandbox-windows.zip + 7z a sandbox-windows.zip FunctionSandbox + rd /s/q FunctionSandbox ) diff --git a/vlib.h b/vlib.h index b081806..04728b4 100644 --- a/vlib.h +++ b/vlib.h @@ -79,6 +79,7 @@ extern "C" { #include #include #include +#include // what the fuck is wrong with you microsoft #ifdef min @@ -105,6 +106,10 @@ extern "C" { #endif #endif +typedef unsigned int uint; +typedef unsigned long ulong; +typedef unsigned long long ullong; + // ---- WINAPI FUNCTIONS ---- #if V_WINDOWS void OutputDebugStringA(const char *); @@ -130,12 +135,6 @@ void OutputDebugStringA(const char *); _Pragma("GCC diagnostic ignored \"-Wshadow\"") #define NO_WARN_END \ _Pragma("GCC diagnostic pop") -#elif V_MSVC -#define NO_WARN_START \ - _Pragma("warning(push)") \ - _Pragma("warning(disable: 4456 4457 4100 4244 4701)") -#define NO_WARN_END \ - _Pragma("warning(pop)") #else #define NO_WARN_START #define NO_WARN_END @@ -11151,7 +11150,6 @@ V_DECL bool window_create(const char *title, int width, int height, uint32_t fla } } else { strbuf_cpy(V_window_error, SDL_GetError()); - V_window_die(); if (!(flags & WINDOW_CREATE_DONT_QUIT_ON_ERROR)) V_window_die(); } @@ -11203,7 +11201,7 @@ typedef struct { static V_AudioUserData V_audio_user_data = {0}; static SDL_AudioDeviceID V_audio_device; -static SDLCALL void V_audio_callback(void *userdata, uint8_t *buffer, int len) { +static void V_audio_callback(void *userdata, uint8_t *buffer, int len) { V_AudioUserData *audio = (V_AudioUserData *)userdata; if (len > 0) { memset(buffer, 0, (size_t)len); @@ -12974,6 +12972,11 @@ static void model_delete(Model *model) { return main_(argc, argv); } #endif + + #ifdef main + #undef main + #endif + #define main main_ #endif -- cgit v1.2.3