[gtksourceview/meson.msvc: 4/8] meson: Fix Visual Studio DLL builds
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/meson.msvc: 4/8] meson: Fix Visual Studio DLL builds
- Date: Wed, 24 Apr 2019 10:54:49 +0000 (UTC)
commit 8eda1cd717dd241cd50793379737eb3f48694643
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Apr 24 16:20:14 2019 +0800
meson: Fix Visual Studio DLL builds
Unfortunately, Visual Studio builds do not really like the concept of
linking 2 static libraries and not using any sources for building a
given DLL (it will not include those items when linking the final DLL as
it will optimize most of the items out as the linker does not believe
those items are being really used in the final DLL), so we need to do
the following for the Visual Studio builds:
-Define a separate GtkSourceView shared library target that contain the
core sources *and* the word completion provider sources, along with the
generated glib-mkenums and GResource sources. This is actually how the
Visual Studio projects build the sources for the GtkSourceView DLL, due
to the same reasoning.
-Declare the various internal dependencies accordingly; note that we
still need the static core library for building the test programs.
This means that on Visual Studio builds we need to build the core
sources 2 times, it seems that this is unavoidable at this point.
The build files for the tests in tests/ and testsuite/ has been updated
accordingly so that things will build and link. Note that for the
test-stylescheme test, we need to ensure that we only link to the
static core library, otherwise it will fail to link.
-Update the enumeration source generating process, so that we include
config.h during the build and so ensure that the symbols in the
enumeration sources are properly exported. This is necessary
especially for the introspection builds on Visual Studio, as well as
for the test programs.
-For builds prior to Visual Studio 2013, we must include our math.h so
that we can have a fallback implementation for round(), which is only
provided in Visual Studio 2013 and later.
.../completion-providers/words/meson.build | 37 +++++++-------
gtksourceview/meson.build | 59 +++++++++++++++-------
tests/meson.build | 3 +-
testsuite/meson.build | 2 +-
4 files changed, 63 insertions(+), 38 deletions(-)
---
diff --git a/gtksourceview/completion-providers/words/meson.build
b/gtksourceview/completion-providers/words/meson.build
index 7e351c3a..75d942b8 100644
--- a/gtksourceview/completion-providers/words/meson.build
+++ b/gtksourceview/completion-providers/words/meson.build
@@ -26,26 +26,29 @@ install_headers(
)
)
-completionwords_lib = static_library(
- package_string + 'completionwords',
- completionwords_public_c,
- include_directories: rootdir,
- dependencies: core_dep,
- c_args: completionwords_c_args,
- install: false,
-)
+if cc.get_id() != 'msvc'
+ completionwords_lib = static_library(
+ package_string + 'completionwords',
+ completionwords_public_c,
+ include_directories: rootdir,
+ dependencies: core_dep,
+ c_args: completionwords_c_args,
+ install: false,
+ )
-gtksource_libs += [
- completionwords_lib,
-]
+ gtksource_libs += [
+ completionwords_lib,
+ ]
-completionwords_dep = declare_dependency(
- link_with: completionwords_lib,
- include_directories: rootdir,
- dependencies: core_dep,
-)
+ completionwords_dep = declare_dependency(
+ link_with: completionwords_lib,
+ include_directories: rootdir,
+ dependencies: core_dep,
+ )
+
+ gtksource_deps += completionwords_dep
-gtksource_deps += completionwords_dep
+endif
extra_public_sources += files([
'gtksourcecompletionwords.c',
diff --git a/gtksourceview/meson.build b/gtksourceview/meson.build
index be74f737..991403fe 100644
--- a/gtksourceview/meson.build
+++ b/gtksourceview/meson.build
@@ -120,16 +120,24 @@ if config_h.has('OS_OSX')
]
endif
-extra_include_dirs = []
if cc.get_id() == 'msvc'
# include our math.h to implement round() for pre-2013 Visual Studio
msvc_maj_ver = cc.version().split('.')[0].to_int()
if msvc_maj_ver < 18
- extra_include_dirs = include_directories('../win32')
+ gtksourceview_include_dirs = [rootdir, include_directories('../win32')]
+ else
+ gtksourceview_include_dirs = rootdir
endif
+else
+ gtksourceview_include_dirs = rootdir
endif
core_enums_header = '''
+
+#if defined (GTK_SOURCE_COMPILATION) && defined (HAVE_CONFIG_H)
+# include <config.h>
+#endif
+
#if !defined (GTK_SOURCE_H_INSIDE) && !defined (GTK_SOURCE_COMPILATION)
# error "Only <gtksourceview/gtksource.h> can be included directly."
#endif
@@ -171,19 +179,15 @@ install_headers(
install_dir: join_paths(pkgincludedir, 'gtksourceview'),
)
+core_enums_h = core_enums.get(1)
+
core_lib = static_library(package_string + 'core', core_sources,
- include_directories: [rootdir, extra_include_dirs],
+ include_directories: gtksourceview_include_dirs,
dependencies: core_deps,
c_args: core_c_args,
install: false
)
-gtksource_libs = [
- core_lib,
-]
-
-core_enums_h = core_enums.get(1)
-
core_dep = declare_dependency(
link_with: core_lib,
include_directories: rootdir,
@@ -195,6 +199,8 @@ gtksource_deps = [
core_dep,
]
+gtksource_libs = cc.get_id() == 'msvc' ? [] : [core_lib]
+
extra_public_sources = []
subdir('completion-providers')
@@ -204,15 +210,30 @@ gtksource_res = gnome.compile_resources(
'gtksourceview.gresource.xml'
)
-gtksource_lib = shared_library(package_string, gtksource_res,
- version: lib_version,
- include_directories: rootdir,
- dependencies: gtksource_deps,
- link_whole: gtksource_libs,
- c_args: core_c_args,
- install: true,
- gnu_symbol_visibility: 'hidden',
-)
+if cc.get_id() == 'msvc'
+ gtksource_word_provider_sources = []
+ foreach s: completionwords_public_c
+ gtksource_word_provider_sources += files(['completion-providers/words/@0@'.format(s)])
+ endforeach
+ gtksource_lib = shared_library(package_string,
+ [core_sources, gtksource_word_provider_sources, gtksource_res],
+ version: lib_version,
+ include_directories: gtksourceview_include_dirs,
+ dependencies: core_deps,
+ c_args: core_c_args,
+ install: true,
+ )
+else
+ gtksource_lib = shared_library(package_string, gtksource_res,
+ version: lib_version,
+ include_directories: gtksourceview_include_dirs,
+ dependencies: gtksource_deps,
+ link_whole: gtksource_libs,
+ c_args: core_c_args,
+ install: true,
+ gnu_symbol_visibility: 'hidden',
+ )
+endif
gtksource_dep_sources = [
core_enums_h,
@@ -272,7 +293,7 @@ endif
gtksource_dep = declare_dependency(
link_with: gtksource_lib,
include_directories: rootdir,
- dependencies: gtksource_deps,
+ dependencies: cc.get_id() == 'msvc' ? core_deps : gtksource_deps,
sources: gtksource_dep_sources,
)
diff --git a/tests/meson.build b/tests/meson.build
index e1430fbc..2df53390 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -29,5 +29,6 @@ foreach test_name, test_sources: tests_sources
executable('test-@0@'.format(test_name), test_sources,
c_args: tests_c_args,
- dependencies: [gtksource_dep])
+ dependencies: cc.get_id() == 'msvc' ? [gtksource_dep, core_dep] : [gtksource_dep],
+ )
endforeach
diff --git a/testsuite/meson.build b/testsuite/meson.build
index e820a606..09088859 100644
--- a/testsuite/meson.build
+++ b/testsuite/meson.build
@@ -44,7 +44,7 @@ foreach test: testsuite_sources
test_exe = executable(test_name, test_sources,
c_args: testsuite_c_args,
- dependencies: [gtksource_dep],
+ dependencies: cc.get_id() == 'msvc' and test_name == 'test-stylescheme' ? [core_dep] : [gtksource_dep],
install: get_option('install_tests'),
install_dir: testexecdir
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]