Skip to content

Commit

Permalink
Merge branch 'master' into path
Browse files Browse the repository at this point in the history
  • Loading branch information
darealshinji authored Jan 1, 2025
2 parents bd99505 + d7bacc1 commit 3993398
Show file tree
Hide file tree
Showing 138 changed files with 5,980 additions and 2,676 deletions.
74 changes: 59 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
msvc: true
buildtype: release
args: >-
-Ddefault_library=static
--force-fallback-for=zlib,harfbuzz,freetype2,fribidi,libpng
-Dfreetype2:harfbuzz=disabled
-Dharfbuzz:freetype=disabled
-Dharfbuzz:cairo=disabled
-Dharfbuzz:glib=disabled
-Ddefault_library=static
--force-fallback-for=zlib,harfbuzz,freetype2,fribidi,libpng
-Dfreetype2:harfbuzz=disabled
-Dharfbuzz:freetype=disabled
-Dharfbuzz:cairo=disabled
-Dharfbuzz:glib=disabled
-Dharfbuzz:gobject=disabled
-Dharfbuzz:tests=disabled
-Dharfbuzz:docs=disabled
Expand All @@ -40,14 +40,26 @@ jobs:
# msvc: false
#}
- {
name: Ubuntu Debug,
os: ubuntu-latest,
name: Ubuntu 22 Debug,
os: ubuntu-22.04,
buildtype: debugoptimized,
args: ''
}
- {
name: Ubuntu Release,
os: ubuntu-latest,
name: Ubuntu 22 Release,
os: ubuntu-22.04,
buildtype: release,
args: ''
}
- {
name: Ubuntu 24 Debug,
os: ubuntu-24.04,
buildtype: debugoptimized,
args: ''
}
- {
name: Ubuntu 24 Release,
os: ubuntu-24.04,
buildtype: release,
args: ''
}
Expand Down Expand Up @@ -116,17 +128,24 @@ jobs:
brew install pulseaudio # NO OpenAL in github CI
- name: Install dependencies (Linux)
if: matrix.config.os == 'ubuntu-latest'
if: startsWith(matrix.config.os, 'ubuntu-')
run: |
sudo apt-get update
sudo apt-get install ninja-build build-essential libx11-dev libwxgtk3.0-gtk3-dev libfreetype6-dev pkg-config libfontconfig1-dev libass-dev libasound2-dev libffms2-dev intltool libboost-all-dev libhunspell-dev libcurl4-openssl-dev libuchardet-dev
sudo apt-get install ninja-build build-essential libx11-dev libfreetype6-dev pkg-config libfontconfig1-dev libass-dev libasound2-dev libffms2-dev intltool libboost-all-dev libhunspell-dev libcurl4-openssl-dev libuchardet-dev libgtest-dev libgmock-dev ${{ matrix.config.os == 'ubuntu-22.04' && 'libwxgtk3.0-gtk3-dev' || 'libwxgtk3.2-dev' }}
- name: Set compiler (Linux)
if: matrix.config.os == 'ubuntu-22.04'
run: |
# We need to use Clang on Ubuntu 22 to avoid a bug with GCC 11
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Configure
run: meson setup build ${{ matrix.config.args }} -Dbuildtype=${{ matrix.config.buildtype }} ${{ github.ref_type == 'tag' && '-Dofficial_release=true' || '' }}

- name: Build
run: meson compile -C build

- name: Run test
run: meson test -C build --verbose "gtest main"

Expand All @@ -149,14 +168,14 @@ jobs:
name: ${{ matrix.config.name }} - installer
path: build/Aegisub-*.exe
if-no-files-found: error

- name: Upload artifacts - portable.zip
uses: actions/upload-artifact@v4
if: matrix.config.os == 'windows-latest'
with:
name: ${{ matrix.config.name }} - portable
path: build/aegisub-portable-64.zip

# macOS artifacts
- name: Generate macOS installer
if: startsWith(matrix.config.os, 'macos-')
Expand All @@ -171,3 +190,28 @@ jobs:
name: ${{ matrix.config.name }} - installer
path: build/Aegisub-*.dmg
if-no-files-found: error

# Tarball
- name: Generate tarball
if: matrix.config.os == 'ubuntu-24.04' && matrix.config.buildtype == 'release'
run: |
set -e
# Work around https://github.com/mesonbuild/meson/issues/14005
rm -rf subprojects/luajit/.git
meson dist --include-subprojects -C build
# Make sure the subprojects we need are included
mkdir distcheck
tar -xJf build/meson-dist/*.tar.xz -C distcheck/
test -e distcheck/*/subprojects/luabins/meson.build
test -e distcheck/*/subprojects/luajit/meson.build
- name: Upload artifacts - tarball
uses: actions/upload-artifact@v4
if: matrix.config.os == 'ubuntu-24.04' && matrix.config.buildtype == 'release'
with:
name: Source Tarball
path: build/meson-dist/*.tar.xz
if-no-files-found: error
2 changes: 1 addition & 1 deletion libaegisub/audio/provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class writer {
std::ostream& out;

public:
writer(std::filesystem::path const& filename) : outfile(filename, true), out(outfile.Get()) { }
writer(agi::fs::path const& filename) : outfile(filename, true), out(outfile.Get()) { }

template<int N>
void write(const char(&str)[N]) {
Expand Down
4 changes: 2 additions & 2 deletions libaegisub/audio/provider_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DummyAudioProvider final : public AudioProvider {
}

public:
DummyAudioProvider(std::filesystem::path const& uri) {
DummyAudioProvider(agi::fs::path const& uri) {
noise = uri.string().find(":noise?") != std::string::npos;
channels = 1;
sample_rate = 44100;
Expand All @@ -70,7 +70,7 @@ class DummyAudioProvider final : public AudioProvider {
}

namespace agi {
std::unique_ptr<AudioProvider> CreateDummyAudioProvider(std::filesystem::path const& file, agi::BackgroundRunner *) {
std::unique_ptr<AudioProvider> CreateDummyAudioProvider(agi::fs::path const& file, agi::BackgroundRunner *) {
if (!file.string().starts_with("dummy-audio:"))
return {};
return std::make_unique<DummyAudioProvider>(file);
Expand Down
8 changes: 3 additions & 5 deletions libaegisub/audio/provider_hd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
#include <libaegisub/fs.h>
#include <libaegisub/path.h>

#include <filesystem>
#include <boost/interprocess/detail/os_thread_functions.hpp>
#include <ctime>
#include <thread>

namespace {
using namespace agi;
using namespace std::filesystem;

class HDAudioProvider final : public AudioProviderWrapper {
mutable temp_file_mapping file;
Expand All @@ -49,7 +47,7 @@ class HDAudioProvider final : public AudioProviderWrapper {
}
}

path CacheFilename(path const& dir) {
fs::path CacheFilename(fs::path const& dir) {
// Check free space
if ((uint64_t)num_samples * bytes_per_sample > fs::FreeSpace(dir))
throw AudioProviderError("Not enough free disk space in " + dir.string() + " to cache the audio");
Expand All @@ -59,7 +57,7 @@ class HDAudioProvider final : public AudioProviderWrapper {
}

public:
HDAudioProvider(std::unique_ptr<AudioProvider> src, path const& dir)
HDAudioProvider(std::unique_ptr<AudioProvider> src, fs::path const& dir)
: AudioProviderWrapper(std::move(src))
, file(dir / CacheFilename(dir), num_samples * bytes_per_sample)
{
Expand All @@ -83,7 +81,7 @@ class HDAudioProvider final : public AudioProviderWrapper {
}

namespace agi {
std::unique_ptr<AudioProvider> CreateHDAudioProvider(std::unique_ptr<AudioProvider> src, std::filesystem::path const& dir) {
std::unique_ptr<AudioProvider> CreateHDAudioProvider(std::unique_ptr<AudioProvider> src, agi::fs::path const& dir) {
return std::make_unique<HDAudioProvider>(std::move(src), dir);
}
}
2 changes: 1 addition & 1 deletion libaegisub/common/charset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif

namespace agi::charset {
std::string Detect(std::filesystem::path const& file) {
std::string Detect(agi::fs::path const& file) {
agi::read_file_mapping fp(file);

// First check for known magic bytes which identify the file type
Expand Down
6 changes: 3 additions & 3 deletions libaegisub/common/file_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ char *map(int64_t s_offset, uint64_t length, boost::interprocess::mode_t mode,
}

namespace agi {
file_mapping::file_mapping(std::filesystem::path const& filename, bool temporary)
file_mapping::file_mapping(agi::fs::path const& filename, bool temporary)
#ifdef _WIN32
: handle(CreateFileW(filename.wstring().c_str(),
temporary ? read_write : read_only,
Expand Down Expand Up @@ -116,7 +116,7 @@ file_mapping::~file_mapping() {
}
}

read_file_mapping::read_file_mapping(std::filesystem::path const& filename)
read_file_mapping::read_file_mapping(agi::fs::path const& filename)
: file(filename, false)
{
offset_t size = 0;
Expand All @@ -134,7 +134,7 @@ const char *read_file_mapping::read(int64_t offset, uint64_t length) {
return map(offset, length, read_only, file_size, file, region, mapping_start);
}

temp_file_mapping::temp_file_mapping(std::filesystem::path const& filename, uint64_t size)
temp_file_mapping::temp_file_mapping(agi::fs::path const& filename, uint64_t size)
: file(filename, true)
, file_size(size)
{
Expand Down
3 changes: 1 addition & 2 deletions libaegisub/common/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <libaegisub/format.h>

#include <libaegisub/charset_conv.h>

#include <filesystem>
#include <libaegisub/fs.h>

#ifdef _MSC_VER
#define WCHAR_T_ENC "utf-16le"
Expand Down
21 changes: 18 additions & 3 deletions libaegisub/common/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace sfs = std::filesystem;

namespace agi::fs {
namespace {
void check_error(std::error_code ec, const char *exp, sfs::path const& src_path, sfs::path const& dst_path) {
void check_error(std::error_code ec, const char *exp, path const& src_path, path const& dst_path) {
if (ec == std::error_code{}) return;
using enum std::errc;
switch (ec.value()) {
Expand Down Expand Up @@ -55,7 +55,7 @@ void check_error(std::error_code ec, const char *exp, sfs::path const& src_path,
check_error(ec, #exp, src_path, dst_path);

#define CHECKED_CALL_RETURN(exp, src_path) \
CHECKED_CALL(auto ret = exp, src_path, std::filesystem::path()); \
CHECKED_CALL(auto ret = exp, src_path, agi::fs::path()); \
return ret

#define WRAP_SFS(sfs_name, agi_name) \
Expand All @@ -69,6 +69,12 @@ void check_error(std::error_code ec, const char *exp, sfs::path const& src_path,
return sfs::sfs_name(p, ec); \
}

#define WRAP_SFS_AGI_PATH(sfs_name, agi_name) \
auto agi_name(path const& p) -> agi::fs::path { \
CHECKED_CALL(auto ret = sfs::sfs_name(p, ec), p, agi::fs::path()); \
return agi::fs::path(std::move(ret)); \
}

// sasuga windows.h
#undef CreateDirectory

Expand All @@ -82,7 +88,8 @@ void check_error(std::error_code ec, const char *exp, sfs::path const& src_path,
WRAP_SFS(last_write_time, ModifiedTime)
WRAP_SFS(create_directories, CreateDirectory)
WRAP_SFS(remove, Remove)
WRAP_SFS(canonical, Canonicalize)
WRAP_SFS_AGI_PATH(canonical, Canonicalize)
WRAP_SFS_AGI_PATH(absolute, Absolute)

uintmax_t Size(path const& p) {
if (DirectoryExists(p))
Expand All @@ -104,4 +111,12 @@ void check_error(std::error_code ec, const char *exp, sfs::path const& src_path,
if (filename[filename.size() - ext.size() - 1] != '.') return false;
return boost::iends_with(filename, ext);
}

agi::fs::path CurrentPath() {
return agi::fs::path(std::filesystem::current_path());
}

void CurrentPath(path const& path) {
std::filesystem::current_path(path);
}
}
2 changes: 1 addition & 1 deletion libaegisub/common/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <fstream>

namespace agi::io {
using namespace std::filesystem;
using namespace agi::fs;

std::unique_ptr<std::istream> Open(path const& file, bool binary) {
LOG_D("agi/io/open/file") << file;
Expand Down
2 changes: 1 addition & 1 deletion libaegisub/common/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ json::UnknownElement parse(std::istream &stream) {
}
}

json::UnknownElement file(std::filesystem::path const& file, std::string_view default_config) {
json::UnknownElement file(agi::fs::path const& file, std::string_view default_config) {
try {
if (fs::FileExists(file))
return parse(*io::Open(file));
Expand Down
4 changes: 2 additions & 2 deletions libaegisub/common/keyframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ int wwxd(std::string const& line) {
}

namespace agi::keyframe {
void Save(std::filesystem::path const& filename, std::vector<int> const& keyframes) {
void Save(agi::fs::path const& filename, std::vector<int> const& keyframes) {
io::Save file(filename);
std::ostream& of = file.Get();
of << "# keyframe format v1" << std::endl;
of << "fps " << 0 << std::endl;
boost::copy(keyframes, std::ostream_iterator<int>(of, "\n"));
}

std::vector<int> Load(std::filesystem::path const& filename) {
std::vector<int> Load(agi::fs::path const& filename) {
auto file = io::Open(filename);
std::istream &is(*file);

Expand Down
4 changes: 2 additions & 2 deletions libaegisub/common/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#include "libaegisub/cajun/elements.h"
#include "libaegisub/cajun/writer.h"
#include "libaegisub/dispatch.h"
#include "libaegisub/fs.h"
#include "libaegisub/util.h"

#include <boost/range/algorithm/remove_if.hpp>
#include <chrono>
#include <filesystem>
#include <fstream>

namespace agi::log {
Expand Down Expand Up @@ -97,7 +97,7 @@ Message::~Message() {
agi::log::log->Log(sm);
}

JsonEmitter::JsonEmitter(std::filesystem::path const& directory)
JsonEmitter::JsonEmitter(agi::fs::path const& directory)
: fp(new std::ofstream(directory/util::strftime("%Y-%m-%d-%H-%M-%S.json")))
{
}
Expand Down
8 changes: 4 additions & 4 deletions libaegisub/common/mru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int mru_index(std::string_view key) {
}

namespace agi {
MRUManager::MRUManager(std::filesystem::path const& config, std::string_view default_config, agi::Options *options)
MRUManager::MRUManager(agi::fs::path const& config, std::string_view default_config, agi::Options *options)
: config_name(config)
, options(options)
{
Expand All @@ -78,7 +78,7 @@ MRUManager::MRUListMap &MRUManager::Find(std::string_view key) {
return mru[index];
}

void MRUManager::Add(std::string_view key, std::filesystem::path const& entry) {
void MRUManager::Add(std::string_view key, agi::fs::path const& entry) {
MRUListMap &map = Find(key);
auto it = find(begin(map), end(map), entry);
if (it == begin(map) && it != end(map))
Expand All @@ -93,7 +93,7 @@ void MRUManager::Add(std::string_view key, std::filesystem::path const& entry) {
Flush();
}

void MRUManager::Remove(std::string_view key, std::filesystem::path const& entry) {
void MRUManager::Remove(std::string_view key, agi::fs::path const& entry) {
auto& map = Find(key);
map.erase(remove(begin(map), end(map), entry), end(map));
Flush();
Expand All @@ -103,7 +103,7 @@ const MRUManager::MRUListMap* MRUManager::Get(std::string_view key) {
return &Find(key);
}

std::filesystem::path const& MRUManager::GetEntry(std::string_view key, const size_t entry) {
agi::fs::path const& MRUManager::GetEntry(std::string_view key, const size_t entry) {
const auto map = Get(key);
if (entry >= map->size())
throw MRUError("Requested element index is out of range.");
Expand Down
2 changes: 1 addition & 1 deletion libaegisub/common/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ struct option_name_cmp {

namespace agi {

Options::Options(std::filesystem::path const& file, std::string_view default_config, OptionSetting setting)
Options::Options(agi::fs::path const& file, std::string_view default_config, OptionSetting setting)
: config_file(file)
, setting(setting)
{
Expand Down
Loading

0 comments on commit 3993398

Please sign in to comment.