[geany/geany] a40ab0: Explicitly list symbols to dynamically export

Matthew Brush git-noreply at xxxxx
Fri Apr 10 15:06:50 UTC 2015


Branch:      refs/heads/master
Author:      Matthew Brush <matt at geany.org>
Committer:   Thomas Martitz <kugel at rockbox.org>
Date:        Tue, 10 Mar 2015 21:06:18 UTC
Commit:      a40ab0a4d9715b5f2c334f777e46ecb0fb6c5530
             https://github.com/geany/geany/commit/a40ab0a4d9715b5f2c334f777e46ecb0fb6c5530

Log Message:
-----------
Explicitly list symbols to dynamically export

Uses a Python script to generate a listing used by the linker to
determine which symbols to dynamically export. This provides finer
grained control of which symbols are dynamically exported, limiting
only to the ones needed for GtkBuilder signal connections.

The build system integration could probably be done a little cleaner.


Modified Paths:
--------------
    configure.ac
    scripts/dynamicsymbols.py
    src/Makefile.am
    src/dynamicsymbols.list

Modified: configure.ac
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -74,7 +74,7 @@ AM_CONDITIONAL([GTK3], [test "x$gtk_package" = "xgtk+-3.0"])
 
 # GTK/GLib/GIO checks
 gtk_modules="$gtk_package >= $gtk_min_version glib-2.0 >= 2.20"
-gtk_modules_private="gio-2.0 >= 2.20 gmodule-2.0"
+gtk_modules_private="gio-2.0 >= 2.20 gmodule-no-export-2.0"
 PKG_CHECK_MODULES([GTK], [$gtk_modules $gtk_modules_private])
 AC_SUBST([DEPENDENCIES], [$gtk_modules])
 AC_SUBST([GTK_CFLAGS])


Modified: scripts/dynamicsymbols.py
73 lines changed, 73 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+
+"""
+Script to parse GtkBuilder XML file for signal handler references and list
+them in a linker file for which symbols to dynamically export.
+"""
+
+import optparse
+import os
+import re
+import sys
+from xml.etree import ElementTree as ET
+
+def find_handlers(xml_filename, excludes=[]):
+    def is_excluded(name, excludes):
+        for exclude in excludes:
+            m = re.match(exclude, name)
+            if m:
+                return True
+        return False
+
+    tree = ET.parse(xml_filename)
+    root = tree.getroot()
+    handlers = []
+    signals = root.findall(".//signal")
+
+    for signal in signals:
+        handler = signal.attrib["handler"]
+        if not is_excluded(handler, excludes):
+            handlers.append(handler)
+
+    return sorted(handlers)
+
+def write_dynamic_list(handlers, output_file):
+    output_file.write("""\
+/* This file was auto-generated by the `%s' script, do not edit. */
+{
+""" % os.path.basename(__file__))
+    for handler in handlers:
+        output_file.write("\t%s;\n" % handler)
+    output_file.write("};\n")
+
+def main(args):
+    p = optparse.OptionParser(usage="%prog [-o FILE] XMLFILE")
+    p.add_option("-o", "--output", metavar="FILE", dest="output_file",
+        default="-", help="write the output to this file (default `-' for stdin)")
+
+    opts, args = p.parse_args(args)
+
+    output_file = None
+    try:
+        if opts.output_file == "-":
+            output_file = sys.stdout
+        else:
+            output_file = open(opts.output_file, 'w')
+
+        args = args[1:]
+        if len(args) == 0:
+            p.error("invalid XMLFILE argument, expecting a filename, got none")
+        elif len(args) > 1:
+            p.error("too many XMLFILE arguments, expecting a single filename")
+
+        handlers = find_handlers(args[0], ["gtk_.+"])
+        write_dynamic_list(handlers, output_file)
+
+    finally:
+        if output_file is not None and output_file is not sys.stdout:
+            output_file.close()
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main(sys.argv))


Modified: src/Makefile.am
11 lines changed, 10 insertions(+), 1 deletions(-)
===================================================================
@@ -10,7 +10,8 @@ EXTRA_DIST = \
 	keybindingsprivate.h \
 	pluginprivate.h \
 	projectprivate.h \
-	makefile.win32
+	makefile.win32 \
+	$(top_srcdir)/src/dynamicsymbols.list
 
 bin_PROGRAMS = geany
 
@@ -146,6 +147,8 @@ geany_LDADD = \
 	$(MAC_INTEGRATION_LIBS) \
 	$(INTLLIBS)
 
+geany_LDFLAGS = -Wl,--dynamic-list="$(srcdir)/dynamicsymbols.list"
+
 AM_CFLAGS = -DGEANY_DATADIR=\""$(datadir)"\" \
 			-DGEANY_DOCDIR=\""$(docdir)"\" \
 			-DGEANY_LIBDIR=\""$(libdir)"\" \
@@ -157,5 +160,11 @@ AM_CFLAGS = -DGEANY_DATADIR=\""$(datadir)"\" \
 
 clean-local:
 
+# Helper rule to rebuild the dynamicsymbols.list file when handlers are
+# added to data/geany.glade. Run `make dynamic-symbols' from the src builddir.
+$(top_srcdir)/src/dynamicsymbols.list: $(top_srcdir)/data/geany.glade
+	-python $(top_srcdir)/scripts/dynamicsymbols.py -o $@ $(top_srcdir)/data/geany.glade
+dynamic-symbols: $(top_srcdir)/src/dynamicsymbols.list
+
 endif
 


Modified: src/dynamicsymbols.list
161 lines changed, 161 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,161 @@
+/* This file was auto-generated by the `dynamicsymbols.py' script, do not edit. */
+{
+	on_button_customize_toolbar_clicked;
+	on_change_font1_activate;
+	on_clone1_activate;
+	on_close1_activate;
+	on_close_all1_activate;
+	on_close_other_documents1_activate;
+	on_comments_bsd_activate;
+	on_comments_changelog_activate;
+	on_comments_changelog_activate;
+	on_comments_fileheader_activate;
+	on_comments_fileheader_activate;
+	on_comments_function_activate;
+	on_comments_function_activate;
+	on_comments_gpl_activate;
+	on_comments_multiline_activate;
+	on_context_action1_activate;
+	on_copy1_activate;
+	on_copy1_activate;
+	on_copy_current_lines1_activate;
+	on_count_words1_activate;
+	on_cr_activate;
+	on_crlf_activate;
+	on_customize_toolbar1_activate;
+	on_cut1_activate;
+	on_cut1_activate;
+	on_cut_current_lines1_activate;
+	on_debug_messages1_activate;
+	on_delete1_activate;
+	on_delete1_activate;
+	on_delete_current_lines1_activate;
+	on_detect_type_from_file_activate;
+	on_detect_width_from_file_activate;
+	on_duplicate_line_or_selection1_activate;
+	on_edit1_activate;
+	on_escape_key_press_event;
+	on_file1_activate;
+	on_file_properties_activate;
+	on_find1_activate;
+	on_find_document_usage1_activate;
+	on_find_document_usage1_activate;
+	on_find_in_files1_activate;
+	on_find_next1_activate;
+	on_find_nextsel1_activate;
+	on_find_previous1_activate;
+	on_find_prevsel1_activate;
+	on_find_usage1_activate;
+	on_find_usage1_activate;
+	on_fullscreen1_toggled;
+	on_go_to_line_activate;
+	on_go_to_next_marker1_activate;
+	on_go_to_previous_marker1_activate;
+	on_goto_tag_declaration1;
+	on_goto_tag_definition1;
+	on_goto_tag_definition1;
+	on_help1_activate;
+	on_help_menu_item_bug_report_activate;
+	on_help_menu_item_donate_activate;
+	on_help_menu_item_wiki_activate;
+	on_help_shortcuts1_activate;
+	on_hide_toolbar1_activate;
+	on_indent_width_activate;
+	on_indent_width_activate;
+	on_indent_width_activate;
+	on_indent_width_activate;
+	on_indent_width_activate;
+	on_indent_width_activate;
+	on_indent_width_activate;
+	on_indent_width_activate;
+	on_info1_activate;
+	on_insert_alternative_white_space1_activate;
+	on_insert_alternative_white_space1_activate;
+	on_lf_activate;
+	on_line_breaking1_activate;
+	on_line_wrapping1_toggled;
+	on_load_tags1_activate;
+	on_mark_all1_activate;
+	on_markers_margin1_toggled;
+	on_menu_color_schemes_activate;
+	on_menu_comment_line1_activate;
+	on_menu_comments_bsd_activate;
+	on_menu_comments_gpl_activate;
+	on_menu_comments_multiline_activate;
+	on_menu_decrease_indent1_activate;
+	on_menu_fold_all1_activate;
+	on_menu_increase_indent1_activate;
+	on_menu_open_selected_file1_activate;
+	on_menu_open_selected_file1_activate;
+	on_menu_project1_activate;
+	on_menu_reload_configuration1_activate;
+	on_menu_remove_indicators1_activate;
+	on_menu_select_all1_activate;
+	on_menu_select_all1_activate;
+	on_menu_show_indentation_guides1_toggled;
+	on_menu_show_line_endings1_toggled;
+	on_menu_show_sidebar1_toggled;
+	on_menu_show_white_space1_toggled;
+	on_menu_toggle_all_additional_widgets1_activate;
+	on_menu_toggle_line_commentation1_activate;
+	on_menu_uncomment_line1_activate;
+	on_menu_unfold_all1_activate;
+	on_menu_write_unicode_bom1_toggled;
+	on_motion_event;
+	on_move_lines_down1_activate;
+	on_move_lines_up1_activate;
+	on_new1_activate;
+	on_next_message1_activate;
+	on_normal_size1_activate;
+	on_notebook1_switch_page_after;
+	on_open1_activate;
+	on_page_setup1_activate;
+	on_paste1_activate;
+	on_paste1_activate;
+	on_plugin_preferences1_activate;
+	on_preferences1_activate;
+	on_previous_message1_activate;
+	on_print1_activate;
+	on_project_close1_activate;
+	on_project_new1_activate;
+	on_project_open1_activate;
+	on_project_properties1_activate;
+	on_quit1_activate;
+	on_redo1_activate;
+	on_redo1_activate;
+	on_reflow_lines_block1_activate;
+	on_remove_markers1_activate;
+	on_replace1_activate;
+	on_replace_spaces_activate;
+	on_replace_tabs_activate;
+	on_reset_indentation1_activate;
+	on_save1_activate;
+	on_save_all1_activate;
+	on_save_as1_activate;
+	on_search1_activate;
+	on_select_current_lines1_activate;
+	on_select_current_paragraph1_activate;
+	on_send_selection_to_vte1_activate;
+	on_set_file_readonly1_toggled;
+	on_show_color_chooser1_activate;
+	on_show_line_numbers1_toggled;
+	on_show_messages_window1_toggled;
+	on_show_toolbar1_toggled;
+	on_smart_line_indent1_activate;
+	on_spaces1_activate;
+	on_strip_trailing_spaces1_activate;
+	on_tabs1_activate;
+	on_tabs_and_spaces1_activate;
+	on_toggle_case1_activate;
+	on_toolbutton_reload_clicked;
+	on_tv_notebook_switch_page;
+	on_tv_notebook_switch_page_after;
+	on_undo1_activate;
+	on_undo1_activate;
+	on_use_auto_indentation1_toggled;
+	on_website1_activate;
+	on_window_delete_event;
+	on_window_state_event;
+	on_zoom_in1_activate;
+	on_zoom_out1_activate;
+};



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list