Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 054261a

Browse files
committedJan 3, 2025··
fix: compilation with BUILD_SHARED_LIBS with MSVC
1 parent d104e7c commit 054261a

22 files changed

+129
-37
lines changed
 

‎.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
apple-clang *
4141
standards: '20'
4242
latest-factors: |
43-
msvc Optimized-Debug
43+
msvc Optimized-Debug Shared
4444
gcc Coverage
4545
factors: ''
4646
runs-on: |
@@ -375,6 +375,7 @@ jobs:
375375
package-dir: packages
376376
package-generators: ${{ matrix.mrdocs-package-generators }}
377377
package-artifact: false
378+
shared: ${{ matrix.shared }}
378379

379380
- name: Check YAML schema
380381
run: |

‎CMakeLists.txt

+11-8
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ if (WIN32)
292292
target_compile_options(
293293
mrdocs-core
294294
PUBLIC
295-
/permissive- # strict C++
296-
/W4 # enable all warnings
297-
/MP # multi-processor compilation
298-
/EHs # C++ Exception handling
299-
$<$<CONFIG:Debug>:/Oy-> # Disable frame pointer omission
295+
/permissive- # strict C++
296+
/W4 # enable all warnings
297+
$<$<CXX_COMPILER_ID:MSVC>:/MP> # multi-processor compilation
298+
/EHs # C++ Exception handling
299+
$<$<CONFIG:Debug>:/Oy-> # Disable frame pointer omission
300300
)
301301
endif()
302302
endif ()
@@ -326,7 +326,6 @@ list(APPEND TOOL_SOURCES
326326
${CMAKE_CURRENT_BINARY_DIR}/src/tool/PublicToolArgs.cpp)
327327

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

331330
target_include_directories(mrdocs
332331
PUBLIC
@@ -338,7 +337,6 @@ target_include_directories(mrdocs
338337
"${PROJECT_BINARY_DIR}/src"
339338
)
340339

341-
target_compile_definitions(mrdocs PRIVATE -DMRDOCS_TOOL)
342340
target_link_libraries(mrdocs PUBLIC mrdocs-core)
343341
if (MRDOCS_CLANG)
344342
target_compile_options(
@@ -529,9 +527,14 @@ if (MRDOCS_INSTALL)
529527
#-------------------------------------------------
530528
install(TARGETS mrdocs-core
531529
EXPORT mrdocs-targets
530+
RUNTIME_DEPENDENCIES
531+
PRE_EXCLUDE_REGEXES "^api-ms-.*\\.dll$" "^ext-ms-.*\\.dll$"
532+
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll$"
532533
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
533534
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
534-
COMPONENT development
535+
COMPONENT development
536+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
537+
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
535538
)
536539

537540
install(EXPORT mrdocs-targets

‎include/mrdocs/Config.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MRDOCS_DECL
6060
public:
6161
/** Settings values used to generate the Corpus and Docs
6262
*/
63-
struct Settings : public PublicSettings
63+
struct MRDOCS_DECL Settings : public PublicSettings
6464
{
6565
/**
6666
* @brief Loads the public configuration settings from the specified YAML file.
@@ -157,13 +157,11 @@ class MRDOCS_DECL
157157

158158
/** Destructor.
159159
*/
160-
MRDOCS_DECL
161160
virtual
162161
~Config() noexcept = 0;
163162

164163
/** Return a pool of threads for executing work.
165164
*/
166-
MRDOCS_DECL
167165
virtual
168166
ThreadPool&
169167
threadPool() const noexcept = 0;

‎include/mrdocs/Dom/Array.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,21 @@ class MRDOCS_DECL
269269
/** Compare two arrays for equality.
270270
*/
271271
friend
272+
MRDOCS_DECL
272273
bool
273274
operator==(Array const&, Array const&) noexcept;
274275

275276
/** Compare two arrays for precedence.
276277
*/
277278
friend
279+
MRDOCS_DECL
278280
std::strong_ordering
279281
operator<=>(Array const&, Array const&) noexcept;
280282

281283
/** Return a diagnostic string.
282284
*/
283285
friend
286+
MRDOCS_DECL
284287
std::string
285288
toString(Array const&);
286289

@@ -364,6 +367,13 @@ class MRDOCS_DECL
364367
DefaultArrayImpl();
365368
explicit DefaultArrayImpl(
366369
storage_type elements) noexcept;
370+
371+
DefaultArrayImpl(const DefaultArrayImpl&);
372+
DefaultArrayImpl(DefaultArrayImpl&&);
373+
DefaultArrayImpl& operator=(const DefaultArrayImpl&);
374+
DefaultArrayImpl& operator=(DefaultArrayImpl&&);
375+
~DefaultArrayImpl();
376+
367377
size_type size() const override;
368378
value_type get(size_type i) const override;
369379
void set(size_type i, Value v) override;

‎include/mrdocs/Dom/Object.hpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ class MRDOCS_DECL
298298
/** Compare two objects for equality.
299299
*/
300300
friend
301+
MRDOCS_DECL
301302
bool
302303
operator==(Object const& a, Object const& b) noexcept;
303304

@@ -318,7 +319,7 @@ class MRDOCS_DECL
318319

319320
/** Return a diagnostic string.
320321
*/
321-
friend std::string toString(Object const&);
322+
friend MRDOCS_DECL std::string toString(Object const&);
322323
};
323324

324325
//------------------------------------------------
@@ -402,6 +403,11 @@ class MRDOCS_DECL
402403
{
403404
public:
404405
DefaultObjectImpl() noexcept;
406+
DefaultObjectImpl(const DefaultObjectImpl&);
407+
DefaultObjectImpl(DefaultObjectImpl&&);
408+
DefaultObjectImpl& operator=(const DefaultObjectImpl&);
409+
DefaultObjectImpl& operator=(DefaultObjectImpl&&);
410+
~DefaultObjectImpl();
405411

406412
explicit DefaultObjectImpl(
407413
storage_type entries) noexcept;

‎include/mrdocs/Dom/Value.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ namespace mrdocs {
4646
4747
@see https://handlebarsjs.com/api-reference/utilities.html#handlebars-safestring-string
4848
*/
49+
MRDOCS_DECL
4950
dom::Value
5051
safeString(std::string_view str);
5152

53+
MRDOCS_DECL
5254
dom::Value
5355
safeString(dom::Value const& str);
5456

@@ -415,6 +417,7 @@ class MRDOCS_DECL
415417
operator, which does not perform type conversions.
416418
*/
417419
friend
420+
MRDOCS_DECL
418421
bool
419422
operator==(
420423
Value const& lhs,
@@ -423,6 +426,7 @@ class MRDOCS_DECL
423426
/** Compare two values for inequality.
424427
*/
425428
friend
429+
MRDOCS_DECL
426430
std::strong_ordering
427431
operator<=>(
428432
Value const& lhs,
@@ -453,6 +457,7 @@ class MRDOCS_DECL
453457
/** Add or concatenate two values.
454458
*/
455459
friend
460+
MRDOCS_DECL
456461
dom::Value
457462
operator+(Value const& lhs, Value const& rhs);
458463

@@ -477,6 +482,7 @@ class MRDOCS_DECL
477482
This function is equivalent to the JavaScript `||` operator.
478483
*/
479484
friend
485+
MRDOCS_DECL
480486
dom::Value
481487
operator||(Value const& lhs, Value const& rhs);
482488

@@ -501,6 +507,7 @@ class MRDOCS_DECL
501507
This function is equivalent to the JavaScript `&&` operator.
502508
*/
503509
friend
510+
MRDOCS_DECL
504511
dom::Value
505512
operator&&(Value const& lhs, Value const& rhs);
506513

@@ -523,6 +530,7 @@ class MRDOCS_DECL
523530
/** Return value as a string.
524531
*/
525532
friend
533+
MRDOCS_DECL
526534
std::string
527535
toString(Value const& value);
528536
};

‎include/mrdocs/Metadata/Javadoc.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ struct Copied : Reference
371371
struct MRDOCS_DECL
372372
Block : Node
373373
{
374+
Block(const Block&) = delete;
375+
Block(Block&&);
376+
Block& operator=(const Block&) = delete;
377+
Block& operator=(Block&&);
378+
~Block();
379+
374380
List<Text> children;
375381

376382
bool isBlock() const noexcept final
@@ -919,7 +925,6 @@ class MRDOCS_DECL
919925
public:
920926
/** Constructor.
921927
*/
922-
MRDOCS_DECL
923928
Javadoc() noexcept;
924929

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

936+
Javadoc(const Javadoc&) = delete;
937+
Javadoc(Javadoc&&);
938+
Javadoc& operator=(const Javadoc&) = delete;
939+
Javadoc& operator=(Javadoc&&);
940+
931941
/** Return true if this is empty
932942
*/
933943
bool

‎include/mrdocs/Platform.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#ifndef MRDOCS_API_PLATFORM_HPP
1212
#define MRDOCS_API_PLATFORM_HPP
1313

14-
#include <mrdocs/Support/Assert.hpp>
1514
#include <type_traits>
1615

1716
#if __cplusplus < 202002L
@@ -79,4 +78,6 @@ namespace mrdocs {
7978
} // mrdocs
8079
} // clang
8180

81+
#include <mrdocs/Support/Assert.hpp>
82+
8283
#endif

‎include/mrdocs/Support/Assert.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef MRDOCS_API_SUPPORT_ASSERT_HPP
1212
#define MRDOCS_API_SUPPORT_ASSERT_HPP
1313

14+
#include <mrdocs/Platform.hpp>
1415
#include <cstdint>
1516

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

34+
MRDOCS_DECL
3335
void
3436
assert_failed(
3537
const char* msg,

‎include/mrdocs/Support/Glob.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace clang::mrdocs {
3131
3232
Nested brace expansions "{<glob>,"{<glob>,...}",...}" are not supported.
3333
*/
34-
class GlobPattern {
34+
class MRDOCS_DECL GlobPattern {
3535
struct Impl;
3636
std::unique_ptr<Impl> impl_;
3737
public:
@@ -110,7 +110,7 @@ class GlobPattern {
110110
A glob pattern matcher where "*" does not match path separators.
111111
The pattern "**" can be used to match any number of path separators.
112112
*/
113-
class PathGlobPattern {
113+
class MRDOCS_DECL PathGlobPattern {
114114
GlobPattern glob_;
115115
public:
116116
/** Constructs a PathGlobPattern with the given pattern.
@@ -201,7 +201,7 @@ class PathGlobPattern {
201201
A glob pattern matcher where "*" does not match "::".
202202
The pattern "**" can be used to match any number of "::".
203203
*/
204-
class SymbolGlobPattern {
204+
class MRDOCS_DECL SymbolGlobPattern {
205205
GlobPattern glob_;
206206
public:
207207
/** Constructs a SymbolGlobPattern with the given pattern.

‎include/mrdocs/Support/Handlebars.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ namespace detail {
633633
634634
@see https://handlebarsjs.com/
635635
*/
636-
class Handlebars {
636+
class MRDOCS_DECL Handlebars {
637637
using helpers_map = std::unordered_map<
638638
std::string, dom::Function, detail::string_hash, std::equal_to<>>;
639639

‎include/mrdocs/Support/JavaScript.hpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class MRDOCS_DECL Value
414414
via @ref Scope::reset.
415415
416416
*/
417-
MRDOCS_DECL ~Value();
417+
~Value();
418418

419419
/** Constructor
420420
@@ -424,36 +424,36 @@ class MRDOCS_DECL Value
424424
The value is undefined.
425425
426426
*/
427-
MRDOCS_DECL Value() noexcept;
427+
Value() noexcept;
428428

429429
/** Constructor
430430
431431
The function pushes a duplicate of
432432
value to the stack and associates
433433
the new value the top of the stack.
434434
*/
435-
MRDOCS_DECL Value(Value const&);
435+
Value(Value const&);
436436

437437
/** Constructor
438438
439439
The function associates the
440440
existing value with this object.
441441
*/
442-
MRDOCS_DECL Value(Value&&) noexcept;
442+
Value(Value&&) noexcept;
443443

444444
/** Copy assignment.
445445
446446
@copydetails Value(Value const&)
447447
448448
*/
449-
MRDOCS_DECL Value& operator=(Value const&);
449+
Value& operator=(Value const&);
450450

451451
/** Move assignment.
452452
453453
@copydetails Value(Value&&)
454454
455455
*/
456-
MRDOCS_DECL Value& operator=(Value&&) noexcept;
456+
Value& operator=(Value&&) noexcept;
457457

458458
/** Return the type of the value.
459459
@@ -476,7 +476,7 @@ class MRDOCS_DECL Value
476476
internal ECMAScript class `Function`.
477477
478478
*/
479-
MRDOCS_DECL Type type() const noexcept;
479+
Type type() const noexcept;
480480

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

707707
/** Set or replace the value for a given key.
708708
*/
709-
MRDOCS_DECL
710709
void
711710
set(
712711
std::string_view key,
713712
Value const& value) const;
714713

715714
/** Set or replace the value for a given key.
716715
*/
717-
MRDOCS_DECL
718716
void
719717
set(
720718
std::string_view key,
@@ -821,6 +819,7 @@ class MRDOCS_DECL Value
821819
operator, which does not perform type conversions.
822820
*/
823821
friend
822+
MRDOCS_DECL
824823
bool
825824
operator==(
826825
Value const& lhs,
@@ -870,6 +869,7 @@ class MRDOCS_DECL Value
870869
/** Compare two values for inequality.
871870
*/
872871
friend
872+
MRDOCS_DECL
873873
std::strong_ordering
874874
operator<=>(
875875
Value const& lhs,
@@ -880,6 +880,7 @@ class MRDOCS_DECL Value
880880
This function is equivalent to the JavaScript `||` operator.
881881
*/
882882
friend
883+
MRDOCS_DECL
883884
Value
884885
operator||(Value const& lhs, Value const& rhs);
885886

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

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

934937
private:
935-
MRDOCS_DECL
936938
Expected<Value>
937939
callImpl(
938940
std::initializer_list<dom::Value> args) const;
939941

940-
MRDOCS_DECL
941942
Expected<Value>
942943
callImpl(std::span<dom::Value> args) const;
943944

944-
MRDOCS_DECL
945945
Expected<Value>
946946
callPropImpl(
947947
std::string_view prop,

‎include/mrdocs/Support/ThreadPool.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class MRDOCS_VISIBLE
149149
@return Zero or more errors which were
150150
thrown from submitted work.
151151
*/
152-
MRDOCS_DECL
153152
[[nodiscard]]
153+
MRDOCS_DECL
154154
std::vector<Error>
155155
wait();
156156

‎src/lib/Dom/Array.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,23 @@ emplace_back(
164164
DefaultArrayImpl::
165165
DefaultArrayImpl() = default;
166166

167+
DefaultArrayImpl::
168+
DefaultArrayImpl(const DefaultArrayImpl&) = default;
169+
170+
DefaultArrayImpl::
171+
DefaultArrayImpl(DefaultArrayImpl&&) = default;
172+
173+
DefaultArrayImpl&
174+
DefaultArrayImpl::
175+
operator=(const DefaultArrayImpl&) = default;
176+
177+
DefaultArrayImpl&
178+
DefaultArrayImpl::
179+
operator=(DefaultArrayImpl&&) = default;
180+
181+
DefaultArrayImpl::
182+
~DefaultArrayImpl() = default;
183+
167184
DefaultArrayImpl::
168185
DefaultArrayImpl(
169186
storage_type elements) noexcept

‎src/lib/Dom/Object.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ DefaultObjectImpl(
139139
{
140140
}
141141

142+
DefaultObjectImpl::
143+
DefaultObjectImpl(const DefaultObjectImpl&) = default;
144+
145+
DefaultObjectImpl::
146+
DefaultObjectImpl(DefaultObjectImpl&&) = default;
147+
148+
DefaultObjectImpl&
149+
DefaultObjectImpl::
150+
operator=(const DefaultObjectImpl&) = default;
151+
152+
DefaultObjectImpl&
153+
DefaultObjectImpl::
154+
operator=(DefaultObjectImpl&&) = default;
155+
156+
DefaultObjectImpl::
157+
~DefaultObjectImpl() = default;
158+
142159
std::size_t
143160
DefaultObjectImpl::
144161
size() const

‎src/lib/Lib/CMakeExecution.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace mrdocs {
3131
* @return An `Expected` object containing the path to the generated `compile_commands.json` file if successful.
3232
* Returns `Unexpected` if the project path is not found or if CMake execution fails.
3333
*/
34+
MRDOCS_DECL
3435
Expected<std::string>
3536
executeCmakeExportCompileCommands(llvm::StringRef projectPath, llvm::StringRef cmakeArgs, llvm::StringRef tempDir);
3637

‎src/lib/Lib/Config.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ struct PublicSettingsVisitor {
258258
{
259259
for (auto& value : values)
260260
{
261-
MRDOCS_DECL(normalizeStringPath(self, name, value, dirs, opts, usingDefault));
261+
MRDOCS_TRY(normalizeStringPath(self, name, value, dirs, opts, usingDefault));
262262
}
263263

264264
// Move command line sink values to appropriate destinations

‎src/lib/Lib/ConfigImpl.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class ConfigImpl
9696
9797
@param threadPool The thread pool to use.
9898
*/
99+
MRDOCS_DECL
99100
static
100101
Expected<std::shared_ptr<ConfigImpl const>>
101102
load(

‎src/lib/Lib/CorpusImpl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class CorpusImpl : public Corpus
8282
@param config A shared pointer to the configuration.
8383
@param compilations A compilations database for the input files.
8484
*/
85-
// MRDOCS_DECL
8685
[[nodiscard]]
86+
MRDOCS_DECL
8787
static
8888
mrdocs::Expected<std::unique_ptr<Corpus>>
8989
build(

‎src/lib/Lib/MrDocsCompilationDatabase.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace mrdocs {
3333
- Warnings are disabled
3434
3535
*/
36-
class MrDocsCompilationDatabase
36+
class MRDOCS_DECL MrDocsCompilationDatabase
3737
: public tooling::CompilationDatabase
3838
{
3939
std::vector<tooling::CompileCommand> AllCommands_;

‎src/lib/Metadata/Javadoc.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ namespace mrdocs {
2323

2424
namespace doc {
2525

26+
Block::
27+
Block(Block&&) = default;
28+
29+
Block&
30+
Block::
31+
operator=(Block&&) = default;
32+
33+
Block::~Block() = default;
34+
2635
Text&
2736
Block::
2837
emplace_back(
@@ -149,6 +158,13 @@ Javadoc(
149158
{
150159
}
151160

161+
Javadoc::
162+
Javadoc(Javadoc&&) = default;
163+
164+
Javadoc&
165+
Javadoc::
166+
operator=(Javadoc&&) = default;
167+
152168
doc::Paragraph const*
153169
Javadoc::
154170
getBrief(Corpus const& corpus) const noexcept

‎src/lib/Support/Path.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ using SmallPathString = llvm::SmallString<340>;
3535
On Unix, this function is a no-op because backslashes
3636
are valid path chracters.
3737
*/
38+
MRDOCS_DECL
3839
llvm::StringRef
3940
convert_to_slash(
4041
llvm::SmallVectorImpl<char> &path,
@@ -43,7 +44,7 @@ convert_to_slash(
4344

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

8485
/** A temporary directory that is deleted when it goes out of scope.
8586
*/
86-
class ScopedTempDirectory
87+
class MRDOCS_DECL ScopedTempDirectory
8788
{
8889
clang::mrdocs::SmallPathString path_;
8990
bool ok_ = false;

0 commit comments

Comments
 (0)
Please sign in to comment.