Skip to content

Commit

Permalink
Add RmlUi to build system
Browse files Browse the repository at this point in the history
Not all is ready and there will be more work needed on build system, but
the basic integration of RmlUi Core is done.

- I've not created and linked any of the provided GL3 or SDL backends,
  that needs separate work
- Lua bindings are blocked on mikke89/RmlUi#302
  we need to find some workaround for that
- Tracy integration is blocked on mikke89/RmlUi#516
  • Loading branch information
p2004a committed Sep 30, 2023
1 parent 490e7ab commit dba9934
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@
[submodule "rts/lib/entt"]
path = rts/lib/entt
url = https://github.com/skypjack/entt
[submodule "rts/lib/RmlUi"]
path = rts/lib/RmlUi
url = https://github.com/mikke89/RmlUi.git
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ else()
set(JAVA_COMPILE_FLAG_CONDITIONAL "-g:lines,source")
endif()

# By default, the libraries that don't explicily specify SHARED/STATIC are build statically.
# See https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html
option(BUILD_SHARED_LIBS "Build shared (dynamic) libraries" OFF)

# Tell windows to pass arguments around in @response files
# (32k arg limit workaround)
Expand Down
17 changes: 17 additions & 0 deletions rts/System/SpringApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <iostream>
#include <chrono>

// Include before other headers that define a bunch of macros that break stuff.
#include <RmlUi/Core.h>

#include <SDL.h>
#include <System/GflagsExt.h>

Expand Down Expand Up @@ -216,6 +219,17 @@ SpringApp::~SpringApp()
spring_clock::PopTickRate();
}

class DummyRmlUiSpringSystemInterface : public Rml::SystemInterface {
public:
double GetElapsedTime() override {
return 0.0;
}

private:
std::chrono::steady_clock::time_point start;
};

static DummyRmlUiSpringSystemInterface dummyRmlUiSpringSystemInterface;

/**
* @brief Initializes the SpringApp instance
Expand All @@ -241,6 +255,9 @@ bool SpringApp::Init()
Watchdog::Install();
Watchdog::RegisterThread(WDT_MAIN, true);

// A dummy call to basic RmlUi function to verify that all is linking correctly.
Rml::SetSystemInterface(&dummyRmlUiSpringSystemInterface);

// Create Window
if (!InitWindow(("Spring " + SpringVersion::GetSync()).c_str())) {
SDL_Quit();
Expand Down
1 change: 1 addition & 0 deletions rts/builds/headless/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ list(APPEND engineHeadlessLibraries ${engineCommonLibraries})
list(APPEND engineHeadlessLibraries no-sound)
list(APPEND engineHeadlessLibraries engineSim)
list(APPEND engineHeadlessLibraries pr-downloader)
list(APPEND engineHeadlessLibraries RmlCore)

include_directories(${ENGINE_SRC_ROOT_DIR}/lib/assimp/include)
include_directories(${ENGINE_SRC_ROOT_DIR}/lib/asio/include)
Expand Down
2 changes: 2 additions & 0 deletions rts/builds/legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if (FONTCONFIG_FOUND)
endif (PREFER_STATIC_LIBS)
endif (FONTCONFIG_FOUND)

# !!! If you change freetype resolution here, change it also in rts/lib
find_freetype_hack() # hack to find different named freetype.dll
find_package_static(Freetype REQUIRED)
foreach(f ${FREETYPE_INCLUDE_DIRS})
Expand Down Expand Up @@ -64,6 +65,7 @@ list(APPEND engineLibraries ${engineCommonLibraries})
list(APPEND engineLibraries ${SPRING_SIM_LIBRARIES})
list(APPEND engineLibraries engineSim)
list(APPEND engineLibraries pr-downloader)
list(APPEND engineLibraries RmlCore)

### Assemble external incude dirs
list(APPEND engineIncludes ${OPENAL_INCLUDE_DIR})
Expand Down
17 changes: 17 additions & 0 deletions rts/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,20 @@ option(TRACY_ON_DEMAND "Enable tracy profiling" ON)
option(TRACY_PROFILE_MEMORY "Profile memory allocations" OFF)

add_subdirectory(tracy)

# TODO(p2004): Enabling tracy for RmlUi is at the momemnt broken and waits for
# resolution upstream https://github.com/mikke89/RmlUi/issues/516.
# if (TRACY_ENABLE)
# set(ENABLE_TRACY_PROFILING ON CACHE BOOL "Enable RmlUi tracy profiling")
# # Place the include directories for tracy in TRACY_INCLUDE_DIR as that's
# # what RmlUi expects to be set in their FindTracy.cmake
# get_target_property(TRACY_INCLUDE_DIR TracyClient INCLUDE_DIRECTORIES)
# endif()

# We resolve freetype here to make sure RmlUi find_package picks the same
# correct version as picked by the engine.
# !!! If you change freetype resolution here, change it also in rts/builds/legacy
find_freetype_hack() # hack to find different named freetype.dll
find_package_static(Freetype REQUIRED)

add_subdirectory(RmlUi)
1 change: 1 addition & 0 deletions rts/lib/RmlUi
Submodule RmlUi added at a602da

0 comments on commit dba9934

Please sign in to comment.