Skip to content

Commit

Permalink
fix: compilation with BUILD_SHARED_LIBS with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Jan 3, 2025
1 parent d104e7c commit 6b6979b
Show file tree
Hide file tree
Showing 22 changed files with 124 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
apple-clang *
standards: '20'
latest-factors: |
msvc Optimized-Debug
msvc Optimized-Debug Shared
gcc Coverage
factors: ''
runs-on: |
Expand Down Expand Up @@ -375,6 +375,7 @@ jobs:
package-dir: packages
package-generators: ${{ matrix.mrdocs-package-generators }}
package-artifact: false
shared: ${{ matrix.shared }}

- name: Check YAML schema
run: |
Expand Down
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ if (WIN32)
target_compile_options(
mrdocs-core
PUBLIC
/permissive- # strict C++
/W4 # enable all warnings
/MP # multi-processor compilation
/EHs # C++ Exception handling
$<$<CONFIG:Debug>:/Oy-> # Disable frame pointer omission
/permissive- # strict C++
/W4 # enable all warnings
$<$<CXX_COMPILER_ID:MSVC>:/MP> # multi-processor compilation
/EHs # C++ Exception handling
$<$<CONFIG:Debug>:/Oy-> # Disable frame pointer omission
)
endif()
endif ()
Expand Down Expand Up @@ -326,7 +326,6 @@ list(APPEND TOOL_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/src/tool/PublicToolArgs.cpp)

add_executable(mrdocs ${TOOL_SOURCES})
target_compile_definitions(mrdocs PRIVATE -DMRDOCS_TOOL)

target_include_directories(mrdocs
PUBLIC
Expand All @@ -338,7 +337,6 @@ target_include_directories(mrdocs
"${PROJECT_BINARY_DIR}/src"
)

target_compile_definitions(mrdocs PRIVATE -DMRDOCS_TOOL)
target_link_libraries(mrdocs PUBLIC mrdocs-core)
if (MRDOCS_CLANG)
target_compile_options(
Expand Down Expand Up @@ -532,6 +530,7 @@ if (MRDOCS_INSTALL)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT development
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(EXPORT mrdocs-targets
Expand Down
4 changes: 1 addition & 3 deletions include/mrdocs/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MRDOCS_DECL
public:
/** Settings values used to generate the Corpus and Docs
*/
struct Settings : public PublicSettings
struct MRDOCS_DECL Settings : public PublicSettings
{
/**
* @brief Loads the public configuration settings from the specified YAML file.
Expand Down Expand Up @@ -157,13 +157,11 @@ class MRDOCS_DECL

/** Destructor.
*/
MRDOCS_DECL
virtual
~Config() noexcept = 0;

/** Return a pool of threads for executing work.
*/
MRDOCS_DECL
virtual
ThreadPool&
threadPool() const noexcept = 0;
Expand Down
10 changes: 10 additions & 0 deletions include/mrdocs/Dom/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,21 @@ class MRDOCS_DECL
/** Compare two arrays for equality.
*/
friend
MRDOCS_DECL
bool
operator==(Array const&, Array const&) noexcept;

/** Compare two arrays for precedence.
*/
friend
MRDOCS_DECL
std::strong_ordering
operator<=>(Array const&, Array const&) noexcept;

/** Return a diagnostic string.
*/
friend
MRDOCS_DECL
std::string
toString(Array const&);

Expand Down Expand Up @@ -364,6 +367,13 @@ class MRDOCS_DECL
DefaultArrayImpl();
explicit DefaultArrayImpl(
storage_type elements) noexcept;

DefaultArrayImpl(const DefaultArrayImpl&);
DefaultArrayImpl(DefaultArrayImpl&&);
DefaultArrayImpl& operator=(const DefaultArrayImpl&);
DefaultArrayImpl& operator=(DefaultArrayImpl&&);
~DefaultArrayImpl();

size_type size() const override;
value_type get(size_type i) const override;
void set(size_type i, Value v) override;
Expand Down
8 changes: 7 additions & 1 deletion include/mrdocs/Dom/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class MRDOCS_DECL
/** Compare two objects for equality.
*/
friend
MRDOCS_DECL
bool
operator==(Object const& a, Object const& b) noexcept;

Expand All @@ -318,7 +319,7 @@ class MRDOCS_DECL

/** Return a diagnostic string.
*/
friend std::string toString(Object const&);
friend MRDOCS_DECL std::string toString(Object const&);
};

//------------------------------------------------
Expand Down Expand Up @@ -402,6 +403,11 @@ class MRDOCS_DECL
{
public:
DefaultObjectImpl() noexcept;
DefaultObjectImpl(const DefaultObjectImpl&);
DefaultObjectImpl(DefaultObjectImpl&&);
DefaultObjectImpl& operator=(const DefaultObjectImpl&);
DefaultObjectImpl& operator=(DefaultObjectImpl&&);
~DefaultObjectImpl();

explicit DefaultObjectImpl(
storage_type entries) noexcept;
Expand Down
8 changes: 8 additions & 0 deletions include/mrdocs/Dom/Value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ namespace mrdocs {
@see https://handlebarsjs.com/api-reference/utilities.html#handlebars-safestring-string
*/
MRDOCS_DECL
dom::Value
safeString(std::string_view str);

MRDOCS_DECL
dom::Value
safeString(dom::Value const& str);

Expand Down Expand Up @@ -415,6 +417,7 @@ class MRDOCS_DECL
operator, which does not perform type conversions.
*/
friend
MRDOCS_DECL
bool
operator==(
Value const& lhs,
Expand All @@ -423,6 +426,7 @@ class MRDOCS_DECL
/** Compare two values for inequality.
*/
friend
MRDOCS_DECL
std::strong_ordering
operator<=>(
Value const& lhs,
Expand Down Expand Up @@ -453,6 +457,7 @@ class MRDOCS_DECL
/** Add or concatenate two values.
*/
friend
MRDOCS_DECL
dom::Value
operator+(Value const& lhs, Value const& rhs);

Expand All @@ -477,6 +482,7 @@ class MRDOCS_DECL
This function is equivalent to the JavaScript `||` operator.
*/
friend
MRDOCS_DECL
dom::Value
operator||(Value const& lhs, Value const& rhs);

Expand All @@ -501,6 +507,7 @@ class MRDOCS_DECL
This function is equivalent to the JavaScript `&&` operator.
*/
friend
MRDOCS_DECL
dom::Value
operator&&(Value const& lhs, Value const& rhs);

Expand All @@ -523,6 +530,7 @@ class MRDOCS_DECL
/** Return value as a string.
*/
friend
MRDOCS_DECL
std::string
toString(Value const& value);
};
Expand Down
12 changes: 11 additions & 1 deletion include/mrdocs/Metadata/Javadoc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ struct Copied : Reference
struct MRDOCS_DECL
Block : Node
{
Block(const Block&) = delete;
Block(Block&&);
Block& operator=(const Block&) = delete;
Block& operator=(Block&&);
~Block();

List<Text> children;

bool isBlock() const noexcept final
Expand Down Expand Up @@ -919,7 +925,6 @@ class MRDOCS_DECL
public:
/** Constructor.
*/
MRDOCS_DECL
Javadoc() noexcept;

/** Constructor
Expand All @@ -928,6 +933,11 @@ class MRDOCS_DECL
Javadoc(
doc::List<doc::Block> blocks);

Javadoc(const Javadoc&) = delete;
Javadoc(Javadoc&&);
Javadoc& operator=(const Javadoc&) = delete;
Javadoc& operator=(Javadoc&&);

/** Return true if this is empty
*/
bool
Expand Down
3 changes: 2 additions & 1 deletion include/mrdocs/Platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#ifndef MRDOCS_API_PLATFORM_HPP
#define MRDOCS_API_PLATFORM_HPP

#include <mrdocs/Support/Assert.hpp>
#include <type_traits>

#if __cplusplus < 202002L
Expand Down Expand Up @@ -79,4 +78,6 @@ namespace mrdocs {
} // mrdocs
} // clang

#include <mrdocs/Support/Assert.hpp>

#endif
2 changes: 2 additions & 0 deletions include/mrdocs/Support/Assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef MRDOCS_API_SUPPORT_ASSERT_HPP
#define MRDOCS_API_SUPPORT_ASSERT_HPP

#include <mrdocs/Platform.hpp>
#include <cstdint>

namespace clang {
Expand All @@ -30,6 +31,7 @@ namespace mrdocs {
#define MRDOCS_UNREACHABLE() static_cast<void>(__debugbreak(), __assume(false))
#endif

MRDOCS_DECL
void
assert_failed(
const char* msg,
Expand Down
6 changes: 3 additions & 3 deletions include/mrdocs/Support/Glob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace clang::mrdocs {
Nested brace expansions "{<glob>,"{<glob>,...}",...}" are not supported.
*/
class GlobPattern {
class MRDOCS_DECL GlobPattern {
struct Impl;
std::unique_ptr<Impl> impl_;
public:
Expand Down Expand Up @@ -110,7 +110,7 @@ class GlobPattern {
A glob pattern matcher where "*" does not match path separators.
The pattern "**" can be used to match any number of path separators.
*/
class PathGlobPattern {
class MRDOCS_DECL PathGlobPattern {
GlobPattern glob_;
public:
/** Constructs a PathGlobPattern with the given pattern.
Expand Down Expand Up @@ -201,7 +201,7 @@ class PathGlobPattern {
A glob pattern matcher where "*" does not match "::".
The pattern "**" can be used to match any number of "::".
*/
class SymbolGlobPattern {
class MRDOCS_DECL SymbolGlobPattern {
GlobPattern glob_;
public:
/** Constructs a SymbolGlobPattern with the given pattern.
Expand Down
2 changes: 1 addition & 1 deletion include/mrdocs/Support/Handlebars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ namespace detail {
@see https://handlebarsjs.com/
*/
class Handlebars {
class MRDOCS_DECL Handlebars {
using helpers_map = std::unordered_map<
std::string, dom::Function, detail::string_hash, std::equal_to<>>;

Expand Down
Loading

0 comments on commit 6b6979b

Please sign in to comment.