Skip to content

Commit bd7215d

Browse files
Merge pull request #5093 from Sonicadvance1/13
SteamRT4: Adds support for building the steam depot
2 parents c460cf0 + f3f134f commit bd7215d

File tree

17 files changed

+599
-111
lines changed

17 files changed

+599
-111
lines changed

.github/workflows/steamrt4.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ env:
1212
BUILD_TYPE: Release
1313
CC: clang
1414
CXX: clang++
15-
FEX_PORTABLE: 1
1615

1716
jobs:
1817
steamrt4_build:
@@ -56,9 +55,25 @@ jobs:
5655
- name: Configure CMake
5756
shell: bash
5857
working-directory: ${{runner.workspace}}/build
59-
run: distrobox enter --name steamrt4 -- cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G Ninja -DENABLE_LTO=False -DENABLE_ASSERTIONS=False -DBUILD_THUNKS=True -DBUILD_FEXCONFIG=False -DBUILD_TESTING=False -DENABLE_CLANG_THUNKS=True -DUSE_LINKER=lld -DCMAKE_INSTALL_PREFIX=${{runner.workspace}}/build/install
58+
run: distrobox enter --name steamrt4 -- cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G Ninja -DBUILD_STEAM_SUPPORT=True -DENABLE_LTO=True -DENABLE_ASSERTIONS=False -DBUILD_THUNKS=True -DBUILD_FEXCONFIG=False -DBUILD_TESTING=False -DENABLE_CLANG_THUNKS=True -DUSE_LINKER=lld -DCMAKE_INSTALL_PREFIX=/usr
6059

6160
- name: Build
6261
working-directory: ${{runner.workspace}}/build
6362
shell: bash
6463
run: distrobox enter --name steamrt4 -- cmake --build . --config $BUILD_TYPE
64+
65+
- name: install
66+
working-directory: ${{runner.workspace}}/build
67+
shell: bash
68+
env:
69+
DESTDIR: ${{runner.workspace}}/install
70+
run: distrobox enter --name steamrt4 -- cmake --build . --config $BUILD_TYPE -t install
71+
- name: Upload libraries
72+
uses: 'actions/upload-artifact@v4'
73+
timeout-minutes: 1
74+
with:
75+
overwrite: true
76+
name: steamrt4_steampipe_depot
77+
path: ${{runner.workspace}}/install/*
78+
retention-days: 1
79+
compression-level: 9

CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ option(ENABLE_FEXCORE_PROFILER "Enables use of the FEXCore timeline profiling ca
3333
set (FEXCORE_PROFILER_BACKEND "gpuvis" CACHE STRING "Set which backend to use for the FEXCore profiler (gpuvis, tracy)")
3434
option(ENABLE_GLIBC_ALLOCATOR_HOOK_FAULT "Enables glibc memory allocation hooking with fault for CI testing")
3535
option(USE_PDB_DEBUGINFO "Builds debug info in PDB format" FALSE)
36+
option(BUILD_STEAM_SUPPORT "Builds FEX for integration into Steam" FALSE)
3637

3738
set (X86_32_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Data/CMake/toolchain_x86_32.cmake" CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting i686")
3839
set (X86_64_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Data/CMake/toolchain_x86_64.cmake" CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting x86_64")
@@ -64,6 +65,10 @@ if (NOT MINGW_BUILD)
6465
endif()
6566
endif()
6667

68+
if (BUILD_STEAM_SUPPORT)
69+
add_definitions(-DFEX_STEAM_SUPPORT=1)
70+
endif()
71+
6772
if (ENABLE_FEXCORE_PROFILER)
6873
add_definitions(-DENABLE_FEXCORE_PROFILER=1)
6974
string(TOUPPER "${FEXCORE_PROFILER_BACKEND}" FEXCORE_PROFILER_BACKEND)
@@ -476,13 +481,16 @@ add_subdirectory(FEXHeaderUtils/)
476481
add_subdirectory(CodeEmitter/)
477482
add_subdirectory(FEXCore/)
478483

479-
if (_M_ARM_64 AND NOT MINGW_BUILD)
484+
if (_M_ARM_64 AND NOT MINGW_BUILD AND NOT BUILD_STEAM_SUPPORT)
480485
# Binfmt_misc files must be installed prior to Source/ installs
481486
add_subdirectory(Data/binfmts/)
482487
endif()
483488

484489
add_subdirectory(Source/)
485-
add_subdirectory(Data/AppConfig/)
490+
491+
if (NOT BUILD_STEAM_SUPPORT)
492+
add_subdirectory(Data/AppConfig/)
493+
endif()
486494

487495
# Install the ThunksDB file
488496
file(GLOB CONFIG_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Data/*.json)
@@ -582,6 +590,10 @@ if (BUILD_THUNKS)
582590
add_dependencies(uninstall uninstall_guest-libs-32)
583591
endif()
584592

593+
if (BUILD_STEAM_SUPPORT)
594+
add_subdirectory(Source/Steam/)
595+
endif()
596+
585597
set(FEX_VERSION_MAJOR "0")
586598
set(FEX_VERSION_MINOR "0")
587599
set(FEX_VERSION_PATCH "0")

FEXCore/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-strict-aliasing> $<$<COMPILE_
7474

7575
add_subdirectory(Source/)
7676

77-
install (DIRECTORY include/FEXCore ${CMAKE_BINARY_DIR}/include/FEXCore
78-
DESTINATION include
79-
COMPONENT Development)
77+
if (NOT BUILD_STEAM_SUPPORT)
78+
install (DIRECTORY include/FEXCore ${CMAKE_BINARY_DIR}/include/FEXCore
79+
DESTINATION include
80+
COMPONENT Development)
81+
endif()
8082

8183
if (BUILD_TESTING)
8284
add_subdirectory(unittests/)

FEXCore/Source/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ add_custom_target(CONFIG_INC
201201
DEPENDS "${OUTPUT_MAN_NAME}"
202202
DEPENDS "${OUTPUT_MAN_NAME_COMPRESS}")
203203

204-
# Install the compressed man page
205-
install(FILES ${OUTPUT_MAN_NAME_COMPRESS} COMPONENT Runtime DESTINATION ${MAN_DIR}/man1)
204+
if (NOT BUILD_STEAM_SUPPORT)
205+
# Install the compressed man page
206+
install(FILES ${OUTPUT_MAN_NAME_COMPRESS} COMPONENT Runtime DESTINATION ${MAN_DIR}/man1)
207+
endif()
206208

207209
# Add in diagnostic colours if the option is available.
208210
# Ninja code generator will kill colours if this isn't here
@@ -289,7 +291,7 @@ AddObject(${PROJECT_NAME}_object OBJECT)
289291
AddLibrary(${PROJECT_NAME} STATIC)
290292
AddLibrary(${PROJECT_NAME}_shared SHARED)
291293

292-
if (NOT MINGW_BUILD)
294+
if (NOT MINGW_BUILD AND NOT BUILD_STEAM_SUPPORT)
293295
install(TARGETS ${PROJECT_NAME}_shared
294296
LIBRARY
295297
DESTINATION ${CMAKE_INSTALL_LIBDIR}

FEXCore/include/FEXCore/Utils/StringUtils.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,19 @@ inline fextl::string Trim(fextl::string String, std::string_view TrimTokens = "
2828
return RightTrim(LeftTrim(std::move(String), TrimTokens), TrimTokens);
2929
}
3030

31+
inline fextl::string& ReplaceAllInPlace(fextl::string& Str, std::string_view Token, std::string_view New) {
32+
const auto OriginalTokenSize = Token.size();
33+
const auto NewTokenSize = New.size();
34+
35+
size_t TokenPos {};
36+
auto TokenIter = Str.find(Token, TokenPos);
37+
while (TokenIter != Str.npos) {
38+
Str.replace(TokenIter, OriginalTokenSize, New);
39+
TokenPos += NewTokenSize;
40+
TokenIter = Str.find(Token, TokenPos);
41+
}
42+
43+
return Str;
44+
}
45+
3146
} // namespace FEXCore::StringUtils

Source/Common/Config.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,13 @@ const char* GetHomeDirectory() {
542542
#endif
543543

544544
fextl::string GetDataDirectory(bool Global, const PortableInformation& PortableInfo) {
545+
#ifdef FEX_STEAM_SUPPORT
546+
const char* SteamDataPath = getenv("STEAM_COMPAT_DATA_PATH");
547+
if (SteamDataPath) {
548+
return fextl::fmt::format("{}/fex-emu/", SteamDataPath);
549+
}
550+
#endif
551+
545552
const char* DataOverride = getenv("FEX_APP_DATA_LOCATION");
546553

547554
if (PortableInfo.IsPortable && (Global || !DataOverride)) {
@@ -566,6 +573,13 @@ fextl::string GetDataDirectory(bool Global, const PortableInformation& PortableI
566573
}
567574

568575
fextl::string GetConfigDirectory(bool Global, const PortableInformation& PortableInfo) {
576+
#ifdef FEX_STEAM_SUPPORT
577+
const char* SteamDataPath = getenv("STEAM_COMPAT_DATA_PATH");
578+
if (SteamDataPath) {
579+
return fextl::fmt::format("{}/fex-emu/", SteamDataPath);
580+
}
581+
#endif
582+
569583
const char* ConfigOverride = getenv("FEX_APP_CONFIG_LOCATION");
570584
if (PortableInfo.IsPortable && (Global || !ConfigOverride)) {
571585
return fextl::fmt::format("{}/fex-emu/", PortableInfo.InterpreterPath);
@@ -608,6 +622,13 @@ fextl::string GetCacheDirectory() {
608622
return CacheOverride;
609623
}
610624

625+
#ifdef FEX_STEAM_SUPPORT
626+
const char* SteamDataPath = getenv("STEAM_COMPAT_SHADER_PATH");
627+
if (SteamDataPath) {
628+
return fextl::fmt::format("{}/fex-emu/", SteamDataPath);
629+
}
630+
#endif
631+
611632
const char* HomeDir = GetHomeDirectory();
612633
const char* CacheXDG = getenv("XDG_CACHE_HOME");
613634
return (CacheXDG ? fextl::string {CacheXDG} : (fextl::string {HomeDir} + "/.cache")) + "/fex-emu/";

0 commit comments

Comments
 (0)