From d3325bf879c21751b5acdc8e28976f8ff0b484f6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 14 Feb 2024 10:20:08 +0000 Subject: [PATCH 1/5] gi-compile-repository: Remove unused --module option This hasn't actually done anything since commit 45a04358 "[gircompiler] Clean up parsing" (originally gobject-introspection@8942500c). Signed-off-by: Simon McVittie --- girepository/compiler/compiler.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/girepository/compiler/compiler.c b/girepository/compiler/compiler.c index 120b474a7..17f9bc9b8 100644 --- a/girepository/compiler/compiler.c +++ b/girepository/compiler/compiler.c @@ -43,7 +43,6 @@ gchar **includedirs = NULL; gchar **input = NULL; gchar *output = NULL; -gchar *mname = NULL; gchar **shlibs = NULL; gboolean include_cwd = FALSE; gboolean debug = FALSE; @@ -141,7 +140,6 @@ log_handler (const gchar *log_domain, static GOptionEntry options[] = { { "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search path", NULL }, { "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" }, - { "module", 'm', 0, G_OPTION_ARG_STRING, &mname, "module to compile", "NAME" }, { "shared-library", 'l', 0, G_OPTION_ARG_FILENAME_ARRAY, &shlibs, "shared library", "FILE" }, { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "show debug messages", NULL }, { "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, "show verbose messages", NULL }, From a41496643b5ab893efc246e8ecf8f2052e00fab7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 14 Feb 2024 10:21:44 +0000 Subject: [PATCH 2/5] gi-compile-repository: Remove unused variable Signed-off-by: Simon McVittie --- girepository/compiler/compiler.c | 1 - 1 file changed, 1 deletion(-) diff --git a/girepository/compiler/compiler.c b/girepository/compiler/compiler.c index 17f9bc9b8..438ae8deb 100644 --- a/girepository/compiler/compiler.c +++ b/girepository/compiler/compiler.c @@ -44,7 +44,6 @@ gchar **includedirs = NULL; gchar **input = NULL; gchar *output = NULL; gchar **shlibs = NULL; -gboolean include_cwd = FALSE; gboolean debug = FALSE; gboolean verbose = FALSE; gboolean show_version = FALSE; From 3f6de0706ea13908460e367876dd9bf52272f156 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 14 Feb 2024 10:36:23 +0000 Subject: [PATCH 3/5] girparser: Don't rely on gi-compile-repository exporting debug level It seems cleaner to store this in the parser, rather than having the compiler export a global variable that the parser must read. Signed-off-by: Simon McVittie --- girepository/compiler/compiler.c | 3 ++- girepository/girparser-private.h | 2 ++ girepository/girparser.c | 13 ++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/girepository/compiler/compiler.c b/girepository/compiler/compiler.c index 438ae8deb..add502a42 100644 --- a/girepository/compiler/compiler.c +++ b/girepository/compiler/compiler.c @@ -124,7 +124,7 @@ out: return success; } -GLogLevelFlags logged_levels; +static GLogLevelFlags logged_levels; static void log_handler (const gchar *log_domain, @@ -198,6 +198,7 @@ main (int argc, char **argv) includedirs ? g_strv_length (includedirs) : 0); parser = gi_ir_parser_new (); + gi_ir_parser_set_debug (parser, logged_levels); gi_ir_parser_set_includes (parser, (const char *const *) includedirs); diff --git a/girepository/girparser-private.h b/girepository/girparser-private.h index 473b08c19..4754a83bb 100644 --- a/girepository/girparser-private.h +++ b/girepository/girparser-private.h @@ -33,6 +33,8 @@ typedef struct _GIIrParser GIIrParser; GIIrParser *gi_ir_parser_new (void); void gi_ir_parser_free (GIIrParser *parser); +void gi_ir_parser_set_debug (GIIrParser *parser, + GLogLevelFlags logged_levels); void gi_ir_parser_set_includes (GIIrParser *parser, const char *const *includes); diff --git a/girepository/girparser.c b/girepository/girparser.c index 0d65590f6..647cf2498 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -61,6 +61,7 @@ struct _GIIrParser char **includes; char **gi_gir_path; GList *parsed_modules; /* All previously parsed modules */ + GLogLevelFlags logged_levels; }; typedef enum @@ -191,9 +192,17 @@ gi_ir_parser_new (void) if (gi_gir_path != NULL) parser->gi_gir_path = g_strsplit (gi_gir_path, G_SEARCHPATH_SEPARATOR_S, 0); + parser->logged_levels = G_LOG_LEVEL_MASK & ~(G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_DEBUG); return parser; } +void +gi_ir_parser_set_debug (GIIrParser *parser, + GLogLevelFlags logged_levels) +{ + parser->logged_levels = logged_levels; +} + void gi_ir_parser_free (GIIrParser *parser) { @@ -2915,8 +2924,6 @@ parse_include (GMarkupParseContext *context, return TRUE; } -extern GLogLevelFlags logged_levels; - static void start_element_handler (GMarkupParseContext *context, const char *element_name, @@ -2927,7 +2934,7 @@ start_element_handler (GMarkupParseContext *context, { ParseContext *ctx = user_data; - if (logged_levels & G_LOG_LEVEL_DEBUG) + if (ctx->parser->logged_levels & G_LOG_LEVEL_DEBUG) { GString *tags = g_string_new (""); int i; From d40e1b9db3f4711f54b8ce49530508ad88abda8c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 14 Feb 2024 10:23:03 +0000 Subject: [PATCH 4/5] gi-compile-repository: Make file-scoped variables static This means the compiler will warn us if they become unused. Signed-off-by: Simon McVittie --- girepository/compiler/compiler.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/girepository/compiler/compiler.c b/girepository/compiler/compiler.c index add502a42..7d8c053c4 100644 --- a/girepository/compiler/compiler.c +++ b/girepository/compiler/compiler.c @@ -40,13 +40,13 @@ #include "girnode-private.h" #include "girparser-private.h" -gchar **includedirs = NULL; -gchar **input = NULL; -gchar *output = NULL; -gchar **shlibs = NULL; -gboolean debug = FALSE; -gboolean verbose = FALSE; -gboolean show_version = FALSE; +static gchar **includedirs = NULL; +static gchar **input = NULL; +static gchar *output = NULL; +static gchar **shlibs = NULL; +static gboolean debug = FALSE; +static gboolean verbose = FALSE; +static gboolean show_version = FALSE; static gboolean write_out_typelib (gchar *prefix, From 4180a2069c725b6fd109e2568b630754e894dddd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 14 Feb 2024 10:42:39 +0000 Subject: [PATCH 5/5] gi-decompile-repository: Remove unused --shlib option This seems to have been a remnant of support for embedding the typelib in the shared library, which was removed from this tool in commit 4bf5ef6b "[girepository] Actually verify header of loaded typelibs in g_irepository_require" (originally gobject-introspection@05ffd857). The feature of embedding the typelib in a shared library was itself removed in commit b2df59c3 "compiler: Remove --code argument", originally gobject-introspection@ac81f3e8, with a note that because we rely on being able to load the shared library into g-ir-scanner, anything that links g-ir-scanner output into the shared library would be a circular dependency. Signed-off-by: Simon McVittie --- girepository/decompiler/decompiler.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/girepository/decompiler/decompiler.c b/girepository/decompiler/decompiler.c index aad3cf58b..26119e0e3 100644 --- a/girepository/decompiler/decompiler.c +++ b/girepository/decompiler/decompiler.c @@ -36,7 +36,6 @@ int main (int argc, char *argv[]) { GIRepository *repository = NULL; - gboolean shlib = FALSE; gchar *output = NULL; gchar **includedirs = NULL; gboolean show_all = FALSE; @@ -48,7 +47,6 @@ main (int argc, char *argv[]) gint i; GOptionEntry options[] = { - { "shlib", 0, 0, G_OPTION_ARG_NONE, &shlib, "handle typelib embedded in shlib", NULL }, { "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" }, { "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search path", NULL }, { "all", 0, 0, G_OPTION_ARG_NONE, &show_all, "show all available information", NULL, },