yanet-platform / yanet

A high performance framework for forwarding traffic based on DPDK
Other
164 stars 17 forks source link

Add option to enable ACL debug build to meson #192

Closed ol-imorozko closed 1 month ago

ol-imorozko commented 1 month ago

There was no option to enable ACL_DEBUG rather than specifying this symbol directly in the code, which is awkward

Also, this branch is rebased on top of ol-imorozko:improve-meson (#191), so the actual diff is:

diff --git a/controlplane/acl.cpp b/controlplane/acl.cpp
index 19da4a4..ebdaf3b 100644
--- a/controlplane/acl.cpp
+++ b/controlplane/acl.cpp
@@ -10,8 +10,6 @@
 #include <unordered_set>
 #include <vector>

-//#define ACL_DEBUG
-
 #ifdef ACL_DEBUG
 #define ACL_DEBUGLEVEL (1)
 #else
diff --git a/controlplane/acl/bitset.h b/controlplane/acl/bitset.h
index 0b6ff6c..f6299e5 100644
--- a/controlplane/acl/bitset.h
+++ b/controlplane/acl/bitset.h
@@ -4,6 +4,10 @@
 #include <tuple>
 #include <vector>

+#ifdef ACL_DEBUG
+#include <string>
+#endif
+
 namespace acl
 {

diff --git a/meson.build b/meson.build
index 890f2ec..b63e343 100644
--- a/meson.build
+++ b/meson.build
@@ -28,6 +28,9 @@ compiler_args += [
     '-DYANET_VERSION_CUSTOM=' + get_option('version_custom'),
 ]

+if get_option('enable_acl_debug')
+    compiler_args += '-DACL_DEBUG'
+endif

 # Add all global arguments at once
 add_global_arguments(compiler_args, language: 'cpp')
diff --git a/meson_options.txt b/meson_options.txt
index 7e023a2..474745e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -41,3 +41,8 @@ option('version_custom',
        value: 'develop',
        description: 'Set the custom string version.',
        yield: true)
+
+option('enable_acl_debug',
+       type: 'boolean',
+       value: false,
+       description: 'Enable ACL debug flags.')