mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-05 21:15:39 -05:00
[WIP] Linux support
This commit is contained in:
@@ -70,4 +70,5 @@ misc-*,
|
|||||||
-readability-function-cognitive-complexity,
|
-readability-function-cognitive-complexity,
|
||||||
-*-include-cleaner,
|
-*-include-cleaner,
|
||||||
-*-lambda-function-name,
|
-*-lambda-function-name,
|
||||||
-*-err58-cpp'
|
-*-err58-cpp,
|
||||||
|
-*-misplaced-const'
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ include(KoalaBox/cmake/KoalaBox.cmake)
|
|||||||
add_subdirectory(KoalaBox)
|
add_subdirectory(KoalaBox)
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
|
|
||||||
set_32_and_64(STEAMAPI_DLL steam_api)
|
|
||||||
set_32_and_64(STEAMCLIENT_DLL steamclient)
|
|
||||||
set_32_and_64(STEAM_API_DLL steam_api steam_api64)
|
|
||||||
set_32_and_64(SMOKEAPI_DLL SmokeAPI32 SmokeAPI64)
|
|
||||||
|
|
||||||
configure_build_config(extra_build_config)
|
configure_build_config(extra_build_config)
|
||||||
|
|
||||||
set(SMOKE_API_STATIC_SOURCES
|
set(SMOKE_API_STATIC_SOURCES
|
||||||
@@ -50,9 +45,22 @@ set(SMOKE_API_SOURCES
|
|||||||
src/steam_api/steam_interfaces.cpp
|
src/steam_api/steam_interfaces.cpp
|
||||||
src/steam_api/steam_interfaces.hpp
|
src/steam_api/steam_interfaces.hpp
|
||||||
src/steamclient/steamclient.cpp
|
src/steamclient/steamclient.cpp
|
||||||
src/main.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set_32_and_64(STEAM_API_MODULE steam_api)
|
||||||
|
set_32_and_64(STEAMCLIENT_DLL steamclient)
|
||||||
|
|
||||||
|
list(APPEND SMOKE_API_SOURCES src/main_win.cpp)
|
||||||
|
else()
|
||||||
|
set_32_and_64(LINUX_DIR linux32 linux64)
|
||||||
|
set(STEAM_API_MODULE libsteam_api)
|
||||||
|
set(STEAMCLIENT_DLL steamclient)
|
||||||
|
|
||||||
|
list(APPEND SMOKE_API_SOURCES src/main_linux.cpp)
|
||||||
|
endif()
|
||||||
|
set_32_and_64(SMOKE_API_FILENAME smoke_api32 smoke_api64)
|
||||||
|
|
||||||
### SmokeAPI interface
|
### SmokeAPI interface
|
||||||
|
|
||||||
add_library(SmokeAPI_common INTERFACE)
|
add_library(SmokeAPI_common INTERFACE)
|
||||||
@@ -73,35 +81,46 @@ target_link_libraries(SmokeAPI_static PUBLIC SmokeAPI::common)
|
|||||||
|
|
||||||
### Shared SmokeAPI
|
### Shared SmokeAPI
|
||||||
|
|
||||||
add_library(SmokeAPI SHARED ${SMOKE_API_SOURCES} ${VERSION_RESOURCE})
|
add_library(SmokeAPI SHARED ${SMOKE_API_SOURCES})
|
||||||
target_link_libraries(SmokeAPI PUBLIC SmokeAPI::common)
|
target_link_libraries(SmokeAPI PUBLIC SmokeAPI::common)
|
||||||
set_target_properties(SmokeAPI PROPERTIES RUNTIME_OUTPUT_NAME ${SMOKEAPI_DLL})
|
set_target_properties(SmokeAPI PROPERTIES OUTPUT_NAME ${SMOKE_API_FILENAME})
|
||||||
configure_version_resource(
|
|
||||||
TARGET SmokeAPI
|
|
||||||
FILE_DESC "Steamworks DLC unlocker"
|
|
||||||
ORIG_NAME ${SMOKEAPI_DLL}
|
|
||||||
)
|
|
||||||
configure_include_directories()
|
configure_include_directories()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
configure_version_resource(
|
||||||
|
TARGET SmokeAPI
|
||||||
|
FILE_DESC "Steamworks DLC unlocker"
|
||||||
|
ORIG_NAME ${SMOKE_API_FILENAME}
|
||||||
|
)
|
||||||
|
configure_linker_exports(
|
||||||
|
TARGET SmokeAPI
|
||||||
|
HEADER_NAME "linker_exports_for_steam_api.h"
|
||||||
|
FORWARDED_DLL "${STEAM_API_MODULE}_o"
|
||||||
|
INPUT_SOURCES_DIR ""
|
||||||
|
DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${STEAM_API_MODULE}.dll"
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_linker_exports(
|
||||||
|
TARGET SmokeAPI
|
||||||
|
HEADER_NAME "linker_exports_for_version.h"
|
||||||
|
FORWARDED_DLL "C:/Windows/System32/version.dll"
|
||||||
|
INPUT_SOURCES_DIR ""
|
||||||
|
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 ""
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
## https://github.com/batterycenter/embed
|
## https://github.com/batterycenter/embed
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
URI "gh:batterycenter/embed@1.2.19"
|
URI "gh:batterycenter/embed@1.2.19"
|
||||||
OPTIONS "B_PRODUCTION_MODE ON"
|
OPTIONS "B_PRODUCTION_MODE ON"
|
||||||
)
|
)
|
||||||
b_embed(SmokeAPI "res/interface_lookup.json")
|
b_embed(SmokeAPI "res/interface_lookup.json")
|
||||||
|
|
||||||
configure_linker_exports(
|
|
||||||
TARGET SmokeAPI
|
|
||||||
HEADER_NAME "linker_exports_for_steam_api"
|
|
||||||
FORWARDED_DLL "${STEAMAPI_DLL}_o"
|
|
||||||
INPUT_SOURCES_DIR ""
|
|
||||||
DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${STEAM_API_DLL}.dll"
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_linker_exports(
|
|
||||||
TARGET SmokeAPI
|
|
||||||
HEADER_NAME "linker_exports_for_version"
|
|
||||||
FORWARDED_DLL "C:/Windows/System32/version.dll"
|
|
||||||
INPUT_SOURCES_DIR ""
|
|
||||||
DLL_FILES_GLOB "C:/Windows/System32/version.dll"
|
|
||||||
)
|
|
||||||
|
|||||||
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: 92749037d5...cbf46eba34
20
src/main_linux.cpp
Normal file
20
src/main_linux.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#include "smoke_api/smoke_api.hpp"
|
||||||
|
|
||||||
|
extern "C" void __attribute__((constructor)) on_loaded() {
|
||||||
|
// On linux we don't automatically get current module handle,
|
||||||
|
// hence we get it manually
|
||||||
|
Dl_info info;
|
||||||
|
if(dladdr(reinterpret_cast<void*>(&on_loaded), &info) && info.dli_fname) {
|
||||||
|
void* handle = dlopen(info.dli_fname, RTLD_NOW | RTLD_NOLOAD);
|
||||||
|
smoke_api::init(handle);
|
||||||
|
} else {
|
||||||
|
OutputDebugString("Initialization error: failed to get own module handle.");
|
||||||
|
DebugBreak();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void __attribute__((destructor)) on_unloaded() {
|
||||||
|
smoke_api::shutdown();
|
||||||
|
}
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
#include <koalabox/hook.hpp>
|
#include <koalabox/hook.hpp>
|
||||||
#include <koalabox/loader.hpp>
|
#include <koalabox/loader.hpp>
|
||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
|
#include <koalabox/module.hpp>
|
||||||
#include <koalabox/path.hpp>
|
#include <koalabox/path.hpp>
|
||||||
#include <koalabox/paths.hpp>
|
#include <koalabox/paths.hpp>
|
||||||
#include <koalabox/util.hpp>
|
#include <koalabox/util.hpp>
|
||||||
#include <koalabox/win.hpp>
|
|
||||||
|
|
||||||
#include "smoke_api.hpp"
|
#include "smoke_api.hpp"
|
||||||
|
|
||||||
@@ -41,16 +41,17 @@
|
|||||||
namespace {
|
namespace {
|
||||||
namespace kb = koalabox;
|
namespace kb = koalabox;
|
||||||
|
|
||||||
HMODULE original_steamapi_handle = nullptr;
|
void* original_steamapi_handle = nullptr;
|
||||||
|
|
||||||
std::set<std::string> find_steamclient_versions(const HMODULE steamapi_handle) {
|
std::set<std::string> find_steamclient_versions(const HMODULE steamapi_handle) {
|
||||||
std::set<std::string> versions;
|
std::set<std::string> versions;
|
||||||
|
|
||||||
const auto rdata = kb::win::get_pe_section_or_throw(steamapi_handle, ".rdata").to_string();
|
const auto rdata_section = kb::module::get_section_or_throw(steamapi_handle, kb::module::CONST_STR_SECTION);
|
||||||
|
const auto rdata = rdata_section.to_string();
|
||||||
|
|
||||||
const std::regex pattern(R"(SteamClient\d{3})");
|
const std::regex pattern(R"(SteamClient\d{3})");
|
||||||
auto matches_begin = std::sregex_iterator(rdata.begin(), rdata.end(), pattern);
|
const auto matches_begin = std::sregex_iterator(rdata.begin(), rdata.end(), pattern);
|
||||||
auto matches_end = std::sregex_iterator();
|
const auto matches_end = std::sregex_iterator();
|
||||||
|
|
||||||
for(std::sregex_iterator i = matches_begin; i != matches_end; ++i) {
|
for(std::sregex_iterator i = matches_begin; i != matches_end; ++i) {
|
||||||
versions.insert(i->str());
|
versions.insert(i->str());
|
||||||
@@ -60,16 +61,16 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper disable once CppDFAConstantFunctionResult
|
// ReSharper disable once CppDFAConstantFunctionResult
|
||||||
bool on_steamclient_loaded(const HMODULE steamclient_handle) noexcept {
|
bool on_steamclient_loaded(const HMODULE steamclient_handle) {
|
||||||
auto* const steamapi_handle = original_steamapi_handle
|
auto* const steamapi_handle = original_steamapi_handle
|
||||||
? original_steamapi_handle
|
? original_steamapi_handle
|
||||||
: GetModuleHandle(TEXT(STEAMAPI_DLL));
|
: kb::module::get_library_handle(TEXT(STEAMAPI_DLL));
|
||||||
if(!steamapi_handle) {
|
if(!steamapi_handle) {
|
||||||
LOG_ERROR("{} -> {} is not loaded", __func__, STEAMAPI_DLL);
|
LOG_ERROR("{} -> {} is not loaded", __func__, STEAMAPI_DLL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const auto CreateInterface$ = KB_WIN_GET_PROC(steamclient_handle, CreateInterface);
|
static const auto CreateInterface$ = KB_MOD_GET_FUNC(steamclient_handle, CreateInterface);
|
||||||
|
|
||||||
const auto steamclient_versions = find_steamclient_versions(steamapi_handle);
|
const auto steamclient_versions = find_steamclient_versions(steamapi_handle);
|
||||||
for(const auto& steamclient_version : steamclient_versions) {
|
for(const auto& steamclient_version : steamclient_versions) {
|
||||||
@@ -110,7 +111,7 @@ namespace smoke_api {
|
|||||||
LOG_INFO("{} v{} | Built at '{}'", PROJECT_NAME, PROJECT_VERSION, __TIMESTAMP__);
|
LOG_INFO("{} v{} | Built at '{}'", PROJECT_NAME, PROJECT_VERSION, __TIMESTAMP__);
|
||||||
LOG_DEBUG("Parsed config:\n{}", nlohmann::ordered_json(config::instance).dump(2));
|
LOG_DEBUG("Parsed config:\n{}", nlohmann::ordered_json(config::instance).dump(2));
|
||||||
|
|
||||||
const auto exe_path = kb::win::get_module_path(nullptr);
|
const auto exe_path = kb::module::get_fs_path(nullptr);
|
||||||
const auto exe_name = kb::path::to_str(exe_path.filename());
|
const auto exe_name = kb::path::to_str(exe_path.filename());
|
||||||
|
|
||||||
LOG_DEBUG("Process name: '{}' [{}-bit]", exe_name, kb::util::BITNESS);
|
LOG_DEBUG("Process name: '{}' [{}-bit]", exe_name, kb::util::BITNESS);
|
||||||
@@ -136,14 +137,14 @@ namespace smoke_api {
|
|||||||
|
|
||||||
LOG_INFO("Initialization complete");
|
LOG_INFO("Initialization complete");
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
kb::util::panic(fmt::format("Initialization error: {}", e.what()));
|
kb::util::panic(std::format("Initialization error: {}", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown() {
|
void shutdown() {
|
||||||
try {
|
try {
|
||||||
if(original_steamapi_handle != nullptr) {
|
if(original_steamapi_handle != nullptr) {
|
||||||
kb::win::free_library(original_steamapi_handle);
|
kb::module::unload_library(original_steamapi_handle);
|
||||||
original_steamapi_handle = nullptr;
|
original_steamapi_handle = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ namespace smoke_api {
|
|||||||
|
|
||||||
AppId_t get_app_id() {
|
AppId_t get_app_id() {
|
||||||
try {
|
try {
|
||||||
const auto app_id_str = kb::win::get_env_var("SteamAppId");
|
const auto app_id_str = kb::util::get_env_var("SteamAppId");
|
||||||
static auto app_id = std::stoi(app_id_str);
|
static auto app_id = std::stoi(app_id_str);
|
||||||
return app_id;
|
return app_id;
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#include <ranges>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <battery/embed.hpp>
|
#include <battery/embed.hpp>
|
||||||
|
|
||||||
#include <koalabox/hook.hpp>
|
#include <koalabox/hook.hpp>
|
||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
#include <koalabox/win.hpp>
|
|
||||||
|
|
||||||
#include "steam_api/steam_interfaces.hpp"
|
#include "steam_api/steam_interfaces.hpp"
|
||||||
|
|
||||||
|
#include "koalabox/module.hpp"
|
||||||
#include "smoke_api/smoke_api.hpp"
|
#include "smoke_api/smoke_api.hpp"
|
||||||
#include "smoke_api/steamclient/steamclient.hpp"
|
#include "smoke_api/steamclient/steamclient.hpp"
|
||||||
#include "virtuals/steam_api_virtuals.hpp"
|
#include "virtuals/steam_api_virtuals.hpp"
|
||||||
@@ -210,7 +210,7 @@ namespace steam_interfaces {
|
|||||||
const auto prefixes = std::views::keys(virtual_hook_map) | std::ranges::to<std::set>();
|
const auto prefixes = std::views::keys(virtual_hook_map) | std::ranges::to<std::set>();
|
||||||
|
|
||||||
// Prepare HSteamPipe and HSteamUser
|
// Prepare HSteamPipe and HSteamUser
|
||||||
const auto CreateInterface$ = KB_WIN_GET_PROC(steamclient_handle, CreateInterface);
|
const auto CreateInterface$ = KB_MOD_GET_FUNC(steamclient_handle, CreateInterface);
|
||||||
const auto* const THIS = CreateInterface$(steam_client_interface_version.c_str(), nullptr);
|
const auto* const THIS = CreateInterface$(steam_client_interface_version.c_str(), nullptr);
|
||||||
hook_virtuals(THIS, steam_client_interface_version);
|
hook_virtuals(THIS, steam_client_interface_version);
|
||||||
|
|
||||||
@@ -223,12 +223,13 @@ namespace steam_interfaces {
|
|||||||
constexpr auto steam_pipe = 1;
|
constexpr auto steam_pipe = 1;
|
||||||
constexpr auto steam_user = 1;
|
constexpr auto steam_user = 1;
|
||||||
|
|
||||||
const bool should_hook = std::ranges::any_of(
|
bool should_hook = false;
|
||||||
prefixes,
|
for(const auto& prefix : prefixes) {
|
||||||
[&](const auto& prefix) {
|
if(interface_version.starts_with(prefix)) {
|
||||||
return std::ranges::starts_with(interface_version, prefix);
|
should_hook = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
if(not should_hook) {
|
if(not should_hook) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ VIRTUAL(bool) ISteamInventory_GetResultItems(
|
|||||||
SteamItemDetails_t* pOutItemsArray,
|
SteamItemDetails_t* pOutItemsArray,
|
||||||
uint32_t* punOutItemsArraySize
|
uint32_t* punOutItemsArraySize
|
||||||
)
|
)
|
||||||
) noexcept {
|
) noexcept {
|
||||||
return smoke_api::steam_inventory::GetResultItems(
|
return smoke_api::steam_inventory::GetResultItems(
|
||||||
__func__,
|
__func__,
|
||||||
resultHandle,
|
resultHandle,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace {
|
|||||||
std::set<uint32_t> fully_fetched; // NOLINT(cert-err58-cpp)
|
std::set<uint32_t> fully_fetched; // NOLINT(cert-err58-cpp)
|
||||||
|
|
||||||
std::string get_app_id_log(const uint32_t app_id) {
|
std::string get_app_id_log(const uint32_t app_id) {
|
||||||
return app_id ? fmt::format("App ID: {:>8}, ", app_id) : "";
|
return app_id ? std::format("App ID: {:>8}, ", app_id) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,9 +176,11 @@ namespace smoke_api::steam_apps {
|
|||||||
*pDlcId = dlc.get_id();
|
*pDlcId = dlc.get_id();
|
||||||
*pbAvailable = config::is_dlc_unlocked(app_id, *pDlcId, is_originally_unlocked);
|
*pbAvailable = config::is_dlc_unlocked(app_id, *pDlcId, is_originally_unlocked);
|
||||||
|
|
||||||
auto name = dlc.get_name();
|
const auto& name = dlc.get_name();
|
||||||
name = name.substr(0, cchNameBufferSize + 1);
|
|
||||||
memcpy_s(pchName, cchNameBufferSize, name.c_str(), name.size());
|
const auto bytes_to_copy = std::min(static_cast<size_t>(cchNameBufferSize - 1), name.size());
|
||||||
|
std::memcpy(pchName, name.c_str(), bytes_to_copy);
|
||||||
|
pchName[bytes_to_copy] = '\0'; // Ensure null-termination
|
||||||
};
|
};
|
||||||
|
|
||||||
if(app_dlcs.contains(app_id)) {
|
if(app_dlcs.contains(app_id)) {
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ namespace smoke_api::steam_inventory {
|
|||||||
try {
|
try {
|
||||||
const auto success = original_function();
|
const auto success = original_function();
|
||||||
|
|
||||||
LOG_DEBUG("{} -> Handle: {}", function_name, fmt::ptr(pResultHandle));
|
LOG_DEBUG("{} -> Handle: {}", function_name, static_cast<void*>(pResultHandle));
|
||||||
|
|
||||||
if(success && pInstanceIDs != nullptr) {
|
if(success && pInstanceIDs != nullptr) {
|
||||||
for(int i = 0; i < unCountInstanceIDs; i++) {
|
for(int i = 0; i < unCountInstanceIDs; i++) {
|
||||||
|
|||||||
@@ -42,15 +42,17 @@
|
|||||||
* have to omit it from the function signature.
|
* have to omit it from the function signature.
|
||||||
*
|
*
|
||||||
* The macros below implement the above-mentioned considerations.
|
* The macros below implement the above-mentioned considerations.
|
||||||
|
* Also, note the ## prefix before __VA_ARGS__. This enables a GCC extension
|
||||||
|
* which strips trailing comma if __VA_ARGS__ is empty.
|
||||||
*/
|
*/
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#define PARAMS(...) const void* RCX, __VA_ARGS__
|
#define PARAMS(...) const void* RCX, ##__VA_ARGS__
|
||||||
#define ARGS(...) RCX, __VA_ARGS__
|
#define ARGS(...) RCX, ##__VA_ARGS__
|
||||||
#define THIS RCX
|
#define THIS RCX
|
||||||
#define DECLARE_EDX()
|
#define DECLARE_EDX()
|
||||||
#else
|
#else
|
||||||
#define PARAMS(...) const void* ECX, const void* EDX, __VA_ARGS__
|
#define PARAMS(...) const void* ECX, const void* EDX, ##__VA_ARGS__
|
||||||
#define ARGS(...) ECX, EDX, __VA_ARGS__
|
#define ARGS(...) ECX, EDX, ##__VA_ARGS__
|
||||||
#define THIS ECX
|
#define THIS ECX
|
||||||
#define DECLARE_EDX() const void* EDX = nullptr;
|
#define DECLARE_EDX() const void* EDX = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -49,11 +49,23 @@ namespace {
|
|||||||
return unzip_dir / "headers/steam" / fs::path(name).filename();
|
return unzip_dir / "headers/steam" / fs::path(name).filename();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name.starts_with("sdk/redistributable_bin/") && name.ends_with(".dll") &&
|
// Windows binaries
|
||||||
name.find("steam_api") != std::string::npos) {
|
if(
|
||||||
|
name.starts_with("sdk/redistributable_bin/") &&
|
||||||
|
name.ends_with(".dll") &&
|
||||||
|
name.contains("steam_api")
|
||||||
|
) {
|
||||||
return unzip_dir / "binaries" / fs::path(name).filename();
|
return unzip_dir / "binaries" / fs::path(name).filename();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Linux binaries
|
||||||
|
if(
|
||||||
|
name.starts_with("sdk/redistributable_bin/linux") &&
|
||||||
|
name.ends_with("libsteam_api.so")
|
||||||
|
) {
|
||||||
|
return unzip_dir / "binaries" / name.substr(name.find("linux"));
|
||||||
|
}
|
||||||
|
|
||||||
return fs::path();
|
return fs::path();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -84,7 +96,7 @@ namespace {
|
|||||||
* A tool for downloading Steamworks SDK and unpacking its headers and binaries
|
* A tool for downloading Steamworks SDK and unpacking its headers and binaries
|
||||||
* for further processing by other tools.
|
* for further processing by other tools.
|
||||||
*/
|
*/
|
||||||
int wmain(const int argc, const wchar_t** argv) { // NOLINT(*-use-internal-linkage)
|
int MAIN(const int argc, const TCHAR* argv[]) { // NOLINT(*-use-internal-linkage)
|
||||||
if(argc == 1) {
|
if(argc == 1) {
|
||||||
print_help();
|
print_help();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ namespace {
|
|||||||
|
|
||||||
kb::parser::walk(
|
kb::parser::walk(
|
||||||
root,
|
root,
|
||||||
[&](const auto& current_node) {
|
[&](const ts::Node& current_node) {
|
||||||
const auto current_type = current_node.getType();
|
const auto current_type = current_node.getType();
|
||||||
const auto current_value = current_node.getSourceRange(source);
|
// const auto current_value = current_node.getSourceRange(source);
|
||||||
const auto current_sexpr = current_node.getSExpr();
|
const auto current_sexpr = current_node.getSExpr();
|
||||||
|
|
||||||
if(current_type == "class_specifier") {
|
if(current_type == "class_specifier") {
|
||||||
@@ -101,7 +101,7 @@ namespace {
|
|||||||
|
|
||||||
if(preproc_node.getType() == "preproc_arg") {
|
if(preproc_node.getType() == "preproc_arg") {
|
||||||
const auto quoted_version = preproc_node.getSourceRange(source);
|
const auto quoted_version = preproc_node.getSourceRange(source);
|
||||||
const auto trimmed_version = koalabox::str::trim(quoted_version);
|
const auto trimmed_version = koalabox::str::trim(std::string(quoted_version));
|
||||||
interface_version = unquote_if_quoted(trimmed_version);
|
interface_version = unquote_if_quoted(trimmed_version);
|
||||||
LOG_DEBUG("Interface version: {}", interface_version);
|
LOG_DEBUG("Interface version: {}", interface_version);
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ namespace {
|
|||||||
// Go over each file in headers directory
|
// Go over each file in headers directory
|
||||||
for(const auto& entry : fs::directory_iterator(headers_dir)) {
|
for(const auto& entry : fs::directory_iterator(headers_dir)) {
|
||||||
if(const auto& header_path = entry.path(); header_path.extension() == ".h") {
|
if(const auto& header_path = entry.path(); header_path.extension() == ".h") {
|
||||||
const auto task = pool.submit_task(
|
const auto task = pool.submit_task( // NOLINT(*-unused-local-non-trivial-variable)
|
||||||
[&, header_path] {
|
[&, header_path] {
|
||||||
try {
|
try {
|
||||||
LOG_DEBUG("Parsing header: {}", kb::path::to_str(header_path));
|
LOG_DEBUG("Parsing header: {}", kb::path::to_str(header_path));
|
||||||
@@ -227,7 +227,7 @@ namespace {
|
|||||||
* Optionally accepts a list of folder names that filters which sdk versions will be parsed.
|
* Optionally accepts a list of folder names that filters which sdk versions will be parsed.
|
||||||
* No list means all versions will be parsed.
|
* No list means all versions will be parsed.
|
||||||
*/
|
*/
|
||||||
int wmain(const int argc, const wchar_t* argv[]) { // NOLINT(*-use-internal-linkage)
|
int MAIN(const int argc, const TCHAR* argv[]) { // NOLINT(*-use-internal-linkage)
|
||||||
try {
|
try {
|
||||||
koalabox::logger::init_console_logger();
|
koalabox::logger::init_console_logger();
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ int wmain(const int argc, const wchar_t* argv[]) { // NOLINT(*-use-internal-link
|
|||||||
const auto steamworks_dir = fs::path("steamworks");
|
const auto steamworks_dir = fs::path("steamworks");
|
||||||
|
|
||||||
if(!fs::exists(steamworks_dir)) {
|
if(!fs::exists(steamworks_dir)) {
|
||||||
throw std::exception("Expected to find 'steamworks' in current working directory.");
|
throw std::runtime_error("Expected to find 'steamworks' in current working directory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto start = std::chrono::steady_clock::now();
|
const auto start = std::chrono::steady_clock::now();
|
||||||
@@ -251,7 +251,7 @@ int wmain(const int argc, const wchar_t* argv[]) { // NOLINT(*-use-internal-link
|
|||||||
const auto elapsed = duration_cast<std::chrono::seconds>(end - start);
|
const auto elapsed = duration_cast<std::chrono::seconds>(end - start);
|
||||||
|
|
||||||
LOG_INFO("Finished parsing steamworks in {} seconds", elapsed.count());
|
LOG_INFO("Finished parsing steamworks in {} seconds", elapsed.count());
|
||||||
} catch(std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
LOG_CRITICAL("Error: {}", e.what());
|
LOG_CRITICAL("Error: {}", e.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user