Skip to content

Commit a08b545

Browse files
authored
allow CMake/compile option to DISABLE_GREASE (#377)
* allow CMake/compile option to DISABLE_GREASE * make the DISABLE_GREASE default explicit * clang format cleanup
1 parent 7e19d51 commit a08b545

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ option(TESTING "Build tests" OFF)
99
option(CLANG_TIDY "Perform linting with clang-tidy" OFF)
1010
option(SANITIZERS "Enable sanitizers" OFF)
1111
option(MLS_NAMESPACE_SUFFIX "Namespace Suffix for CXX and CMake Export")
12+
option(DISABLE_GREASE "Disables the inclusion of MLS protocol recommended GREASE values" OFF)
1213

1314
if(MLS_NAMESPACE_SUFFIX)
1415
set(MLS_CXX_NAMESPACE "mls_${MLS_NAMESPACE_SUFFIX}" CACHE STRING "Top-level Namespace for CXX")
@@ -79,6 +80,10 @@ if("$ENV{MACOSX_DEPLOYMENT_TARGET}" STREQUAL "10.11")
7980
add_compile_options(-DVARIANT_COMPAT)
8081
endif()
8182

83+
if (DISABLE_GREASE)
84+
add_compile_options(-DDISABLE_GREASE)
85+
endif ()
86+
8287
###
8388
### Enable testing
8489
###

src/grease.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@
66

77
namespace MLS_NAMESPACE {
88

9+
#ifdef DISABLE_GREASE
10+
11+
Capabilities
12+
grease(Capabilities&& capabilities,
13+
[[maybe_unused]] const ExtensionList& extensions)
14+
{
15+
return capabilities;
16+
}
17+
18+
ExtensionList
19+
grease(ExtensionList&& extensions)
20+
{
21+
return extensions;
22+
}
23+
24+
#else
25+
926
// Randomness parmeters:
1027
// * Given a list of N items, insert max(1, rand(p_grease * N)) GREASE values
1128
// * Each GREASE value added is distinct, unless more than 15 values are needed
@@ -118,4 +135,6 @@ grease(ExtensionList&& extensions)
118135
return { ext };
119136
}
120137

138+
#endif // DISABLE_GREASE
139+
121140
} // namespace MLS_NAMESPACE

0 commit comments

Comments
 (0)