This commit is contained in:
Sergey Asadov 2026-11-13 11:55:09 +00:00 • committed by GitHub
commit bbe6e910f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 218 additions and 30 deletions

View file

@ -34,17 +34,11 @@ jobs:
run: |
cmake -DOPENAL_INCLUDE_DIR=$(brew --prefix openal-soft)/include \
-DOPENAL_LIBRARY=$(brew --prefix openal-soft)/lib/libopenal.dylib \
-S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOXELENGINE_BUILD_TESTS=ON -DVOXELENGINE_BUILD_APPDIR=1 -DVC_BUILD_NAME="${{ inputs.build_name }}" -DVC_VERSION_PATCH="${{ inputs.version_patch }}"
-S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOXELENGINE_BUILD_TESTS=ON -DVOXELENGINE_BUILD_MACOS_BUNDLE=ON -DVC_BUILD_NAME="${{ inputs.build_name }}" -DVC_VERSION_PATCH="${{ inputs.version_patch }}"
- name: Build
run: |
cmake --build build -t install
- name: Make fix_dylibs.sh executable
run: chmod +x dev/fix_dylibs.sh
- name: Fix dylibs
run: ./dev/fix_dylibs.sh VoxelCore Release build
cmake --build build
- name: Run tests
run: ctest --output-on-failure --test-dir build
@ -52,16 +46,25 @@ jobs:
- name: Run engine tests
timeout-minutes: 5
run: |
chmod +x build/VoxelCore
chmod +x AppDir/usr/bin/vctest
AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- "
build/vctest/vctest -e build/VoxelCore -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- "
- name: Create DMG
run: |
mkdir VoxelCoreDmgContent
cp -r build/res VoxelCoreDmgContent/
cp -r build/VoxelCore VoxelCoreDmgContent/
cp -r build/libs VoxelCoreDmgContent/libs
hdiutil create VoxelCoreMacApp.dmg -volname "VoxelCore" -srcfolder VoxelCoreDmgContent -ov -format UDZO
cd build
cpack
mv VoxelCore.dmg ../VoxelCoreMacApp.dmg
- name: Check bundle
run: |
app=build/_CPack_Packages/Darwin/DragNDrop/VoxelCore/VoxelCore.app
test -x "$app/Contents/MacOS/VoxelCore"
test -d "$app/Contents/Resources/res"
if find "$app/Contents" -type f -perm +111 -exec otool -L {} \; 2>/dev/null \
| grep -E '^[[:space:]]+(/opt/homebrew|/usr/local)/'; then
echo "bundle depends on libraries outside of it"
exit 1
fi
codesign --verify --deep --strict "$app"
- name: Upload artifacts
uses: actions/upload-artifact@v4

13
Brewfile Normal file
View file

@ -0,0 +1,13 @@
brew "cmake"
brew "ninja"
brew "pkgconf"
brew "glfw"
brew "glew"
brew "glm"
brew "libpng"
brew "libvorbis"
brew "luajit"
brew "openal-soft"
brew "freetype"
brew "openssl@3"
brew "googletest"

View file

@ -9,6 +9,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} --version)
option(VOXELENGINE_BUILD_APPDIR "Pack linux build" OFF)
option(VOXELENGINE_BUILD_TESTS "Build tests" OFF)
option(VOXELENGINE_BUILD_MACOS_BUNDLE "Pack macOS .app bundle" OFF)
add_compile_definitions(VC_BUILD_NAME="${VC_BUILD_NAME}")
@ -41,6 +42,10 @@ if(VOXELENGINE_BUILD_APPDIR)
include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake)
endif()
if(VOXELENGINE_BUILD_MACOS_BUNDLE)
include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildMacBundle.cmake)
endif()
target_link_libraries(VoxelCore PRIVATE VoxelCoreSrc
$<$<PLATFORM_ID:Windows>:winmm>)

View file

@ -72,8 +72,8 @@
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"VOXELENGINE_BUILD_TESTS": "ON",
"VOXELENGINE_BUILD_APPDIR": "ON"
"CMAKE_BUILD_TYPE": "Release",
"VOXELENGINE_BUILD_TESTS": "ON"
}
}
],
@ -105,8 +105,7 @@
},
{
"name": "default-ninja-clang-macos",
"configurePreset": "default-ninja-clang-macos",
"configuration": "Debug"
"configurePreset": "default-ninja-clang-macos"
}
],
"testPresets": [

View file

@ -65,23 +65,31 @@ cmake --build . --parallel
### Install libraries
```sh
brew install glfw glew glm libpng libvorbis lua luajit libcurl openal-soft freetype
git clone --recursive https://github.com/MihailRis/VoxelCore.git
cd VoxelCore
brew bundle
```
> [!TIP]
> If Homebrew fails to install `lua`, `luajit`, or `openal-soft`, download, compile, and install them manually.
### Building engine with CMake
```sh
git clone --recursive https://github.com/MihailRis/VoxelCore.git
cd VoxelCore
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallel
cmake --preset default-ninja-clang-macos
cmake --build --preset default-ninja-clang-macos
```
### Building `.app` and `.dmg`
> [!NOTE]
> User files are stored in `~/Library/Application Support/VoxelCore`.
```sh
cmake --preset default-ninja-clang-macos -DVOXELENGINE_BUILD_MACOS_BUNDLE=ON
cmake --build --preset default-ninja-clang-macos
cd build
cpack
```
This creates `build/VoxelCore.dmg` with a self-contained `VoxelCore.app`
(Homebrew libraries are copied into the bundle).
---
## Building in Windows

View file

@ -0,0 +1,72 @@
# VoxelCore.app packed to VoxelCore.dmg with cpack
set(VC_BUNDLE_CONTENTS VoxelCore.app/Contents)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/constants.hpp VC_CONSTANTS)
string(REGEX MATCH "ENGINE_VERSION_MAJOR = ([0-9]+)" _ "${VC_CONSTANTS}")
set(VC_VERSION_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "ENGINE_VERSION_MINOR = ([0-9]+)" _ "${VC_CONSTANTS}")
set(VC_VERSION_MINOR ${CMAKE_MATCH_1})
if(VC_VERSION_PATCH STREQUAL "")
set(VC_BUNDLE_VERSION ${VC_VERSION_MAJOR}.${VC_VERSION_MINOR}.0)
else()
set(VC_BUNDLE_VERSION
${VC_VERSION_MAJOR}.${VC_VERSION_MINOR}.${VC_VERSION_PATCH})
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/dev/macos/Info.plist.in
${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY
)
install(
PROGRAMS $<TARGET_FILE:VoxelCore>
DESTINATION ${VC_BUNDLE_CONTENTS}/MacOS
RENAME VoxelCore-bin
)
install(
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/dev/macos/launcher.sh
DESTINATION ${VC_BUNDLE_CONTENTS}/MacOS
RENAME VoxelCore
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
DESTINATION ${VC_BUNDLE_CONTENTS}
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/dev/macos/VoxelCore.icns
DESTINATION ${VC_BUNDLE_CONTENTS}/Resources
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res
DESTINATION ${VC_BUNDLE_CONTENTS}/Resources
)
execute_process(
COMMAND brew --prefix
OUTPUT_VARIABLE VC_BREW_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
install(
CODE "set(VC_LIB_DIRS \"${VC_BREW_PREFIX}/lib\")"
)
install(
CODE [[
include(BundleUtilities)
set(app "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/VoxelCore.app")
fixup_bundle("${app}" "${app}/Contents/MacOS/VoxelCore-bin"
"${VC_LIB_DIRS}")
execute_process(COMMAND codesign --force --deep --sign - "${app}"
COMMAND_ERROR_IS_FATAL ANY)
]])
set(CPACK_GENERATOR DragNDrop)
set(CPACK_PACKAGE_NAME VoxelCore)
set(CPACK_PACKAGE_VERSION ${VC_BUNDLE_VERSION})
set(CPACK_PACKAGE_FILE_NAME VoxelCore)
set(CPACK_DMG_VOLUME_NAME VoxelCore)
set(CPACK_DMG_BACKGROUND_IMAGE ${CMAKE_CURRENT_SOURCE_DIR}/dev/macos/dmg-background.tiff)
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/dev/macos/dmg-setup.applescript)
include(CPack)

28
dev/macos/Info.plist.in Normal file
View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>VoxelCore</string>
<key>CFBundleDisplayName</key>
<string>VoxelCore</string>
<key>CFBundleIdentifier</key>
<string>io.github.mihailris.voxelcore</string>
<key>CFBundleExecutable</key>
<string>VoxelCore</string>
<key>CFBundleIconFile</key>
<string>VoxelCore</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@VC_BUNDLE_VERSION@</string>
<key>CFBundleVersion</key>
<string>@VC_BUNDLE_VERSION@</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSMicrophoneUsageDescription</key>
<string>VoxelCore uses the microphone for audio input when content requests it.</string>
</dict>
</plist>

BIN
dev/macos/VoxelCore.icns Normal file

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,36 @@
on run argv
set volumeName to item 1 of argv
tell application "Finder"
set targetDisk to missing value
set candidates to every disk whose name is volumeName
repeat with i from 1 to count of candidates
set d to item i of candidates
set diskPath to POSIX path of (d as alias)
try
do shell script "test -w " & quoted form of diskPath
set targetDisk to d
exit repeat
end try
end repeat
if targetDisk is missing value then error "writable disk not found: " & volumeName
tell targetDisk
open
set win to container window
set current view of win to icon view
set toolbar visible of win to false
set statusbar visible of win to false
set the bounds of win to {200, 120, 800, 548}
set opts to the icon view options of win
set arrangement of opts to not arranged
set icon size of opts to 128
set text size of opts to 13
set background picture of opts to file ".background:background.tiff"
set position of item "VoxelCore.app" of win to {180, 200}
set position of item "Applications" of win to {420, 200}
update without registering applications
delay 2
close
end tell
end tell
end run

7
dev/macos/launcher.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
DIR="$(cd "$(dirname "$0")" && pwd)"
USER_DIR="$HOME/Library/Application Support/VoxelCore"
mkdir -p "$USER_DIR"
exec "$DIR/VoxelCore-bin" --res "$DIR/../Resources/res" --dir "$USER_DIR" "$@"

View file

@ -13,6 +13,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# specific for vcpkg
find_package(OpenAL CONFIG REQUIRED)
else()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT OPENAL_INCLUDE_DIR)
execute_process(
COMMAND brew --prefix openal-soft
OUTPUT_VARIABLE OPENAL_SOFT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(EXISTS "${OPENAL_SOFT_DIR}/include/AL/alext.h")
set(OPENAL_INCLUDE_DIR "${OPENAL_SOFT_DIR}/include" CACHE PATH "")
set(OPENAL_LIBRARY "${OPENAL_SOFT_DIR}/lib/libopenal.dylib"
CACHE FILEPATH "")
endif()
endif()
find_package(OpenAL REQUIRED)
if(NOT TARGET OpenAL::OpenAL)
add_library(OpenAL::OpenAL UNKNOWN IMPORTED)
@ -25,6 +36,12 @@ endif()
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(CURL REQUIRED)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT OPENSSL_ROOT_DIR)
execute_process(
COMMAND brew --prefix openssl@3
OUTPUT_VARIABLE OPENSSL_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
endif()
find_package(OpenSSL 3.0 REQUIRED COMPONENTS Crypto)
find_package(glfw3 REQUIRED)
find_package(Freetype REQUIRED)