Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 10 additions & 28 deletions .github/workflows/x86-windows.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
name: x86-windows
on: push
env:
VCPKG_TRIPLET: x86-windows-static
jobs:
x86-windows:
runs-on: windows-2022
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install pre-requisites
shell: bash
run: |
choco install --allow-empty-checksums pkgconfiglite
pip install meson ninja
- name: Install dependencies
uses: lukka/run-vcpkg@v7
with:
vcpkgGitCommitId: 095a29ce59608465032c3747307dd0009b3e089c
vcpkgTriplet: ${{ env.VCPKG_TRIPLET }}
vcpkgArguments: boost-asio boost-filesystem boost-date-time boost-interprocess boost-json fmt libgit2 openssl sqlite3
- name: Fix Boost.Filesystem library location
shell: bash
run: |
VCPKG_LIBRARYDIR=$VCPKG_ROOT/installed/$VCPKG_TRIPLET/lib
cp $VCPKG_LIBRARYDIR/boost_filesystem-vc143-mt-x32-1_88.lib $VCPKG_LIBRARYDIR/libboost_filesystem-vc143-mt-s.lib
- name: Set x86 windows build tools as default
uses: ilammy/msvc-dev-cmd@v1
- name: Setup msys2
uses: msys2/setup-msys2@v2
with:
arch: win32
update: true
msystem: mingw32
install: mingw-w64-i686-toolchain make mingw-w64-i686-libgit2-winhttp mingw-w64-i686-fmt mingw-w64-i686-boost mingw-w64-i686-sqlite3 mingw-w64-i686-openssl pkgconf mingw-w64-i686-meson
- name: Meson build
shell: cmd
shell: msys2 {0}
run: |
set PKG_CONFIG_PATH=%VCPKG_ROOT%\installed\%VCPKG_TRIPLET%\lib\pkgconfig
set BOOST_ROOT=%VCPKG_ROOT%\installed\%VCPKG_TRIPLET%
meson setup build -Dbackend=ninja -Dbuildtype=release -Dstrip=true -Db_lto=true -Db_ndebug=true
meson compile -C build -j2
LDFLAGS="-static-libstdc++ -static-libgcc -static" meson setup build -Dbuildtype=release -Dstrip=true -Db_lto=true -Db_ndebug=true
meson compile -C build -j$(nproc)
- name: Setup directory with artifacts
shell: bash
run: |
Expand All @@ -46,7 +28,7 @@ jobs:
cp etc/config.json $RDIR/
sed -i "s/libocgcore\\\\\\\.so/ocgcore\\\\\\\.dll/g" $RDIR/config.json
- name: Upload artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: Multirole
path: Multirole/
33 changes: 26 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@ project('multirole', 'c', 'cpp',
version : '1.1.0'
)

static_deps = host_machine.system() == 'windows'
cc = meson.get_compiler('cpp')

atomic_dep = meson.get_compiler('cpp').find_library('atomic', required : false)
boost_dep = dependency('boost', version : '>=1.78', modules : ['filesystem'], static : static_deps)
dl_dep = meson.get_compiler('cpp').find_library('dl', required : false)
is_windows = host_machine.system() == 'windows'
is_not_msvc = cc.get_id() != 'msvc'
static_deps = is_windows
is_mingw = is_windows and is_not_msvc

atomic_dep = cc.find_library('atomic', required : false)
boost_dep = dependency('boost', version : '>=1.78', static : static_deps)
dl_dep = cc.find_library('dl', required : false)
fs_dep = cc.find_library('stdc++fs', required : false)
libgit2_dep = dependency('libgit2', static : static_deps)
openssl_dep = dependency('openssl', static : static_deps)
rt_dep = meson.get_compiler('cpp').find_library('rt', required : false)
rt_dep = cc.find_library('rt', required : false)
sqlite3_dep = dependency('sqlite3', static : static_deps)
tcm_dep = dependency('libtcmalloc_minimal', required : get_option('use_tcmalloc'), static : static_deps)
thread_dep = dependency('threads')

mingw_deps=[]
if is_mingw
mswsock_dep = cc.find_library('mswsock', required: true)
rpcrt4p_dep = cc.find_library('rpcrt4', required: true)
winhttp_dep = cc.find_library('winhttp', required: true)
mingw_deps = [
mswsock_dep,
rpcrt4p_dep,
winhttp_dep
]
endif

# Get fmt dependency and configure so it's header-only
fmt_dep = dependency('fmt', version : '>=6.0.0')
fmt_dep = dependency('fmt', version : '>=6.0.0', static : static_deps and not get_option('fmt_ho'))
if get_option('fmt_ho')
fmt_dep = declare_dependency(compile_args : '-DFMT_HEADER_ONLY', dependencies : fmt_dep)
fmt_dep = fmt_dep.partial_dependency(compile_args : true, includes : true)
Expand Down Expand Up @@ -93,14 +111,15 @@ executable('multirole', multirole_src_files,
atomic_dep,
boost_dep,
dl_dep,
fs_dep,
fmt_dep,
libgit2_dep,
openssl_dep,
rt_dep,
sqlite3_dep,
tcm_dep,
thread_dep
])
] + mingw_deps)

executable('hornet', hornet_src_files,
cpp_args: [
Expand Down
5 changes: 3 additions & 2 deletions src/Multirole/GitRepo.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "GitRepo.hpp"

#include <boost/filesystem.hpp>
#include <filesystem>

#include <boost/json/value.hpp>

#include "I18N.hpp"
Expand Down Expand Up @@ -42,7 +43,7 @@ GitRepo::GitRepo(Service::LogHandler& lh, boost::asio::io_context& ioCtx, const
cred->at("username").as_string().data(),
cred->at("password").as_string().data());
}
if(boost::filesystem::exists(path) && !boost::filesystem::is_directory(path))
if(exists(path) && !is_directory(path))
throw std::runtime_error(I18N::GIT_REPO_PATH_IS_NOT_DIR);
if(!CheckIfRepoExists())
{
Expand Down
4 changes: 2 additions & 2 deletions src/Multirole/GitRepo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GitRepo final : public Endpoint::Webhook
Service::LogHandler& lh;
const std::string token;
const std::string remote;
const boost::filesystem::path path;
const std::filesystem::path path;
std::unique_ptr<Credentials> credPtr;
git_repository* repo;
std::vector<IGitRepoObserver*> observers;
Expand All @@ -47,7 +47,7 @@ class GitRepo final : public Endpoint::Webhook
void ResetToFetchHead();

GitDiff GetFilesDiff() const;
std::vector<boost::filesystem::path> GetTrackedFiles() const;
std::vector<std::filesystem::path> GetTrackedFiles() const;
};

} // namespace Ignis::Multirole
Expand Down
8 changes: 4 additions & 4 deletions src/Multirole/IGitRepoObserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#define IGITREPOOBSERVER_HPP
#include <vector>

#include <boost/filesystem/path.hpp>
#include <filesystem>

namespace Ignis::Multirole
{

using PathVector = std::vector<boost::filesystem::path>;
using PathVector = std::vector<std::filesystem::path>;

struct GitDiff
{
Expand All @@ -19,8 +19,8 @@ struct GitDiff
class IGitRepoObserver
{
public:
virtual void OnAdd(const boost::filesystem::path& path, const PathVector& fileList) = 0;
virtual void OnDiff(const boost::filesystem::path& path, const GitDiff& diff) = 0;
virtual void OnAdd(const std::filesystem::path& path, const PathVector& fileList) = 0;
virtual void OnDiff(const std::filesystem::path& path, const GitDiff& diff) = 0;
protected:
inline ~IGitRepoObserver() noexcept = default;
};
Expand Down
8 changes: 4 additions & 4 deletions src/Multirole/Service/BanlistProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ YGOPro::BanlistPtr Service::BanlistProvider::GetBanlistByHash(YGOPro::BanlistHas
return nullptr;
}

void Service::BanlistProvider::OnAdd(const boost::filesystem::path& path, const PathVector& fileList)
void Service::BanlistProvider::OnAdd(const std::filesystem::path& path, const PathVector& fileList)
{
LoadBanlists(path, fileList);
}

void Service::BanlistProvider::OnDiff(const boost::filesystem::path& path, const GitDiff& diff)
void Service::BanlistProvider::OnDiff(const std::filesystem::path& path, const GitDiff& diff)
{
LoadBanlists(path, diff.added);
}

// private

void Service::BanlistProvider::LoadBanlists(const boost::filesystem::path& path, const PathVector& fileList) noexcept
void Service::BanlistProvider::LoadBanlists(const std::filesystem::path& path, const PathVector& fileList) noexcept
{
YGOPro::BanlistMap tmp;
for(const auto& fn : fileList)
Expand All @@ -49,7 +49,7 @@ void Service::BanlistProvider::LoadBanlists(const boost::filesystem::path& path,
LOG_INFO(I18N::BANLIST_PROVIDER_LOADING_ONE, fullPath.string());
try
{
std::ifstream f(fullPath.native());
std::ifstream f(fullPath);
YGOPro::ParseForBanlists(f, tmp);
}
catch(const std::exception& e)
Expand Down
6 changes: 3 additions & 3 deletions src/Multirole/Service/BanlistProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class Service::BanlistProvider final : public IGitRepoObserver
YGOPro::BanlistPtr GetBanlistByHash(YGOPro::BanlistHash hash) const noexcept;

// IGitRepoObserver overrides
void OnAdd(const boost::filesystem::path& path, const PathVector& fileList) override;
void OnDiff(const boost::filesystem::path& path, const GitDiff& diff) override;
void OnAdd(const std::filesystem::path& path, const PathVector& fileList) override;
void OnDiff(const std::filesystem::path& path, const GitDiff& diff) override;
private:
Service::LogHandler& lh;
const std::regex fnRegex;
YGOPro::BanlistMap banlists;
mutable std::shared_mutex mBanlists;

void LoadBanlists(const boost::filesystem::path& path, const PathVector& fileList) noexcept;
void LoadBanlists(const std::filesystem::path& path, const PathVector& fileList) noexcept;
};

} // namespace Ignis::Multirole
Expand Down
22 changes: 10 additions & 12 deletions src/Multirole/Service/CoreProvider.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#include "CoreProvider.hpp"

#include <filesystem>
#include <fstream>

#include <boost/filesystem.hpp>

#include "LogHandler.hpp"
#define LOG_INFO(...) lh.Log(ServiceType::CORE_PROVIDER, Level::INFO, __VA_ARGS__)
#define LOG_ERROR(...) lh.Log(ServiceType::CORE_PROVIDER, Level::ERROR, __VA_ARGS__)
Expand All @@ -14,7 +13,7 @@
namespace Ignis::Multirole
{

Service::CoreProvider::CoreProvider(Service::LogHandler& lh, std::string_view fnRegexStr, const boost::filesystem::path& tmpDir, CoreType type, bool loadPerCall)
Service::CoreProvider::CoreProvider(Service::LogHandler& lh, std::string_view fnRegexStr, const std::filesystem::path& tmpDir, CoreType type, bool loadPerCall)
:
lh(lh),
fnRegex(fnRegexStr.data()),
Expand All @@ -25,7 +24,6 @@ Service::CoreProvider::CoreProvider(Service::LogHandler& lh, std::string_view fn
loadCount(0U),
shouldTest(true)
{
using namespace boost::filesystem;
if(!exists(tmpDir) && !create_directory(tmpDir))
throw std::runtime_error(I18N::CORE_PROVIDER_COULD_NOT_CREATE_TMP_DIR);
if(!is_directory(tmpDir))
Expand All @@ -35,7 +33,7 @@ Service::CoreProvider::CoreProvider(Service::LogHandler& lh, std::string_view fn
Service::CoreProvider::~CoreProvider() noexcept
{
for(const auto& fn : pLocs)
boost::filesystem::remove(fn);
remove(fn);
}

Service::CoreProvider::CorePtr Service::CoreProvider::GetCore() const
Expand All @@ -46,12 +44,12 @@ Service::CoreProvider::CorePtr Service::CoreProvider::GetCore() const
return core;
}

void Service::CoreProvider::OnAdd(const boost::filesystem::path& path, const PathVector& fileList)
void Service::CoreProvider::OnAdd(const std::filesystem::path& path, const PathVector& fileList)
{
OnGitUpdate(path, fileList);
}

void Service::CoreProvider::OnDiff(const boost::filesystem::path& path, const GitDiff& diff)
void Service::CoreProvider::OnDiff(const std::filesystem::path& path, const GitDiff& diff)
{
OnGitUpdate(path, diff.added);
}
Expand All @@ -67,7 +65,7 @@ Service::CoreProvider::CorePtr Service::CoreProvider::LoadCore() const
throw std::runtime_error(I18N::CORE_PROVIDER_WRONG_CORE_TYPE);
}

void Service::CoreProvider::OnGitUpdate(const boost::filesystem::path& path, const PathVector& fileList)
void Service::CoreProvider::OnGitUpdate(const std::filesystem::path& path, const PathVector& fileList)
{
auto it = fileList.begin();
for(; it != fileList.end(); ++it)
Expand All @@ -80,13 +78,13 @@ void Service::CoreProvider::OnGitUpdate(const boost::filesystem::path& path, con
return;
}
std::scoped_lock lock(mCore);
const boost::filesystem::path oldCoreLoc = coreLoc;
const boost::filesystem::path repoCore = (path / *it).lexically_normal();
const std::filesystem::path oldCoreLoc = coreLoc;
const std::filesystem::path repoCore = (path / *it).lexically_normal();
coreLoc = (tmpDir / fmt::format("{}-{}-{}", uniqueId, loadCount++, repoCore.filename().string())).lexically_normal();
LOG_INFO(I18N::CORE_PROVIDER_COPYING_CORE_FILE, repoCore.string(), coreLoc.string());
pLocs.emplace_back(coreLoc);
boost::filesystem::copy_file(repoCore, coreLoc);
if(!boost::filesystem::exists(coreLoc))
copy_file(repoCore, coreLoc);
if(!exists(coreLoc))
{
LOG_ERROR(I18N::CORE_PROVIDER_FAILED_TO_COPY_CORE_FILE);
coreLoc = oldCoreLoc;
Expand Down
14 changes: 7 additions & 7 deletions src/Multirole/Service/CoreProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@ class Service::CoreProvider final : public IGitRepoObserver

using CorePtr = std::shared_ptr<Core::IWrapper>;

CoreProvider(Service::LogHandler& lh, std::string_view fnRegexStr, const boost::filesystem::path& tmpDir, CoreType type, bool loadPerCall);
CoreProvider(Service::LogHandler& lh, std::string_view fnRegexStr, const std::filesystem::path& tmpDir, CoreType type, bool loadPerCall);
~CoreProvider() noexcept;

// Will return a core instance based on the options set.
CorePtr GetCore() const;

// IGitRepoObserver overrides
void OnAdd(const boost::filesystem::path& path, const PathVector& fileList) override;
void OnDiff(const boost::filesystem::path& path, const GitDiff& diff) override;
void OnAdd(const std::filesystem::path& path, const PathVector& fileList) override;
void OnDiff(const std::filesystem::path& path, const GitDiff& diff) override;
private:
Service::LogHandler& lh;
const std::regex fnRegex;
const boost::filesystem::path tmpDir;
const std::filesystem::path tmpDir;
const CoreType type;
const bool loadPerCall;
const std::chrono::system_clock::rep uniqueId;
std::size_t loadCount;
bool shouldTest;
boost::filesystem::path coreLoc;
std::filesystem::path coreLoc;
CorePtr core;
std::list<boost::filesystem::path> pLocs; // Previous locations for core file.
std::list<std::filesystem::path> pLocs; // Previous locations for core file.
mutable std::shared_mutex mCore; // used for both corePath and core.

CorePtr LoadCore() const;

void OnGitUpdate(const boost::filesystem::path& path, const PathVector& fileList);
void OnGitUpdate(const std::filesystem::path& path, const PathVector& fileList);
};

} // namespace Ignis::Multirole
Expand Down
4 changes: 2 additions & 2 deletions src/Multirole/Service/DataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::shared_ptr<YGOPro::CardDatabase> Service::DataProvider::GetDatabase() const
return db;
}

void Service::DataProvider::OnAdd(const boost::filesystem::path& path, const PathVector& fileList)
void Service::DataProvider::OnAdd(const std::filesystem::path& path, const PathVector& fileList)
{
// Filter and add to set of dbs
for(const auto& fn : fileList)
Expand All @@ -40,7 +40,7 @@ void Service::DataProvider::OnAdd(const boost::filesystem::path& path, const Pat
ReloadDatabases();
}

void Service::DataProvider::OnDiff(const boost::filesystem::path& path, const GitDiff& diff)
void Service::DataProvider::OnDiff(const std::filesystem::path& path, const GitDiff& diff)
{
// Filter and remove from sets of dbs
for(const auto& fn : diff.removed)
Expand Down
6 changes: 3 additions & 3 deletions src/Multirole/Service/DataProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class Service::DataProvider final : public IGitRepoObserver
std::shared_ptr<YGOPro::CardDatabase> GetDatabase() const noexcept;

// IGitRepoObserver overrides
void OnAdd(const boost::filesystem::path& path, const PathVector& fileList) override;
void OnDiff(const boost::filesystem::path& path, const GitDiff& diff) override;
void OnAdd(const std::filesystem::path& path, const PathVector& fileList) override;
void OnDiff(const std::filesystem::path& path, const GitDiff& diff) override;
private:
Service::LogHandler& lh;
const std::regex fnRegex;
std::set<boost::filesystem::path> paths;
std::set<std::filesystem::path> paths;
std::shared_ptr<YGOPro::CardDatabase> db;
mutable std::shared_mutex mDb;

Expand Down
Loading