Skip to content

Commit d46a112

Browse files
committed
Build: De-hardcode coverage regex exclusion
1 parent 82315df commit d46a112

File tree

4 files changed

+128
-78
lines changed

4 files changed

+128
-78
lines changed

Tools/SC-build.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ Result buildTestProject(const Parameters& parameters, Project& project)
9999
project.addPresetConfiguration(Configuration::Preset::Debug, parameters);
100100
project.addPresetConfiguration(Configuration::Preset::Release, parameters);
101101
project.addPresetConfiguration(Configuration::Preset::DebugCoverage, parameters);
102+
project.configurations.back().coverage.excludeRegex =
103+
".*\\/Tools.*|"
104+
".*\\Test.(cpp|h|c)|"
105+
".*\\test.(c|h)|"
106+
".*\\/Tests/.*\\.*|"
107+
".*\\/LibC\\+\\+.inl|" // new / delete overloads
108+
".*\\/Assert.h|" // Can't test Assert::unreachable
109+
".*\\/PluginMacros.h|" // macros for client plugins
110+
".*\\/ProcessPosixFork.inl|" // Can't compute coverage for fork
111+
".*\\/EnvironmentTable.h|" // Can't compute coverage for fork
112+
".*\\/InitializerList.h|" // C++ Language Support
113+
".*\\/Reflection/.*\\.*|" // constexpr and templates
114+
".*\\/ContainersReflection/.*\\.*|" // constexpr and templates
115+
".*\\/SerializationBinary/.*\\.*|" // constexpr and templates
116+
".*\\/LibrariesExtra/.*\\.*";
102117
if (parameters.platform == Platform::Linux)
103118
{
104119
project.addPresetConfiguration(Configuration::Preset::Debug, parameters, "DebugValgrind");

Tools/SC-build.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ constexpr StringView INTERMEDIATES_SUBDIR = "_Intermediates";
6262
StringView afterSplit;
6363
if (arguments.arguments[0].splitBefore(SC_NATIVE_STR(":"), action.workspaceName))
6464
{
65-
SC_TRUST_RESULT(arguments.arguments[0].splitAfter(SC_NATIVE_STR(":"), action.target));
65+
SC_TRUST_RESULT(arguments.arguments[0].splitAfter(SC_NATIVE_STR(":"), action.projectName));
6666
}
6767
else
6868
{
69-
action.target = arguments.arguments[0];
69+
action.projectName = arguments.arguments[0];
7070
}
7171
}
7272
// TODO: We should run a matrix of all generators / platforms / architectures
@@ -124,11 +124,11 @@ constexpr StringView INTERMEDIATES_SUBDIR = "_Intermediates";
124124
StringView afterSplit;
125125
if (arguments.arguments[0].splitBefore(SC_NATIVE_STR(":"), action.workspaceName))
126126
{
127-
SC_TRUST_RESULT(arguments.arguments[0].splitAfter(SC_NATIVE_STR(":"), action.target));
127+
SC_TRUST_RESULT(arguments.arguments[0].splitAfter(SC_NATIVE_STR(":"), action.projectName));
128128
}
129129
else
130130
{
131-
action.target = arguments.arguments[0];
131+
action.projectName = arguments.arguments[0];
132132
}
133133
}
134134
StringSpan args[3];
@@ -146,7 +146,7 @@ constexpr StringView INTERMEDIATES_SUBDIR = "_Intermediates";
146146

147147
if (not args[0].isEmpty())
148148
{
149-
action.configuration = args[0];
149+
action.configurationName = args[0];
150150
}
151151

152152
if (args[1] == "xcode")

Tools/SC-build/Build.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ struct SourceFiles
304304
[[nodiscard]] bool removeSelection(StringView directory, StringView filter);
305305
};
306306

307+
/// @brief Coverage specific flags
308+
struct CoverageFlags
309+
{
310+
String excludeRegex; ///< Regex of files to exclude from coverage
311+
};
312+
307313
/// @brief Groups SC::Build::CompileFlags and SC::Build::LinkFlags for a given SC::Build::Architecture
308314
struct Configuration
309315
{
@@ -350,6 +356,8 @@ struct Configuration
350356
CompileFlags compile; ///< Configuration compile flags
351357
LinkFlags link; ///< Configuration link flags
352358

359+
CoverageFlags coverage; ///< Configuration coverage flags
360+
353361
Architecture::Type architecture = Architecture::Any; ///< Restrict this configuration to a specific architecture
354362

355363
Configuration();
@@ -491,6 +499,10 @@ struct Definition
491499
/// @param workspaceName Name of the workspace to generate
492500
/// @param parameters Set of parameters with the wanted platforms, architectures and generators to generate
493501
Result configure(StringView workspaceName, const Parameters& parameters) const;
502+
503+
/// @brief Finds the configuration with given name in given workspace and project
504+
[[nodiscard]] bool findConfiguration(StringView workspaceName, StringView projectName, StringView configurationName,
505+
Workspace*& workspace, Project*& project, Configuration*& configuration);
494506
};
495507

496508
//! @}
@@ -516,10 +528,12 @@ struct Action
516528
Type action = Configure;
517529

518530
Parameters parameters;
519-
StringView configuration;
520-
StringView target;
531+
StringView configurationName;
532+
StringView projectName;
521533
StringView workspaceName;
522534

535+
bool allTargets = false;
536+
523537
Span<const StringView> additionalArguments;
524538

525539
private:

0 commit comments

Comments
 (0)