refactor: clean up meson build scripts, use in-tree zlib

This commit is contained in:
Tropical 2026-03-06 00:17:31 -06:00
parent c55ed7b261
commit 7baf1cbfa1
10 changed files with 69 additions and 60 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
build/
builddir/
.cache/
.idea/
cmake-build-debug/

View file

@ -1,6 +1,6 @@
#include "../../../../../Minecraft.World/Build/stdafx.h"
#include "../../../Minecraft.World/Socket.h"
#include "../../../Minecraft.World/StringHelpers.h"
#include "../../../../../Minecraft.World/Network/Socket.h"
#include "../../../../../Minecraft.World/Util/StringHelpers.h"
#include "PlatformNetworkManagerSony.h"
#include "NetworkPlayerSony.h"
#include "../GameNetworkManager.h"

View file

@ -1,7 +1,7 @@
#pragma once
using namespace std;
#include <vector>
#include "../../../Minecraft.World/C4JThread.h"
#include "../../../../../Minecraft.World/Util/C4JThread.h"
#include "../NetworkPlayerInterface.h"
#include "../PlatformNetworkManagerInterface.h"
#include "../SessionInfo.h"

View file

@ -5,10 +5,10 @@
#ifdef __psp2__
#include <stddef.h>
#include <apputil.h>
#elif __ORBIS__
#elif defined(__ORBIS__)
#include <stddef.h>
#define SceAppUtilSaveDataDataSlot int
#elif __PS3__
#elif defined(__PS3__)
#define SceAppUtilSaveDataDataSlot int
#endif

View file

@ -31,6 +31,10 @@
#ifndef ZLIB_H
#define ZLIB_H
#ifdef __linux__
#define HAVE_UNISTD_H 1
#endif
#include "zconf.h"
#ifdef __cplusplus

View file

@ -22,7 +22,6 @@
#include <time.h>
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <locale>
#include <linux/mman.h>
#include <sys/mman.h>

View file

@ -1,40 +1,35 @@
# get all those files (excluding Sony-SDK-dependent, Xbox XUI, and redist dirs)
_client_build_raw = run_command(
# sources that shouldn't be compiled for whatever reason
exclude_sources = [
' ! -path "*/Platform/*"',
' ! -path "*/Build/Common/Network/Sony/*"',
' ! -path "*/Build/Common/XUI/*"',
]
# get all those files
client_sources = run_command(
'sh', '-c',
'find "' + meson.current_source_dir() / 'Build' + '" -name "*.cpp"' +
' ! -path "*/redist64/*"' +
' ! -path "*/Network/Sony/*"' +
' ! -path "*/Common/XUI/*"',
'find "'
+ meson.current_source_dir()
+ '" \\( -name "*.cpp" -o -name "*.c" \\) '
+ ' '.join(exclude_sources),
check : true,
).stdout().strip().split('\n')
# Non-Build, non-Platform Minecraft.Client sources (Rendering/, UI/, Textures/,
# GameState/, Input/, Level/, Network/, Player/, Commands/, Utils/, etc.)
_client_root_raw = run_command(
'sh', '-c',
'find "' + meson.current_source_dir() + '" -name "*.cpp"' +
' ! -path "*/Build/*"' +
' ! -path "*/Platform/*"' +
' ! -path "*/CMakeFiles/*"',
check : true,
).stdout().strip().split('\n')
platform_sources = []
# linux files
_linux_cpp_sources = files(
'Platform/Linux/Linux_App.cpp',
'Platform/Linux/linux_game_stubs.cpp',
'Platform/Linux/LinuxGL.cpp',
'Platform/Linux/Linux_Minecraft.cpp',
'Platform/Linux/Linux_UIController.cpp',
'Platform/Linux/Linux_ShutdownManager.cpp',
)
_linux_c_sources = files(
'Platform/Linux/Iggy/gdraw/gdraw_glfw.c',
)
# linux-specific files (everything in Platform/Linux)
if host_machine.system() == 'linux'
platform_sources += run_command(
'sh', '-c',
'find "'
+ meson.current_source_dir() / 'Platform/Linux'
+ '" \\( -name "*.cpp" -o -name "*.c" \\) ',
check : true,
).stdout().strip().split('\n')
endif
executable('Minecraft.Client',
_client_build_raw + _client_root_raw + _linux_cpp_sources + _linux_c_sources,
client_sources + platform_sources,
include_directories : include_directories('Build'),
dependencies : [
render_dep,

View file

@ -1,33 +1,38 @@
# sources that shouldn't be compiled for whatever reason
exclude_sources = [
'! -name DurangoStats.cpp', # Durango-specific
# Incomplete/Unused
'! -name SkyIslandDimension.cpp',
'! -name MemoryChunkStorage.cpp',
'! -name MemoryLevelStorage.cpp',
'! -name MemoryLevelStorageSource.cpp',
'! -name NbtSlotFile.cpp',
'! -name ZonedChunkStorage.cpp',
'! -name ZoneFile.cpp',
'! -name ZoneIo.cpp',
]
# GET IT ALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
# Note: the files below are commented-out in CMakeLists.txt (missing headers or
# unfinished ports) and must be excluded from the build.
_world_sources_raw = run_command(
# TODO: make this process more portable using a python script :3
world_sources = run_command(
'sh', '-c',
'find "' + meson.current_source_dir() + '" -name "*.cpp"' +
' ! -name "DurangoStats.cpp"' +
' ! -name "MemoryChunkStorage.cpp"' +
' ! -name "MemoryLevelStorage.cpp"' +
' ! -name "MemoryLevelStorageSource.cpp"' +
' ! -name "NbtSlotFile.cpp"' +
' ! -name "SkyIslandDimension.cpp"' +
' ! -name "ZonedChunkStorage.cpp"' +
' ! -name "ZoneFile.cpp"' +
' ! -name "ZoneIo.cpp"',
'find "'
+ meson.current_source_dir()
+ '" \\( -name "*.cpp" -o -name "*.c" \\) '
+ ' '.join(exclude_sources),
check : true,
).stdout().strip().split('\n')
lib_world = static_library('Minecraft.World',
_world_sources_raw,
world_sources,
include_directories : include_directories('Build', 'Build/x64headers'),
cpp_args : global_cpp_args + global_cpp_defs + [
'-include', meson.current_source_dir() / 'Build/stdafx.h',
],
)
dep_zlib = dependency('zlib')
world_dep = declare_dependency(
link_with : lib_world,
dependencies : [dep_zlib],
include_directories : include_directories('Build/x64headers'),
)

View file

@ -91,16 +91,16 @@ sudo pacman -S meson ninja
```bash
# 1. Configure that bih
meson setup build_meson
meson setup build
# 2. Build
ninja -C build_meson
meson compile -C build
```
The binary is output to:
```
build_meson/Minecraft.Client
build/Minecraft.Client
```
#### Clean
@ -118,7 +118,7 @@ Then re-run `meson setup build_meson` to reconfigure.
```bash
# Release build
meson setup build_release --buildtype=release
ninja -C build_release
meson compile -C build_release
```
---

View file

@ -32,11 +32,16 @@ global_cpp_defs = [
'-D_DEBUG_MENUS_ENABLED',
'-D_DEBUG',
'-DDEBUG',
'-DLINUX',
'-D_LINUX',
'-D__linux__',
]
if host_machine.system() == 'linux'
global_cpp_defs += [
'-Dlinux',
'-D__linux',
'-D__linux__',
]
endif
subdir('4J.Render')
subdir('4J.Input')
subdir('4J.Profile')