twn_amalgam.c: a way for single unit compilation, controlled with -DTWN_USE_AMALGAM in cmake

This commit is contained in:
2024-10-13 19:04:23 +03:00
parent 9329d3c2be
commit ed93072371
5 changed files with 51 additions and 22 deletions

19
src/twn_amalgam.c Normal file
View File

@ -0,0 +1,19 @@
/* a technique for faster compilation */
/* it includes all non-optional .c files directly in a single compilation unit */
#include "twn_audio.c"
#include "twn_camera.c"
#include "twn_context.c"
#include "twn_input.c"
#include "twn_loop.c"
#include "twn_main.c"
#include "twn_textures.c"
#include "twn_util.c"
#include "rendering/twn_circles.c"
#include "rendering/twn_draw.c"
#include "rendering/twn_fog.c"
#include "rendering/twn_skybox.c"
#include "rendering/twn_sprites.c"
#include "rendering/twn_text.c"
#include "rendering/twn_triangles.c"

24
src/twn_stb.c Normal file
View File

@ -0,0 +1,24 @@
/* single compilation unit for every stb implementation */
#define STB_DS_IMPLEMENTATION
#define STBDS_ASSERT SDL_assert
#define STBDS_REALLOC(context,ptr,size) ((void)(context), SDL_realloc(ptr, size))
#define STBDS_FREE(context,ptr) ((void)(context), SDL_free(ptr))
#include <stb_ds.h>
#define STB_RECT_PACK_IMPLEMENTATION
#define STBRP_SORT SDL_qsort
#define STBRP_ASSERT SDL_assert
#include <stb_rect_pack.h>
#define STB_TRUETYPE_IMPLEMENTATION
#define STBTT_malloc(x,u) ((void)(u), SDL_malloc(x))
#define STBTT_free(x,u) ((void)(u), SDL_free(x))
#define STBTT_assert(x) SDL_assert(x)
#define STBTT_strlen(x) SDL_strlen(x)
#define STBTT_memcpy SDL_memcpy
#define STBTT_memset SDL_memset
#include <stb_truetype.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>

View File

@ -8,8 +8,6 @@
#include <physfsrwops.h>
#include <stb_ds.h>
#include <stb_rect_pack.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#include <stdbool.h>

View File

@ -4,23 +4,7 @@
#include <SDL2/SDL.h>
#include <physfsrwops.h>
#define STB_DS_IMPLEMENTATION
#define STBDS_ASSERT SDL_assert
#define STBDS_REALLOC(context,ptr,size) ((void)(context), SDL_realloc(ptr, size))
#define STBDS_FREE(context,ptr) ((void)(context), SDL_free(ptr))
#include <stb_ds.h>
#define STB_RECT_PACK_IMPLEMENTATION
#define STBRP_SORT SDL_qsort
#define STBRP_ASSERT SDL_assert
#include <stb_rect_pack.h>
#define STB_TRUETYPE_IMPLEMENTATION
#define STBTT_malloc(x,u) ((void)(u), SDL_malloc(x))
#define STBTT_free(x,u) ((void)(u), SDL_free(x))
#define STBTT_assert(x) SDL_assert(x)
#define STBTT_strlen(x) SDL_strlen(x)
#define STBTT_memcpy SDL_memcpy
#define STBTT_memset SDL_memset
#include <stb_truetype.h>
#include <stdarg.h>