Skip to content

Commit 745f7a5

Browse files
committed
Improved submodules
1 parent 2f0bb63 commit 745f7a5

33 files changed

+641
-312
lines changed

cmake/yup_modules.cmake

Lines changed: 27 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ function (_yup_module_fetch_upstream module_name module_path module_upstream mod
108108

109109
_yup_message (STATUS "Fetching upstream sources for ${module_name}")
110110

111+
set (upstream_target_dir "${CMAKE_BINARY_DIR}/externals/${module_name}")
112+
111113
if (module_upstream)
112114
set (download_dir "${CMAKE_BINARY_DIR}/_yup_upstream_downloads")
113115
file (MAKE_DIRECTORY "${download_dir}")
@@ -139,28 +141,26 @@ function (_yup_module_fetch_upstream module_name module_path module_upstream mod
139141
endif()
140142
endif()
141143

142-
set (upstream_target_dir "${CMAKE_BINARY_DIR}/externals/${module_name}/upstream")
143-
file (REMOVE_RECURSE "${upstream_target_dir}")
144-
file (MAKE_DIRECTORY "${upstream_target_dir}")
145144
file (GLOB extracted_items "${source_dir}/*")
146145
if (extracted_items)
146+
file (REMOVE_RECURSE "${upstream_target_dir}")
147+
file (MAKE_DIRECTORY "${upstream_target_dir}")
147148
file (COPY ${extracted_items} DESTINATION "${upstream_target_dir}")
148149
endif()
149150
else()
150151
if (NOT module_branch)
151152
set (module_branch "HEAD")
152153
endif()
153154

154-
set (upstream_target_dir "${CMAKE_BINARY_DIR}/externals/${module_name}/upstream")
155155
if (module_submodules)
156156
set (module_submodules_recurse ON)
157157
else()
158158
set (module_submodules_recurse OFF)
159159
endif()
160160

161-
file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/externals/${module_name}")
162-
163161
file (REMOVE_RECURSE "${upstream_target_dir}")
162+
file (MAKE_DIRECTORY "${upstream_target_dir}")
163+
164164
set (module_branch_value "${module_branch}")
165165
string (STRIP "${module_branch_value}" module_branch_value)
166166
string (REGEX REPLACE "^\"(.*)\"$" "\\1" module_branch_value "${module_branch_value}")
@@ -208,7 +208,7 @@ function (_yup_module_fetch_upstream module_name module_path module_upstream mod
208208
list (APPEND clone_args "${module_repository}" "${upstream_target_dir}")
209209
execute_process (
210210
COMMAND ${clone_args}
211-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals/${module_name}"
211+
WORKING_DIRECTORY "${upstream_target_dir}"
212212
RESULT_VARIABLE clone_result)
213213
endif()
214214

@@ -712,9 +712,10 @@ function (yup_add_module module_path modules_definitions module_group)
712712
if (module_upstream OR module_repository)
713713
_yup_module_get_upstream_path ("${module_name}" "${module_path}" module_upstream_path)
714714
if (module_upstream_path)
715-
list (APPEND module_include_paths "${module_upstream_path}")
715+
get_filename_component (module_upstream_include_path ${module_upstream_path} DIRECTORY)
716+
list (APPEND module_include_paths "${module_upstream_path}" "${module_upstream_include_path}")
716717
else()
717-
list (APPEND module_include_paths "${CMAKE_BINARY_DIR}/externals/${module_name}/upstream")
718+
list (APPEND module_include_paths "${CMAKE_BINARY_DIR}/externals")
718719
endif()
719720
endif()
720721

@@ -726,7 +727,7 @@ function (yup_add_module module_path modules_definitions module_group)
726727
elseif (module_upstream_path AND EXISTS "${module_upstream_path}/${searchpath}")
727728
list (APPEND module_include_paths "${module_upstream_path}/${searchpath}")
728729
elseif (module_upstream OR module_repository)
729-
list (APPEND module_include_paths "${CMAKE_BINARY_DIR}/externals/${module_name}/upstream/${searchpath}")
730+
list (APPEND module_include_paths "${CMAKE_BINARY_DIR}/externals/${module_name}/${searchpath}")
730731
endif()
731732
endforeach()
732733

@@ -821,60 +822,25 @@ macro (yup_add_default_modules modules_path)
821822

822823
# ==== Thirdparty modules
823824
set (thirdparty_group "Thirdparty")
824-
yup_add_module (${modules_path}/thirdparty/zlib "${modules_definitions}" ${thirdparty_group})
825-
yup_add_module (${modules_path}/thirdparty/glad "${modules_definitions}" ${thirdparty_group})
826-
yup_add_module (${modules_path}/thirdparty/harfbuzz "${modules_definitions}" ${thirdparty_group})
827-
yup_add_module (${modules_path}/thirdparty/libpng "${modules_definitions}" ${thirdparty_group})
828-
yup_add_module (${modules_path}/thirdparty/libwebp "${modules_definitions}" ${thirdparty_group})
829-
yup_add_module (${modules_path}/thirdparty/sheenbidi "${modules_definitions}" ${thirdparty_group})
830-
yup_add_module (${modules_path}/thirdparty/yoga_library "${modules_definitions}" ${thirdparty_group})
831-
yup_add_module (${modules_path}/thirdparty/rive "${modules_definitions}" ${thirdparty_group})
832-
yup_add_module (${modules_path}/thirdparty/rive_decoders "${modules_definitions}" ${thirdparty_group})
833-
yup_add_module (${modules_path}/thirdparty/rive_renderer "${modules_definitions}" ${thirdparty_group})
834-
yup_add_module (${modules_path}/thirdparty/oboe_library "${modules_definitions}" ${thirdparty_group})
835-
yup_add_module (${modules_path}/thirdparty/pffft_library "${modules_definitions}" ${thirdparty_group})
836-
yup_add_module (${modules_path}/thirdparty/dr_libs "${modules_definitions}" ${thirdparty_group})
837-
yup_add_module (${modules_path}/thirdparty/opus_library "${modules_definitions}" ${thirdparty_group})
838-
yup_add_module (${modules_path}/thirdparty/flac_library "${modules_definitions}" ${thirdparty_group})
839-
yup_add_module (${modules_path}/thirdparty/hmp3_library "${modules_definitions}" ${thirdparty_group})
825+
file (GLOB thirdparty_module_dirs "${modules_path}/thirdparty/*")
826+
foreach (thirdparty_module_dir IN LISTS thirdparty_module_dirs)
827+
if (IS_DIRECTORY "${thirdparty_module_dir}")
828+
get_filename_component (module_dir_name "${thirdparty_module_dir}" NAME)
829+
yup_add_module (${modules_path}/thirdparty/${module_dir_name} "${modules_definitions}" ${thirdparty_group})
830+
endif()
831+
endforeach()
840832

841833
# ==== Yup modules
842834
set (modules_group "Modules")
843-
yup_add_module (${modules_path}/modules/yup_core "${modules_definitions}" ${modules_group})
844-
add_library (yup::yup_core ALIAS yup_core)
845-
846-
yup_add_module (${modules_path}/modules/yup_events "${modules_definitions}" ${modules_group})
847-
add_library (yup::yup_events ALIAS yup_events)
848-
849-
yup_add_module (${modules_path}/modules/yup_data_model "${modules_definitions}" ${modules_group})
850-
add_library (yup::yup_data_model ALIAS yup_data_model)
851-
852-
yup_add_module (${modules_path}/modules/yup_dsp "${modules_definitions}" ${modules_group})
853-
add_library (yup::yup_dsp ALIAS yup_dsp)
854-
855-
yup_add_module (${modules_path}/modules/yup_graphics "${modules_definitions}" ${modules_group})
856-
add_library (yup::yup_graphics ALIAS yup_graphics)
857-
858-
yup_add_module (${modules_path}/modules/yup_gui "${modules_definitions}" ${modules_group})
859-
add_library (yup::yup_gui ALIAS yup_gui)
860-
861-
yup_add_module (${modules_path}/modules/yup_audio_basics "${modules_definitions}" ${modules_group})
862-
add_library (yup::yup_audio_basics ALIAS yup_audio_basics)
863-
864-
yup_add_module (${modules_path}/modules/yup_audio_devices "${modules_definitions}" ${modules_group})
865-
add_library (yup::yup_audio_devices ALIAS yup_audio_devices)
866-
867-
yup_add_module (${modules_path}/modules/yup_audio_formats "${modules_definitions}" ${modules_group})
868-
add_library (yup::yup_audio_formats ALIAS yup_audio_formats)
869-
870-
yup_add_module (${modules_path}/modules/yup_audio_processors "${modules_definitions}" ${modules_group})
871-
add_library (yup::yup_audio_processors ALIAS yup_audio_processors)
872-
873-
yup_add_module (${modules_path}/modules/yup_audio_gui "${modules_definitions}" ${modules_group})
874-
add_library (yup::yup_audio_gui ALIAS yup_audio_gui)
875-
876-
yup_add_module (${modules_path}/modules/yup_audio_plugin_client "${modules_definitions}" ${modules_group})
877-
add_library (yup::yup_audio_plugin_client ALIAS yup_audio_plugin_client)
835+
file (GLOB yup_module_dirs "${modules_path}/modules/*")
836+
list (FILTER yup_module_dirs EXCLUDE REGEX ".*yup_python.*")
837+
foreach (yup_module_dir IN LISTS yup_module_dirs)
838+
if (IS_DIRECTORY "${yup_module_dir}")
839+
get_filename_component (module_dir_name "${yup_module_dir}" NAME)
840+
yup_add_module (${modules_path}/modules/${module_dir_name} "${modules_definitions}" ${modules_group})
841+
add_library (yup::${module_dir_name} ALIAS ${module_dir_name})
842+
endif()
843+
endforeach()
878844

879845
if (YUP_ARG_ENABLE_PYTHON)
880846
if (NOT YUP_BUILD_WHEEL)

cmake/yup_utilities.cmake

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,15 @@ endfunction()
206206
#==============================================================================
207207

208208
function (_yup_collect_upstream_candidate_paths module_name module_path output_variable)
209-
set (candidate_paths "${module_path}/upstream")
210-
211-
if (DEFINED YUP_UPSTREAM_ROOT AND NOT "${YUP_UPSTREAM_ROOT}" STREQUAL "")
212-
list (APPEND candidate_paths "${YUP_UPSTREAM_ROOT}/${module_name}/upstream")
213-
endif()
214-
215-
if (CMAKE_SOURCE_DIR)
216-
list (APPEND candidate_paths "${CMAKE_SOURCE_DIR}/build/externals/${module_name}/upstream")
217-
list (APPEND candidate_paths "${CMAKE_SOURCE_DIR}/../build/externals/${module_name}/upstream")
218-
endif()
209+
set (candidate_paths
210+
"${module_path}/upstream"
211+
"${CMAKE_SOURCE_DIR}/build/externals/${module_name}"
212+
"${CMAKE_SOURCE_DIR}/../build/externals/${module_name}")
219213

220214
set (candidate_root "${CMAKE_BINARY_DIR}")
221215
set (max_depth 10)
222216
while (max_depth GREATER 0)
223-
list (APPEND candidate_paths "${candidate_root}/externals/${module_name}/upstream")
217+
list (APPEND candidate_paths "${candidate_root}/externals/${module_name}")
224218

225219
get_filename_component (candidate_parent "${candidate_root}" DIRECTORY)
226220
if ("${candidate_parent}" STREQUAL "${candidate_root}")
@@ -234,6 +228,8 @@ function (_yup_collect_upstream_candidate_paths module_name module_path output_v
234228
set (${output_variable} "${candidate_paths}" PARENT_SCOPE)
235229
endfunction()
236230

231+
#==============================================================================
232+
237233
function (_yup_resolve_variable_paths input_list output_list)
238234
set (resolved_list "")
239235

@@ -293,16 +289,9 @@ function (_yup_convert_png_to_icns png_path icons_path output_variable)
293289
file (REMOVE_RECURSE "${temp_iconset_path}")
294290
file (MAKE_DIRECTORY "${temp_iconset_path}")
295291

296-
_yup_execute_process_or_fail (/usr/bin/sips -z 16 16 "${png_path}" --out "${temp_iconset_path}/icon_16x16.png")
297-
_yup_execute_process_or_fail (/usr/bin/sips -z 32 32 "${png_path}" --out "${temp_iconset_path}/icon_32x32.png")
298-
_yup_execute_process_or_fail (/usr/bin/sips -z 32 32 "${png_path}" --out "${temp_iconset_path}/[email protected]")
299-
_yup_execute_process_or_fail (/usr/bin/sips -z 64 64 "${png_path}" --out "${temp_iconset_path}/[email protected]")
300-
_yup_execute_process_or_fail (/usr/bin/sips -z 128 128 "${png_path}" --out "${temp_iconset_path}/icon_128x128.png")
301-
_yup_execute_process_or_fail (/usr/bin/sips -z 256 256 "${png_path}" --out "${temp_iconset_path}/[email protected]")
302-
_yup_execute_process_or_fail (/usr/bin/sips -z 256 256 "${png_path}" --out "${temp_iconset_path}/icon_256x256.png")
303-
_yup_execute_process_or_fail (/usr/bin/sips -z 512 512 "${png_path}" --out "${temp_iconset_path}/[email protected]")
304-
_yup_execute_process_or_fail (/usr/bin/sips -z 512 512 "${png_path}" --out "${temp_iconset_path}/icon_512x512.png")
305-
_yup_execute_process_or_fail (/usr/bin/sips -z 1024 1024 "${png_path}" --out "${temp_iconset_path}/[email protected]")
292+
foreach (size IN ITEMS 16 32 128 256 512)
293+
_yup_execute_process_or_fail (/usr/bin/sips -z ${size} ${size} "${png_path}" --out "${temp_iconset_path}/icon_${size}x${size}.png")
294+
endforeach()
306295
_yup_execute_process_or_fail (/usr/bin/iconutil -c icns -o "${output_iconset_path}" "${temp_iconset_path}")
307296

308297
file (REMOVE_RECURSE "${temp_iconset_path}")

examples/graphics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ yup_standalone_app (
7878
flac_library
7979
hmp3_library
8080
dr_libs
81+
libvorbis
8182
libpng
8283
libwebp
8384
${additional_modules}

modules/yup_audio_formats/common/yup_AudioFormatManager.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,36 @@ AudioFormatManager::AudioFormatManager()
2626
{
2727
}
2828

29-
void AudioFormatManager::registerDefaultFormats()
29+
void AudioFormatManager::registerDefaultFormats (AudioFormatType types)
3030
{
3131
#if YUP_AUDIO_FORMAT_COREAUDIO
32-
registerFormat (std::make_unique<AppleCoreAudioFormat>());
32+
if (hasBitValueSet (types, AudioFormatType::coreAudio))
33+
registerFormat (std::make_unique<AppleCoreAudioFormat>());
3334
#endif
3435

3536
#if YUP_AUDIO_FORMAT_MEDIAFOUNDATION
36-
registerFormat (std::make_unique<WindowsMediaAudioFormat>());
37+
if (hasBitValueSet (types, AudioFormatType::windowsMedia))
38+
registerFormat (std::make_unique<WindowsMediaAudioFormat>());
3739
#endif
3840

3941
#if YUP_AUDIO_FORMAT_WAVE
40-
registerFormat (std::make_unique<WaveAudioFormat>());
42+
if (hasBitValueSet (types, AudioFormatType::wav))
43+
registerFormat (std::make_unique<WaveAudioFormat>());
4144
#endif
4245

4346
#if YUP_AUDIO_FORMAT_FLAC
44-
registerFormat (std::make_unique<FlacAudioFormat>());
47+
if (hasBitValueSet (types, AudioFormatType::flac))
48+
registerFormat (std::make_unique<FlacAudioFormat>());
4549
#endif
4650

4751
#if YUP_AUDIO_FORMAT_MP3
48-
registerFormat (std::make_unique<Mp3AudioFormat>());
52+
if (hasBitValueSet (types, AudioFormatType::mp3))
53+
registerFormat (std::make_unique<Mp3AudioFormat>());
4954
#endif
5055

5156
#if YUP_AUDIO_FORMAT_OPUS
52-
registerFormat (std::make_unique<OpusAudioFormat>());
57+
if (hasBitValueSet (types, AudioFormatType::opus))
58+
registerFormat (std::make_unique<OpusAudioFormat>());
5359
#endif
5460

5561
// TODO: Add other formats like:

modules/yup_audio_formats/common/yup_AudioFormatManager.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@
2222
namespace yup
2323
{
2424

25+
//==============================================================================
26+
/** Enumeration of supported audio format types. */
27+
enum class AudioFormatType
28+
{
29+
wav = 1 << 0,
30+
mp3 = 1 << 1,
31+
flac = 1 << 2,
32+
ogg = 1 << 3,
33+
opus = 1 << 4,
34+
coreAudio = 1 << 5,
35+
windowsMedia = 1 << 6,
36+
37+
all = ~0
38+
};
39+
40+
YUP_DECLARE_SCOPED_ENUM_BITWISE_OPERATORS (AudioFormatType)
41+
2542
//==============================================================================
2643
/**
2744
Central registry and factory for audio format handlers.
@@ -82,7 +99,7 @@ class YUP_API AudioFormatManager
8299
The specific formats registered may depend on compile-time configuration
83100
and available dependencies.
84101
*/
85-
void registerDefaultFormats();
102+
void registerDefaultFormats (AudioFormatType types = AudioFormatType::all);
86103

87104
/** Registers a custom audio format implementation.
88105

thirdparty/dr_libs/dr_libs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121

2222
#define DR_MP3_IMPLEMENTATION
23-
#include <dr_mp3.h>
23+
#include <dr_libs/dr_mp3.h>
2424

2525
#define DR_WAV_IMPLEMENTATION
26-
#include <dr_wav.h>
26+
#include <dr_libs/dr_wav.h>

thirdparty/dr_libs/dr_libs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#pragma once
4444

4545
#define DR_MP3_NO_STDIO 1
46-
#include <dr_mp3.h>
46+
#include <dr_libs/dr_mp3.h>
4747

4848
#define DR_WAV_NO_STDIO 1
49-
#include <dr_wav.h>
49+
#include <dr_libs/dr_wav.h>

thirdparty/flac_library/flac_library.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
upstream: https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.5.0.tar.xz
3434
license: BSD
3535
36-
defines: FLAC__NO_DLL=1 FLAC__HAS_OGG=0
36+
dependencies: libogg
37+
defines: FLAC__NO_DLL=1 FLAC__HAS_OGG=1 HAVE_LROUND=1
3738
macDefines: FLAC__SYS_DARWIN=1
38-
searchpaths: include src src/libFLAC src/libFLAC/include
39+
searchpaths: include src/libFLAC src/libFLAC/include
3940
4041
END_YUP_MODULE_DECLARATION
4142

thirdparty/flac_library/flac_library_1.c

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,32 @@
2121

2222
#include "flac_include_pre.h"
2323

24-
#include "bitmath.c"
25-
#include "bitreader.c"
26-
#include "bitwriter.c"
27-
#include "cpu.c"
28-
#include "crc.c"
29-
#include "fixed_intrin_avx2.c"
30-
#include "fixed_intrin_sse2.c"
31-
#include "fixed_intrin_sse42.c"
32-
#include "fixed_intrin_ssse3.c"
24+
#include <flac_library/src/libFLAC/bitmath.c>
25+
#include <flac_library/src/libFLAC/bitreader.c>
26+
#include <flac_library/src/libFLAC/bitwriter.c>
27+
#include <flac_library/src/libFLAC/cpu.c>
28+
#include <flac_library/src/libFLAC/crc.c>
29+
#include <flac_library/src/libFLAC/fixed_intrin_avx2.c>
30+
#include <flac_library/src/libFLAC/fixed_intrin_sse2.c>
31+
#include <flac_library/src/libFLAC/fixed_intrin_sse42.c>
32+
#include <flac_library/src/libFLAC/fixed_intrin_ssse3.c>
3333

3434
#if defined(CHECK_ORDER_IS_VALID)
3535
#undef CHECK_ORDER_IS_VALID
3636
#endif
3737

38-
#include "fixed.c"
39-
#include "float.c"
40-
#include "format.c"
41-
#include "lpc.c"
42-
#include "lpc_intrin_avx2.c"
43-
#include "lpc_intrin_fma.c"
44-
#include "lpc_intrin_neon.c"
45-
#include "lpc_intrin_sse2.c"
46-
#include "lpc_intrin_sse41.c"
47-
#include "md5.c"
48-
#include "memory.c"
49-
#include "stream_decoder.c"
50-
#include "window.c"
51-
52-
//#include "metadata_iterators.c"
53-
//#include "metadata_object.c"
54-
//#include "ogg_decoder_aspect.c"
55-
//#include "ogg_encoder_aspect.c"
56-
//#include "ogg_helper.c"
57-
//#include "ogg_mapping.c"
38+
#include <flac_library/src/libFLAC/fixed.c>
39+
#include <flac_library/src/libFLAC/float.c>
40+
#include <flac_library/src/libFLAC/format.c>
41+
#include <flac_library/src/libFLAC/lpc.c>
42+
#include <flac_library/src/libFLAC/lpc_intrin_avx2.c>
43+
#include <flac_library/src/libFLAC/lpc_intrin_fma.c>
44+
#include <flac_library/src/libFLAC/lpc_intrin_neon.c>
45+
#include <flac_library/src/libFLAC/lpc_intrin_sse2.c>
46+
#include <flac_library/src/libFLAC/lpc_intrin_sse41.c>
47+
#include <flac_library/src/libFLAC/md5.c>
48+
#include <flac_library/src/libFLAC/memory.c>
49+
#include <flac_library/src/libFLAC/stream_decoder.c>
50+
#include <flac_library/src/libFLAC/window.c>
5851

5952
#include "flac_include_post.h"

0 commit comments

Comments
 (0)