Skip to content

Commit

Permalink
added macos support to cmake/vscode/gdext project files
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlac committed Oct 12, 2023
1 parent 1639221 commit 24dcab0
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 47 deletions.
11 changes: 9 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@
"configurationProvider": "ms-vscode.cmake-tools",
"intelliSenseMode": "linux-gcc-x64",
"cppStandard": "gnu++23",
"compilerPath": "/usr/bin/g++"
"compilerPath": "g++"
},
{
"name": "GDNative C++ (Clang)",
"configurationProvider": "ms-vscode.cmake-tools",
"intelliSenseMode": "linux-clang-x64",
"cppStandard": "gnu++23",
"compilerPath": "/usr/bin/clang++"
"compilerPath": "clang++"
},
{
"name": "Mac GDNative C++ (Clang)",
"configurationProvider": "ms-vscode.cmake-tools",
"intelliSenseMode": "macos-clang-x64",
"cppStandard": "gnu++23",
"compilerPath": "clang++"
},
{
"name": "GDNative C++ (MSVC)",
Expand Down
43 changes: 43 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,49 @@
"visualizerFile": "${workspaceFolder}/extern/godot-engine/platform/windows/godot.natvis",
"internalConsoleOptions": "openOnSessionStart",
"console": "internalConsole",
},
{
"name": "project (lldb)",
"type": "lldb",
"request": "launch",
"cwd": "${workspaceFolder}",
"args": [
"--debug",
"--verbose",
"--path",
"${workspaceFolder}/project"
],
"linux": {
"program": "${workspaceFolder}/extern/godot-engine/bin/godot.linuxbsd.editor.dev.x86_64"
},
"windows": {
"program": "${workspaceFolder}/extern/godot-engine/bin/godot.windows.editor.dev.x86_64.exe"
},
"osx": {
"program": "${workspaceFolder}/extern/godot-engine/bin/godot.macos.editor.dev.arm64"
}
},
{
"name": "editor (lldb)",
"type": "lldb",
"request": "launch",
"cwd": "${workspaceFolder}",
"args": [
"--editor",
"--debug",
"--verbose",
"--path",
"${workspaceFolder}/project"
],
"linux": {
"program": "${workspaceFolder}/extern/godot-engine/bin/godot.linuxbsd.editor.dev.x86_64"
},
"windows": {
"program": "${workspaceFolder}/extern/godot-engine/bin/godot.windows.editor.dev.x86_64.exe"
},
"osx": {
"program": "${workspaceFolder}/extern/godot-engine/bin/godot.macos.editor.dev.arm64"
}
}
]
}
18 changes: 10 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/src"
)

# linker options for the gdextension library
target_link_options(${PROJECT_NAME} PRIVATE
$<$<NOT:${compiler_is_msvc}>:
-static-libgcc
-static-libstdc++
-Wl,-R,'$$ORIGIN'
>
)
if (NOT APPLE)
# linker options for the gdextension library
target_link_options(${PROJECT_NAME} PRIVATE
$<$<NOT:${compiler_is_msvc}>:
-static-libgcc
-static-libstdc++
-Wl,-R,'$$ORIGIN'
>
)
endif()

# =======================================================================
# Optional configuration / build features
Expand Down
11 changes: 8 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"environment": {
"NINJA_STATUS": "%p [%es] (%f/%t) -"
}
Expand All @@ -29,7 +33,8 @@
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
"CMAKE_CXX_COMPILER": "cl",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md"
},
"condition": {
"type": "equals",
Expand Down Expand Up @@ -108,9 +113,9 @@
"CMAKE_CXX_COMPILER": "clang++"
},
"condition": {
"type": "equals",
"type": "notEquals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
"rhs": "Windows"
}
},
{
Expand Down
22 changes: 15 additions & 7 deletions cmake/godot-dev-configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ endif()
# Godot editor/engine debug build
# =======================================================================

string(TOLOWER "${CMAKE_SYSTEM_NAME}" host_os)

# define variable to be used in the engine build when specifying platform.
set(host_os_engine "${host_os}")
if(UNIX)
if (APPLE)
# ${CMAKE_SYSTEM_NAME} returns Darwin, but the scons platform name will be macos
set(host_os_engine "macos")
elseif(UNIX)
# the scons build expects linuxbsd to be passed in as the platform
# when building on linux, so just append bsd to CMAKE_SYSTEM_NAME
set(host_os_engine "${host_os}bsd")
Expand All @@ -70,16 +75,19 @@ message(NOTICE "godot_debug_editor_executable = ${godot_debug_editor_executable}
if(NOT EXISTS "${godot_debug_editor_executable}")
message("Godot engine debug binaries not found, invoking debug build of engine...")

execute_process(
COMMAND scons platform=${host_os} arch=x64 target=editor use_static_cpp=yes dev_build=yes debug_symbols=yes optimize=none use_lto=no --clean
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/godot-engine"
COMMAND_ERROR_IS_FATAL ANY
)
set(GODOT_ENGINE_CLEAN_BUILD OFF)
if (GODOT_ENGINE_CLEAN_BUILD MATCHES ON)
execute_process(
COMMAND "${SCONS_PROGRAM}" arch=x64 target=editor use_static_cpp=yes dev_build=yes debug_symbols=yes optimize=none use_lto=no --clean
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/godot-engine"
COMMAND_ERROR_IS_FATAL ANY
)
endif()

# this build should only ever need to be run once (unless the enging debug binaries
# are deleted or you want to change the build configuration/command invoked below).
execute_process(
COMMAND scons platform=${host_os} arch=x64 target=editor use_static_cpp=yes dev_build=yes debug_symbols=yes optimize=none use_lto=no
COMMAND "${SCONS_PROGRAM}" arch=x64 target=editor use_static_cpp=yes dev_build=yes debug_symbols=yes optimize=none use_lto=no
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extern/godot-engine"
COMMAND_ERROR_IS_FATAL ANY
)
Expand Down
26 changes: 25 additions & 1 deletion cmake/vcpkg-init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,33 @@ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/extern/vcpkg/ports")
)
endif()

# =======================================================================
# VCPKG triplet definition (should enforce static linkage for all deps)
# This would typically be passed in from CMakePresets.json, but if
# the cmake configuration is invoked without using a preset this fallback
# should define a preset that prefers static linkage for 3rd party libs.
# =======================================================================

if (NOT VCPKG_TARGET_TRIPLET)
if (WIN32)
# static-md enforces static linkage to all dependencies,
# as well as dynamic linkage to the C runtime for consistency.
# if this gives you trouble change to "x64-windows-static".
set(VCPKG_TARGET_TRIPLET "x64-windows-static-md")
elseif(APPLE)
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(VCPKG_TARGET_TRIPLET "arm64-macos")
else()
set(VCPKG_TARGET_TRIPLET "x64-macos")
endif()
elseif(UNIX)
set(VCPKG_TARGET_TRIPLET "x64-linux")
endif()
endif()

# =======================================================================
# Define VCPKG toolchain file. This would typically be passed in from
# CMakePresets.json, but if the cmake configuration is invoked without
# CMakePresets.json, but if the cmake configuration is invoked without
# using a preset this fallback should detect that the path is missing.
# =======================================================================
if(NOT CMAKE_TOOLCHAIN_FILE)
Expand Down
7 changes: 0 additions & 7 deletions cmake/vcpkg-install-deps.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# =======================================================================
# VCPKG triplet definition (should enforce static linkage for all deps)
# =======================================================================

string(TOLOWER "${CMAKE_SYSTEM_NAME}" host_os)
set(VCPKG_TARGET_TRIPLET "x64-${host_os}-static")

# =======================================================================
# VCPKG bootstrap / initialization.
# =======================================================================
Expand Down
11 changes: 0 additions & 11 deletions project/bin/roguelite.gdextension

This file was deleted.

13 changes: 13 additions & 0 deletions project/roguelite.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[configuration]

entry_symbol = "extension_library_init"
compatibility_minimum = 4.1

[libraries]

windows.debug.x86_64 = "res://bin/roguelite.windows.64.debug.dll"
windows.release.x86_64 = "res://bin/roguelite.windows.64.release.dll"
linux.debug.x86_64 = "res://bin/libroguelite.linux.64.debug.so"
linux.release.x86_64 = "res://bin/libroguelite.linux.64.release.so"
macos.debug = "res://bin/libroguelite.darwin.64.debug.dylib"
macos.release = "res://bin/libroguelite.darwin.64.release.dylib"
6 changes: 3 additions & 3 deletions src/entity/character/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ namespace rl
if (m_character_controller != nullptr)
{
signal<event::character_move>::connect<CharacterController>(m_character_controller)
<=> slot(this, on_character_movement);
<=> signal_callback(this, on_character_movement);

signal<event::character_rotate>::connect<CharacterController>(m_character_controller)
<=> slot(this, on_character_rotate);
<=> signal_callback(this, on_character_rotate);

signal<event::character_shoot>::connect<CharacterController>(m_character_controller)
<=> slot(this, on_character_shoot);
<=> signal_callback(this, on_character_shoot);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/entity/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ namespace rl
if (controller != nullptr)
{
signal<event::position_changed>::connect<CharacterController>(controller)
<=> slot(this, on_character_position_changed);
<=> signal_callback(this, on_character_position_changed);

signal<event::spawn_projectile>::connect<Player>(m_player)
<=> slot(this, on_player_spawn_projectile);
<=> signal_callback(this, on_player_spawn_projectile);
}
}

Expand Down Expand Up @@ -100,10 +100,10 @@ namespace rl
projectile->set_rotation(firing_pt->get_global_rotation());

signal<event::body_entered>::connect<Projectile>(projectile)
<=> slot(this, on_physics_box_entered);
<=> signal_callback(this, on_physics_box_entered);

signal<event::body_exited>::connect<Projectile>(projectile)
<=> slot(this, on_physics_box_exited);
<=> signal_callback(this, on_physics_box_exited);
}

this->add_child(projectile);
Expand Down
2 changes: 1 addition & 1 deletion src/util/bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#define bind_member_function(class_name, func_name) method<&class_name::func_name>::bind(#func_name)

#define slot(slot_owner, slot_callback) \
#define signal_callback(slot_owner, slot_callback) \
std::forward_as_tuple(godot::Callable(slot_owner, #slot_callback), slot_owner)

#define bind_property(class_name, prop_name, prop_type) \
Expand Down

0 comments on commit 24dcab0

Please sign in to comment.