Skip to content

Commit f67925c

Browse files
committed
std/boost unit headers
Enable ScanSourceForModuleDependencies for Module project manually
1 parent 7b2d027 commit f67925c

File tree

26 files changed

+279
-83
lines changed

26 files changed

+279
-83
lines changed

main.sharpmake.cs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,16 @@ public virtual void ConfigureAll(Configuration conf, CustomTarget target)
8686
conf.AdditionalCompilerOptions.Add("/bigobj");
8787

8888
conf.Defines.Add("_MBCS");
89-
conf.Defines.Add("_SCL_SECURE_NO_WARNINGS");
89+
conf.Defines.Add("BOOST_NO_USER_CONFIG");
90+
conf.Defines.Add("BOOST_ENDIAN_DEPRECATED_NAMES");
91+
conf.Defines.Add("BOOST_ALL_NO_LIB");
92+
93+
conf.Defines.Add("_SCL_SECURE_NO_WARNINGS");
9094
conf.Defines.Add("_CRT_SECURE_NO_WARNINGS");
91-
conf.Defines.Add("BOOST_NO_USER_CONFIG");
92-
conf.Defines.Add("_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING");
93-
conf.Defines.Add("BOOST_ENDIAN_DEPRECATED_NAMES");
94-
95-
conf.Defines.Add("BOOST_ALL_NO_LIB");
9695
conf.Defines.Add("NOMINMAX");
96+
conf.Defines.Add("_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING");
97+
98+
9799

98100

99101
if (target.Mode == Mode.Dev)
@@ -186,7 +188,30 @@ public override void ConfigureAll(Configuration conf, CustomTarget target)
186188
}
187189
}
188190

191+
192+
[Sharpmake.Generate]
193+
public class Modules : Library
194+
{
195+
public Modules()
196+
{
197+
SourceRootPath = @"[project.SharpmakeCsPath]\sources\Modules";
198+
AssemblyName = "Modules";
199+
200+
CustomProperties.Add("ScanSourceForModuleDependencies", "true");
201+
}
202+
203+
204+
public override void ConfigureAll(Configuration conf, CustomTarget target)
205+
{
206+
base.ConfigureAll(conf, target);
207+
conf.IncludePaths.Add(@"[project.SourceRootPath]/include");
189208

209+
conf.ExportAdditionalLibrariesEvenForStaticLib = false;
210+
211+
}
212+
}
213+
214+
190215
[Sharpmake.Generate]
191216
public class Core : Library
192217
{
@@ -205,8 +230,9 @@ public override void ConfigureAll(Configuration conf, CustomTarget target)
205230

206231
conf.LibraryFiles.Add("Dbghelp.lib");
207232
conf.LibraryFiles.Add("version.lib");
208-
209-
conf.AddPublicDependency<ZipLib>(target);
233+
234+
conf.AddPublicDependency<Modules>(target);
235+
conf.AddPublicDependency<ZipLib>(target);
210236
}
211237
}
212238

@@ -248,8 +274,10 @@ public override void ConfigureAll(Configuration conf, CustomTarget target)
248274

249275

250276

251-
conf.AddPublicDependency<Core>(target);
277+
conf.AddPublicDependency<Core>(target);
278+
252279
conf.AddPrivateDependency<Aftermath>(target);
280+
253281

254282
}
255283
}

sources/Core/Data/Data.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#pragma once
22
#include "Debug/Exceptions.h"
33
#include "Utils/utils.h"
4-
#include "Serialization/serialization.h"
4+
#include "Serialization/serialization_defines.h"
5+
6+
import serialization;
7+
58
namespace DataPacker
69
{
710

sources/Core/Events/Events.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#pragma once
22
#include "Data/Data.h"
3-
#include "Serialization/serialization.h"
3+
#include "Serialization/serialization_defines.h"
44

55
import Vectors;
6+
import serialization;
7+
68
namespace Events
79
{
810

sources/Core/FlowGraph/FlowGraph.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#pragma once
22

3-
#include "Serialization/serialization.h"
3+
#include "Serialization/serialization_defines.h"
44
#include "Data/Data.h"
55
#include "Math/Math.h"
66
#include "Utils/Hash/crc32.h"
77

8+
import serialization;
9+
810
namespace FlowGraph
911
{
1012
/* enum class data_types : int

sources/Core/Math/Constants.ixx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module;
2-
#include <cmath>
2+
33
export module Constants;
4+
import stl.core;
45

56
export
67
{

sources/Core/Math/Primitives/Primitive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Constants;
33
import Vectors;
44
import Quaternion;
55
import Matrices;
6-
#include "Serialization/serialization.h"
6+
#include "Serialization/serialization_defines.h"
77

88
enum class primitive_types
99
{

sources/Core/Math/Types/Matrices.ixx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
module;
2-
#include <type_traits>
3-
2+
#include "Serialization/serialization_defines.h"
43
export module Matrices;
54

6-
5+
import stl.core;
76
import Quaternion;
87
import Vectors;
98
import Constants;
10-
11-
#include "Serialization/serialization.h"
9+
import serialization;
1210

1311
export {
1412

sources/Core/Math/Types/Vectors.ixx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
11
module;
2-
#include <typeinfo>
3-
#include <cmath>
4-
#include <ranges>
5-
#include <algorithm>
6-
#include <numeric>
7-
#include <vector>
8-
#include <array>
9-
10-
#define NVP(name) serialization::make_nvp("hello", name)
11-
#define NP(name, param) serialization::make_nvp(name, param)
12-
13-
#define SAVE_PARENT(type) serialization::make_nvp("parent", serialization::base_object<type>(*this))
14-
#define SERIALIZE() friend class serialization::access; template<class Archive> void serialize(Archive& ar, const unsigned int version)
15-
#define SERIALIZE_PRETTY() friend class serialization::access; template<PrettyArchive Archive> void serialize(Archive& ar, const unsigned int version)
16-
17-
2+
#include "Serialization/serialization_defines.h"
183
export module Vectors;
19-
export import Constants;
20-
export import serialization;
21-
namespace ranges = std::ranges;
22-
namespace view = std::ranges::views;
234

5+
import Constants;
6+
import stl.core;
7+
import serialization;
248

259
namespace internal
2610
{
@@ -30,7 +14,6 @@ namespace internal
3014
T::N;
3115
};
3216

33-
3417
template<class T>
3518
consteval int get_count() requires (!IsVectorType<T>)
3619
{

sources/Core/Serialization/Serializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
#include "Log/Log.h"
33
#include "serialization_archives.h"
4-
#include "serialization.h"
4+
#include "serialization_defines.h"
55
class Serializer
66
{
77

sources/Core/Serialization/serialization.h

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 120 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,129 @@
11
module;
2-
#include <boost/serialization/vector.hpp>
3-
#include <boost/serialization/map.hpp>
4-
#include <boost/serialization/array.hpp>
5-
#include <boost/serialization/list.hpp>
6-
#include <boost/serialization/set.hpp>
7-
#include <boost/serialization/nvp.hpp>
8-
#include <boost/serialization/string.hpp>
9-
#include <boost/serialization/access.hpp>
10-
#include <boost/serialization/base_object.hpp>
11-
#include <boost/serialization/export.hpp>
12-
132
export module serialization;
3+
export import boost.serialization;
4+
//import stl.core;
145

15-
export
6+
export template<typename T> concept PrettyArchive = requires () { T::PRETTY; };
7+
/*
8+
namespace boost
169
{
10+
namespace serialization
11+
{
12+
13+
template<class Archive, class Type>
14+
void save(Archive& archive, const std::shared_ptr<Type>& value, const unsigned int
15+
{
16+
Type* data = value.get();
17+
archive << NVP(data);
18+
}
19+
20+
static std::map<void*, std::weak_ptr<void>> hash;
21+
static std::mutex m;
1722
18-
namespace serialization
23+
template<class Archive, class Type>
24+
void load(Archive& archive, std::shared_ptr<Type>& value, const unsigned int)
1925
{
20-
using boost::serialization::access;
21-
using boost::serialization::make_nvp;
22-
using boost::serialization::base_object;
26+
Type* data;
27+
archive >> NVP(data);
28+
std::lock_guard<std::mutex> g(m);
29+
auto&& info = hash[data];
2330
31+
if (info.expired())
32+
{
33+
value = std::shared_ptr<Type>(data);
34+
info = value;
35+
}
36+
37+
else value = static_pointer_cast<Type>(info.lock());
2438
}
25-
26-
}
2739
28-
export template<typename T> concept PrettyArchive = requires () { T::PRETTY; };
40+
template<class Archive, class Type>
41+
inline void serialize(Archive& archive, std::shared_ptr<Type>& value, const unsigned int version)
42+
{
43+
split_free(archive, value, version);
44+
}
45+
46+
47+
template<class Archive, class Type>
48+
void save(Archive& archive, const std::unique_ptr<Type>& value, const unsigned int)
49+
{
50+
Type* data = value.get();
51+
archive& NVP(data);
52+
}
53+
54+
55+
56+
template<class Archive, class Type>
57+
void load(Archive& archive, std::unique_ptr<Type>& value, const unsigned int )
58+
{
59+
Type* data;
60+
archive >> NVP(data);
61+
62+
63+
value.reset(data);
64+
// Type &data = *value.get();
65+
// archive & NVP(data);
66+
}
67+
68+
template<class Archive, class Type>
69+
inline void serialize(Archive& archive, std::unique_ptr<Type>& value, const unsigned int version)
70+
{
71+
split_free(archive, value, version);
72+
}
73+
74+
template<class Archive, class Type>
75+
inline void serialize(Archive& archive, std::span<Type>& values, const unsigned int version)
76+
{
77+
for (int i = 0; i < values.size(); i++)
78+
{
79+
archive& values[i];
80+
}
81+
}
82+
83+
84+
85+
86+
namespace chrn = std::chrono;
87+
88+
template<class Archive, typename clock>
89+
void load(Archive& ar, chrn::time_point<clock>& tp, unsigned)
90+
{
91+
chrn::milliseconds::rep millis;
92+
ar& NVP(millis);
93+
tp = chrn::time_point<clock>(chrn::milliseconds(millis));
94+
}
95+
96+
template<class Archive, typename clock>
97+
void save(Archive& ar, chrn::time_point<clock> const& tp, unsigned)
98+
{
99+
chrn::milliseconds::rep millis = chrn::duration_cast<chrn::milliseconds>(tp.time_since_epoch()).count();
100+
ar& NVP(millis);
101+
}
102+
103+
template<class Archive, typename clock>
104+
inline void serialize(Archive& ar, std::chrono::time_point<clock>& tp, unsigned version)
105+
{
106+
boost::serialization::split_free(ar, tp, version);
107+
}
108+
109+
110+
template<class Archive>
111+
inline void serialize(Archive& ar, Guid& g, unsigned version)
112+
{
113+
if constexpr (Archive::is_loading::value)
114+
{
115+
std::array<unsigned char, 16> v;
116+
ar& NVP(v);
117+
g = Guid(v);
118+
119+
}
120+
else
121+
{
122+
auto& v = g.bytes();
123+
ar& NVP(v);
124+
}
125+
//boost::serialization::split_free(ar, tp, version);
126+
}
127+
}
128+
}
129+
*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#define NVP(name) boost::serialization::make_nvp(BOOST_PP_STRINGIZE(name), name)
2+
#define NP(name, param)boost::serialization::make_nvp(name, param)
3+
4+
#define SAVE_PARENT(type) boost::serialization::make_nvp("parent", boost::serialization::base_object<type>(*this))
5+
#define SERIALIZE() friend class boost::serialization::access; template<class Archive> void serialize(Archive& ar, const unsigned int version)
6+
#define SERIALIZE_PRETTY() friend class boost::serialization::access; template<PrettyArchive Archive> void serialize(Archive& ar, const unsigned int version)
7+

sources/DirectXFramework/DX12/Buffer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#pragma once
22
#include "Utils/Allocators/Allocators.h"
3-
#include "Serialization/serialization.h"
3+
#include "Serialization/serialization_defines.h"
44

55
#include "DX12/CommandList.h"
66
#include "DX12/Device12.h"
77
#include "DX12/Resource.h"
88

99
#include "SIG/Concepts.h"
1010

11+
import serialization;
12+
1113
namespace DX12
1214
{
1315

sources/DirectXFramework/Resource/TextureData/Header.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
#include "Serialization/serialization.h"
1+
#include "Serialization/serialization_defines.h"
22
#include "FileSystem/FileSystem.h"
33

44
#include "helper.h"
5+
6+
import serialization;
7+
58
static void GetSurfaceInfo2(_In_ size_t width,
69
_In_ size_t height,
710
_In_ DXGI_FORMAT fmt,

0 commit comments

Comments
 (0)