[epiphany] Disable debug goo in release mode



commit 8b888311ae5bbe28e9ffa578d9f1d89c270edbbf
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Wed Aug 30 11:02:06 2017 -0500

    Disable debug goo in release mode
    
    All our debug stuff has been enabled in release mode since switching to
    meson. Time to fix that.

 lib/ephy-debug.c  |   22 +++++++---------------
 lib/ephy-debug.h  |   38 +++++++++-----------------------------
 meson.build       |    3 ++-
 meson_options.txt |    6 ++++++
 4 files changed, 24 insertions(+), 45 deletions(-)
---
diff --git a/lib/ephy-debug.c b/lib/ephy-debug.c
index cd5358d..55b9e74 100644
--- a/lib/ephy-debug.c
+++ b/lib/ephy-debug.c
@@ -41,13 +41,10 @@
 
 static const char *ephy_debug_break = NULL;
 
-#ifndef DISABLE_PROFILING
+#if DEVELOPER_MODE
 static GHashTable *ephy_profilers_hash = NULL;
 static char **ephy_profile_modules;
 static gboolean ephy_profile_all_modules;
-#endif /* !DISABLE_PROFILING */
-
-#ifndef NDEBUG
 
 static char **
 build_modules (const char *name,
@@ -67,9 +64,6 @@ build_modules (const char *name,
 
   return g_strsplit (g_getenv (name), ":", -1);
 }
-#endif
-
-#ifndef DISABLE_LOGGING
 
 static char **ephy_log_modules;
 static gboolean ephy_log_all_modules;
@@ -99,7 +93,7 @@ log_module (const gchar   *log_domain,
     g_print ("%s\n", message);
   }
 }
-#endif /* !DISABLE_LOGGING */
+#endif
 
 #define MAX_DEPTH 200
 
@@ -158,21 +152,18 @@ trap_handler (const char    *log_domain,
 void
 ephy_debug_init (void)
 {
-#ifndef DISABLE_LOGGING
+#if DEVELOPER_MODE
   ephy_log_modules = build_modules ("EPHY_LOG_MODULES", &ephy_log_all_modules);
-
   g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, log_module, NULL);
+
+  ephy_profile_modules = build_modules ("EPHY_PROFILE_MODULES", &ephy_profile_all_modules);
 #endif
 
   ephy_debug_break = g_getenv ("EPHY_DEBUG_BREAK");
   g_log_set_default_handler (trap_handler, NULL);
-
-#ifndef DISABLE_PROFILING
-  ephy_profile_modules = build_modules ("EPHY_PROFILE_MODULES", &ephy_profile_all_modules);
-#endif
 }
 
-#ifndef DISABLE_PROFILING
+#if DEVELOPER_MODE
 
 static EphyProfiler *
 ephy_profiler_new (const char *name, const char *module)
@@ -280,4 +271,5 @@ ephy_profiler_stop (const char *name)
   ephy_profiler_dump (profiler);
   ephy_profiler_free (profiler);
 }
+
 #endif
diff --git a/lib/ephy-debug.h b/lib/ephy-debug.h
index 092db11..e98c129 100644
--- a/lib/ephy-debug.h
+++ b/lib/ephy-debug.h
@@ -24,40 +24,20 @@
 
 G_BEGIN_DECLS
 
-#ifdef NDEBUG
-#define DISABLE_LOGGING
-#define DISABLE_PROFILING
-#endif
-
-#if defined(G_HAVE_GNUC_VARARGS)
-
-#ifdef DISABLE_LOGGING
-#define LOG(msg, args...) G_STMT_START { } G_STMT_END
+#if DEVELOPER_MODE
+#define LOG(msg, args...)               g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                \
+                                    "[ %s ] " msg,                             \
+                                    __FILE__ , ## args)
 #else
-#define LOG(msg, args...)                      \
-g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                \
-       "[ %s ] " msg,                          \
-       __FILE__ , ## args)
-#endif
-
-#elif defined(G_HAVE_ISO_VARARGS)
-
 #define LOG(...) G_STMT_START { } G_STMT_END
-
-#else /* no varargs macros */
-
-static void LOG(const char *format, ...) {}
-
 #endif
 
-#ifdef DISABLE_PROFILING
+#if DEVELOPER_MODE
+#define START_PROFILER(name)   ephy_profiler_start (name, __FILE__);
+#define STOP_PROFILER(name)   ephy_profiler_stop (name);
+#else
 #define START_PROFILER(name)
 #define STOP_PROFILER(name)
-#else
-#define START_PROFILER(name)   \
-ephy_profiler_start (name, __FILE__);
-#define STOP_PROFILER(name)    \
-ephy_profiler_stop (name);
 #endif
 
 typedef struct
@@ -69,7 +49,7 @@ typedef struct
 
 void           ephy_debug_init         (void);
 
-#ifndef DISABLE_PROFILING
+#if DEVELOPER_MODE
 
 void           ephy_profiler_start     (const char *name,
                                         const char *module);
diff --git a/meson.build b/meson.build
index 5a83411..726d3b2 100644
--- a/meson.build
+++ b/meson.build
@@ -33,8 +33,9 @@ conf.set_quoted('PKGLIBEXECDIR', pkglibexecdir)
 conf.set_quoted('SOURCE_ROOT', meson.source_root())
 conf.set_quoted('VERSION', meson.project_version())
 
-conf.set10('ENABLE_NLS', true)
+conf.set10('DEVELOPER_MODE', get_option('developer_mode'))
 conf.set10('ENABLE_HTTPS_EVERYWHERE', get_option('enable_https_everywhere'))
+conf.set10('ENABLE_NLS', true)
 
 configure_file(
   output: 'config.h',
diff --git a/meson_options.txt b/meson_options.txt
index d4a415e..fdc3bb6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,9 @@
+option('developer_mode',
+  type: 'boolean',
+  value: false,
+  description: 'Enable developer mode'
+)
+
 option('distributor_name',
   type: 'string',
   value: 'GNOME Web',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]