[geany/geany] 9644fb: Define GEANY_{EXPORT, API}_SYMBOL from the build system

Colomban Wendling git-noreply at xxxxx
Fri Apr 10 14:08:08 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Fri, 10 Apr 2015 14:08:08 UTC
Commit:      9644fb0ae21601b5acb6a5a5763a1e558a95c315
             https://github.com/geany/geany/commit/9644fb0ae21601b5acb6a5a5763a1e558a95c315

Log Message:
-----------
Define GEANY_{EXPORT,API}_SYMBOL from the build system

This makes it easier to define it consistently to what the compiler
and platform supports, and avoids having to include a special header
everywhere, which is some kind of a problem for separate libraries
like TagManager and especially Scintilla.

As we only use these macros from the source and not the headers, it
is fine for it to be defined to a configure-time check from the build
system.

Warning: Although Waf and Windows makefiles are updated they are not
         tested an will probably required tuning.


Modified Paths:
--------------
    m4/geany-lib.m4
    scintilla/gtk/makefile.win32
    src/Makefile.am
    src/build.c
    src/callbacks.c
    src/dialogs.c
    src/document.c
    src/editor.c
    src/encodings.c
    src/filetypes.c
    src/highlighting.c
    src/keybindings.c
    src/libmain.c
    src/makefile.win32
    src/msgwindow.c
    src/navqueue.c
    src/pluginexport.h
    src/pluginutils.c
    src/project.c
    src/sciwrappers.c
    src/search.c
    src/stash.c
    src/symbols.c
    src/templates.c
    src/ui_utils.c
    src/utils.c
    tagmanager/src/makefile.win32
    tagmanager/src/tm_source_file.c
    tagmanager/src/tm_workspace.c
    wscript

Modified: m4/geany-lib.m4
55 lines changed, 38 insertions(+), 17 deletions(-)
===================================================================
@@ -1,5 +1,42 @@
+dnl checks whether the compiler supports GCC4-style visibility
+AC_DEFUN([GCC4_VISIBILITY],
+[
+	have_gcc4_visibility=no
+	AC_MSG_CHECKING([whether compiler supports GCC4-style visibility])
+	gcc_visibility_backup_cflags=$CFLAGS
+	CFLAGS=-fvisibility=hidden
+	AC_LINK_IFELSE([AC_LANG_SOURCE([[__attribute__((visibility("default")))
+									 int main(int argc, char **argv) { return 0; }]])],
+				   [have_gcc4_visibility=yes])
+	AC_MSG_RESULT([$have_gcc4_visibility])
+	CFLAGS="${gcc_visibility_backup_cflags}"
+])
+
+dnl Checks and fills LIBGEANY_EXPORT_CFLAGS
+AC_DEFUN([GEANY_EXPORT],
+[
+	AC_REQUIRE([GEANY_CHECK_MINGW])
+	AC_REQUIRE([GCC4_VISIBILITY])
+
+	dnl FIXME: better way to detect Windows?
+	AM_COND_IF([MINGW], [win32=yes], [win32=false])
+
+	export_CFLAGS=
+	AS_IF([test x$win32 = xyes],
+		  [export_CFLAGS='-DGEANY_EXPORT_SYMBOL="__declspec(dllexport)"'],
+		  [test x$have_gcc4_visibility = xyes],
+		  [export_CFLAGS='-fvisibility=hidden -DGEANY_EXPORT_SYMBOL="__attribute__((visibility(\"default\")))"'],
+		  [dnl GEANY_EXPORT_SYMBOL expands to nothing
+		   export_CFLAGS='-DGEANY_EXPORT_SYMBOL'])
+
+	LIBGEANY_EXPORT_CFLAGS="${export_CFLAGS} -DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL"
+
+	AC_SUBST([LIBGEANY_EXPORT_CFLAGS])
+])
+
 AC_DEFUN([GEANY_LIB_INIT],
 [
+	AC_REQUIRE([GEANY_EXPORT])
 
 dnl In the future, if we want to use libtool/library versioning, we can
 dnl set these variables accordingly. For now its the same as if not specified (0:0:0)
@@ -7,23 +44,7 @@ dnl set these variables accordingly. For now its the same as if not specified (0
 	libgeany_revision=0
 	libgeany_age=0
 
-dnl Try and see if we can use -fvisibility compiler option and GCC`s
-dnl `__attribute__((visibility(...)))` extension and use it if so.
-	AC_MSG_CHECKING([whether compiler supports -fvisibility])
-	libgeany_backup_cflags=$CFLAGS
-	CFLAGS=-fvisibility=hidden
-	AC_TRY_COMPILE([], [
-			__attribute__ ((visibility ("default")))
-			int main(int argc, char **argv) { return 0; }
-		], [
-			LIBGEANY_CFLAGS="${CFLAGS}"
-			AC_MSG_RESULT([yes])
-		], [
-			LIBGEANY_CFLAGS=""
-			AC_MSG_RESULT([no])
-		])
-	CFLAGS="${libgeany_backup_cflags}"
-
+	LIBGEANY_CFLAGS="${LIBGEANY_EXPORT_CFLAGS}"
 	LIBGEANY_LDFLAGS="-version-info ${libgeany_current}:${libgeany_revision}:${libgeany_age}"
 
 	AC_SUBST([LIBGEANY_CFLAGS])


Modified: scintilla/gtk/makefile.win32
4 lines changed, 3 insertions(+), 1 deletions(-)
===================================================================
@@ -32,7 +32,9 @@ vpath %.h ../src ../include ../lexlib
 vpath %.cxx ../src ../lexlib ../lexers
 
 INCLUDEDIRS=-I ../include -I ../src -I ../lexlib
-CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -DGTK -DSCI_LEXER $(INCLUDEDIRS)
+CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -DGTK -DSCI_LEXER $(INCLUDEDIRS) \
+	-DGEANY_EXPORT_SYMBOL="__declspec(dllexport)" \
+	-DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL
 
 ifdef THREADS
 THREADFLAGS=


Modified: src/Makefile.am
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -44,7 +44,6 @@ SRCS = \
 	navqueue.c navqueue.h \
 	notebook.c notebook.h \
 	osx.c osx.h \
-	pluginexport.h \
 	plugins.c plugins.h \
 	pluginutils.c pluginutils.h \
 	prefix.c prefix.h \


Modified: src/build.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -41,7 +41,6 @@
 #include "geanyobject.h"
 #include "keybindingsprivate.h"
 #include "msgwindow.h"
-#include "pluginexport.h"
 #include "prefs.h"
 #include "projectprivate.h"
 #include "sciwrappers.h"


Modified: src/callbacks.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -45,7 +45,6 @@
 #include "main.h"
 #include "msgwindow.h"
 #include "navqueue.h"
-#include "pluginexport.h"
 #include "plugins.h"
 #include "pluginutils.h"
 #include "prefs.h"


Modified: src/dialogs.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -35,7 +35,6 @@
 #include "encodings.h"
 #include "filetypes.h"
 #include "main.h"
-#include "pluginexport.h"
 #include "support.h"
 #include "utils.h"
 #include "ui_utils.h"


Modified: src/document.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -44,7 +44,6 @@
 #include "msgwindow.h"
 #include "navqueue.h"
 #include "notebook.h"
-#include "pluginexport.h"
 #include "project.h"
 #include "sciwrappers.h"
 #include "sidebar.h"


Modified: src/editor.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -48,7 +48,6 @@
 #include "highlighting.h"
 #include "keybindings.h"
 #include "main.h"
-#include "pluginexport.h"
 #include "prefs.h"
 #include "projectprivate.h"
 #include "sciwrappers.h"


Modified: src/encodings.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -39,7 +39,6 @@
 #include "app.h"
 #include "callbacks.h"
 #include "documentprivate.h"
-#include "pluginexport.h"
 #include "support.h"
 #include "ui_utils.h"
 #include "utils.h"


Modified: src/filetypes.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -40,7 +40,6 @@
 #include "geany.h"
 #include "geanyobject.h"
 #include "highlighting.h"
-#include "pluginexport.h"
 #include "projectprivate.h"
 #include "sciwrappers.h"
 #include "support.h"


Modified: src/highlighting.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -37,7 +37,6 @@
 #include "document.h"
 #include "editor.h"
 #include "filetypesprivate.h"
-#include "pluginexport.h"
 #include "sciwrappers.h"
 #include "support.h"
 #include "symbols.h"


Modified: src/keybindings.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -43,7 +43,6 @@
 #include "msgwindow.h"
 #include "navqueue.h"
 #include "notebook.h"
-#include "pluginexport.h"
 #include "prefs.h"
 #include "sciwrappers.h"
 #include "sidebar.h"


Modified: src/libmain.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -46,7 +46,6 @@
 #include "msgwindow.h"
 #include "navqueue.h"
 #include "notebook.h"
-#include "pluginexport.h"
 #include "plugins.h"
 #include "prefs.h"
 #include "printing.h"


Modified: src/makefile.win32
4 lines changed, 3 insertions(+), 1 deletions(-)
===================================================================
@@ -6,7 +6,9 @@ DEFINES = -DHAVE_CONFIG_H \
 	-DGEANY_LOCALEDIR=\"\" \
 	-DGEANY_LIBDIR=\"\" \
 	-DGEANY_PREFIX=\"\" \
-	-DGTK
+	-DGTK \
+	-DGEANY_EXPORT_SYMBOL="__declspec(dllexport)" \
+	-DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL
 
 .SUFFIXES: .c .o .h .a
 WINDRES = windres.exe


Modified: src/msgwindow.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -40,7 +40,6 @@
 #include "keybindings.h"
 #include "main.h"
 #include "navqueue.h"
-#include "pluginexport.h"
 #include "prefs.h"
 #include "support.h"
 #include "ui_utils.h"


Modified: src/navqueue.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -32,7 +32,6 @@
 
 #include "document.h"
 #include "geanyobject.h"
-#include "pluginexport.h"
 #include "sciwrappers.h"
 #include "toolbar.h"
 #include "utils.h"


Modified: src/pluginexport.h
34 lines changed, 0 insertions(+), 34 deletions(-)
===================================================================
@@ -1,34 +0,0 @@
-/*
- * pluginexport.h - this file is part of Geany, a fast and lightweight IDE
- *
- * Copyright 2014 Matthew Brush <mbrush at codebrainz.ca>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef GEANY_PLUGINEXPORT_H
-#define GEANY_PLUGINEXPORT_H 1
-
-#if defined(_WIN32) || defined(__CYGWIN__)
-# define GEANY_EXPORT_SYMBOL __declspec(dllexport)
-#elif defined(__GNUC__) && __GNUC__ >= 4
-# define GEANY_EXPORT_SYMBOL __attribute__((visibility ("default")))
-#else
-# define GEANY_API_SYMBOL
-#endif
-
-#define GEANY_API_SYMBOL GEANY_EXPORT_SYMBOL
-
-#endif /* GEANY_PLUGINEXPORT_H */


Modified: src/pluginutils.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -34,7 +34,6 @@
 #include "app.h"
 #include "geanyobject.h"
 #include "plugindata.h"
-#include "pluginexport.h"
 #include "pluginprivate.h"
 #include "plugins.h"
 #include "support.h"


Modified: src/project.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -38,7 +38,6 @@
 #include "geanyobject.h"
 #include "keyfile.h"
 #include "main.h"
-#include "pluginexport.h"
 #include "projectprivate.h"
 #include "sidebar.h"
 #include "stash.h"


Modified: src/sciwrappers.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -37,7 +37,6 @@
 
 #include "sciwrappers.h"
 
-#include "pluginexport.h"
 #include "utils.h"
 
 #include <string.h>


Modified: src/search.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -35,7 +35,6 @@
 #include "encodings.h"
 #include "keyfile.h"
 #include "msgwindow.h"
-#include "pluginexport.h"
 #include "prefs.h"
 #include "sciwrappers.h"
 #include "stash.h"


Modified: src/stash.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -78,7 +78,6 @@
 
 #include "stash.h"
 
-#include "pluginexport.h" /* for GEANY_API_SYMBOL */
 #include "support.h" /* only for _("text") */
 #include "utils.h"   /* only for foreach_*, utils_get_setting_*(). Stash should not depend on Geany. */
 


Modified: src/symbols.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -47,7 +47,6 @@
 #include "geanyobject.h"
 #include "main.h"
 #include "navqueue.h"
-#include "pluginexport.h"
 #include "sciwrappers.h"
 #include "sidebar.h"
 #include "support.h"


Modified: src/templates.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -37,7 +37,6 @@
 #include "geany.h"
 #include "geanymenubuttonaction.h"
 #include "geanyobject.h"
-#include "pluginexport.h"
 #include "support.h"
 #include "toolbar.h"
 #include "ui_utils.h"


Modified: src/ui_utils.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -40,7 +40,6 @@
 #include "keyfile.h"
 #include "main.h"
 #include "msgwindow.h"
-#include "pluginexport.h"
 #include "prefs.h"
 #include "project.h"
 #include "sciwrappers.h"


Modified: src/utils.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -32,7 +32,6 @@
 #include "app.h"
 #include "dialogs.h"
 #include "document.h"
-#include "pluginexport.h"
 #include "prefs.h"
 #include "sciwrappers.h"
 #include "support.h"


Modified: tagmanager/src/makefile.win32
4 lines changed, 3 insertions(+), 1 deletions(-)
===================================================================
@@ -29,7 +29,9 @@ GTK_INCLUDES= \
 
 INCLUDEDIRS=-I ../ctags -I ../ -I . $(GTK_INCLUDES)
 
-CBASEFLAGS=-Wall -pipe -mms-bitfields -DGEANY_PRIVATE -DPACKAGE=\"geany\" -Wno-missing-braces -Wno-char-subscripts $(INCLUDEDIRS)
+CBASEFLAGS=-Wall -pipe -mms-bitfields -DGEANY_PRIVATE -DPACKAGE=\"geany\" -Wno-missing-braces -Wno-char-subscripts $(INCLUDEDIRS) \
+	-DGEANY_EXPORT_SYMBOL="__declspec(dllexport)" \
+	-DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL
 ifdef DEBUG
 CFLAGS= -O0 -g $(CBASEFLAGS)
 else


Modified: tagmanager/src/tm_source_file.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -34,7 +34,6 @@
 #define LIBCTAGS_DEFINED
 #include "tm_source_file.h"
 #include "tm_tag.h"
-#include "../src/pluginexport.h" /* for GEANY_API_SYMBOL */
 
 
 static TMSourceFile *current_source_file = NULL;


Modified: tagmanager/src/tm_workspace.c
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -32,7 +32,6 @@
 
 #include "tm_workspace.h"
 #include "tm_tag.h"
-#include "../src/pluginexport.h" /* for GEANY_API_SYMBOL */
 
 
 /* when changing, always keep the three sort criteria below in sync */


Modified: wscript
13 lines changed, 13 insertions(+), 0 deletions(-)
===================================================================
@@ -305,6 +305,19 @@ but you then may not have a local copy of the HTML manual.'''
 
     conf.write_config_header('config.h', remove=False)
 
+    # GEANY_EXPORT_SYMBOL and GEANY_API_SYMBOL
+    # FIXME: should I put quoting in the appended values or are they passed as-is?
+    if is_win32:
+        conf.env.append_value('CFLAGS', ['-DGEANY_EXPORT_SYMBOL=__declspec(dllexport)'])
+    # FIXME: check for -fvisibility and the __attribute__((visibility)), or
+    #        at least for GCC >= 4
+    elif conf.env['CC_NAME'] == 'gcc':
+        conf.env.append_value('CFLAGS', ['-fvisibility=hidden',
+                                         '-DGEANY_EXPORT_SYMBOL=__attribute__((visibility("default")))'])
+    else:  # unknown, define to nothing
+        conf.env.append_value('CFLAGS', ['-DGEANY_EXPORT_SYMBOL='])
+    conf.env.append_value('CFLAGS', ['-DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL'])
+
     # some more compiler flags
     conf.env.append_value('CFLAGS', ['-DHAVE_CONFIG_H'])
     if conf.env['CC_NAME'] == 'gcc' and '-O' not in ''.join(conf.env['CFLAGS']):



--------------
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