Skip to content

Commit

Permalink
Merge removing Boost Filesystem; resolves rwengine#682
Browse files Browse the repository at this point in the history
  • Loading branch information
tsjost committed Oct 12, 2021
2 parents 115ff7f + 74993e2 commit c5e6709
Show file tree
Hide file tree
Showing 31 changed files with 141 additions and 184 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ matrix:
# - os: osx
# compiler: clang
# env: NAME="Apple macOS" NAME_SUFFIX="mac"
# osx_image: xcode10.1
# osx_image: xcode11
# install:
# - brew update
# - /usr/bin/yes | pip2 uninstall numpy # see https://github.com/travis-ci/travis-ci/issues/6688
# - brew upgrade python
# - brew upgrade
# - brew install boost cmake bullet ffmpeg glm openal-soft qt5 sdl2 jack freetype
# - export PATH="/usr/local/opt/qt/bin:$PATH"
Expand Down
1 change: 0 additions & 1 deletion cmake/modules/WrapTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function(rwdep_wrap_conan_targets)
endif()

rwdep_wrap_conan_target(Boost::boost boost)
rwdep_wrap_conan_target(Boost::filesystem boost)
rwdep_wrap_conan_target(Boost::program_options boost)
rwdep_wrap_conan_target(Boost::system boost)
rwdep_wrap_conan_target(Boost::unit_test_framework boost)
Expand Down
15 changes: 2 additions & 13 deletions cmake_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,8 @@ if(USE_CONAN)
endif()
endif()

if(FILESYSTEM_LIBRARY STREQUAL "CXX17")
set(CMAKE_CXX_STANDARD 17)
target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=0")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_link_libraries(rw_interface INTERFACE "stdc++fs")
endif()
elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS")
target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=1")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_link_libraries(rw_interface INTERFACE "stdc++fs")
endif()
else()
message(FATAL_ERROR "Illegal FILESYSTEM_LIBRARY option. (was '${FILESYSTEM_LIBRARY}')")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_link_libraries(rw_interface INTERFACE "stdc++fs")
endif()

if(ENABLE_SCRIPT_DEBUG)
Expand Down
3 changes: 0 additions & 3 deletions cmake_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ option(TEST_DATA "Enable tests that require game data")
set(FAILED_CHECK_ACTION "IGNORE" CACHE STRING "What action to perform on a failed RW_CHECK (in debug mode)")
set_property(CACHE FAILED_CHECK_ACTION PROPERTY STRINGS "IGNORE" "ABORT" "BREAKPOINT")

set(FILESYSTEM_LIBRARY "CXX17" CACHE STRING "Which filesystem library to use")
set_property(CACHE FILESYSTEM_LIBRARY PROPERTY STRINGS "CXX17" "CXXTS")

set(CMAKE_CONFIGURATION_TYPES "Release;Debug;RelWithDebInfo;MinSizeRel" CACHE INTERNAL "Build types supported by this project.")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}")
Expand Down
2 changes: 0 additions & 2 deletions openrw_iwyu.imp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
{ "include": [ "@<glm/gtx/\\.\\./gtc/quaternion\\.hpp>", "public", "<glm/gtc/quaternion.hpp>", "public"] },
{ "include": [ "@<glm/gtx/\\.\\./gtx/quaternion\\.hpp>", "public", "<glm/gtx/quaternion.hpp>", "public"] },
{ "symbol": [ "glm::value_ptr", "private", "<glm/gtc/type_ptr.hpp>", "public"] },
# Boost filesystem:
{ "include": [ "@<boost/filesystem/.*>", "private", "<boost/filesystem.hpp>", "public"] },
# Boost iterator:
{ "include": [ "@<boost/range/iterator_range_core\\.hpp>", "private", "<boost/range/iterator_range.hpp>", "public"] },
# Bullet:
Expand Down
1 change: 0 additions & 1 deletion rwcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ add_library(rwcore

rw/abort.cpp
rw/casts.hpp
rw/filesystem.hpp
rw/forward.hpp
rw/types.hpp
rw/debug.hpp
Expand Down
2 changes: 1 addition & 1 deletion rwcore/loaders/LoaderIMG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void to_lowercase_inplace(char* name) {

}

bool LoaderIMG::load(const rwfs::path& filepath) {
bool LoaderIMG::load(const std::filesystem::path& filepath) {
assert(m_archive.empty());
m_archive = filepath;

Expand Down
7 changes: 3 additions & 4 deletions rwcore/loaders/LoaderIMG.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
#define _LIBRW_LOADERIMG_HPP_

#include <cstddef>
#include <filesystem>
#include <string>
#include <vector>
#include <memory>
#include <fstream>

#include <rw/filesystem.hpp>

/// \brief Points to one file within the archive
class LoaderIMGFile {
public:
Expand Down Expand Up @@ -40,7 +39,7 @@ class LoaderIMG {
/// Load the structure of the archive
/// Omit the extension in filename so both .dir and .img are loaded when
/// appropriate
bool load(const rwfs::path& filepath);
bool load(const std::filesystem::path& filepath);

/// Load a file from the archive to memory and pass a pointer to it
/// Warning: Returns nullptr if by any reason it can't load the file
Expand Down Expand Up @@ -72,7 +71,7 @@ class LoaderIMG {

private:
Version m_version = GTAIIIVC; ///< Version of this IMG archive
rwfs::path m_archive; ///< Path to the archive being used (no extension)
std::filesystem::path m_archive; ///< Path to the archive being used (no extension)
std::ifstream m_archive_stream; ///< File stream for archive

std::vector<LoaderIMGFile> m_assets; ///< Asset info of the archive
Expand Down
2 changes: 1 addition & 1 deletion rwcore/loaders/LoaderSDT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "rw/debug.hpp"

bool LoaderSDT::load(const rwfs::path& sdtPath, const rwfs::path& rawPath) {
bool LoaderSDT::load(const std::filesystem::path& sdtPath, const std::filesystem::path& rawPath) {
const auto sdtName = sdtPath.string();
const auto rawName = rawPath.string();

Expand Down
5 changes: 2 additions & 3 deletions rwcore/loaders/LoaderSDT.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#ifndef _LIBRW_LOADERSDT_HPP_
#define _LIBRW_LOADERSDT_HPP_

#include <rw/filesystem.hpp>

#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <memory>
#include <string>
#include <vector>
Expand Down Expand Up @@ -62,7 +61,7 @@ class LoaderSDT {
~LoaderSDT() = default;

/// Load the structure of the archive
bool load(const rwfs::path& sdtPath, const rwfs::path& rawPath);
bool load(const std::filesystem::path& sdtPath, const std::filesystem::path& rawPath);

/// Load a file from the archive to memory and pass a pointer to it
/// Warning: Returns nullptr if by any reason it can't load the file
Expand Down
16 changes: 8 additions & 8 deletions rwcore/platform/FileIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ std::string FileIndex::normalizeFilePath(const std::string &filePath) {
return oss.str();
}

void FileIndex::indexTree(const rwfs::path &path) {
void FileIndex::indexTree(const std::filesystem::path &path) {
// Remove the trailing "/" or "/." from base_path. Boost 1.66 and c++17 have different lexically_relative behavior.
rwfs::path basePath = (path / ".").lexically_normal();
std::filesystem::path basePath = (path / ".").lexically_normal();
basePath = basePath.parent_path();

for (const rwfs::path &path :
rwfs::recursive_directory_iterator(basePath)) {
if (!rwfs::is_regular_file(path)) {
for (const std::filesystem::path &path :
std::filesystem::recursive_directory_iterator(basePath)) {
if (!std::filesystem::is_regular_file(path)) {
continue;
}
auto relPath = path.lexically_relative(basePath);
Expand All @@ -43,7 +43,7 @@ const FileIndex::IndexedData *FileIndex::getIndexedDataAt(const std::string &fil
return &indexedData_.at(normPath);
}

rwfs::path FileIndex::findFilePath(const std::string &filePath) const {
std::filesystem::path FileIndex::findFilePath(const std::string &filePath) const {
return getIndexedDataAt(filePath)->path;
}

Expand All @@ -70,7 +70,7 @@ FileContentsInfo FileIndex::openFileRaw(const std::string &filePath) const {
}

void FileIndex::indexArchive(const std::string &archive) {
rwfs::path path = findFilePath(archive);
std::filesystem::path path = findFilePath(archive);

LoaderIMG& img = loaders_[path.string()];
if (!img.load(path.string())) {
Expand Down Expand Up @@ -109,7 +109,7 @@ FileContentsInfo FileIndex::openFile(const std::string &filePath) {

auto& loader = loaderPos->second;
LoaderIMGFile file;
auto filename = rwfs::path(indexedData.assetData).filename().string();
auto filename = std::filesystem::path(indexedData.assetData).filename().string();
if (loader.findAssetInfo(filename, file)) {
length = file.size * 2048;
data = loader.loadToMemory(filename);
Expand Down
6 changes: 3 additions & 3 deletions rwcore/platform/FileIndex.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef _LIBRW_FILEINDEX_HPP_
#define _LIBRW_FILEINDEX_HPP_

#include <filesystem>
#include <unordered_map>
#include <memory>

#include <loaders/LoaderIMG.hpp>
#include <rw/filesystem.hpp>
#include <rw/forward.hpp>


Expand All @@ -25,15 +25,15 @@ class FileIndex {
* This is used to build the mapping of lower-case file paths to the
* true case on the file system for platforms where this is an issue.
*/
void indexTree(const rwfs::path &path);
void indexTree(const std::filesystem::path &path);

/**
* @brief findFilePath finds disk path for a game data file
* @param filePath the path to find
* @return The file path as it exists on disk
* @throws if this FileIndex has not indexed the path
*/
rwfs::path findFilePath(const std::string &filePath) const;
std::filesystem::path findFilePath(const std::string &filePath) const;

/**
* @brief openFileRaw Opens a raw file on the disk
Expand Down
34 changes: 0 additions & 34 deletions rwcore/rw/filesystem.hpp

This file was deleted.

1 change: 0 additions & 1 deletion rwengine/src/audio/SoundManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <glm/vec3.hpp>

#include <rw/filesystem.hpp>
#include <loaders/LoaderSDT.hpp>

#include <string>
Expand Down
12 changes: 6 additions & 6 deletions rwengine/src/audio/SoundSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool SoundSource::allocateAudioFrame() {
return true;
}

bool SoundSource::allocateFormatContext(const rwfs::path& filePath) {
bool SoundSource::allocateFormatContext(const std::filesystem::path& filePath) {
formatContext = nullptr;
if (avformat_open_input(&formatContext, filePath.string().c_str(), nullptr,
nullptr) != 0) {
Expand Down Expand Up @@ -100,7 +100,7 @@ bool SoundSource::prepareFormatContextSfx(LoaderSDT& sdt, size_t index,
return true;
}

bool SoundSource::findAudioStream(const rwfs::path& filePath) {
bool SoundSource::findAudioStream(const std::filesystem::path& filePath) {
RW_UNUSED(filePath); // it's used by macro

if (avformat_find_stream_info(formatContext, nullptr) < 0) {
Expand Down Expand Up @@ -354,15 +354,15 @@ void SoundSource::decodeFrames(size_t framesToDecode) {
}
}

void SoundSource::decodeFramesWrap(const rwfs::path& filePath) {
void SoundSource::decodeFramesWrap(const std::filesystem::path& filePath) {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 100)
decodeFramesLegacy(kNrFramesToPreload);
#else
decodeAndResampleFrames(filePath, kNrFramesToPreload);
#endif
}

void SoundSource::decodeAndResampleFrames(const rwfs::path& filePath,
void SoundSource::decodeAndResampleFrames(const std::filesystem::path& filePath,
size_t framesToDecode) {
RW_UNUSED(filePath); // it's used by macro
AVFrame* resampled = av_frame_alloc();
Expand Down Expand Up @@ -485,7 +485,7 @@ void SoundSource::exposeSfxMetadata(LoaderSDT& sdt) {
sampleRate = sdt.assetInfo.sampleRate;
}

void SoundSource::decodeRestSoundFramesAndCleanup(const rwfs::path& filePath) {
void SoundSource::decodeRestSoundFramesAndCleanup(const std::filesystem::path& filePath) {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 100)
decodeFramesLegacy(0);
#else
Expand All @@ -505,7 +505,7 @@ void SoundSource::decodeRestSfxFramesAndCleanup() {
cleanupAfterSfxLoading();
}

void SoundSource::loadFromFile(const rwfs::path& filePath, bool streaming) {
void SoundSource::loadFromFile(const std::filesystem::path& filePath, bool streaming) {
if (allocateAudioFrame() && allocateFormatContext(filePath) &&
findAudioStream(filePath) && prepareCodecContextWrap()) {
exposeSoundMetadata();
Expand Down
17 changes: 7 additions & 10 deletions rwengine/src/audio/SoundSource.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#ifndef _RWENGINE_SOUND_SOURCE_HPP_
#define _RWENGINE_SOUND_SOURCE_HPP_

#include <rw/filesystem.hpp>

extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
}

#include <cstdint>
#include <filesystem>
#include <future>
#include <mutex>
#include <vector>
Expand All @@ -25,8 +24,6 @@ class AVStream;
class AVIOContext;
class LoaderSDT;

class LoaderSDT;

/// Opaque for raw sound,
/// cooperate with ffmpeg
/// (loading and decoding sound)
Expand All @@ -38,10 +35,10 @@ class SoundSource {
public:
bool allocateAudioFrame();

bool allocateFormatContext(const rwfs::path& filePath);
bool allocateFormatContext(const std::filesystem::path& filePath);
bool prepareFormatContextSfx(LoaderSDT& sdt, size_t index, bool asWave);

bool findAudioStream(const rwfs::path& filePath);
bool findAudioStream(const std::filesystem::path& filePath);
bool findAudioStreamSfx();

bool prepareCodecContextWrap();
Expand All @@ -59,10 +56,10 @@ class SoundSource {
void decodeFramesLegacy(size_t framesToDecode);
#endif

void decodeFramesWrap(const rwfs::path& filePath);
void decodeFramesWrap(const std::filesystem::path& filePath);
void decodeFramesSfxWrap();
void decodeFrames(size_t framesToDecode);
void decodeAndResampleFrames(const rwfs::path& filePath,
void decodeAndResampleFrames(const std::filesystem::path& filePath,
size_t framesToDecode);

void cleanupAfterSoundLoading();
Expand All @@ -71,11 +68,11 @@ class SoundSource {
void exposeSoundMetadata();
void exposeSfxMetadata(LoaderSDT& sdt);

void decodeRestSoundFramesAndCleanup(const rwfs::path& filePath);
void decodeRestSoundFramesAndCleanup(const std::filesystem::path& filePath);
void decodeRestSfxFramesAndCleanup();

/// Load sound from mp3/wav file
void loadFromFile(const rwfs::path& filePath, bool streaming = false);
void loadFromFile(const std::filesystem::path& filePath, bool streaming = false);

/// Load sound from sdt file
void loadSfx(LoaderSDT& sdt, std::size_t index, bool asWave = true,
Expand Down
Loading

0 comments on commit c5e6709

Please sign in to comment.