Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compilation with BUILD_SHARED_LIBS with MSVC #776

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ jobs:
apple-clang *
standards: '20'
latest-factors: |
msvc Optimized-Debug
msvc Optimized-Debug Shared
gcc Coverage
factors: ''
runs-on: |
@@ -388,6 +388,7 @@ jobs:
package-dir: packages
package-generators: ${{ matrix.mrdocs-package-generators }}
package-artifact: false
shared: ${{ matrix.shared }}

- name: Check YAML schema
run: |
19 changes: 11 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -300,11 +300,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 ()
@@ -334,7 +334,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
@@ -346,7 +345,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(
@@ -537,9 +535,14 @@ if (MRDOCS_INSTALL)
#-------------------------------------------------
install(TARGETS mrdocs-core
EXPORT mrdocs-targets
RUNTIME_DEPENDENCIES
PRE_EXCLUDE_REGEXES "^api-ms-.*\\.dll$" "^ext-ms-.*\\.dll$"
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll$"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT development
COMPONENT development
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(EXPORT mrdocs-targets
4 changes: 1 addition & 3 deletions include/mrdocs/Config.hpp
Original file line number Diff line number Diff line change
@@ -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.
@@ -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;
10 changes: 10 additions & 0 deletions include/mrdocs/Dom/Array.hpp
Original file line number Diff line number Diff line change
@@ -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&);

@@ -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;
8 changes: 7 additions & 1 deletion include/mrdocs/Dom/Object.hpp
Original file line number Diff line number Diff line change
@@ -298,6 +298,7 @@ class MRDOCS_DECL
/** Compare two objects for equality.
*/
friend
MRDOCS_DECL
bool
operator==(Object const& a, Object const& b) noexcept;

@@ -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&);
};

//------------------------------------------------
@@ -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;
8 changes: 8 additions & 0 deletions include/mrdocs/Dom/Value.hpp
Original file line number Diff line number Diff line change
@@ -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);

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

@@ -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);

@@ -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);

@@ -523,6 +530,7 @@ class MRDOCS_DECL
/** Return value as a string.
*/
friend
MRDOCS_DECL
std::string
toString(Value const& value);
};
2 changes: 1 addition & 1 deletion include/mrdocs/Metadata/Info.hpp
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ tag_invoke(

/** Base class with common properties of all symbols
*/
struct MRDOCS_VISIBLE Info
struct MRDOCS_DECL Info
: SourceInfo
{
/** The unique identifier for this symbol.
13 changes: 12 additions & 1 deletion include/mrdocs/Metadata/Javadoc.hpp
Original file line number Diff line number Diff line change
@@ -375,6 +375,13 @@ struct MRDOCS_DECL
{
std::vector<PolymorphicValue<Text>> children;

Block(Block&&);
Block(const Block&);
~Block();

Block &operator=(Block&&);
Block &operator=(const Block&);

bool isBlock() const noexcept final
{
return true;
@@ -979,7 +986,6 @@ struct MRDOCS_DECL

/** Constructor.
*/
MRDOCS_DECL
Javadoc() noexcept;

/** Constructor
@@ -988,6 +994,11 @@ struct MRDOCS_DECL
Javadoc(
std::vector<PolymorphicValue<doc::Block>> blocks);

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

/** Return true if this is empty
*/
bool
3 changes: 2 additions & 1 deletion include/mrdocs/Platform.hpp
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -11,6 +11,7 @@
#ifndef MRDOCS_API_SUPPORT_ASSERT_HPP
#define MRDOCS_API_SUPPORT_ASSERT_HPP

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

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

MRDOCS_DECL
void
assert_failed(
char const* msg,
6 changes: 3 additions & 3 deletions include/mrdocs/Support/Glob.hpp
Original file line number Diff line number Diff line change
@@ -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:
@@ -120,7 +120,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.
@@ -224,7 +224,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.
2 changes: 1 addition & 1 deletion include/mrdocs/Support/Handlebars.hpp
Original file line number Diff line number Diff line change
@@ -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<>>;

24 changes: 12 additions & 12 deletions include/mrdocs/Support/JavaScript.hpp
Original file line number Diff line number Diff line change
@@ -414,7 +414,7 @@ class MRDOCS_DECL Value
via @ref Scope::reset.
*/
MRDOCS_DECL ~Value();
~Value();

/** Constructor
@@ -424,36 +424,36 @@ class MRDOCS_DECL Value
The value is undefined.
*/
MRDOCS_DECL Value() noexcept;
Value() noexcept;

/** Constructor
The function pushes a duplicate of
value to the stack and associates
the new value the top of the stack.
*/
MRDOCS_DECL Value(Value const&);
Value(Value const&);

/** Constructor
The function associates the
existing value with this object.
*/
MRDOCS_DECL Value(Value&&) noexcept;
Value(Value&&) noexcept;

/** Copy assignment.
@copydetails Value(Value const&)
*/
MRDOCS_DECL Value& operator=(Value const&);
Value& operator=(Value const&);

/** Move assignment.
@copydetails Value(Value&&)
*/
MRDOCS_DECL Value& operator=(Value&&) noexcept;
Value& operator=(Value&&) noexcept;

/** Return the type of the value.
@@ -476,7 +476,7 @@ class MRDOCS_DECL Value
internal ECMAScript class `Function`.
*/
MRDOCS_DECL Type type() const noexcept;
Type type() const noexcept;

/// Check if the value is undefined.
bool
@@ -706,15 +706,13 @@ class MRDOCS_DECL Value

/** Set or replace the value for a given key.
*/
MRDOCS_DECL
void
set(
std::string_view key,
Value const& value) const;

/** Set or replace the value for a given key.
*/
MRDOCS_DECL
void
set(
std::string_view key,
@@ -821,6 +819,7 @@ class MRDOCS_DECL Value
operator, which does not perform type conversions.
*/
friend
MRDOCS_DECL
bool
operator==(
Value const& lhs,
@@ -870,6 +869,7 @@ class MRDOCS_DECL Value
/** Compare two values for inequality.
*/
friend
MRDOCS_DECL
std::strong_ordering
operator<=>(
Value const& lhs,
@@ -880,6 +880,7 @@ class MRDOCS_DECL Value
This function is equivalent to the JavaScript `||` operator.
*/
friend
MRDOCS_DECL
Value
operator||(Value const& lhs, Value const& rhs);

@@ -904,6 +905,7 @@ class MRDOCS_DECL Value
This function is equivalent to the JavaScript `&&` operator.
*/
friend
MRDOCS_DECL
Value
operator&&(Value const& lhs, Value const& rhs);

@@ -928,20 +930,18 @@ class MRDOCS_DECL Value
This function coerces any value to a string.
*/
friend
MRDOCS_DECL
std::string
toString(Value const& value);

private:
MRDOCS_DECL
Expected<Value>
callImpl(
std::initializer_list<dom::Value> args) const;

MRDOCS_DECL
Expected<Value>
callImpl(std::span<dom::Value> args) const;

MRDOCS_DECL
Expected<Value>
callPropImpl(
std::string_view prop,
2 changes: 1 addition & 1 deletion include/mrdocs/Support/ThreadPool.hpp
Original file line number Diff line number Diff line change
@@ -149,8 +149,8 @@ class MRDOCS_VISIBLE
@return Zero or more errors which were
thrown from submitted work.
*/
MRDOCS_DECL
[[nodiscard]]
MRDOCS_DECL
std::vector<Error>
wait();

17 changes: 17 additions & 0 deletions src/lib/Dom/Array.cpp
Original file line number Diff line number Diff line change
@@ -164,6 +164,23 @@ emplace_back(
DefaultArrayImpl::
DefaultArrayImpl() = default;

DefaultArrayImpl::
DefaultArrayImpl(const DefaultArrayImpl&) = default;

DefaultArrayImpl::
DefaultArrayImpl(DefaultArrayImpl&&) = default;

DefaultArrayImpl&
DefaultArrayImpl::
operator=(const DefaultArrayImpl&) = default;

DefaultArrayImpl&
DefaultArrayImpl::
operator=(DefaultArrayImpl&&) = default;

DefaultArrayImpl::
~DefaultArrayImpl() = default;

DefaultArrayImpl::
DefaultArrayImpl(
storage_type elements) noexcept
17 changes: 17 additions & 0 deletions src/lib/Dom/Object.cpp
Original file line number Diff line number Diff line change
@@ -139,6 +139,23 @@ DefaultObjectImpl(
{
}

DefaultObjectImpl::
DefaultObjectImpl(const DefaultObjectImpl&) = default;

DefaultObjectImpl::
DefaultObjectImpl(DefaultObjectImpl&&) = default;

DefaultObjectImpl&
DefaultObjectImpl::
operator=(const DefaultObjectImpl&) = default;

DefaultObjectImpl&
DefaultObjectImpl::
operator=(DefaultObjectImpl&&) = default;

DefaultObjectImpl::
~DefaultObjectImpl() = default;

std::size_t
DefaultObjectImpl::
size() const
1 change: 1 addition & 0 deletions src/lib/Gen/hbs/HandlebarsGenerator.hpp
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ class HandlebarsGenerator

/** Build a tagfile for the corpus.
*/
MRDOCS_DECL
Expected<void>
buildTagfile(
std::ostream& os,
1 change: 1 addition & 0 deletions src/lib/Lib/CMakeExecution.hpp
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ namespace mrdocs {
* @return An `Expected` object containing the path to the generated `compile_commands.json` file if successful.
* Returns `Unexpected` if the project path is not found or if CMake execution fails.
*/
MRDOCS_DECL
Expected<std::string>
executeCmakeExportCompileCommands(llvm::StringRef projectPath, llvm::StringRef cmakeArgs, llvm::StringRef tempDir);

1 change: 1 addition & 0 deletions src/lib/Lib/ConfigImpl.hpp
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@ class ConfigImpl
@param threadPool The thread pool to use.
*/
MRDOCS_DECL
static
Expected<std::shared_ptr<ConfigImpl const>>
load(
3 changes: 2 additions & 1 deletion src/lib/Lib/CorpusImpl.hpp
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ namespace clang::mrdocs {
*/
class CorpusImpl : public Corpus
{
MRDOCS_DECL
friend
void
finalize(CorpusImpl& corpus);
@@ -85,8 +86,8 @@ class CorpusImpl : public Corpus
@param config A shared pointer to the configuration.
@param compilations A compilations database for the input files.
*/
// MRDOCS_DECL
[[nodiscard]]
MRDOCS_DECL
static
mrdocs::Expected<std::unique_ptr<Corpus>>
build(
2 changes: 1 addition & 1 deletion src/lib/Lib/MrDocsCompilationDatabase.hpp
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ namespace mrdocs {
- Warnings are disabled
*/
class MrDocsCompilationDatabase
class MRDOCS_DECL MrDocsCompilationDatabase
: public tooling::CompilationDatabase
{
std::vector<tooling::CompileCommand> AllCommands_;
30 changes: 30 additions & 0 deletions src/lib/Metadata/Javadoc.cpp
Original file line number Diff line number Diff line change
@@ -23,6 +23,22 @@ namespace mrdocs {

namespace doc {

Block::
Block(Block&&) = default;

Block&
Block::
operator=(Block&&) = default;

Block::~Block() = default;

Block::
Block(const Block&) = default;

Block&
Block::
operator=(const Block&) = default;

Text&
Block::
emplace_back(
@@ -87,6 +103,20 @@ Javadoc(
{
}

Javadoc::
Javadoc(Javadoc&&) = default;

Javadoc::
Javadoc(const Javadoc&) = default;

Javadoc&
Javadoc::
operator=(Javadoc&&) = default;

Javadoc&
Javadoc::
operator=(const Javadoc&) = default;

doc::Paragraph const*
Javadoc::
getBrief(Corpus const& corpus) const noexcept
5 changes: 3 additions & 2 deletions src/lib/Support/Path.hpp
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ using SmallPathString = llvm::SmallString<340>;
On Unix, this function is a no-op because backslashes
are valid path chracters.
*/
MRDOCS_DECL
llvm::StringRef
convert_to_slash(
llvm::SmallVectorImpl<char> &path,
@@ -43,7 +44,7 @@ convert_to_slash(

/** A temporary file that is deleted when it goes out of scope.
*/
class ScopedTempFile
class MRDOCS_DECL ScopedTempFile
{
clang::mrdocs::SmallPathString path_;
bool ok_ = false;
@@ -83,7 +84,7 @@ class ScopedTempFile

/** A temporary directory that is deleted when it goes out of scope.
*/
class ScopedTempDirectory
class MRDOCS_DECL ScopedTempDirectory
{
clang::mrdocs::SmallPathString path_;
bool ok_ = false;