Set a DLL define when building a DLL
This commit is contained in:
parent
4c34f1f702
commit
5cc1fc31ff
17
generate.jai
17
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));
|
||||
}
|
||||
|
||||
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") {
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user