mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-05 21:15:39 -05:00
Refactored tool deps into KoalaBoxTools
This commit is contained in:
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: 0b28ad0a33...79b0e77c18
@@ -1,33 +1,13 @@
|
|||||||
cmake_minimum_required(VERSION 3.24)
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
|
||||||
project(smoke-api-tools LANGUAGES CXX)
|
project(SmokeAPITools LANGUAGES CXX)
|
||||||
|
|
||||||
### Thread pool library
|
|
||||||
|
|
||||||
## https://github.com/bshoshany/thread-pool
|
|
||||||
CPMAddPackage(
|
|
||||||
NAME BS_thread_pool
|
|
||||||
GITHUB_REPOSITORY bshoshany/thread-pool
|
|
||||||
VERSION 5.0.0
|
|
||||||
EXCLUDE_FROM_ALL
|
|
||||||
SYSTEM
|
|
||||||
)
|
|
||||||
add_library(BS_thread_pool INTERFACE)
|
|
||||||
target_include_directories(BS_thread_pool INTERFACE ${BS_thread_pool_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
### Steamworks Downloader executable
|
### Steamworks Downloader executable
|
||||||
|
|
||||||
CPMAddPackage("gh:serge1/ELFIO#Release_3.12")
|
|
||||||
add_executable(steamworks_downloader src/steamworks_downloader.cpp)
|
add_executable(steamworks_downloader src/steamworks_downloader.cpp)
|
||||||
target_link_libraries(steamworks_downloader PRIVATE
|
target_link_libraries(steamworks_downloader PRIVATE KoalaBoxTools)
|
||||||
KoalaBox
|
|
||||||
elfio
|
|
||||||
)
|
|
||||||
|
|
||||||
### Steamworks Parser executable
|
### Steamworks Parser executable
|
||||||
|
|
||||||
add_executable(steamworks_parser src/steamworks_parser.cpp)
|
add_executable(steamworks_parser src/steamworks_parser.cpp)
|
||||||
target_link_libraries(steamworks_parser PRIVATE
|
target_link_libraries(steamworks_parser PRIVATE KoalaBoxTools)
|
||||||
KoalaBox
|
|
||||||
BS_thread_pool
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -8,13 +8,15 @@
|
|||||||
|
|
||||||
#include <koalabox/io.hpp>
|
#include <koalabox/io.hpp>
|
||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
#include <koalabox/parser.hpp>
|
|
||||||
#include <koalabox/path.hpp>
|
#include <koalabox/path.hpp>
|
||||||
#include <koalabox/str.hpp>
|
#include <koalabox/str.hpp>
|
||||||
|
|
||||||
|
#include <koalabox_tools/parser.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
namespace kb = koalabox;
|
namespace kb = koalabox;
|
||||||
|
namespace parser = kb::tools::parser;
|
||||||
|
|
||||||
std::string_view unquote_if_quoted(const std::string_view& s) {
|
std::string_view unquote_if_quoted(const std::string_view& s) {
|
||||||
if(s.size() >= 2 && s.front() == '"' && s.back() == '"') {
|
if(s.size() >= 2 && s.front() == '"' && s.back() == '"') {
|
||||||
@@ -26,13 +28,13 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void parse_header(const std::string_view& source, nlohmann::ordered_json& lookup) {
|
void parse_header(const std::string_view& source, nlohmann::ordered_json& lookup) {
|
||||||
const auto tree = kb::parser::parse_source(source);
|
const auto tree = parser::parse_source(source);
|
||||||
const auto root = tree.getRootNode();
|
const auto root = tree.getRootNode();
|
||||||
|
|
||||||
nlohmann::ordered_json current_lookup = {};
|
nlohmann::ordered_json current_lookup = {};
|
||||||
std::string interface_version;
|
std::string interface_version;
|
||||||
|
|
||||||
kb::parser::walk(
|
parser::walk(
|
||||||
root,
|
root,
|
||||||
[&](const ts::Node& current_node) {
|
[&](const ts::Node& current_node) {
|
||||||
const auto current_type = current_node.getType();
|
const auto current_type = current_node.getType();
|
||||||
@@ -43,7 +45,7 @@ namespace {
|
|||||||
std::string interface_name;
|
std::string interface_name;
|
||||||
[[maybe_unused]] int vt_idx = 0;
|
[[maybe_unused]] int vt_idx = 0;
|
||||||
|
|
||||||
kb::parser::walk(
|
parser::walk(
|
||||||
current_node,
|
current_node,
|
||||||
[&](const ts::Node& class_node) {
|
[&](const ts::Node& class_node) {
|
||||||
const auto type = class_node.getType();
|
const auto type = class_node.getType();
|
||||||
@@ -53,12 +55,12 @@ namespace {
|
|||||||
interface_name = value;
|
interface_name = value;
|
||||||
LOG_DEBUG("Found interface: {}", interface_name);
|
LOG_DEBUG("Found interface: {}", interface_name);
|
||||||
|
|
||||||
return kb::parser::visit_result::Continue;
|
return parser::visit_result::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == "field_declaration" && value.starts_with("virtual ")) {
|
if(type == "field_declaration" && value.starts_with("virtual ")) {
|
||||||
if(value.starts_with("virtual ")) {
|
if(value.starts_with("virtual ")) {
|
||||||
kb::parser::walk(
|
parser::walk(
|
||||||
class_node,
|
class_node,
|
||||||
[&](const ts::Node& decl_node) {
|
[&](const ts::Node& decl_node) {
|
||||||
if(decl_node.getType() == "field_identifier") {
|
if(decl_node.getType() == "field_identifier") {
|
||||||
@@ -71,29 +73,29 @@ namespace {
|
|||||||
// functions. Hence, no fixes have been implemented so far.
|
// functions. Hence, no fixes have been implemented so far.
|
||||||
|
|
||||||
current_lookup[function_name] = vt_idx++;
|
current_lookup[function_name] = vt_idx++;
|
||||||
return kb::parser::visit_result::Stop;
|
return parser::visit_result::Stop;
|
||||||
}
|
}
|
||||||
return kb::parser::visit_result::Continue;
|
return parser::visit_result::Continue;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return kb::parser::visit_result::SkipChildren;
|
return parser::visit_result::SkipChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
return kb::parser::visit_result::Continue;
|
return parser::visit_result::Continue;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if(current_type == "preproc_def") {
|
} else if(current_type == "preproc_def") {
|
||||||
kb::parser::walk(
|
parser::walk(
|
||||||
current_node,
|
current_node,
|
||||||
[&](const ts::Node& preproc_node) {
|
[&](const ts::Node& preproc_node) {
|
||||||
if(preproc_node.getType() == "identifier") {
|
if(preproc_node.getType() == "identifier") {
|
||||||
const auto identifier = preproc_node.getSourceRange(source);
|
const auto identifier = preproc_node.getSourceRange(source);
|
||||||
|
|
||||||
return identifier.ends_with("INTERFACE_VERSION")
|
return identifier.ends_with("INTERFACE_VERSION")
|
||||||
? kb::parser::visit_result::Continue
|
? parser::visit_result::Continue
|
||||||
: kb::parser::visit_result::Stop;
|
: parser::visit_result::Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(preproc_node.getType() == "preproc_arg") {
|
if(preproc_node.getType() == "preproc_arg") {
|
||||||
@@ -102,17 +104,17 @@ namespace {
|
|||||||
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);
|
||||||
|
|
||||||
return kb::parser::visit_result::Stop;
|
return parser::visit_result::Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
return kb::parser::visit_result::Continue;
|
return parser::visit_result::Continue;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if(current_type == "translation_unit" || current_type == "preproc_ifdef") {
|
} else if(current_type == "translation_unit" || current_type == "preproc_ifdef") {
|
||||||
return kb::parser::visit_result::Continue;
|
return parser::visit_result::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return kb::parser::visit_result::SkipChildren;
|
return parser::visit_result::SkipChildren;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -155,7 +157,6 @@ namespace {
|
|||||||
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));
|
||||||
@@ -164,7 +165,7 @@ namespace {
|
|||||||
parse_header(processed_header, lookup);
|
parse_header(processed_header, lookup);
|
||||||
} catch(std::exception& e) {
|
} catch(std::exception& e) {
|
||||||
LOG_CRITICAL(e.what());
|
LOG_CRITICAL(e.what());
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user