diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f5954c..bdc437f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,16 +5,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository and submodules - uses: actions/checkout@v3 - with: - submodules: recursive - fetch-depth: 0 + uses: actions/checkout@v4 - name: Install deps run: | sudo apt-get update - sudo apt-get install -y build-essential cmake lua5.3 xorg-dev libgl1-mesa-dev + sudo apt-get install -y build-essential meson cmake lua5.3 xorg-dev libgl1-mesa-dev - name: Build run: | - cmake -B build -S src - cd build - make -j$(nproc) + meson setup build + meson compile -C build diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index eddaecf..a20928b 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -5,14 +5,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository and submodules - uses: actions/checkout@v3 - with: - submodules: recursive - fetch-depth: 0 + uses: actions/checkout@v4 - name: Install deps run: | sudo apt-get update - sudo apt-get install -y build-essential cmake lua5.3 xorg-dev libgl1-mesa-dev mingw-w64 curl zip + sudo apt-get install -y build-essential cmake meson lua5.3 xorg-dev libgl1-mesa-dev mingw-w64 curl zip - name: Build linux snapshot run: | ./snapshot.sh diff --git a/.gitignore b/.gitignore index 639d6e8..68add8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -build/* -!build/debug.sh -!build/debug_loop.sh -snapshot/* +/build/ +!/build/debug.sh +!/build/debug_loop.sh +/snapshots/* +/subprojects/* +!/subprojects/packagefiles +!/subprojects/*.wrap diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index bf29ca1..0000000 --- a/.gitmodules +++ /dev/null @@ -1,48 +0,0 @@ -[submodule "deps/linmath.h"] - path = deps/linmath.h - url = https://github.com/datenwolf/linmath.h -[submodule "deps/perlin"] - path = deps/perlin - url = https://github.com/dragonblocks/perlin -[submodule "deps/stb"] - path = deps/stb - url = https://github.com/nothings/stb -[submodule "deps/dragonstd"] - path = deps/dragonstd - url = https://github.com/dragonblocks/dragonstd -[submodule "deps/endian.h"] - path = deps/endian.h - url = https://github.com/dragonblocks/endian.h -[submodule "deps/asprintf"] - path = deps/asprintf - url = https://github.com/dragonblocks/asprintf -[submodule "deps/dragonnet"] - path = deps/dragonnet - url = https://github.com/dragonblocks/dragonnet -[submodule "deps/linenoise"] - path = deps/linenoise - url = https://github.com/dragonblocks/linenoise -[submodule "deps/protogen"] - path = deps/protogen - url = https://github.com/dragonblocks/protogen -[submodule "deps/getline"] - path = deps/getline - url = https://github.com/dragonblocks/getline -[submodule "deps/glfw"] - path = deps/glfw - url = https://github.com/glfw/glfw -[submodule "deps/glew-cmake"] - path = deps/glew-cmake - url = https://github.com/Perlmint/glew-cmake -[submodule "deps/freetype"] - path = deps/freetype - url = https://gitlab.freedesktop.org/freetype/freetype -[submodule "deps/sqlite3-cmake"] - path = deps/sqlite3-cmake - url = https://github.com/dragonblocks/sqlite3-cmake -[submodule "deps/stpcpy"] - path = deps/stpcpy - url = https://github.com/dragonblocks/stpcpy -[submodule "deps/zlib"] - path = deps/zlib - url = https://github.com/dragonblocks/zlib diff --git a/BUILDING.md b/BUILDING.md index 79243ec..b6dc7e4 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,36 +1,51 @@ # Building instructions ## Dependencies -You need Git, CMake, Lua, Bash and GCC. Make sure these dependencies are installed on your system. (on Debian based systems: `apt install git cmake build-essential lua5.4`) -All other dependencies are included as submodules, compiled automatically and statically linked. -Make sure to clone the repository recursively: +- You need Git, Meson, CMake, Lua and GCC. Make sure these dependencies are installed on your system. + - Debian: `apt-get install git meson cmake build-essential lua5.4` + - Arch: `pacman -S git meson cmake gcc lua` -```bash -git clone --recurse-submodules https://github.com/dragonblocks/dragonblocks_alpha.git -``` +- For the client, OpenGL is required: + - Debian: `apt-get install libgl1-mesa-dev` + - Arch: `pacman -S mesa` + +### Dependencies with fallbacks + +These dependencies will be built from source if they are not present. -## Client dependencies +- ZLib is required by both client and server. + - Debian: `apt-get install libz-dev` + - Arch: `pacman -S zlib` -If you want to build the client, it is required to install the build dependencies for GLEW and GLFW (on X11/Debian based systems: `apt install xorg-dev libgl1-mesa-dev`). +- The server requires SQLite3. + - Debian: `apt-get install libsqlite3-dev` + - Arch: `pacman -S sqlite3` + +- The client requires Freetype2, GLFW and GLEW. + - Debian: `apt-get install libglfw3-dev libglew-dev libfreetype-dev` + - Arch: `pacman -S freetype2 glfw glew` + +If you plan to build GLFW and GLEW from source, you still need their build dependencies, refer to: -Refer to: - https://www.glfw.org/docs/3.3/compile.html - http://glew.sourceforge.net/build.html +(on X11/Debian based systems: `apt-get install xorg-dev libxkbcommon-dev`) + ## Building a debug build -By default CMake will make a debug build if nothing else is specified. Simply use + +By default Meson will make a debug build. Simply use ```bash -cmake -B build -S src -cd build -make -j$(nproc) +meson setup build +meson compile -C build ``` to build the dragonblocks client and server. If you use a debug build, the singleplayer script should be invoked from the build/ directory, because that's where the binaries are located. -## Building a release snapshot +## Building a statically linked release snapshot ```bash # Native snapshot @@ -38,10 +53,10 @@ If you use a debug build, the singleplayer script should be invoked from the bui # Crosscompiling for windows -# win32 (requires i686-w64-mingw32-gcc-posix) +# win32 (requires i686-w64-mingw32-gcc) ./snapshot.sh win32 -# win64 (requires x86_64-w64-mingw32-gcc-posix) +# win64 (requires x86_64-w64-mingw32-gcc) ./snapshot.sh win64 ``` diff --git a/build/debug.sh b/build/debug.sh index 8decc74..9aadfa9 100755 --- a/build/debug.sh +++ b/build/debug.sh @@ -1,6 +1,6 @@ #!/bin/bash -if ! make -j$(nproc); then +if ! meson compile; then exit 1 fi diff --git a/cross/win32.txt b/cross/win32.txt new file mode 100644 index 0000000..91ad9c5 --- /dev/null +++ b/cross/win32.txt @@ -0,0 +1,31 @@ +[binaries] +c = '/usr/bin/i686-w64-mingw32-gcc' +cpp = '/usr/bin/i686-w64-mingw32-g++' +objc = '/usr/bin/i686-w64-mingw32-gcc' +ar = '/usr/bin/i686-w64-mingw32-ar' +strip = '/usr/bin/i686-w64-mingw32-strip' +pkg-config = '/usr/bin/i686-w64-mingw32-pkg-config' +windres = '/usr/bin/i686-w64-mingw32-windres' +exe_wrapper = 'wine' +ld = '/usr/bin/i686-w64-mingw32-ld' +cmake = '/usr/bin/cmake' + +[properties] +# Directory that contains 'bin', 'lib', etc +root = '/usr/i686-w64-mingw32' +# Directory that contains 'bin', 'lib', etc for the toolchain and system libraries +sys_root = '/usr/i686-w64-mingw32/sys-root/mingw' + +[host_machine] +system = 'windows' +cpu_family = 'x86' +cpu = 'i686' +endian = 'little' + +[cmake] + +CMAKE_BUILD_WITH_INSTALL_RPATH = 'ON' +CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = 'NEVER' +CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = 'ONLY' diff --git a/cross/win64.txt b/cross/win64.txt new file mode 100644 index 0000000..08fa704 --- /dev/null +++ b/cross/win64.txt @@ -0,0 +1,30 @@ +[binaries] +c = '/usr/bin/x86_64-w64-mingw32-gcc' +cpp = '/usr/bin/x86_64-w64-mingw32-g++' +objc = '/usr/bin/x86_64-w64-mingw32-gcc' +ar = '/usr/bin/x86_64-w64-mingw32-ar' +strip = '/usr/bin/x86_64-w64-mingw32-strip' +pkg-config = '/usr/bin/x86_64-w64-mingw32-pkg-config' +windres = '/usr/bin/x86_64-w64-mingw32-windres' +exe_wrapper = 'wine' +cmake = '/usr/bin/cmake' + +[properties] +# Directory that contains 'bin', 'lib', etc +root = '/usr/x86_64-w64-mingw32' +# Directory that contains 'bin', 'lib', etc for the toolchain and system libraries +sys_root = '/usr/x86_64-w64-mingw32/sys-root/mingw' + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' + +[cmake] + +CMAKE_BUILD_WITH_INSTALL_RPATH = 'ON' +CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = 'NEVER' +CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = 'ONLY' diff --git a/deps/asprintf b/deps/asprintf deleted file mode 160000 index bae4b13..0000000 --- a/deps/asprintf +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bae4b1328ca21926ecf9ba637e64d31cae930b1e diff --git a/deps/dragonnet b/deps/dragonnet deleted file mode 160000 index 7a90462..0000000 --- a/deps/dragonnet +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7a90462574c664582bb55898b136b9ddb5d5ec8e diff --git a/deps/dragonstd b/deps/dragonstd deleted file mode 160000 index 8cb199e..0000000 --- a/deps/dragonstd +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8cb199e8551e64823b88d3a762e089a1501b5a31 diff --git a/deps/endian.h b/deps/endian.h deleted file mode 160000 index f24960e..0000000 --- a/deps/endian.h +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f24960eca3bb806fa72d8de2b9a761a889fdeee3 diff --git a/deps/freetype b/deps/freetype deleted file mode 160000 index d59c7ce..0000000 --- a/deps/freetype +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d59c7ce1b970bfe38b3df161e9dd711b75392709 diff --git a/deps/getline b/deps/getline deleted file mode 160000 index 31d5395..0000000 --- a/deps/getline +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 31d5395d3bfd1f1a0f70a1a14d7fa6231d3b920b diff --git a/deps/glew-cmake b/deps/glew-cmake deleted file mode 160000 index 7c2b751..0000000 --- a/deps/glew-cmake +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7c2b7514f64234756f7df051b9316f1e46f5a6e7 diff --git a/deps/glfw b/deps/glfw deleted file mode 160000 index 4cb3687..0000000 --- a/deps/glfw +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4cb36872a5fe448c205d0b46f0e8c8b57530cfe0 diff --git a/deps/linenoise b/deps/linenoise deleted file mode 160000 index 2da54ed..0000000 --- a/deps/linenoise +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2da54ed285c5da913c9fb11e0b0410becccb8a39 diff --git a/deps/linmath.h b/deps/linmath.h deleted file mode 160000 index 0538757..0000000 --- a/deps/linmath.h +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 05387571f57224f8cbc2b390b423dab6b9158988 diff --git a/deps/perlin b/deps/perlin deleted file mode 160000 index 8a9301d..0000000 --- a/deps/perlin +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8a9301d6daf259ee36fe68bffd86c4c016c2d30d diff --git a/deps/protogen b/deps/protogen deleted file mode 160000 index f506262..0000000 --- a/deps/protogen +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f506262076d602340500786703ac384d92683e26 diff --git a/deps/sqlite3-cmake b/deps/sqlite3-cmake deleted file mode 160000 index b23390e..0000000 --- a/deps/sqlite3-cmake +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b23390e443baca0a93bf2a7939d0518fdc6f4ed8 diff --git a/deps/stb b/deps/stb deleted file mode 160000 index af1a5bc..0000000 --- a/deps/stb +++ /dev/null @@ -1 +0,0 @@ -Subproject commit af1a5bc352164740c1cc1354942b1c6b72eacb8a diff --git a/deps/stpcpy b/deps/stpcpy deleted file mode 160000 index 969029a..0000000 --- a/deps/stpcpy +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 969029a8ad4947745d873c9b4d13929af33ec633 diff --git a/deps/zlib b/deps/zlib deleted file mode 160000 index 4b4fbf4..0000000 --- a/deps/zlib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4b4fbf4ee10310760f763bcb674775f0325b842a diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..2e5b69e --- /dev/null +++ b/meson.build @@ -0,0 +1,131 @@ +project('dragonblocks', 'c', default_options: ['warning_level=2']) + +add_project_arguments([ + '-Wno-address-of-packed-member', + '-DGLEW_NO_GLU', + '-DUSE_DRAGONNET', + '-DASSET_PATH="' + get_option('asset_path') + '"', +], language: 'c') + +cc = meson.get_compiler('c') + +include = 'src/' + +deps = [ + cc.find_library('m', required: false), + dependency('threads'), + dependency('protogen'), + dependency('endian'), + dependency('linmath'), + dependency('perlin'), + dependency('dragonnet'), + dependency('dragonstd'), + dependency('getline'), + dependency('zlib'), +] + +common_lib = static_library('dragonblocks', + sources: [ + vcs_tag( + command: [find_program('git'), 'describe', '--tags'], + input: 'src/version.h.in', + output: 'version.h', + replace_string: '@GIT_VERSION@', + ), + custom_target('protogen_types', + output: ['types.c', 'types.h'], + input: 'src/types.def', + command: [find_program('protogen'), '@INPUT@', '@OUTPUT@'], + ), + 'src/common/color.c', + 'src/common/config.c', + 'src/common/day.c', + 'src/common/environment.c', + 'src/common/facedir.c', + 'src/common/init.c', + 'src/common/interrupt.c', + 'src/common/item.c', + 'src/common/node.c', + 'src/common/perlin.c', + 'src/common/physics.c', + 'src/common/terrain.c', + ], + dependencies: deps, + include_directories: include, +) + +common = declare_dependency( + link_with: common_lib, + dependencies: deps, + include_directories: include, +) + +executable('dragonblocks_client', + sources: [ + 'src/client/camera.c', + 'src/client/client.c', + 'src/client/client_auth.c', + 'src/client/client_config.c', + 'src/client/client_entity.c', + 'src/client/client_inventory.c', + 'src/client/client_item.c', + 'src/client/client_node.c', + 'src/client/client_player.c', + 'src/client/client_terrain.c', + 'src/client/cube.c', + 'src/client/debug_menu.c', + 'src/client/facecache.c', + 'src/client/font.c', + 'src/client/frustum.c', + 'src/client/game.c', + 'src/client/gui.c', + 'src/client/input.c', + 'src/client/interact.c', + 'src/client/light.c', + 'src/client/mesh.c', + 'src/client/model.c', + 'src/client/opengl.c', + 'src/client/raycast.c', + 'src/client/screenshot.c', + 'src/client/shader.c', + 'src/client/sky.c', + 'src/client/terrain_gfx.c', + 'src/client/texture.c', + 'src/client/window.c', + ], + dependencies: [ + common, + dependency('stb'), + dependency('glew'), + dependency('gl'), + dependency('glfw3'), + dependency('asprintf'), + dependency('linenoise'), + dependency('freetype2'), + ], + install: true, +) + +executable('dragonblocks_server', + sources: [ + 'src/server/biomes.c', + 'src/server/database.c', + 'src/server/schematic.c', + 'src/server/server.c', + 'src/server/server_config.c', + 'src/server/server_item.c', + 'src/server/server_node.c', + 'src/server/server_player.c', + 'src/server/server_terrain.c', + 'src/server/terrain_gen.c', + 'src/server/tree.c', + 'src/server/tree_physics.c', + 'src/server/voxel_depth_search.c', + 'src/server/voxel_procedural.c', + ], + dependencies: [ + common, + dependency('sqlite3'), + ], + install: true, +) diff --git a/meson.options b/meson.options new file mode 100644 index 0000000..8e008ae --- /dev/null +++ b/meson.options @@ -0,0 +1 @@ +option('asset_path', type: 'string', value: '../assets/') diff --git a/snapshot.sh b/snapshot.sh index 290617f..54ed46c 100755 --- a/snapshot.sh +++ b/snapshot.sh @@ -3,15 +3,13 @@ set -e version="$(git describe --tags)" -mkdir -p "snapshot" -cd "snapshot" +mkdir -p "snapshots" build="build" snapshot="dragonblocks_alpha-$version" -toolchain="" dotexe="" dotsh=".sh" -flags="-O2" +crossfile="" if [[ "$1" != "" ]]; then build="$build-$1" @@ -19,19 +17,27 @@ if [[ "$1" != "" ]]; then toolchain="$1.cmake" dotexe=".exe" dotsh=".bat" - flags="$flags -static" -fi - -mkdir -p "$build" + crossfile="--cross-file=cross/$1.txt" -cmake -B "$build" -S ../src \ - -DCMAKE_BUILD_TYPE="Release" \ - -DASSET_PATH="assets/" \ - -DCMAKE_C_FLAGS="$flags" \ - -DCMAKE_CXX_FLAGS="$flags" \ - -DCMAKE_TOOLCHAIN_FILE="$toolchain" + export CFLAGS="$CFLAGS -static" +fi -make --no-print-directory -C "$build" -j"$(nproc)" +meson setup "snapshots/$build" \ + -Dbuildtype=release \ + -Doptimization=2 \ + -Dasset_path="assets/" \ + -Ddefault_library=static \ + -Dfreetype2:harfbuzz=disabled \ + -Dfreetype2:bzip2=disabled \ + -Dfreetype2:brotli=disabled \ + -Dfreetype2:png=disabled \ + $crossfile \ + --wrap-mode=forcefallback \ + --reconfigure + +cd "snapshots" + +meson compile -C "$build" rm -rf "$snapshot" mkdir "$snapshot" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 7d82a3d..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,212 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(Dragonblocks) - -# Variables - -set(DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../deps") - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Debug) -endif() - -if(NOT ASSET_PATH) - set(ASSET_PATH "../assets/") -endif() - -# Dependencies - -set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) - -set(SKIP_INSTALL_ALL ON) -set(BUILD_SHARED_LIBS OFF) - -set(ZLIB_LIBRARY zlibstatic) -set(ZLIB_INCLUDE_DIR "${DEPS_DIR}/zlib") - -set(FT_DISABLE_ZLIB OFF) -set(FT_DISABLE_BZIP2 ON) -set(FT_DISABLE_PNG ON) -set(FT_DISABLE_HARFBUZZ ON) -set(FT_DISABLE_BROTLI ON) - -foreach(DEP glfw glew-cmake sqlite3-cmake perlin asprintf dragonnet dragonstd getline stpcpy linenoise zlib freetype) - if(EXISTS "${DEPS_DIR}/${DEP}/CMakeLists.txt") - add_subdirectory("${DEPS_DIR}/${DEP}" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/${DEP}") - else() - message(FATAL_ERROR "Submodule ${DEPS_DIR}/${DEP} does not contain CMakeLists.txt. This is most likely due to submodules not being updated. Use this command to fix the issue:\n\tgit submodule update --init --recursive\nAfter that, run CMake again.") - endif() -endforeach() - -# Options - -if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - add_compile_definitions("ENABLE_GL_DEBUG") -endif() - -add_compile_definitions("USE_DRAGONNET") -add_compile_definitions("GLEW_STATIC") -add_compile_definitions("ASSET_PATH=\"${ASSET_PATH}\"") -add_compile_definitions("__USE_MINGW_ANSI_STDIO") - -add_compile_options( - -Wall - -Wextra - -Wno-address-of-packed-member - -fmax-errors=4 -) - -# System specific options - -if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") - link_directories("/usr/local/lib") - include_directories("/usr/local/include") -endif() - -if("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") - link_directories("/usr/X11R6/lib") - include_directories("/usr/X11R6/include") -endif() - -# Common sources - -add_library(dragonblocks - "${CMAKE_CURRENT_BINARY_DIR}/types.c" - common/color.c - common/config.c - common/day.c - common/environment.c - common/facedir.c - common/init.c - common/interrupt.c - common/item.c - common/node.c - common/perlin.c - common/physics.c - common/terrain.c -) - -target_include_directories(dragonblocks - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC ${CMAKE_CURRENT_BINARY_DIR} - PUBLIC "${DEPS_DIR}/linmath.h" - PUBLIC "${DEPS_DIR}/endian.h" - PUBLIC "${DEPS_DIR}/stb" -) - -target_link_libraries(dragonblocks - PUBLIC pthread - PUBLIC m - PUBLIC ${CMAKE_DL_LIBS} - PUBLIC perlin - PUBLIC dragonnet - PUBLIC dragonstd - PUBLIC getline - PUBLIC zlibstatic - PUBLIC stpcpy -) - -# Client - -add_executable(dragonblocks_client - client/camera.c - client/client.c - client/client_auth.c - client/client_config.c - client/client_entity.c - client/client_inventory.c - client/client_item.c - client/client_node.c - client/client_player.c - client/client_terrain.c - client/cube.c - client/debug_menu.c - client/facecache.c - client/font.c - client/frustum.c - client/game.c - client/gui.c - client/input.c - client/interact.c - client/light.c - client/mesh.c - client/model.c - client/opengl.c - client/raycast.c - client/screenshot.c - client/shader.c - client/sky.c - client/terrain_gfx.c - client/texture.c - client/window.c -) - -target_link_libraries(dragonblocks_client - PUBLIC dragonblocks - PUBLIC libglew_static - PUBLIC glfw - PUBLIC asprintf - PUBLIC linenoise - PUBLIC freetype -) - -# Server - -add_executable(dragonblocks_server - server/biomes.c - server/database.c - server/schematic.c - server/server.c - server/server_config.c - server/server_item.c - server/server_node.c - server/server_player.c - server/server_terrain.c - server/terrain_gen.c - server/tree.c - server/tree_physics.c - server/voxel_depth_search.c - server/voxel_procedural.c -) - -target_link_libraries(dragonblocks_server - PUBLIC dragonblocks - PUBLIC sqlite3 -) - -# Debug - -option(SANITIZE "address | thread: enable -fsanitize") -if(NOT "${SANITIZE}" STREQUAL "OFF") - target_compile_options(dragonblocks PUBLIC -fsanitize=${SANITIZE}) - target_compile_options(dragonblocks_client PUBLIC -fsanitize=${SANITIZE}) - target_compile_options(dragonblocks_server PUBLIC -fsanitize=${SANITIZE}) - - target_link_options(dragonblocks PUBLIC -fsanitize=${SANITIZE}) - target_link_options(dragonblocks_client PUBLIC -fsanitize=${SANITIZE}) - target_link_options(dragonblocks_server PUBLIC -fsanitize=${SANITIZE}) -endif() - -# Version - -add_custom_target(version - COMMAND ${CMAKE_COMMAND} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" -) - -add_dependencies(dragonblocks version) - -# Types - -add_custom_command( - OUTPUT types.c types.h - MAIN_DEPENDENCY types.def - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../deps/protogen/protogen.lua" - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/mktypes.sh" "${CMAKE_CURRENT_SOURCE_DIR}" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" -) - -add_custom_target(types - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/types.c" "${CMAKE_CURRENT_BINARY_DIR}/types.h" -) - -add_dependencies(dragonblocks types) diff --git a/src/mktypes.sh b/src/mktypes.sh deleted file mode 100755 index 3fb766d..0000000 --- a/src/mktypes.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -SOURCE_DIR="$1" - -if [[ "$SOURCE_DIR" = "" ]]; then - SOURCE_DIR="." -fi - -export LUA_PATH="$SOURCE_DIR/../deps/protogen/?.lua;$SOURCE_DIR/../deps/protogen/?/init.lua" -"$SOURCE_DIR/../deps/protogen/protogen.lua" "$SOURCE_DIR/types.def" diff --git a/src/version.cmake b/src/version.cmake deleted file mode 100644 index b439e8d..0000000 --- a/src/version.cmake +++ /dev/null @@ -1,9 +0,0 @@ -execute_process(COMMAND git describe --tags - OUTPUT_VARIABLE GIT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -configure_file( - version.h.in - ${BINARY_DIR}/version.h -) diff --git a/src/win32.cmake b/src/win32.cmake deleted file mode 100644 index 2a51e36..0000000 --- a/src/win32.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(CMAKE_SYSTEM_NAME Windows) - -set(CMAKE_C_COMPILER i686-w64-mingw32-gcc-posix) -set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++-posix) diff --git a/src/win64.cmake b/src/win64.cmake deleted file mode 100644 index 9024694..0000000 --- a/src/win64.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(CMAKE_SYSTEM_NAME Windows) - -set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-posix) -set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix) diff --git a/subprojects/asprintf.wrap b/subprojects/asprintf.wrap new file mode 100644 index 0000000..c4b84b1 --- /dev/null +++ b/subprojects/asprintf.wrap @@ -0,0 +1,8 @@ +[wrap-git] +url = https://github.com/dragonblocks/asprintf +revision = head +depth = 1 +method = cmake + +[provide] +asprintf = asprintf_dep diff --git a/subprojects/dragonnet.wrap b/subprojects/dragonnet.wrap new file mode 100644 index 0000000..efe436d --- /dev/null +++ b/subprojects/dragonnet.wrap @@ -0,0 +1,5 @@ +[wrap-git] +url = https://github.com/dragonblocks/dragonnet +revision = head +clone-recursive = true +depth = 1 diff --git a/subprojects/dragonstd.wrap b/subprojects/dragonstd.wrap new file mode 100644 index 0000000..16797f7 --- /dev/null +++ b/subprojects/dragonstd.wrap @@ -0,0 +1,8 @@ +[wrap-git] +url = https://github.com/dragonblocks/dragonstd +revision = head +depth = 1 +method = cmake + +[provide] +dragonstd = dragonstd_dep diff --git a/subprojects/endian.wrap b/subprojects/endian.wrap new file mode 100644 index 0000000..18d56e3 --- /dev/null +++ b/subprojects/endian.wrap @@ -0,0 +1,5 @@ +[wrap-git] +url = https://github.com/dragonblocks/endian.h +revision = head +depth = 1 +patch_directory = endian diff --git a/subprojects/freetype2.wrap b/subprojects/freetype2.wrap new file mode 100644 index 0000000..e3554c9 --- /dev/null +++ b/subprojects/freetype2.wrap @@ -0,0 +1,11 @@ +[wrap-file] +directory = freetype-2.13.2 +source_url = https://download.savannah.gnu.org/releases/freetype/freetype-2.13.2.tar.xz +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/freetype2_2.13.2-1/freetype-2.13.2.tar.xz +source_filename = freetype-2.13.2.tar.xz +source_hash = 12991c4e55c506dd7f9b765933e62fd2be2e06d421505d7950a132e4f1bb484d +wrapdb_version = 2.13.2-1 + +[provide] +freetype2 = freetype_dep +freetype = freetype_dep diff --git a/subprojects/getline.wrap b/subprojects/getline.wrap new file mode 100644 index 0000000..c6a3644 --- /dev/null +++ b/subprojects/getline.wrap @@ -0,0 +1,8 @@ +[wrap-git] +url = https://github.com/dragonblocks/getline +revision = head +depth = 1 +method = cmake + +[provide] +getline = getline_dep diff --git a/subprojects/glew.wrap b/subprojects/glew.wrap new file mode 100644 index 0000000..390dc9a --- /dev/null +++ b/subprojects/glew.wrap @@ -0,0 +1,12 @@ +[wrap-file] +directory = glew-2.2.0 +source_url = http://downloads.sourceforge.net/glew/glew-2.2.0.tgz +source_filename = glew-2.2.0.tgz +source_hash = d4fc82893cfb00109578d0a1a2337fb8ca335b3ceccf97b97e5cc7f08e4353e1 +patch_filename = glew_2.2.0-2_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/glew_2.2.0-2/get_patch +patch_hash = df7bc80456da53f83e93e89ca5035d04cdff19a836c956887a684b2bee16eb9b +wrapdb_version = 2.2.0-2 + +[provide] +glew = glew_dep diff --git a/subprojects/glfw.wrap b/subprojects/glfw.wrap new file mode 100644 index 0000000..c5a9751 --- /dev/null +++ b/subprojects/glfw.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = glfw-3.3.10 +source_url = https://github.com/glfw/glfw/archive/refs/tags/3.3.10.tar.gz +source_filename = glfw-3.3.10.tar.gz +source_hash = 4ff18a3377da465386374d8127e7b7349b685288cb8e17122f7e1179f73769d5 +patch_filename = glfw_3.3.10-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/glfw_3.3.10-1/get_patch +patch_hash = 3567f96c2576a5fc8c9cafd9059f919d7da404f6c22450c6c2ce3f9938909b8b +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/glfw_3.3.10-1/glfw-3.3.10.tar.gz +wrapdb_version = 3.3.10-1 + +[provide] +glfw3 = glfw_dep diff --git a/subprojects/linenoise.wrap b/subprojects/linenoise.wrap new file mode 100644 index 0000000..717bea7 --- /dev/null +++ b/subprojects/linenoise.wrap @@ -0,0 +1,8 @@ +[wrap-git] +url = https://github.com/dragonblocks/linenoise +revision = head +depth = 1 +method = cmake + +[provide] +linenoise = linenoise_dep diff --git a/subprojects/linmath.wrap b/subprojects/linmath.wrap new file mode 100644 index 0000000..7baf438 --- /dev/null +++ b/subprojects/linmath.wrap @@ -0,0 +1,5 @@ +[wrap-git] +url = https://github.com/datenwolf/linmath.h +revision = head +depth = 1 +patch_directory = linmath diff --git a/subprojects/packagefiles/endian/meson.build b/subprojects/packagefiles/endian/meson.build new file mode 100644 index 0000000..2a6f0a4 --- /dev/null +++ b/subprojects/packagefiles/endian/meson.build @@ -0,0 +1,2 @@ +project('endian') +meson.override_dependency('endian', declare_dependency(include_directories: '.')) diff --git a/subprojects/packagefiles/linmath/meson.build b/subprojects/packagefiles/linmath/meson.build new file mode 100644 index 0000000..6f3d702 --- /dev/null +++ b/subprojects/packagefiles/linmath/meson.build @@ -0,0 +1,2 @@ +project('linmath') +meson.override_dependency('linmath', declare_dependency(include_directories: '.')) diff --git a/subprojects/packagefiles/perlin/meson.build b/subprojects/packagefiles/perlin/meson.build new file mode 100644 index 0000000..b3d540f --- /dev/null +++ b/subprojects/packagefiles/perlin/meson.build @@ -0,0 +1,7 @@ +project('perlin', 'c', default_options : ['warning_level=3']) + +cc = meson.get_compiler('c') +perlin = library('perlin', 'perlin.c', + dependencies: cc.find_library('m')) + +meson.override_dependency('perlin', declare_dependency(link_with: perlin, include_directories: '.')) diff --git a/subprojects/packagefiles/protogen/meson.build b/subprojects/packagefiles/protogen/meson.build new file mode 100644 index 0000000..209fe3c --- /dev/null +++ b/subprojects/packagefiles/protogen/meson.build @@ -0,0 +1,8 @@ +project('protogen') + +meson.override_dependency('protogen', declare_dependency()) +meson.override_find_program('protogen', configure_file( + copy: true, + input: 'protogen.lua', + output: 'protogen.lua', +)) diff --git a/subprojects/packagefiles/stb/meson.build b/subprojects/packagefiles/stb/meson.build new file mode 100644 index 0000000..5f3a201 --- /dev/null +++ b/subprojects/packagefiles/stb/meson.build @@ -0,0 +1,2 @@ +project('stb') +meson.override_dependency('stb', declare_dependency(include_directories: '.')) diff --git a/subprojects/perlin.wrap b/subprojects/perlin.wrap new file mode 100644 index 0000000..4249b46 --- /dev/null +++ b/subprojects/perlin.wrap @@ -0,0 +1,5 @@ +[wrap-git] +url = https://github.com/czinn/perlin +revision = head +depth = 1 +patch_directory = perlin diff --git a/subprojects/protogen.wrap b/subprojects/protogen.wrap new file mode 100644 index 0000000..01c0dd2 --- /dev/null +++ b/subprojects/protogen.wrap @@ -0,0 +1,5 @@ +[wrap-git] +url = https://github.com/dragonblocks/protogen +revision = head +depth = 1 +patch_directory = protogen diff --git a/subprojects/sqlite3.wrap b/subprojects/sqlite3.wrap new file mode 100644 index 0000000..5d2eb5c --- /dev/null +++ b/subprojects/sqlite3.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = sqlite-amalgamation-3460000 +source_url = https://www.sqlite.org/2024/sqlite-amalgamation-3460000.zip +source_filename = sqlite-amalgamation-3460000.zip +source_hash = 712a7d09d2a22652fb06a49af516e051979a3984adb067da86760e60ed51a7f5 +patch_filename = sqlite3_3.46.0-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/sqlite3_3.46.0-1/get_patch +patch_hash = c6dda193e59e4bd11dbc6f399cae1904d231e0cb119224480bec6c94c5d0e04e +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sqlite3_3.46.0-1/sqlite-amalgamation-3460000.zip +wrapdb_version = 3.46.0-1 + +[provide] +sqlite3 = sqlite3_dep diff --git a/subprojects/stb.wrap b/subprojects/stb.wrap new file mode 100644 index 0000000..e33e4f7 --- /dev/null +++ b/subprojects/stb.wrap @@ -0,0 +1,5 @@ +[wrap-git] +url = https://github.com/nothings/stb +revision = af1a5bc352164740c1cc1354942b1c6b72eacb8a +depth = 1 +patch_directory = stb diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap new file mode 100644 index 0000000..aa14de1 --- /dev/null +++ b/subprojects/zlib.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = zlib-1.3.1 +source_url = http://zlib.net/fossils/zlib-1.3.1.tar.gz +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.1-1/zlib-1.3.1.tar.gz +source_filename = zlib-1.3.1.tar.gz +source_hash = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 +patch_filename = zlib_1.3.1-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.1-1/get_patch +patch_hash = e79b98eb24a75392009cec6f99ca5cdca9881ff20bfa174e8b8926d5c7a47095 +wrapdb_version = 1.3.1-1 + +[provide] +zlib = zlib_dep diff --git a/upload.sh b/upload.sh index 62e1786..c28525a 100755 --- a/upload.sh +++ b/upload.sh @@ -2,7 +2,7 @@ set -e name="$(git describe --tags)" -path="@snapshot/dragonblocks_alpha-$name" +path="@snapshots/dragonblocks_alpha-$name" ref="$(git tag --points-at HEAD)" release="1"