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
50 changes: 50 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,52 @@ endif()
set(ESFA_PUBLIC_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(ESFA_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src")

# == Compiler Warnings ==

if(MSVC)
set(ESFA_WARNING_FLAGS
/W4
/permissive-
/w14242
/w14254
/w14263
/w14265
/w14287
/we4289
/w14296
/w14311
/w14545
/w14546
/w14547
/w14549
/w14555
/w14619
/w14640
/w14826
/w14905
/w14906
/w14928
)
else()
set(ESFA_WARNING_FLAGS
-Wall
-Wextra
-Wpedantic
-Wshadow
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wconversion
-Wsign-conversion
-Wnull-dereference
-Wdouble-promotion
-Wformat=2
-Wimplicit-fallthrough
)
endif()

# Processing

add_library(processing ${ESFA_LIB_TYPE}
Expand All @@ -34,6 +80,7 @@ add_library(processing ${ESFA_LIB_TYPE}
)

target_include_directories(processing PUBLIC ${ESFA_PUBLIC_INCLUDES} PRIVATE ${ESFA_SRC}/processing)
target_compile_options(processing PRIVATE ${ESFA_WARNING_FLAGS})

# Interface

Expand All @@ -42,16 +89,19 @@ add_library(interface ${ESFA_LIB_TYPE}
)

target_include_directories(interface PUBLIC ${ESFA_PUBLIC_INCLUDES} PRIVATE ${ESFA_SRC}/interface)
target_compile_options(interface PRIVATE ${ESFA_WARNING_FLAGS})

# esfa lib

add_library(esfa ${ESFA_SRC}/esfa.cpp)
target_include_directories(esfa PUBLIC ${ESFA_PUBLIC_INCLUDES})
target_link_libraries(esfa PUBLIC processing interface)
target_compile_options(esfa PRIVATE ${ESFA_WARNING_FLAGS})
set_target_properties(esfa PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})


# binary / tests

if(ESFA_BUILD_TESTS)
Expand Down
14 changes: 14 additions & 0 deletions include/esfa/esfa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class Processor {
std::any& ctx,
esfa::bit::Endianness sourceEndianness);

std::shared_ptr<interface::ParsedAsset> ParseAsset(
const std::string& typeKey,
std::shared_ptr<stream::Stream> inStream,
const interface::AssetMeta& meta,
std::any& ctx,
bit::Endianness sourceEndianness);

void ExportAsset(
const std::string& typeKey,
std::shared_ptr<interface::ParsedAsset> asset,
Expand All @@ -27,6 +34,13 @@ class Processor {
uint64_t maxSize =
std::numeric_limits<uint64_t>::max());

void ExportAsset(
const std::string& typeKey,
std::shared_ptr<interface::ParsedAsset> asset,
std::shared_ptr<stream::Stream> outStream,
std::any& ctx,
bit::Endianness targetEndianness,
uint64_t maxSize);
private:
const interface::Registry& mRegistry;
};
Expand Down
11 changes: 8 additions & 3 deletions include/esfa/interface/asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ class ParsedAsset {
// Minimal per-asset info the registry needs to pass through.
struct AssetMeta {
std::string name;
uint32_t offset;
uint32_t size;
uint32_t offset = 0;
uint32_t size = 0;
std::filesystem::path sourceFile;

// Allow asset to grow during swap (e.g., uncompressed formats)
// If not set, defaults to input size
std::optional<uint64_t> maxOutputSize;
std::optional<uint64_t> maxOutputSize = std::nullopt;

AssetMeta() = default;
AssetMeta(std::string n, uint32_t off, uint32_t sz, std::filesystem::path src,
std::optional<uint64_t> maxOut = std::nullopt)
: name(std::move(n)), offset(off), size(sz), sourceFile(std::move(src)), maxOutputSize(maxOut) {}
};

}
1 change: 1 addition & 0 deletions include/esfa/processing/binary/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Writer
Writer(std::shared_ptr<esfa::stream::Stream> nStream);

void SetEndianness(esfa::bit::Endianness endianness);
esfa::bit::Endianness GetEndianness() const;

std::shared_ptr<esfa::stream::Stream> GetStream();
uint64_t GetBaseAddress();
Expand Down
Loading
Loading