Use Visiblity-based Symbol Exporting
authorChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 14 Apr 2014 05:26:03 +0000 (13:26 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 25 Apr 2014 00:27:56 +0000 (08:27 +0800)
Update the autotools files to determine the compiler directive used to mark
a symbol for export, and use the appropriate CFLAGS as necessary.  Also
make MinGW builds not to generate atk.def and attempt to generate and
install a Visual Studio .lib file from there.

https://bugzilla.gnome.org/show_bug.cgi?id=728031

atk/Makefile.am
atk/atk.symbols [deleted file]
configure.ac

index 354c0e2..53421bf 100644 (file)
@@ -19,7 +19,8 @@ AM_CPPFLAGS = \
        -DATK_DISABLE_DEPRECATED        \
        -DATK_COMPILATION       \
        -DATK_LOCALEDIR="\"$(datadir)/locale\"" \
-       $(DEP_CFLAGS)
+       $(DEP_CFLAGS)   \
+       $(ATK_HIDDEN_VISIBILITY_CFLAGS)
 
 lib_LTLIBRARIES = libatk-1.0.la
 
@@ -191,41 +192,13 @@ endif
 
 if OS_WIN32
 libatk_1_0_la_LDFLAGS += -export-symbols atk.def -no-undefined -Wl,atk-win32-res.o
-libatk_1_0_la_DEPENDENCIES = atk-win32-res.o atk.def
-
-install-def-file:
-       $(INSTALL) atk.def $(DESTDIR)$(libdir)/atk-1.0.def
-uninstall-def-file:
-       -rm $(DESTDIR)$(libdir)/atk-1.0.def
-else
-install-def-file:
-uninstall-def-file:
+libatk_1_0_la_DEPENDENCIES = atk-win32-res.o
 endif
 
 atk-win32-res.o: atk.rc
        $(WINDRES) $< $@
 
-if MS_LIB_AVAILABLE
-noinst_DATA = atk-$(ATK_API_VERSION).lib
-
-install-ms-lib:
-       $(INSTALL) atk-$(ATK_API_VERSION).lib $(DESTDIR)$(libdir)
-
-uninstall-ms-lib:
-       -rm $(DESTDIR)$(libdir)/atk-$(ATK_API_VERSION).lib
-else
-install-ms-lib:
-uninstall-ms-lib:
-endif
-
-atk.def: atk.symbols
-       (echo -e EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/atk.symbols | sed -e '/^$$/d' -e 's/^/    /' -e 's/G_GNUC_[^ ]*//g') > atk.def
-
-atk-$(ATK_API_VERSION).lib: libatk-$(ATK_API_VERSION).la atk.def
-       lib -machine:$(LIB_EXE_MACHINE_FLAG) -name:libatk-$(ATK_API_VERSION)-$(LT_CURRENT_MINUS_AGE).dll -def:atk.def -out:$@
-
-
-EXTRA_DIST = atk.symbols atk.rc.in atkmarshal.list atk.rc atkversion.h.in
+EXTRA_DIST = atk.rc.in atkmarshal.list atk.rc atkversion.h.in
 
 DISTCLEANFILES = \
   stamp-atkmarshal.h stamp-atkmarshal.c \
@@ -235,7 +208,3 @@ distclean-local:
        if test $(srcdir) = .; then :; else \
          rm -f atkmarshal.h atkmarshal.c atk-enum-types.h atk-enum-types.c; \
        fi
-
-install-data-local: install-ms-lib install-def-file
-
-uninstall-local: uninstall-ms-lib uninstall-def-file
diff --git a/atk/atk.symbols b/atk/atk.symbols
deleted file mode 100644 (file)
index 75579eb..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/* 
- * This list defines the ATK ABI. It is used to generate the atk.def file.
- */
-       atk_action_do_action
-       atk_action_get_description
-       atk_action_get_keybinding
-       atk_action_get_localized_name
-       atk_action_get_n_actions
-       atk_action_get_name
-       atk_action_get_type
-       atk_action_set_description
-       atk_add_focus_tracker
-       atk_add_global_event_listener
-       atk_add_key_event_listener
-       atk_attribute_set_free
-       atk_component_add_focus_handler
-       atk_component_contains
-       atk_component_get_alpha
-       atk_component_get_extents
-       atk_component_get_layer
-       atk_component_get_mdi_zorder
-       atk_component_get_position
-       atk_component_get_size
-       atk_component_get_type
-       atk_component_grab_focus
-       atk_component_ref_accessible_at_point
-       atk_component_remove_focus_handler
-       atk_component_set_extents
-       atk_component_set_position
-       atk_component_set_size
-       atk_coord_type_get_type
-       atk_document_get_attribute_value
-       atk_document_get_attributes
-       atk_document_get_locale
-       atk_document_get_document
-       atk_document_get_document_type
-       atk_document_get_type
-       atk_document_set_attribute_value
-       atk_editable_text_copy_text
-       atk_editable_text_cut_text
-       atk_editable_text_delete_text
-       atk_editable_text_get_type
-       atk_editable_text_insert_text
-       atk_editable_text_paste_text
-       atk_editable_text_set_run_attributes
-       atk_editable_text_set_text_contents
-       atk_focus_tracker_init
-       atk_focus_tracker_notify
-       atk_get_default_registry
-       atk_get_focus_object
-       atk_get_root
-       atk_get_toolkit_name
-       atk_get_toolkit_version
-       atk_gobject_accessible_for_object
-       atk_gobject_accessible_get_object
-       atk_gobject_accessible_get_type
-       atk_hyperlink_get_end_index
-       atk_hyperlink_get_n_anchors
-       atk_hyperlink_get_object
-       atk_hyperlink_get_start_index
-       atk_hyperlink_get_type
-       atk_hyperlink_get_uri
-       atk_hyperlink_is_inline
-#ifndef ATK_DISABLE_DEPRECATED
-       atk_hyperlink_is_selected_link
-#endif /* ATK_DISABLE_DEPRECATED */
-       atk_hyperlink_is_valid
-       atk_hypertext_get_link
-       atk_hypertext_get_link_index
-       atk_hypertext_get_n_links
-       atk_hypertext_get_type
-       atk_hyperlink_state_flags_get_type
-       atk_hyperlink_impl_get_type
-       atk_hyperlink_impl_get_hyperlink
-       atk_image_get_image_description
-       atk_image_get_image_locale
-       atk_image_get_image_position
-       atk_image_get_image_size
-       atk_image_get_type
-       atk_image_set_image_description
-       atk_implementor_get_type
-       atk_implementor_ref_accessible
-       atk_key_event_type_get_type
-       atk_layer_get_type
-       atk_misc_get_instance
-       atk_misc_get_type
-       atk_misc_instance DATA
-       atk_misc_threads_enter
-       atk_misc_threads_leave
-       atk_no_op_object_factory_get_type
-       atk_no_op_object_factory_new
-       atk_no_op_object_get_type
-       atk_no_op_object_new
-       atk_object_add_relationship
-       atk_object_connect_property_change_handler
-       atk_object_factory_create_accessible
-       atk_object_factory_get_accessible_type
-       atk_object_factory_get_type
-       atk_object_factory_invalidate
-       atk_object_get_attributes
-       atk_object_get_description
-       atk_object_get_index_in_parent
-#ifndef ATK_DISABLE_DEPRECATED
-       atk_object_get_layer
-       atk_object_get_mdi_zorder
-#endif /* ATK_DISABLE_DEPRECATED */
-       atk_object_get_n_accessible_children
-       atk_object_get_name
-       atk_object_get_parent
-       atk_object_get_role
-       atk_object_get_type
-       atk_object_initialize
-       atk_object_notify_state_change
-       atk_object_ref_accessible_child
-       atk_object_ref_relation_set
-       atk_object_ref_state_set
-       atk_object_remove_property_change_handler
-       atk_object_remove_relationship
-       atk_object_set_description
-       atk_object_set_name
-       atk_object_set_parent
-       atk_object_set_role
-       atk_plug_get_type
-       atk_rectangle_get_type
-        atk_range_get_type
-        atk_range_copy
-        atk_range_free
-        atk_range_get_lower_limit
-        atk_range_get_upper_limit
-        atk_range_get_description
-        atk_range_new
-       atk_registry_get_factory
-       atk_registry_get_factory_type
-       atk_registry_get_type
-       atk_registry_set_factory_type
-       atk_relation_add_target
-       atk_relation_get_relation_type
-       atk_relation_get_target
-       atk_relation_get_type
-       atk_relation_new
-       atk_relation_set_add
-       atk_relation_set_add_relation_by_type
-       atk_relation_set_contains
-       atk_relation_set_contains_target
-       atk_relation_set_get_n_relations
-       atk_relation_set_get_relation
-       atk_relation_set_get_relation_by_type
-       atk_relation_set_get_type
-       atk_relation_set_new
-       atk_relation_set_remove
-       atk_relation_type_for_name
-       atk_relation_type_get_name
-       atk_relation_type_get_type
-       atk_relation_type_register
-       atk_remove_focus_tracker
-       atk_remove_global_event_listener
-       atk_remove_key_event_listener
-       atk_role_for_name
-       atk_role_get_localized_name
-       atk_role_get_name
-       atk_role_get_type
-       atk_role_register
-       atk_selection_add_selection
-       atk_selection_clear_selection
-       atk_selection_get_selection_count
-       atk_selection_get_type
-       atk_selection_is_child_selected
-       atk_selection_ref_selection
-       atk_selection_remove_selection
-       atk_selection_select_all_selection
-       atk_socket_get_type
-       atk_state_set_add_state
-       atk_state_set_add_states
-       atk_state_set_and_sets
-       atk_state_set_clear_states
-       atk_state_set_contains_state
-       atk_state_set_contains_states
-       atk_state_set_get_type
-       atk_state_set_is_empty
-       atk_state_set_new
-       atk_state_set_or_sets
-       atk_state_set_remove_state
-       atk_state_set_xor_sets
-       atk_state_type_for_name
-       atk_state_type_get_name
-       atk_state_type_get_type
-       atk_state_type_register
-       atk_streamable_content_get_mime_type
-       atk_streamable_content_get_n_mime_types
-       atk_streamable_content_get_stream
-       atk_streamable_content_get_type
-       atk_streamable_content_get_uri
-       atk_table_add_column_selection
-       atk_table_add_row_selection
-       atk_table_cell_get_column_header_cells
-       atk_table_cell_get_column_span
-       atk_table_cell_get_position
-       atk_table_cell_get_row_column_span
-       atk_table_cell_get_row_header_cells
-       atk_table_cell_get_row_span
-       atk_table_cell_get_table
-       atk_table_cell_get_type
-       atk_table_get_caption
-       atk_table_get_column_at_index
-       atk_table_get_column_description
-       atk_table_get_column_extent_at
-       atk_table_get_column_header
-       atk_table_get_index_at
-       atk_table_get_n_columns
-       atk_table_get_n_rows
-       atk_table_get_row_at_index
-       atk_table_get_row_description
-       atk_table_get_row_extent_at
-       atk_table_get_row_header
-       atk_table_get_selected_columns
-       atk_table_get_selected_rows
-       atk_table_get_summary
-       atk_table_get_type
-       atk_table_is_column_selected
-       atk_table_is_row_selected
-       atk_table_is_selected
-       atk_table_ref_at
-       atk_table_remove_column_selection
-       atk_table_remove_row_selection
-       atk_table_set_caption
-       atk_table_set_column_description
-       atk_table_set_column_header
-       atk_table_set_row_description
-       atk_table_set_row_header
-       atk_table_set_summary
-       atk_text_add_selection
-       atk_text_attribute_for_name
-       atk_text_attribute_get_name
-       atk_text_attribute_get_type
-       atk_text_attribute_get_value
-       atk_text_attribute_register
-       atk_text_boundary_get_type
-       atk_text_granularity_get_type
-       atk_text_clip_type_get_type
-       atk_text_free_ranges
-       atk_text_get_bounded_ranges
-       atk_text_get_caret_offset
-       atk_text_get_character_at_offset
-       atk_text_get_character_count
-       atk_text_get_character_extents
-       atk_text_get_default_attributes
-       atk_text_get_n_selections
-       atk_text_get_offset_at_point
-       atk_text_get_range_extents
-       atk_text_get_run_attributes
-       atk_text_get_selection
-       atk_text_get_text
-       atk_text_get_text_after_offset
-       atk_text_get_text_at_offset
-       atk_text_get_text_before_offset
-       atk_text_get_string_at_offset
-       atk_text_get_type
-       atk_text_range_get_type
-       atk_text_remove_selection
-       atk_text_set_caret_offset
-       atk_text_set_selection
-       atk_util_get_type
-       atk_value_get_current_value
-       atk_value_get_increment
-       atk_value_get_maximum_value
-       atk_value_get_minimum_increment
-       atk_value_get_minimum_value
-       atk_value_get_range
-       atk_value_get_sub_ranges
-       atk_value_get_type
-       atk_value_get_value_and_text
-       atk_value_set_current_value
-       atk_value_set_value
-       atk_value_type_get_localized_name
-       atk_value_type_get_name
-       atk_window_get_type
index fe8b2fa..9ec6d62 100644 (file)
@@ -229,6 +229,36 @@ if test x"$PYTHON" = xyes; then
 fi
 AM_PATH_PYTHON(2.5,,PYTHON="/usr/bin/env python2.5")
 
+# Check for the visibility flags
+ATK_HIDDEN_VISIBILITY_CFLAGS=""
+case "$host" in
+  *-*-mingw*)
+    dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+    AC_DEFINE([_ATK_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
+              [defines how to decorate public symbols while building])
+    CFLAGS="${CFLAGS} -fvisibility=hidden"
+    ;;
+  *)
+    dnl on other compilers, check if we can do -fvisibility=hidden
+    SAVED_CFLAGS="${CFLAGS}"
+    CFLAGS="-fvisibility=hidden"
+    AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
+    AC_TRY_COMPILE([], [int main (void) { return 0; }],
+                   AC_MSG_RESULT(yes)
+                   enable_fvisibility_hidden=yes,
+                   AC_MSG_RESULT(no)
+                   enable_fvisibility_hidden=no)
+    CFLAGS="${SAVED_CFLAGS}"
+
+    AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
+      AC_DEFINE([_ATK_EXTERN], [__attribute__((visibility("default"))) extern],
+                [defines how to decorate public symbols while building])
+      ATK_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
+    ])
+    ;;
+esac
+AC_SUBST(ATK_HIDDEN_VISIBILITY_CFLAGS)
+
 GNOME_COMPILE_WARNINGS([maximum])
 
 AC_CONFIG_FILES([