From b58117a5e7b6270ef03f266111d65cfbe6531842 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Fri, 17 Jan 2025 23:08:51 -0500 Subject: [PATCH] libeuropa: Add DLL export stuff Also allows us to re-add -fvisibility=hidden to Linux builds --- cmake/CompilerFlags-GNU.cmake | 2 +- include/europa/io/pak/Reader.hpp | 3 ++- include/europa/io/pak/Writer.hpp | 5 +++-- include/europa/io/yatf/Reader.hpp | 3 ++- include/europa/util/DllExport.hpp | 23 +++++++++++++++++++++++ include/europa/util/ImageSurface.hpp | 3 ++- 6 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 include/europa/util/DllExport.hpp diff --git a/cmake/CompilerFlags-GNU.cmake b/cmake/CompilerFlags-GNU.cmake index 6c0f10c..3c3b0a5 100644 --- a/cmake/CompilerFlags-GNU.cmake +++ b/cmake/CompilerFlags-GNU.cmake @@ -1,6 +1,6 @@ # TODO: This currently assumes libstdc++, later on we should *probably* set this with some detection # also TODO: Use a list so that this isn't one giant line (list JOIN should help.) -set(EUROPA_CORE_COMPILE_ARGS "-Wall -Wextra -Wformat=2 -Wimplicit-fallthrough") +set(EUROPA_CORE_COMPILE_ARGS "-Wall -Wextra -Wformat=2 -Wimplicit-fallthrough -fvisibility=hidden") set(EUROPA_CORE_LINKER_ARGS "-fuse-ld=${EUROPA_LINKER}") if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") # OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo" diff --git a/include/europa/io/pak/Reader.hpp b/include/europa/io/pak/Reader.hpp index d989928..a723ded 100644 --- a/include/europa/io/pak/Reader.hpp +++ b/include/europa/io/pak/Reader.hpp @@ -11,13 +11,14 @@ #include #include +#include #include #include namespace europa::io::pak { /// Reader for Europa package files (.pak). - struct Reader { + struct LIBEUROPA_EXPORT Reader { using FlatType = std::pair; using MapType = std::vector; diff --git a/include/europa/io/pak/Writer.hpp b/include/europa/io/pak/Writer.hpp index 834891e..84cf322 100644 --- a/include/europa/io/pak/Writer.hpp +++ b/include/europa/io/pak/Writer.hpp @@ -15,12 +15,13 @@ #include #include -#include "europa/structs/Pak.hpp" +#include +#include namespace europa::io::pak { /// A efficient writer for Europa package (.pak) files. - struct Writer { + struct LIBEUROPA_EXPORT Writer { /// Vocabulary type for making sector alignment stuff a bit easier to see. enum class SectorAlignment { DoNotAlign, /// Do not align to a sector boundary diff --git a/include/europa/io/yatf/Reader.hpp b/include/europa/io/yatf/Reader.hpp index daed642..f22d748 100644 --- a/include/europa/io/yatf/Reader.hpp +++ b/include/europa/io/yatf/Reader.hpp @@ -10,6 +10,7 @@ #define EUROPA_IO_YATFREADER_H #include +#include #include namespace europa::util { @@ -19,7 +20,7 @@ namespace europa::util { namespace europa::io::yatf { /// Reader for PS2 Europa .tex (YATF - Yet Another Texture Format) files. - struct Reader { + struct LIBEUROPA_EXPORT Reader { explicit Reader(std::istream& is); /// Read image. The image output to [surface] is converted to RGBA8888 implicitly. diff --git a/include/europa/util/DllExport.hpp b/include/europa/util/DllExport.hpp new file mode 100644 index 0000000..5bc4b53 --- /dev/null +++ b/include/europa/util/DllExport.hpp @@ -0,0 +1,23 @@ +// +// EuropaTools +// +// (C) 2021-2025 modeco80 +// +// SPDX-License-Identifier: MIT +// + +#pragma once + +#ifdef europa_EXPORTS + #ifdef _WIN32 + #define LIBEUROPA_EXPORT __declspec(dllexport) + #else + #define LIBEUROPA_EXPORT __attribute__((visibility("default"))) + #endif +#else + #ifdef _WIN32 + #define LIBEUROPA_EXPORT __declspec(dllimport) + #else + #define LIBEUROPA_EXPORT + #endif +#endif \ No newline at end of file diff --git a/include/europa/util/ImageSurface.hpp b/include/europa/util/ImageSurface.hpp index 9f67a82..6743315 100644 --- a/include/europa/util/ImageSurface.hpp +++ b/include/europa/util/ImageSurface.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace europa::util { @@ -66,7 +67,7 @@ namespace europa::util { #endif /// A RGBA8888 image surface. - struct ImageSurface { + struct LIBEUROPA_EXPORT ImageSurface { ImageSurface(); explicit ImageSurface(Size size);