From 5cc1fc31ffe0962cb973698f73241459115208b5 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Tue, 20 Jun 2023 18:19:17 -0400 Subject: [PATCH] Set a DLL define when building a DLL --- generate.jai | 23 ++++++++++++----------- windows/dr_libs.lib | Bin 754930 -> 754930 bytes 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/generate.jai b/generate.jai index f0387f5..42fde88 100644 --- a/generate.jai +++ b/generate.jai @@ -1,5 +1,4 @@ - -libs_to_build :: Libs.WAV | .FLAC | .MP3; // @consider making this a metaprogram/command line arg. Can then use this as a git submodule in a project and a script/build file generate bindings for what the project requires. +LIBS_TO_BUILD: Libs : .WAV | .FLAC | .MP3; // @consider making this a metaprogram/command line arg. Can then use this as a git submodule in a project and a script/build file can generate bindings for what the project requires. Libs :: enum_flags { WAV; @@ -39,26 +38,28 @@ else { } generate_bindings :: () -> bool { - if libs_to_build == 0 { + if LIBS_TO_BUILD == 0 { log_error("You need to specify at least one library for binding generation!\n"); return true; } // Prepare the source for our needs. - { - copy_file(tprint("%/dr_wav.h", SOURCE_PATH), tprint("%/dr_wav.c", SOURCE_PATH)); - copy_file(tprint("%/dr_flac.h", SOURCE_PATH), tprint("%/dr_flac.c", SOURCE_PATH)); - copy_file(tprint("%/dr_mp3.h", SOURCE_PATH), tprint("%/dr_mp3.c", SOURCE_PATH)); - } + copy_file(tprint("%/dr_wav.h", SOURCE_PATH), tprint("%/dr_wav.c", SOURCE_PATH)); + copy_file(tprint("%/dr_flac.h", SOURCE_PATH), tprint("%/dr_flac.c", SOURCE_PATH)); + copy_file(tprint("%/dr_mp3.h", SOURCE_PATH), tprint("%/dr_mp3.c", SOURCE_PATH)); src_files: [..] string; extra: [..] string; libs := type_info(Libs); for libs.names { - if libs_to_build & (xx libs.values[it_index]) { + if LIBS_TO_BUILD & (xx libs.values[it_index]) { array_add(*src_files, tprint("%/dr_%.c", SOURCE_PATH, to_lower_copy(it))); array_add(*extra, tprint("/DDR_%_IMPLEMENTATION", it)); + + #if MAKE_DYNAMIC_LIB { + array_add(*extra, tprint("/DDR%_DLL", it)); + } } } @@ -71,10 +72,10 @@ generate_bindings :: () -> bool { make_directory_if_it_does_not_exist("windows"); #if MAKE_DYNAMIC_LIB { - success = build_cpp_dynamic_lib("windows/dr_libs", ..src_files, extra = extra, debug=COMPILE_DEBUG); + success = build_cpp_dynamic_lib("windows/dr_libs", ..src_files, extra = extra, debug = COMPILE_DEBUG); } else { - success = build_cpp_static_lib("windows/dr_libs", ..src_files, extra = extra, debug=COMPILE_DEBUG); + success = build_cpp_static_lib("windows/dr_libs", ..src_files, extra = extra, debug = COMPILE_DEBUG); if success { // Remove existing DLL otherwise the bindings will have a "#library" directive that loads the DLL. The lib version is "#library,no_dll" if file_exists("windows/dr_libs.dll") { diff --git a/windows/dr_libs.lib b/windows/dr_libs.lib index 4bb8ed3f047476a9386164665d5c542e1efda725..d1876ffa1e78c8a3375f8a58df4576e023db39cf 100644 GIT binary patch delta 138 zcmey=srRWO_Uc6TFNsJh#i#ciW)}b}pMRLWeg0t%Am-dY J|1ekZK>(uKF$@3z delta 138 zcmey=srRWyO(=+GhTxV zPY+CFQfHo5+umNC$OOd9K+FQftU%1Ry*iQoOCpj=@##H>*#*GL=O1QopMRJGh&i{< JKg<<;5CD*IF!KNa