From abeead819e9b57462d2349dc1f82759a783ab67c Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Fri, 10 Apr 2026 02:49:30 -0500 Subject: [PATCH] rework build system dependencies --- meson.build | 114 +++++++++-------- ...ets_to_client.py => copy_assets_to_app.py} | 0 scripts/llvm_native.txt | 4 - subprojects/packagefiles/stb/meson.build | 6 +- targets/app/common/DLCController.cpp | 2 +- targets/app/common/UI/ConsoleUIController.cpp | 2 +- targets/app/meson.build | 120 ++++++++---------- targets/minecraft/client/BufferedImage.cpp | 2 +- .../minecraft/client/player/LocalPlayer.cpp | 2 +- targets/minecraft/meson.build | 63 ++++----- .../minecraft/world/entity/player/Player.cpp | 4 +- .../level/tile/entity/SignTileEntity.cpp | 2 +- targets/platform/fs/meson.build | 10 +- targets/platform/game/meson.build | 10 +- targets/platform/input/IPlatformInput.h | 3 +- targets/platform/input/input.h | 1 + targets/platform/input/meson.build | 11 +- targets/platform/input/sdl2/SDL2Input.cpp | 20 +-- targets/platform/input/sdl2/SDL2Input.h | 2 - targets/platform/leaderboard/meson.build | 10 +- targets/platform/meson.build | 78 +----------- targets/platform/network/meson.build | 11 +- targets/platform/profile/IPlatformProfile.h | 2 +- targets/platform/profile/meson.build | 12 +- targets/platform/profile/stub/StubProfile.cpp | 2 +- targets/platform/profile/stub/StubProfile.h | 2 +- targets/platform/renderer/IPlatformRenderer.h | 2 +- targets/platform/renderer/gl/GLRenderer.cpp | 12 +- targets/platform/renderer/gl/GLRenderer.h | 3 +- targets/platform/renderer/gl/gl_compat.h | 4 +- targets/platform/renderer/meson.build | 28 +++- targets/platform/sound/meson.build | 11 +- targets/platform/storage/IPlatformStorage.h | 2 +- targets/platform/storage/meson.build | 10 +- targets/platform/storage/stub/StubStorage.h | 2 +- targets/platform/stubs.h | 2 +- targets/platform/thread/meson.build | 11 +- targets/util/meson.build | 2 +- 38 files changed, 298 insertions(+), 286 deletions(-) rename scripts/{copy_assets_to_client.py => copy_assets_to_app.py} (100%) diff --git a/meson.build b/meson.build index 5fd5574fd..14daf954d 100644 --- a/meson.build +++ b/meson.build @@ -1,17 +1,20 @@ +# MARK: build configuration + project( - '4jcraft', - ['cpp', 'c'], - version: '0.1.0', - meson_version: '>= 1.3', - default_options: [ - 'cpp_std=c++23', - 'warning_level=0', - 'unity=on', # merge source files per target - 'unity_size=8', # TODO: mess around with this - 'b_pch=true', # precompiled headers - 'b_lto=true', # link-time optimisation (ThinLTO under clang+lld) - 'b_ndebug=if-release', # drop assert() in --buildtype=release - ], + '4jcraft', + ['cpp', 'c'], + version: '0.1.0', + meson_version: '>= 1.3', + default_options: [ + 'cpp_std=c++23', + 'warning_level=0', + 'unity=on', # merge source files per target + 'unity_size=8', # TODO: mess around with this + 'buildtype=debugoptimized', # needed for _FORTIFY_SOURCE + 'b_pch=true', # precompiled headers + 'b_lto=true', # link-time optimisation (ThinLTO under clang+lld) + 'b_ndebug=if-release', # drop assert() in --buildtype=release + ], ) pymod = import('python') @@ -19,36 +22,30 @@ python = pymod.find_installation('python3', required: true) cc = meson.get_compiler('cpp') +global_cpp_args = ['-Wshift-count-overflow', '-pipe'] global_cpp_defs = [ - '-DSPLIT_SAVES', - '-D_LARGE_WORLDS', - '-D_EXTENDED_ACHIEVEMENTS', - '-D_FORTIFY_SOURCE=2', - '-DMULTITHREAD_ENABLE', # always-on threading flag (formerly in App_Defines.h) + '-DSPLIT_SAVES', + '-D_LARGE_WORLDS', + '-D_EXTENDED_ACHIEVEMENTS', + '-D_FORTIFY_SOURCE=2', + '-DMULTITHREAD_ENABLE', # always-on threading flag (formerly in App_Defines.h) ] # Debug-only defines: keep for debug + debugoptimized so iteration is unchanged. # --buildtype=release strips them so shipping builds don't carry debug logging, # debug menu UI, or assert-driven sanity checks. if get_option('buildtype') in ['debug', 'debugoptimized'] - global_cpp_defs += [ - '-D_DEBUG', - '-DDEBUG', - '-D_DEBUG_MENUS_ENABLED', - ] + global_cpp_defs += [ + '-D_DEBUG', + '-DDEBUG', + '-D_DEBUG_MENUS_ENABLED', + ] endif -if get_option('renderer') == 'gles' - global_cpp_defs += ['-DGLES'] - gl_dep = dependency('glesv2', required: true) - glu_dep = dependency('', required: false) -else - gl_dep = dependency('gl', required: true) - glu_dep = dependency('glu', required: true) -endif +# MARK: meson options if get_option('enable_vsync') - global_cpp_defs += ['-DENABLE_VSYNC'] + global_cpp_defs += ['-DENABLE_VSYNC'] endif if get_option('classic_panorama') @@ -56,45 +53,52 @@ if get_option('classic_panorama') endif if get_option('enable_frame_profiler') - global_cpp_defs += ['-DENABLE_FRAME_PROFILER'] + global_cpp_defs += ['-DENABLE_FRAME_PROFILER'] endif if get_option('ui_backend') == 'shiggy' - global_cpp_defs += ['-D_ENABLEIGGY'] + global_cpp_defs += ['-D_ENABLEIGGY'] endif if get_option('ui_backend') == 'java' - global_cpp_defs += '-DENABLE_JAVA_GUIS' + global_cpp_defs += '-DENABLE_JAVA_GUIS' +endif + +if get_option('occlusion_culling') == 'off' + global_cpp_defs += ['-DOCCLUSION_MODE_NONE'] +elif get_option('occlusion_culling') == 'frustum' + global_cpp_defs += ['-DOCCLUSION_MODE_FRUSTUM'] +elif get_option('occlusion_culling') == 'bfs' + global_cpp_defs += ['-DOCCLUSION_MODE_BFS', '-DUSE_OCCLUSION_CULLING'] +elif get_option('occlusion_culling') == 'hardware' + global_cpp_defs += ['-DOCCLUSION_MODE_HARDWARE', '-DUSE_OCCLUSION_CULLING'] endif add_project_arguments(global_cpp_defs, language: ['cpp', 'c']) - -global_cpp_args = [ - '-Wshift-count-overflow', - '-pipe', -] add_project_arguments(global_cpp_args, language: 'cpp') -sdl2_dep = dependency('sdl2') -thread_dep = dependency('threads') -dl_dep = cc.find_library('dl', required: true) -glm_dep = dependency('glm') - -stb = subproject('stb').get_variable('stb_inc') -stb_dep = declare_dependency(include_directories: stb) -simdutf_dep = dependency('simdutf', - fallback: ['simdutf', 'simdutf_dep'], - default_options: ['utf8=true', 'utf16=true', 'utf32=true'] -) -miniaudio_dep = dependency('miniaudio') - -mimalloc_dep = cc.find_library('mimalloc', required: get_option('enable_mimalloc')) - subdir('targets/util') subdir('targets/java') subdir('targets/nbt') subdir('targets/platform') +# MARK: platform configuration + +if host_machine.system() == 'linux' + platform_fs_dep = platform_fs_std_dep + platform_game_dep = platform_game_stub_dep + platform_input_dep = platform_input_sdl2_dep + platform_leaderboard_dep = platform_leaderboard_stub_dep + platform_network_dep = platform_network_stub_dep + platform_profile_dep = platform_profile_stub_dep + platform_renderer_dep = platform_renderer_gl_dep + platform_sound_dep = platform_sound_miniaudio_dep + platform_storage_dep = platform_storage_stub_dep + platform_thread_dep = platform_thread_dep # standardized backend (for now) + + app_platform_sources = files('targets/app/linux/main.cpp') +endif + subdir('targets/resources') subdir('targets/minecraft') subdir('targets/app') diff --git a/scripts/copy_assets_to_client.py b/scripts/copy_assets_to_app.py similarity index 100% rename from scripts/copy_assets_to_client.py rename to scripts/copy_assets_to_app.py diff --git a/scripts/llvm_native.txt b/scripts/llvm_native.txt index 256f052ad..17d5b1824 100644 --- a/scripts/llvm_native.txt +++ b/scripts/llvm_native.txt @@ -3,7 +3,3 @@ c = 'clang' cpp = 'clang++' c_ld = 'lld' cpp_ld = 'lld' - -[built-in options] -cpp_args = ['-stdlib=libc++'] -cpp_link_args = ['-stdlib=libc++'] diff --git a/subprojects/packagefiles/stb/meson.build b/subprojects/packagefiles/stb/meson.build index aad077a49..a1e039357 100644 --- a/subprojects/packagefiles/stb/meson.build +++ b/subprojects/packagefiles/stb/meson.build @@ -1,3 +1,7 @@ project('stb', 'c') -stb_inc = include_directories('.') \ No newline at end of file +stb_dep = declare_dependency( + include_directories: include_directories('.'), +) + +meson.override_dependency('stb', stb_dep) \ No newline at end of file diff --git a/targets/app/common/DLCController.cpp b/targets/app/common/DLCController.cpp index 6e61d5c5e..cb8bbe61f 100644 --- a/targets/app/common/DLCController.cpp +++ b/targets/app/common/DLCController.cpp @@ -240,7 +240,7 @@ int32_t DLCController::registerDLCData(char* pType, char* pBannerName, pDLCData->uiSortIndex = uiSortIndex; pDLCData->iConfig = iConfig; - if (strcmp(!pBannerName, "") != 0) { + if (strcmp(pBannerName, "") != 0) { strncpy(pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE); } if (pDataFile[0] != 0) { diff --git a/targets/app/common/UI/ConsoleUIController.cpp b/targets/app/common/UI/ConsoleUIController.cpp index 8614b6e68..dd7ab903f 100644 --- a/targets/app/common/UI/ConsoleUIController.cpp +++ b/targets/app/common/UI/ConsoleUIController.cpp @@ -7,7 +7,7 @@ #include "app/common/Iggy/include/iggy.h" #include "app/common/UI/All Platforms/UIStructs.h" #include "platform/renderer/renderer.h" -#include "renderer/gl/gl_compat.h" +#include "platform/stubs.h" #ifndef _ENABLEIGGY #include "app/common/Iggy/iggy_stubs.h" #endif diff --git a/targets/app/meson.build b/targets/app/meson.build index 920f4c386..8a55d979a 100644 --- a/targets/app/meson.build +++ b/targets/app/meson.build @@ -2,83 +2,73 @@ # regenerated by scripts/list_sources.py whenever files are added or # removed. fs = import('fs') -platform_sources = files(fs.read('common_sources.txt').strip().split('\n')) -if host_machine.system() == 'linux' - platform_sources += files('linux/main.cpp') -endif - -client_dependencies = [] +app_common_sources = files(fs.read('common_sources.txt').strip().split('\n')) +app_dependencies = [] +app_link_args = [] # mimalloc must come first so the linker resolves malloc/free symbols to it # before glibc. --no-as-needed prevents the linker from dropping it as # "unreferenced" (the override happens via weak symbols, not direct calls). -client_link_args = [] +mimalloc_dep = dependency('mimalloc', required: get_option('enable_mimalloc')) if mimalloc_dep.found() - client_dependencies += mimalloc_dep - client_link_args += ['-Wl,--no-as-needed'] + app_dependencies += mimalloc_dep endif -client_dependencies += [ - java_dep, - nbt_dep, - render_dep, - input_dep, - profile_dep, - storage_dep, - fs_dep, - sound_dep, - assets_localisation_dep, - platform_dep, - minecraft_dep, - gl_dep, - glu_dep, - thread_dep, - dl_dep, - dependency('zlib'), - miniaudio_dep, - stb_dep, - simdutf_dep, - util_dep, -] - if get_option('ui_backend') == 'shiggy' - shiggy_dep = dependency( - 'shiggy', - fallback: ['shiggy', 'shiggy_dep'], - ) - client_dependencies += shiggy_dep + app_dependencies += dependency( + 'shiggy', + fallback: ['shiggy', 'shiggy_dep'], + ) endif -client = executable( - 'Minecraft.Client', - platform_sources + localisation[1], - include_directories: include_directories('..'), - dependencies: client_dependencies, - cpp_args: global_cpp_args - + global_cpp_defs - + [ - '-DUNICODE', - '-D_UNICODE', - ], - c_args: global_cpp_defs + ['-DUNICODE', '-D_UNICODE'], - link_args: client_link_args, - install: true, - install_dir: '', +app_dependencies += [ + dependency('dl'), # blame iggy gdraw, nuke this later + dependency('sdl2'), # blame iggy gdraw, nuke this later + dependency('miniaudio'), # todo: remove once PlatformSound is used + dependency('stb'), + dependency('simdutf'), + java_dep, + nbt_dep, + util_dep, + minecraft_dep, + assets_localisation_dep, + platform_fs_dep, + platform_game_dep, + platform_input_dep, + platform_leaderboard_dep, + platform_network_dep, + platform_profile_dep, + platform_renderer_dep, + platform_sound_dep, + platform_storage_dep, + platform_thread_dep, + # technically also GL/EGL, but the GL renderer needs to not leak GL shit to fix that +] + +app = executable( + 'Minecraft.Client', + app_common_sources + app_platform_sources + localisation[1], + include_directories: include_directories('..'), + dependencies: app_dependencies, + cpp_args: global_cpp_args + global_cpp_defs, + link_args: app_link_args, + install: true, + install_dir: '', ) custom_target( - 'copy_assets_to_client', - input: [client, media_archive], - output: 'assets.stamp', - command: [ - python, - meson.project_source_root() / 'scripts/copy_assets_to_client.py', - meson.project_source_root(), - meson.project_build_root(), - meson.current_build_dir(), - '@INPUT1@', - '@OUTPUT@', - ], - build_by_default: true, + 'copy_assets_to_app', + input: [app, media_archive], + output: 'assets.stamp', + command: [ + python, + meson.project_source_root() / 'scripts/copy_assets_to_app.py', + meson.project_source_root(), + meson.project_build_root(), + meson.current_build_dir(), + '@INPUT1@', + '@OUTPUT@', + ], + build_by_default: true, ) diff --git a/targets/minecraft/client/BufferedImage.cpp b/targets/minecraft/client/BufferedImage.cpp index 59048b4ef..4d71aad6c 100644 --- a/targets/minecraft/client/BufferedImage.cpp +++ b/targets/minecraft/client/BufferedImage.cpp @@ -6,7 +6,7 @@ #include #include -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" #include "minecraft/IGameServices.h" #include "platform/fs/fs.h" #include "platform/renderer/renderer.h" diff --git a/targets/minecraft/client/player/LocalPlayer.cpp b/targets/minecraft/client/player/LocalPlayer.cpp index 17be12f19..4e8c4c701 100644 --- a/targets/minecraft/client/player/LocalPlayer.cpp +++ b/targets/minecraft/client/player/LocalPlayer.cpp @@ -28,7 +28,7 @@ #include "minecraft/world/item/Item.h" #include "minecraft/world/level/tile/Tile.h" // 4J Stu - Added for tutorial callbacks -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" #include "Pos.h" #include "app/common/Audio/ConsoleSoundEngine.h" #include "app/common/Audio/SoundTypes.h" diff --git a/targets/minecraft/meson.build b/targets/minecraft/meson.build index dfa8b95b6..1fceddba1 100644 --- a/targets/minecraft/meson.build +++ b/targets/minecraft/meson.build @@ -2,49 +2,32 @@ # scripts/list_sources.py whenever files are added or removed. Reading # the committed file means meson reconfigures only when the list itself # changes, which is what we want. + fs = import('fs') minecraft_sources = files(fs.read('sources.txt').strip().split('\n')) -occlusion_mode = get_option('occlusion_culling') -if occlusion_mode == 'off' - global_cpp_defs += ['-DOCCLUSION_MODE_NONE'] -elif occlusion_mode == 'frustum' - global_cpp_defs += ['-DOCCLUSION_MODE_FRUSTUM'] -elif occlusion_mode == 'bfs' - global_cpp_defs += ['-DOCCLUSION_MODE_BFS', '-DUSE_OCCLUSION_CULLING'] -elif occlusion_mode == 'hardware' - global_cpp_defs += ['-DOCCLUSION_MODE_HARDWARE', '-DUSE_OCCLUSION_CULLING'] -endif - -if get_option('ui_backend') == 'java' - global_cpp_defs += '-DENABLE_JAVA_GUIS' -endif - -lib_minecraft = static_library('minecraft', - minecraft_sources, - dependencies : [ - sound_dep, - render_dep, - input_dep, - profile_dep, - storage_dep, - fs_dep, - glm_dep, - nbt_dep, - java_dep, - assets_localisation_dep, - platform_dep, - util_dep, - dependency('zlib'), - ], - include_directories : include_directories('..'), - cpp_args : global_cpp_args + global_cpp_defs, -) - -zlib_dep = dependency('zlib') crypto_dep = dependency('libcrypto') # for MD5 in Hasher.cpp on Linux -minecraft_dep = declare_dependency( - link_with : lib_minecraft, - dependencies : [crypto_dep, zlib_dep], +lib_minecraft = static_library('minecraft', + minecraft_sources, + dependencies : [ + dependency('libcrypto'), # for MD5 in Hasher.cpp on Linux + dependency('zlib'), + dependency('glm'), + nbt_dep, + java_dep, + util_dep, + assets_localisation_dep, + platform_sound_dep, + platform_renderer_dep, + platform_input_dep, + platform_profile_dep, + platform_storage_dep, + platform_fs_dep, + platform_thread_dep, + ], + include_directories : include_directories('..'), + cpp_args : global_cpp_args + global_cpp_defs, ) + +minecraft_dep = declare_dependency(link_with : lib_minecraft) diff --git a/targets/minecraft/world/entity/player/Player.cpp b/targets/minecraft/world/entity/player/Player.cpp index fcde9eba2..2c04410a1 100644 --- a/targets/minecraft/world/entity/player/Player.cpp +++ b/targets/minecraft/world/entity/player/Player.cpp @@ -1522,8 +1522,8 @@ Player::BedSleepingResult Player::startSleepInBed(int x, int y, int z, // use the bed in daytime from far away and you'll get the message about // only sleeping at night - if (abs(this->x - x) > 3 || abs(this->y - y) > 2 || - abs(this->z - z) > 3) { + if (std::abs(this->x - x) > 3 || std::abs(this->y - y) > 2 || + std::abs(this->z - z) > 3) { // too far away return TOO_FAR_AWAY; } diff --git a/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp b/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp index 3ed30663b..9eb7abebe 100644 --- a/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp @@ -2,7 +2,7 @@ #include -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" #include "minecraft/client/Minecraft.h" #include "minecraft/network/packet/SignUpdatePacket.h" #include "minecraft/server/level/ServerLevel.h" diff --git a/targets/platform/fs/meson.build b/targets/platform/fs/meson.build index 52f1ce610..1b3593f54 100644 --- a/targets/platform/fs/meson.build +++ b/targets/platform/fs/meson.build @@ -1 +1,9 @@ -platform_fs_sources = files('std/StdFilesystem.cpp') +lib_platform_fs_std = static_library('platform_fs_std', + files('std/StdFilesystem.cpp'), + include_directories: include_directories('../../'), + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_fs_std_dep = declare_dependency( + link_with: lib_platform_fs_std, +) \ No newline at end of file diff --git a/targets/platform/game/meson.build b/targets/platform/game/meson.build index 9b1af37f2..8d3aa3b8d 100644 --- a/targets/platform/game/meson.build +++ b/targets/platform/game/meson.build @@ -1 +1,9 @@ -platform_game_sources = files('stub/StubPlatformGame.cpp') +lib_platform_game_stub = static_library('platform_game_stub', + files('stub/StubPlatformGame.cpp'), + include_directories: include_directories('../../'), + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_game_stub_dep = declare_dependency( + link_with: lib_platform_game_stub, +) \ No newline at end of file diff --git a/targets/platform/input/IPlatformInput.h b/targets/platform/input/IPlatformInput.h index f988975c5..7d0c13167 100644 --- a/targets/platform/input/IPlatformInput.h +++ b/targets/platform/input/IPlatformInput.h @@ -2,8 +2,7 @@ #include -#include "InputConstants.h" -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" class IPlatformInput { public: diff --git a/targets/platform/input/input.h b/targets/platform/input/input.h index fbc78a5c8..19369689f 100644 --- a/targets/platform/input/input.h +++ b/targets/platform/input/input.h @@ -1,6 +1,7 @@ #pragma once #include "IPlatformInput.h" +#include "InputConstants.h" // Function accessor backed by a function-local static (Meyers singleton). // Avoids the static-initialization-order fiasco that the previous diff --git a/targets/platform/input/meson.build b/targets/platform/input/meson.build index f5d38f748..5ff09a76e 100644 --- a/targets/platform/input/meson.build +++ b/targets/platform/input/meson.build @@ -1 +1,10 @@ -platform_input_sources = files('sdl2/SDL2Input.cpp') +lib_platform_input_sdl2 = static_library('platform_input_sdl2', + files('sdl2/SDL2Input.cpp'), + dependencies: dependency('sdl2'), + include_directories: include_directories('../../'), + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_input_sdl2_dep = declare_dependency( + link_with: lib_platform_input_sdl2, +) diff --git a/targets/platform/input/sdl2/SDL2Input.cpp b/targets/platform/input/sdl2/SDL2Input.cpp index ba377ec00..212495de5 100644 --- a/targets/platform/input/sdl2/SDL2Input.cpp +++ b/targets/platform/input/sdl2/SDL2Input.cpp @@ -1,15 +1,15 @@ #include "SDL2Input.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "SDL2/SDL.h" +#include "SDL2/SDL_events.h" +#include "SDL2/SDL_gamecontroller.h" +#include "SDL2/SDL_joystick.h" +#include "SDL2/SDL_keyboard.h" +#include "SDL2/SDL_mouse.h" +#include "SDL2/SDL_scancode.h" +#include "SDL2/SDL_stdinc.h" +#include "SDL2/SDL_video.h" +#include "SDL2/begin_code.h" #include #include #include diff --git a/targets/platform/input/sdl2/SDL2Input.h b/targets/platform/input/sdl2/SDL2Input.h index e2be82f51..dc8079c95 100644 --- a/targets/platform/input/sdl2/SDL2Input.h +++ b/targets/platform/input/sdl2/SDL2Input.h @@ -1,7 +1,5 @@ #pragma once -#include - #include "../IPlatformInput.h" class SDL2Input : public IPlatformInput { diff --git a/targets/platform/leaderboard/meson.build b/targets/platform/leaderboard/meson.build index 8e520726b..597a5c41b 100644 --- a/targets/platform/leaderboard/meson.build +++ b/targets/platform/leaderboard/meson.build @@ -1 +1,9 @@ -platform_leaderboard_sources = files('stub/StubLeaderboard.cpp') +lib_platform_leaderboard_stub = static_library('platform_leaderboard_stub', + files('stub/StubLeaderboard.cpp'), + include_directories: include_directories('../../'), + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_leaderboard_stub_dep = declare_dependency( + link_with: lib_platform_leaderboard_stub, +) diff --git a/targets/platform/meson.build b/targets/platform/meson.build index 5224c1502..6abdd4cb6 100644 --- a/targets/platform/meson.build +++ b/targets/platform/meson.build @@ -1,76 +1,10 @@ -platform_inc = include_directories('.') -_threads = dependency('threads') -_sdl2 = dependency('sdl2') - -if get_option('renderer') == 'gles' - _gl = dependency('glesv2', required: true) - _defs = ['-DGLES'] -else - _gl = dependency('gl', required: true) - _defs = [] -endif - -# Per-subsystem source lists. Each subdir owns its own list of backend -# .cpp files via a `platform__sources` variable. The library -# build is centralised so we get one library per platform target rather -# than one per subsystem; subsystems vary together (an SDL2 platform -# wants SDL2 input + GL renderer + miniaudio together) and a per- -# subsystem split inflates link units without buying flexibility. -subdir('input') -subdir('profile') -subdir('storage') subdir('fs') +subdir('game') +subdir('input') +subdir('leaderboard') +subdir('network') +subdir('profile') subdir('renderer') subdir('sound') -subdir('network') -subdir('leaderboard') -subdir('game') +subdir('storage') subdir('thread') - -# Core: thread + shutdown plumbing, no backend. -lib_platform_core = static_library('platform_core', - platform_thread_sources, - include_directories: [platform_inc, include_directories('..')], - dependencies: [_threads], - cpp_args: global_cpp_args + global_cpp_defs, -) - -platform_dep = declare_dependency( - link_with: lib_platform_core, - include_directories: platform_inc, -) - -lib_platform_sdl2 = static_library('platform_sdl2', - platform_input_sources - + platform_profile_sources - + platform_storage_sources - + platform_fs_sources - + platform_renderer_sources - + platform_sound_sources - + platform_network_sources - + platform_leaderboard_sources - + platform_game_sources, - include_directories: [platform_inc, include_directories('..')], - dependencies: [_sdl2, _gl, _threads, glm_dep, stb_dep, java_dep, - miniaudio_dep], - cpp_args: _defs + global_cpp_args + global_cpp_defs, -) - -# Single dep for the whole platform_sdl2 library. Aliased per-subsystem -# so consumer meson files can keep asking for `input_dep` etc. without -# caring that they all resolve to the same library object today. -platform_sdl2_dep = declare_dependency( - link_with: lib_platform_sdl2, - include_directories: [platform_inc], - dependencies: [_sdl2, _gl, _threads, glm_dep, miniaudio_dep], -) - -input_dep = platform_sdl2_dep -profile_dep = platform_sdl2_dep -storage_dep = platform_sdl2_dep -fs_dep = platform_sdl2_dep -render_dep = platform_sdl2_dep -sound_dep = platform_sdl2_dep -network_dep = platform_sdl2_dep -leaderboard_dep = platform_sdl2_dep -game_dep = platform_sdl2_dep diff --git a/targets/platform/network/meson.build b/targets/platform/network/meson.build index dab092568..34a557dac 100644 --- a/targets/platform/network/meson.build +++ b/targets/platform/network/meson.build @@ -1 +1,10 @@ -platform_network_sources = files('stub/StubPlatformNetwork.cpp', 'stub/StubNetworkPlayer.cpp') +lib_platform_network_stub = static_library('platform_network_stub', + files('stub/StubNetworkPlayer.cpp', 'stub/StubPlatformNetwork.cpp'), + include_directories: include_directories('../../'), + dependencies: java_dep, + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_network_stub_dep = declare_dependency( + link_with: lib_platform_network_stub, +) \ No newline at end of file diff --git a/targets/platform/profile/IPlatformProfile.h b/targets/platform/profile/IPlatformProfile.h index fbde8d1fa..38bdbca97 100644 --- a/targets/platform/profile/IPlatformProfile.h +++ b/targets/platform/profile/IPlatformProfile.h @@ -4,7 +4,7 @@ #include #include -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" class CXuiStringTable; diff --git a/targets/platform/profile/meson.build b/targets/platform/profile/meson.build index 06c9397d4..c8efb5b7c 100644 --- a/targets/platform/profile/meson.build +++ b/targets/platform/profile/meson.build @@ -1 +1,11 @@ -platform_profile_sources = files('stub/StubProfile.cpp') +platform_profile_stub_sources = files('stub/StubProfile.cpp') + +lib_platform_profile_stub = static_library('platform_profile_stub', + files('stub/StubProfile.cpp'), + include_directories: include_directories('../../'), + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_profile_stub_dep = declare_dependency( + link_with: lib_platform_profile_stub, +) \ No newline at end of file diff --git a/targets/platform/profile/stub/StubProfile.cpp b/targets/platform/profile/stub/StubProfile.cpp index 24b660aa2..dcd23a9e5 100644 --- a/targets/platform/profile/stub/StubProfile.cpp +++ b/targets/platform/profile/stub/StubProfile.cpp @@ -5,7 +5,7 @@ #include #include "../ProfileConstants.h" -#include "input/input.h" +#include "platform/input/input.h" namespace platform_internal { IPlatformProfile& PlatformProfile_get() { diff --git a/targets/platform/profile/stub/StubProfile.h b/targets/platform/profile/stub/StubProfile.h index 72d5a865f..3ee620ff0 100644 --- a/targets/platform/profile/stub/StubProfile.h +++ b/targets/platform/profile/stub/StubProfile.h @@ -5,7 +5,7 @@ #include #include "../IPlatformProfile.h" -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" class StubProfile : public IPlatformProfile { public: diff --git a/targets/platform/renderer/IPlatformRenderer.h b/targets/platform/renderer/IPlatformRenderer.h index 186843472..32ab3793f 100644 --- a/targets/platform/renderer/IPlatformRenderer.h +++ b/targets/platform/renderer/IPlatformRenderer.h @@ -2,7 +2,7 @@ #include -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" class IPlatformRenderer { public: diff --git a/targets/platform/renderer/gl/GLRenderer.cpp b/targets/platform/renderer/gl/GLRenderer.cpp index 13e97877a..1eedd9a4e 100644 --- a/targets/platform/renderer/gl/GLRenderer.cpp +++ b/targets/platform/renderer/gl/GLRenderer.cpp @@ -1,6 +1,6 @@ #include "GLRenderer.h" -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" #include "SDL.h" #include "SDL_error.h" #include "SDL_events.h" @@ -9,7 +9,7 @@ #include "java/ByteBuffer.h" #include "java/FloatBuffer.h" #include "java/IntBuffer.h" -#include "renderer/renderer.h" +#include "platform/renderer/renderer.h" // undefine macros from header to avoid argument mismatch #undef glGenTextures @@ -41,15 +41,15 @@ #include "stb_image.h" #define GLM_FORCE_RADIANS +#include "glm/glm.hpp" +#include "glm/gtc/matrix_transform.hpp" +#include "glm/gtc/type_ptr.hpp" + #include #include - #include #include #include -#include -#include -#include #include #include #include diff --git a/targets/platform/renderer/gl/GLRenderer.h b/targets/platform/renderer/gl/GLRenderer.h index 98f395eeb..0ef3e4151 100644 --- a/targets/platform/renderer/gl/GLRenderer.h +++ b/targets/platform/renderer/gl/GLRenderer.h @@ -6,9 +6,8 @@ #include #include -#include -#include "renderer/IPlatformRenderer.h" +#include "platform/renderer/IPlatformRenderer.h" extern IPlatformRenderer& PlatformRenderer; diff --git a/targets/platform/renderer/gl/gl_compat.h b/targets/platform/renderer/gl/gl_compat.h index 280fef444..274fb8342 100644 --- a/targets/platform/renderer/gl/gl_compat.h +++ b/targets/platform/renderer/gl/gl_compat.h @@ -22,8 +22,8 @@ #include #include -#include "renderer/IPlatformRenderer.h" -#include "renderer/renderer.h" +#include "platform/renderer/IPlatformRenderer.h" +#include "platform/renderer/renderer.h" // OpenGL Interception Macros #ifndef GL_MODELVIEW_MATRIX diff --git a/targets/platform/renderer/meson.build b/targets/platform/renderer/meson.build index a000fc34c..0977323a7 100644 --- a/targets/platform/renderer/meson.build +++ b/targets/platform/renderer/meson.build @@ -1 +1,27 @@ -platform_renderer_sources = files('gl/GLRenderer.cpp', 'gl/render_stubs.cpp') +platform_renderer_gl_dependencies = [ + dependency('dl'), + dependency('sdl2'), + dependency('glm'), + dependency('stb'), + java_dep, +] +platform_renderer_gl_defs = [] + +if get_option('renderer') == 'gles' + platform_renderer_gl_dependencies += dependency('glesv2') + platform_renderer_gl_defs = ['-DGLES'] +else + platform_renderer_gl_dependencies += dependency('gl') + platform_renderer_gl_defs = [] +endif + +lib_platform_renderer_gl = static_library('platform_renderer_gl', + files('gl/GLRenderer.cpp', 'gl/render_stubs.cpp'), + include_directories: include_directories('../../'), + dependencies: platform_renderer_gl_dependencies, + cpp_args: platform_renderer_gl_defs + global_cpp_args + global_cpp_defs, +) + +platform_renderer_gl_dep = declare_dependency( + link_with: lib_platform_renderer_gl, +) diff --git a/targets/platform/sound/meson.build b/targets/platform/sound/meson.build index 90a32a5f6..e694b9a4f 100644 --- a/targets/platform/sound/meson.build +++ b/targets/platform/sound/meson.build @@ -1 +1,10 @@ -platform_sound_sources = files('miniaudio/MiniaudioSound.cpp') +lib_platform_sound_miniaudio = static_library('platform_sound_miniaudio', + files('miniaudio/MiniaudioSound.cpp'), + dependencies: dependency('miniaudio'), + include_directories: include_directories('../../'), + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_sound_miniaudio_dep = declare_dependency( + link_with: lib_platform_sound_miniaudio, +) \ No newline at end of file diff --git a/targets/platform/storage/IPlatformStorage.h b/targets/platform/storage/IPlatformStorage.h index d7de03761..1bbf3aedd 100644 --- a/targets/platform/storage/IPlatformStorage.h +++ b/targets/platform/storage/IPlatformStorage.h @@ -6,7 +6,7 @@ #include #include -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" #define MAX_DISPLAYNAME_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3 #define MAX_DETAILS_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3 diff --git a/targets/platform/storage/meson.build b/targets/platform/storage/meson.build index 3dfd0201f..7fa48cb3d 100644 --- a/targets/platform/storage/meson.build +++ b/targets/platform/storage/meson.build @@ -1 +1,9 @@ -platform_storage_sources = files('stub/StubStorage.cpp') +lib_platform_storage_stub = static_library('platform_storage_stub', + files('stub/StubStorage.cpp'), + include_directories: include_directories('../../'), + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_storage_stub_dep = declare_dependency( + link_with: lib_platform_storage_stub, +) diff --git a/targets/platform/storage/stub/StubStorage.h b/targets/platform/storage/stub/StubStorage.h index 813a4d888..9ccfc51a0 100644 --- a/targets/platform/storage/stub/StubStorage.h +++ b/targets/platform/storage/stub/StubStorage.h @@ -8,7 +8,7 @@ // #include #include "../IPlatformStorage.h" -#include "PlatformTypes.h" +#include "platform/PlatformTypes.h" class C4JStringTable; diff --git a/targets/platform/stubs.h b/targets/platform/stubs.h index 8d4fd8721..ef34eeed5 100644 --- a/targets/platform/stubs.h +++ b/targets/platform/stubs.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include "java/File.h" #include "renderer/gl/gl_compat.h" diff --git a/targets/platform/thread/meson.build b/targets/platform/thread/meson.build index c42ec30ec..fc616cda0 100644 --- a/targets/platform/thread/meson.build +++ b/targets/platform/thread/meson.build @@ -1 +1,10 @@ -platform_thread_sources = files('C4JThread.cpp', 'ShutdownManager.cpp') +lib_platform_thread = static_library('platform_thread', + files('C4JThread.cpp', 'ShutdownManager.cpp'), + dependencies: [dependency('threads')], + include_directories: include_directories('../../'), + cpp_args: global_cpp_args + global_cpp_defs, +) + +platform_thread_dep = declare_dependency( + link_with: lib_platform_thread, +) \ No newline at end of file diff --git a/targets/util/meson.build b/targets/util/meson.build index 35789f396..4c4439263 100644 --- a/targets/util/meson.build +++ b/targets/util/meson.build @@ -1,6 +1,6 @@ lib_util = static_library('util', files('StringHelpers.cpp', 'FrameProfiler.cpp'), - dependencies: [simdutf_dep], + dependencies: [dependency('simdutf')], include_directories : include_directories('.', '..'), cpp_args : global_cpp_args + global_cpp_defs, )