Skip to content

Commit

Permalink
Added Meson. Starting redesign. Adding tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
facundo-villa committed Apr 27, 2023
1 parent 7fe6aa2 commit efe9122
Show file tree
Hide file tree
Showing 31 changed files with 626 additions and 335 deletions.
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/src/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++23",
"intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "mesonbuild.mesonbuild"
}
],
"version": 4
}
34 changes: 34 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/TestByteEngine",
"args": ["--threads 1"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
},
{
"description": "Enable break on all exceptions",
"text": "catch throw",
"ignoreFailures": true
}
]
}
],
}
61 changes: 60 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,65 @@
"fstream": "cpp",
"sstream": "cpp",
"regex": "cpp",
"any": "cpp"
"any": "cpp",
"istream": "cpp",
"ostream": "cpp",
"typeinfo": "cpp",
"algorithm": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cerrno": "cpp",
"chrono": "cpp",
"climits": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"map": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"filesystem": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"limits": "cpp",
"locale": "cpp",
"new": "cpp",
"numbers": "cpp",
"queue": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"cstdbool": "cpp"
}
}
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"problemMatcher": "$gcc",
"group": "build",
"command": "ninja -C build"
}
]
}
57 changes: 25 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,22 @@
cmake_minimum_required(VERSION 3.24)
include(FetchContent)

if(UNIX)
add_compile_options(-mavx2)
endif()

project(ByteEngine LANGUAGES CXX VERSION 1.0.0)

# assimp download
FetchContent_Declare(assimp GIT_REPOSITORY "https://github.com/assimp/assimp" GIT_TAG "141c6ca270aa4d344bdccff4b5387bc55cbeb95c")

set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_ZLIB ON CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_INSTALL_PDB OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_OBJ_IMPORTER ON CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_FBX_IMPORTER ON CACHE INTERNAL "" FORCE)

FetchContent_MakeAvailable(assimp)
# assimp download

# stb
FetchContent_Declare(stb GIT_REPOSITORY "https://github.com/nothings/stb" GIT_TAG "af1a5bc352164740c1cc1354942b1c6b72eacb8a")
FetchContent_MakeAvailable(stb)
# stb
include(FetchContent)

# GTSL
FetchContent_Declare(GTSL GIT_REPOSITORY "https://github.com/Game-Tek/Game-Tek-Standard-Library" GIT_TAG "8277242209c09e922b144caed424f62b4601f6a2")
FetchContent_Declare(GTSL GIT_REPOSITORY "https://github.com/Game-Tek/Game-Tek-Standard-Library" GIT_TAG "889283d1d17aaa0b7478a4cfa68e8781d2dff28e")
FetchContent_MakeAvailable(GTSL)
# GTSL

# ByteEngine options
set(BE_GAPI "vulkan")
set(BE_CSHARP_SCRIPTING true)
set(BE_DEBUG true)
# ByteEngine options

add_library(ByteEngine STATIC "${PROJECT_SOURCE_DIR}/src/ByteEngine/Application/EntryPoint.h"
Expand Down Expand Up @@ -82,20 +63,35 @@ target_include_directories(ByteEngine PUBLIC "${PROJECT_SOURCE_DIR}/src")
target_include_directories(ByteEngine PUBLIC "${PROJECT_SOURCE_DIR}/ext")

# assimp
target_link_libraries(ByteEngine INTERFACE assimp)
target_include_directories(ByteEngine PUBLIC "${assimp_SOURCE_DIR}/include")
target_include_directories(ByteEngine PUBLIC "${assimp_BINARY_DIR}/include")
find_package(assimp CONFIG REQUIRED)

set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_ZLIB ON CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_INSTALL_PDB OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT OFF CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_OBJ_IMPORTER ON CACHE INTERNAL "" FORCE)
set(ASSIMP_BUILD_FBX_IMPORTER ON CACHE INTERNAL "" FORCE)

target_link_libraries(ByteEngine INTERFACE assimp::assimp)
target_include_directories(ByteEngine PUBLIC assimp::assimp)
target_include_directories(ByteEngine INTERFACE assimp_INCLUDE_DIRS)
# assimp

# stb
target_include_directories(ByteEngine PUBLIC "${stb_SOURCE_DIR}")
# stb
find_package(stb REQUIRED)
target_include_directories(ByteEngine PUBLIC stb::stb)

# GTSL
target_include_directories(ByteEngine PUBLIC "${gtsl_SOURCE_DIR}")
target_link_libraries(ByteEngine INTERFACE GTSL)
# GTSL

enable_testing()

add_subdirectory(tests)

if (CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(ByteEngine PUBLIC BE_DEBUG=1)
else()
Expand Down Expand Up @@ -161,7 +157,4 @@ if (UNIX)
target_compile_definitions(ByteEngine PUBLIC BE_VULKAN=0)
target_compile_definitions(ByteEngine PUBLIC BE_DX12=0)
endif()
endif()

install(TARGETS ByteEngine DESTINATION lib)
install(FILES "${PROJECT_SOURCE_DIR}/src/ByteEngine.h" DESTINATION include)
endif()
26 changes: 0 additions & 26 deletions CMakePresets.json

This file was deleted.

9 changes: 9 additions & 0 deletions CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"/home/facundovilla/development/Byte-Engine/build/CMakePresets.json"
]
}
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
meson compile -C build
6 changes: 3 additions & 3 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[requires]
assimp/5.2.2
stb/cci.20210910
stb/cci.20220909

[generators]
cmake_find_package_multi
cmake_find_package
PkgConfigDeps
MesonToolchain
8 changes: 7 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
sudo apt update
sudo apt install vulkan-sdk
# Install Vulkan SDK
# Install Vulkan SDK

conan install . --output-folder=build --build=missing

meson setup --native-file ./build/conan_meson_native.ini build

meson compile -C build
61 changes: 61 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
project('ByteEngine', 'cpp')

src = [
'src/ByteEngine/Application/EntryPoint.h',
'src/ByteEngine/Physics/PhysicsWorld.cpp',
'src/ByteEngine/Render/RenderOrchestrator.cpp',
'src/ByteEngine/Application/AllocatorReferences.cpp',
'src/ByteEngine/Application/PoolAllocator.cpp',
'src/ByteEngine/Application/StackAllocator.cpp',
'src/ByteEngine/Application/SystemAllocator.cpp',
'src/ByteEngine/Application/Templates/GameApplication.cpp',
'src/ByteEngine/Debug/FunctionTimer.cpp',
'src/ByteEngine/Game/ApplicationManager.cpp',
'src/ByteEngine/Object.cpp',
'src/ByteEngine/Render/RendererAllocator.cpp',
'src/ByteEngine/Render/RenderSystem.cpp',
'src/ByteEngine/Game/World.cpp',
'src/ByteEngine/Light.cpp',
'src/ByteEngine/Render/StaticMeshSystem.cpp',
'src/ByteEngine/Render/UIManager.cpp',
'src/ByteEngine/Resources/AnimationResourceManager.cpp',
'src/ByteEngine/Resources/AudioResourceManager.cpp',
'src/ByteEngine/Resources/FontResourceManager.cpp',
'src/ByteEngine/Resources/PipelineCacheResourceManager.cpp',
'src/ByteEngine/Resources/ResourceManager.cpp',
'src/ByteEngine/Resources/StaticMeshResourceManager.cpp',
'src/ByteEngine/Resources/TextureResourceManager.cpp',
'src/ByteEngine/Sound/AudioSystem.cpp',
'src/ByteEngine/Utility/Shapes/Cone.cpp',
'src/ByteEngine/Utility/Shapes/ConeWithFalloff.cpp',
'src/ByteEngine/Application/InputManager.cpp',
'src/ByteEngine/Debug/Logger.cpp',
'src/ByteEngine/Application/ScriptingSystem.cpp',
'src/ByteEngine/Application/Clock.cpp',
'src/ByteEngine/Application/Application.cpp',
'src/ByteEngine/Resources/BC7.cpp',
'src/ByteEngine/Render/WorldRenderPipeline.cpp',
]

assimp = dependency('assimp', version: '>=5.0.0')
stb = dependency('stb')
gtsl = dependency('GTSL')
mono = dependency('mono-2')
monosgen = dependency('monosgen-2')
vulkan = dependency('vulkan')
shaderc = dependency('shaderc')
alsa = dependency('alsa')

args = [
'-mavx',
'-DBE_DEBUG=1', '-DBE_PLATFORM_WINDOWS=0', '-DBE_PLATFORM_LINUX=1', '-DBE_VULKAN=1', '-DBE_DX12=0',
'-Db_sanitize=address',
]

ByteEngine = library('ByteEngine', src, dependencies: [assimp, stb, gtsl, mono, monosgen, vulkan, shaderc, alsa], include_directories: include_directories('src'), cpp_args: args)

test_src = ['tests/TestApplication.cpp']

test = executable('TestByteEngine', test_src, link_with: [ByteEngine], include_directories: include_directories('src'))

test('TestByteEngine', test)
9 changes: 7 additions & 2 deletions src/ByteEngine/Application/AllocatorReferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

#include "Application.h"

void BE::SystemAllocatorReference::Allocate(const uint64 size, const uint64 alignment, void** memory, uint64* allocatedSize) const { (*allocatedSize) = size; application->GetSystemAllocator()->Allocate(size, alignment, memory); }
void BE::SystemAllocatorReference::Allocate(const uint64 size, const uint64 alignment, void** memory, uint64* allocatedSize) const {
(*allocatedSize) = size;
BE::Application::Get()->GetSystemAllocator()->Allocate(size, alignment, memory);
}

void BE::SystemAllocatorReference::Deallocate(const uint64 size, const uint64 alignment, void* memory) const { application->GetSystemAllocator()->Deallocate(size, alignment, memory); }
void BE::SystemAllocatorReference::Deallocate(const uint64 size, const uint64 alignment, void* memory) const {
BE::Application::Get()->GetSystemAllocator()->Deallocate(size, alignment, memory);
}

void BE::TransientAllocatorReference::Allocate(const uint64 size, const uint64 alignment, void** memory, uint64* allocatedSize) const { BE::Application::Get()->GetTransientAllocator()->Allocate(size, alignment, memory, allocatedSize, Name); }

Expand Down
Loading

0 comments on commit efe9122

Please sign in to comment.