Fix linux build

This commit is contained in:
acidicoala
2025-09-19 17:03:11 +05:00
parent a7b95fc907
commit d8cdf41439
12 changed files with 50 additions and 27 deletions

View File

@@ -4,6 +4,8 @@
<w>abcdefghijklmnopqrstuvwxyz</w>
<w>acidicoala</w>
<w>ajaxgetdlclist</w>
<w>dlmopen</w>
<w>dlopen</w>
<w>indicies</w>
<w>inlinentd</w>
<w>isteamapps</w>
@@ -13,6 +15,7 @@
<w>koalabox</w>
<w>koality</w>
<w>koaloader</w>
<w>libgtk</w>
<w>polyhook</w>
<w>simplecpp</w>
<w>steamapps</w>

View File

@@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="exports_generator [32] [linux]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="FALSE libsteam_api_o $ProjectFileDir$/res/steamworks/*/binaries/linux32/libsteam_api.so $CMakeCurrentGenerationDir$/generated/libsteam_api_exports.cpp" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="exports_generator" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="exports_generator">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -1,7 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="exports_generator [64]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="FALSE steam_api64_o $ProjectFileDir$/res/steamworks/*/binaries/steam_api64.dll $CMakeCurrentGenerationDir$/generated/linker_exports_for_steam_api.h" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="exports_generator" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="exports_generator">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="exports_generator [64] [win]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="FALSE steam_api64_o $ProjectFileDir$/res/steamworks/*/binaries/steam_api64.dll $CMakeCurrentGenerationDir$/generated/linker_exports_for_steam_api.h" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="exports_generator" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="exports_generator">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="steamworks_parser" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$ProjectFileDir$/res/" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="steamworks_parser" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="steamworks_parser">
<configuration default="false" name="steamworks_parser" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$ProjectFileDir$/res/" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="steamworks_parser" CONFIG_NAME="Debug [64]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="steamworks_parser">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>

View File

@@ -86,9 +86,16 @@ target_link_libraries(SmokeAPI_static PUBLIC SmokeAPI::common)
add_library(SmokeAPI SHARED ${SMOKE_API_SOURCES})
target_link_libraries(SmokeAPI PUBLIC SmokeAPI::common)
set_target_properties(SmokeAPI PROPERTIES OUTPUT_NAME ${SMOKE_API_FILENAME})
configure_include_directories()
## https://github.com/batterycenter/embed
target_compile_definitions(SmokeAPI PUBLIC B_PRODUCTION_MODE)
CPMAddPackage(
URI "gh:batterycenter/embed@1.2.19"
OPTIONS "B_PRODUCTION_MODE ON"
)
b_embed(SmokeAPI "res/interface_lookup.json")
if(WIN32)
configure_version_resource(
TARGET SmokeAPI
@@ -110,19 +117,11 @@ if(WIN32)
DLL_FILES_GLOB "C:/Windows/System32/version.dll"
)
else()
configure_linker_exports(
TARGET SmokeAPI
HEADER_NAME "libsteam_api_exports.cpp"
FORWARDED_DLL "${STEAM_API_MODULE}_o.so"
DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${LINUX_DIR}/${STEAM_API_MODULE}.so"
INPUT_SOURCES_DIR ""
)
# configure_linker_exports(
# TARGET SmokeAPI
# HEADER_NAME "libsteam_api_exports.cpp"
# FORWARDED_DLL "${STEAM_API_MODULE}_o.so"
# DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${LINUX_DIR}/${STEAM_API_MODULE}.so"
# INPUT_SOURCES_DIR ""
# )
endif()
## https://github.com/batterycenter/embed
target_compile_definitions(SmokeAPI PUBLIC B_PRODUCTION_MODE)
CPMAddPackage(
URI "gh:batterycenter/embed@1.2.19"
OPTIONS "B_PRODUCTION_MODE ON"
)
b_embed(SmokeAPI "res/interface_lookup.json")

View File

@@ -180,7 +180,12 @@ namespace smoke_api {
AppId_t get_app_id() {
try {
const auto app_id_str = kb::util::get_env_var("SteamAppId");
const auto* const app_id_str = std::getenv("SteamAppId");
if(app_id_str == nullptr) {
LOG_WARN("No SteamAppId is set in current environment");
return 0;
}
static auto app_id = std::stoi(app_id_str);
return app_id;
} catch(const std::exception& e) {

View File

@@ -2,11 +2,15 @@
#include <nlohmann/json.hpp>
#include <koalabox/core.hpp>
#include <koalabox/hook.hpp>
#ifdef KB_WIN
#define VIRTUAL(TYPE) __declspec(noinline) TYPE __fastcall // NOLINT(*-macro-parentheses)
#define C_DECL(TYPE) extern "C" __declspec(noinline) TYPE __cdecl
#elifdef KB_LINUX
#define VIRTUAL(TYPE) __attribute__ ((__noinline__)) TYPE
#define C_DECL(TYPE) extern "C" __attribute__ ((__noinline__)) TYPE
#endif
// These macros are meant to be used for callbacks that should return original result

View File

@@ -67,6 +67,11 @@ namespace {
return fs::path();
}
);
// TODO: Some older libsteam_api.so binaries have set the `PF_X` flag from `PT_GNU_STACK`.
// This prevents us from loading them on modern Linux distros. Hence, we need to
// clear it using tools like elfio or libelf.
// Affected versions (all 32-bit): 106-107
}
void download_sdk(const fs::path& steamworks_dir, const std::string_view& version) {