@@ -7,93 +7,80 @@ namespace SC
7
7
{
8
8
namespace Build
9
9
{
10
- static constexpr StringView PROJECT_NAME = " SCTest " ;
10
+ SC_COMPILER_WARNING_PUSH_UNUSED_RESULT; // Doing some optimistic coding here, ignoring all failures
11
11
12
- Result configure (Build::Definition& definition, Build:: Parameters& parameters)
12
+ void addSaneCppLibraries (Project& project, const Parameters& parameters)
13
13
{
14
- SC_COMPILER_WARNING_PUSH_UNUSED_RESULT; // Doing some optimistic coding here, ignoring all failures
15
-
16
- // Workspace
17
- Workspace workspace;
18
- workspace.name .assign (PROJECT_NAME);
19
-
20
- // Project
21
- Project project;
22
- project.targetType = TargetType::Executable;
23
- project.name .assign (PROJECT_NAME);
24
- project.targetName .assign (PROJECT_NAME);
25
- // All relative paths are evaluated from this project root directory.
26
- project.setRootDirectory (parameters.directories .libraryDirectory .view ());
27
-
28
- // Project Configurations
29
- project.addPresetConfiguration (Configuration::Preset::Debug);
30
- project.addPresetConfiguration (Configuration::Preset::Release);
31
- if (parameters.generator == Build::Generator::VisualStudio2022)
32
- {
33
- project.addPresetConfiguration (Configuration::Preset::Debug, " Debug Clang" );
34
- project.getConfiguration (" Debug Clang" )->visualStudio .platformToolset = " ClangCL" ;
35
- }
36
- else
37
- {
38
- project.addPresetConfiguration (Configuration::Preset::DebugCoverage);
39
- }
40
-
41
- // Project Configurations special flags
42
- for (Configuration& config : project.configurations )
43
- {
44
- config.compile .set <Compile::enableASAN>(config.preset == Configuration::Preset::Debug);
45
- }
46
-
47
- // Defines
48
- // $(PROJECT_ROOT) is the same directory set with Project::setRootDirectory
49
- project.compile .addDefines ({" SC_LIBRARY_PATH=$(PROJECT_ROOT)" , " SC_COMPILER_ENABLE_CONFIG=1" });
50
-
51
- // Includes
52
- project.compile .addIncludes ({
53
- " ." , // Libraries path (for PluginTest)
54
- " Tests/SCTest" , // SCConfig.h path (enabled by SC_COMPILER_ENABLE_CONFIG == 1)
55
- });
56
-
57
- // Libraries to link
58
- if (parameters.platforms .contains (Build::Platform::MacOS))
59
- {
60
- project.link .addFrameworks ({" CoreFoundation" , " CoreServices" });
61
- }
62
-
63
- // File overrides (order matters regarding to add / remove)
14
+ // Files
64
15
project.addDirectory (" Bindings/c" , " **.cpp" ); // add all cpp support files for c bindings
65
16
project.addDirectory (" Bindings/c" , " **.c" ); // add all c bindings
66
17
project.addDirectory (" Bindings/c" , " **.h" ); // add all c bindings
67
- project.addDirectory (" Tests/SCTest" , " *.cpp" ); // add all .cpp from SCTest directory
68
- project.addDirectory (" Tests/SCTest" , " *.h" ); // add all .h from SCTest directory
69
18
project.addDirectory (" Libraries" , " **.cpp" ); // recursively add all cpp files
70
19
project.addDirectory (" Libraries" , " **.h" ); // recursively add all header files
71
20
project.addDirectory (" Libraries" , " **.inl" ); // recursively add all inline files
72
21
project.addDirectory (" LibrariesExtra" , " **.h" ); // recursively add all header files
73
22
project.addDirectory (" LibrariesExtra" , " **.cpp" ); // recursively add all cpp files
74
23
project.addDirectory (" Support/DebugVisualizers" , " *.cpp" ); // add debug visualizers
75
- project.addDirectory (" Tools" , " SC-*.cpp" ); // add all tools
76
- project.addDirectory (" Tools" , " *.h" ); // add tools headers
77
- project.addDirectory (" Tools" , " *Test.cpp" ); // add tools tests
24
+
25
+ // Libraries to link
26
+ if (parameters.platforms .contains (Platform::MacOS))
27
+ {
28
+ project.link .addFrameworks ({" CoreFoundation" , " CoreServices" });
29
+ }
78
30
79
31
// Debug visualization helpers
80
- if (parameters.generator == Build:: Generator::VisualStudio2022)
32
+ if (parameters.generator == Generator::VisualStudio2022)
81
33
{
82
34
project.addDirectory (" Support/DebugVisualizers/MSVC" , " *.natvis" );
83
35
}
84
36
else
85
37
{
86
38
project.addDirectory (" Support/DebugVisualizers/LLDB" , " *" );
87
39
}
40
+ }
88
41
89
- // Adding to workspace and definition
90
- workspace.projects .push_back (move (project));
91
- definition.workspaces .push_back (move (workspace));
42
+ static constexpr StringView TEST_PROJECT_NAME = " SCTest" ;
43
+
44
+ Project buildTestProject (const Parameters& parameters)
45
+ {
46
+ Project project = {TargetType::Executable, TEST_PROJECT_NAME};
47
+
48
+ // All relative paths are evaluated from this project root directory.
49
+ project.setRootDirectory (parameters.directories .libraryDirectory .view ());
50
+
51
+ // Project Configurations
52
+ project.addPresetConfiguration (Configuration::Preset::Debug, parameters);
53
+ project.addPresetConfiguration (Configuration::Preset::Release, parameters);
54
+ project.addPresetConfiguration (Configuration::Preset::DebugCoverage, parameters);
55
+
56
+ // Defines
57
+ // $(PROJECT_ROOT) expands to Project::setRootDirectory expressed relative to $(PROJECT_DIR)
58
+ project.compile .addDefines ({" SC_LIBRARY_PATH=$(PROJECT_ROOT)" , " SC_COMPILER_ENABLE_CONFIG=1" });
59
+
60
+ // Includes
61
+ project.compile .addIncludes ({
62
+ " ." , // Libraries path (for PluginTest)
63
+ " Tests/SCTest" , // SCConfig.h path (enabled by SC_COMPILER_ENABLE_CONFIG == 1)
64
+ });
92
65
93
- SC_COMPILER_WARNING_POP;
66
+ addSaneCppLibraries (project, parameters);
67
+ project.addDirectory (" Tests/SCTest" , " *.cpp" ); // add all .cpp from SCTest directory
68
+ project.addDirectory (" Tests/SCTest" , " *.h" ); // add all .h from SCTest directory
69
+ project.addDirectory (" Tools" , " SC-*.cpp" ); // add all tools
70
+ project.addDirectory (" Tools" , " *.h" ); // add tools headers
71
+ project.addDirectory (" Tools" , " *Test.cpp" ); // add tools tests
72
+ return project;
73
+ }
74
+
75
+ Result configure (Definition& definition, const Parameters& parameters)
76
+ {
77
+ Workspace workspace = {" SCTest" };
78
+ workspace.projects .push_back (buildTestProject (parameters));
79
+ definition.workspaces .push_back (move (workspace));
94
80
return Result (true );
95
81
}
82
+ SC_COMPILER_WARNING_POP;
96
83
97
- Result executeAction (const Action& action) { return Build::Action::execute (action, configure, PROJECT_NAME ); }
84
+ Result executeAction (const Action& action) { return Build::Action::execute (action, configure, TEST_PROJECT_NAME ); }
98
85
} // namespace Build
99
86
} // namespace SC
0 commit comments