[glibmm/use-dllexport-2-62: 8/8] Visual Studio builds: build giomm without gendef
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/use-dllexport-2-62: 8/8] Visual Studio builds: build giomm without gendef
- Date: Sun, 8 Mar 2020 17:52:10 +0000 (UTC)
commit 3660370a3867099f4b97756ed4ae73bd3116ed72
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Mar 6 15:02:48 2020 +0800
Visual Studio builds: build giomm without gendef
Make sure that we are defining GIOMM_API as __declspec(dllexport) when
building giomm and so stop the use of gendef.exe. We are now ready to
drop gendef from the glibmm sources.
MSVC_NMake/build-rules-msvc.mak | 15 +++-------
MSVC_NMake/config-msvc.mak | 1 -
MSVC_NMake/generate-msvc.mak | 5 ----
gio/giomm/meson.build | 64 +++++++++++++----------------------------
gio/giommconfig.h.in | 15 ++++------
gio/giommconfig.h.meson | 15 ++++------
6 files changed, 36 insertions(+), 79 deletions(-)
---
diff --git a/MSVC_NMake/build-rules-msvc.mak b/MSVC_NMake/build-rules-msvc.mak
index f28a5377..15231167 100644
--- a/MSVC_NMake/build-rules-msvc.mak
+++ b/MSVC_NMake/build-rules-msvc.mak
@@ -97,10 +97,10 @@ $(GLIBMM_DLL): vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm $(glibmm_OBJS)
link /DLL $(LDFLAGS_NOLTCG) $(GOBJECT_LIBS) $(LIBSIGC_LIB) /implib:$(GLIBMM_LIB) -out:$@ @<<
$(glibmm_OBJS)
<<
-
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
-$(GIOMM_DLL): $(GLIBMM_LIB) vs$(PDBVER)\$(CFG)\$(PLAT)\giomm\giomm.def $(giomm_OBJS)
- link /DLL $(LDFLAGS_NOLTCG) $(GLIBMM_LIB) $(GIO_LIBS) $(LIBSIGC_LIB) /implib:$(GIOMM_LIB)
/def:vs$(PDBVER)\$(CFG)\$(PLAT)\giomm\giomm.def -out:$@ @<<
+
+$(GIOMM_DLL): vs$(PDBVER)\$(CFG)\$(PLAT)\giomm $(GLIBMM_LIB) $(giomm_OBJS)
+ link /DLL $(LDFLAGS_NOLTCG) $(GLIBMM_LIB) $(GIO_LIBS) $(LIBSIGC_LIB) /implib:$(GIOMM_LIB) -out:$@ @<<
$(giomm_OBJS)
<<
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
@@ -113,11 +113,6 @@ $(giomm_OBJS)
# <<
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
-# For the gendef tool
-{.\gendef\}.cc{vs$(PDBVER)\$(CFG)\$(PLAT)\}.exe:
- @if not exist vs$(PDBVER)\$(CFG)\$(PLAT)\gendef\ $(MAKE) -f Makefile.vc CFG=$(CFG)
vs$(PDBVER)\$(CFG)\$(PLAT)\gendef
- $(CXX) $(GLIBMM_BASE_CFLAGS) $(CFLAGS) /Fo$(@D)\gendef\ /Fd$(@D)\gendef\ $< /link $(LDFLAGS) /out:$@
-
# For the buildable glibmm examples
vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm-ex-compose.exe: ..\examples\compose\main.cc $(GLIBMM_LIB)
vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm-ex-dispatcher2.exe: ..\examples\thread\dispatcher2.cc $(GLIBMM_LIB)
@@ -256,6 +251,7 @@ clean:
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.lib
@-del ..\tools\generate_wrap_init.pl
@-del ..\tools\gmmproc
+<<<<<<< HEAD
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\gschemas.compiled
@-del vs$(PDBVER)\$(CFG)\$(PLAT)\glib-extra-defs-gen\*.pdb
@-del vs$(PDBVER)\$(CFG)\$(PLAT)\glib-extra-defs-gen\*.obj
@@ -281,8 +277,6 @@ clean:
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm\*.cc
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm\private\*.h
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm\*.h
- @-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\gendef\*.obj
- @-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\gendef\*.pdb
@-if exist vs$(PDBVER)\$(CFG)\$(PLAT)\giomm-tests rd vs$(PDBVER)\$(CFG)\$(PLAT)\giomm-tests
@-rd vs$(PDBVER)\$(CFG)\$(PLAT)\glib-extra-defs-gen
@-rd vs$(PDBVER)\$(CFG)\$(PLAT)\giomm-ex
@@ -292,6 +286,5 @@ clean:
@-rd vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm-ex
@-rd vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm\private
@-rd vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm
- @-rd vs$(PDBVER)\$(CFG)\$(PLAT)\gendef
.SUFFIXES: .cc .h .ccg .hg .obj .cc.m4 .h.m4
diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak
index 6ed22ecd..93029a0c 100644
--- a/MSVC_NMake/config-msvc.mak
+++ b/MSVC_NMake/config-msvc.mak
@@ -75,7 +75,6 @@ GIOMM_LIBNAME = giomm-vc$(PDBVER)0$(DEBUG_SUFFIX)-$(GLIBMM_MAJOR_VERSION)_$(GLIB
GIOMM_DLL = vs$(PDBVER)\$(CFG)\$(PLAT)\$(GIOMM_LIBNAME).dll
GIOMM_LIB = vs$(PDBVER)\$(CFG)\$(PLAT)\$(GIOMM_LIBNAME).lib
-GENDEF = vs$(PDBVER)\$(CFG)\$(PLAT)\gendef.exe
GOBJECT_LIBS = gobject-2.0.lib gmodule-2.0.lib glib-2.0.lib
GIO_LIBS = gio-2.0.lib $(GOBJECT_LIBS)
diff --git a/MSVC_NMake/generate-msvc.mak b/MSVC_NMake/generate-msvc.mak
index 7b67f436..bd9a9dd6 100644
--- a/MSVC_NMake/generate-msvc.mak
+++ b/MSVC_NMake/generate-msvc.mak
@@ -4,7 +4,6 @@
# one is maintaining the NMake build files.
# Create the build directories
-vs$(PDBVER)\$(CFG)\$(PLAT)\gendef \
vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm \
vs$(PDBVER)\$(CFG)\$(PLAT)\glibmm\private \
vs$(PDBVER)\$(CFG)\$(PLAT)\giomm \
@@ -16,10 +15,6 @@ vs$(PDBVER)\$(CFG)\$(PLAT)\giomm-tests \
vs$(PDBVER)\$(CFG)\$(PLAT)\glib-extra-defs-gen:
@-md $@
-# Generate .def files
-vs$(PDBVER)\$(CFG)\$(PLAT)\giomm\giomm.def: $(GENDEF) vs$(PDBVER)\$(CFG)\$(PLAT)\giomm $(giomm_OBJS)
- vs$(PDBVER)\$(CFG)\$(PLAT)\gendef.exe $@ $(GIOMM_LIBNAME) vs$(PDBVER)\$(CFG)\$(PLAT)\giomm\*.obj
-
# Compile schema for giomm settings example
vs$(PDBVER)\$(CFG)\$(PLAT)\gschema.compiled: ..\examples\settings\org.gtkmm.demo.gschema.xml
$(GLIB_COMPILE_SCHEMAS) --targetdir=vs$(PDBVER)\$(CFG)\$(PLAT) ..\examples\settings
diff --git a/gio/giomm/meson.build b/gio/giomm/meson.build
index a64cb8c7..99aa3d68 100644
--- a/gio/giomm/meson.build
+++ b/gio/giomm/meson.build
@@ -3,7 +3,7 @@
# Input: giomm_build_dep, giomm_pcname, maintainer_mode, project_source_root,
# generate_binding_py, handle_built_files_py, m4_files, pm_files,
# glibmm_libversion, install_includedir, python3, giomm_rc, gmmproc_dir,
-# is_host_windows, gendef, gmmproc, generate_wrap_init_pl
+# is_host_windows, gmmproc, generate_wrap_init_pl
# Output: giomm_hg_ccg_basenames, giomm_extra_h_files, built_files_root,
# giomm_built_h_file_targets, giomm_dep
@@ -210,6 +210,16 @@ install_headers(giomm_extra_h_files, subdir: giomm_pcname / 'giomm')
untracked_giomm = 'untracked' / 'gio' / 'giomm'
src_untracked_giomm = project_source_root / untracked_giomm
+extra_giomm_objects = []
+giomm_cpp_flags = [ '-DGIOMM_BUILD=1' ]
+
+# Build the .rc file for Windows builds and link to it
+if is_host_windows
+ windows = import('windows')
+ giomm_res = windows.compile_resources(giomm_rc)
+ extra_giomm_objects += giomm_res
+endif
+
if maintainer_mode
# Maintainer mode. Generate .h and .cc files from .hg and .ccg files in ../src.
@@ -291,13 +301,15 @@ if maintainer_mode
)
extra_include_dirs = ['..', '..' / '..' / 'glib']
- gio_int_lib = static_library('giomm-int',
+
+ giomm_library = library(giomm_pcname, extra_giomm_objects,
giomm_used_built_cc_file_targets, giomm_extra_cc_files, built_dummy_h_file_target,
+ version: glibmm_libversion,
include_directories: extra_include_dirs,
- cpp_args: '-DGIOMM_BUILD=1',
+ cpp_args: giomm_cpp_flags,
dependencies: giomm_build_dep,
link_with: glibmm_library,
- install: false,
+ install: true,
)
built_h_cc_dir = meson.current_build_dir()
@@ -338,56 +350,20 @@ else # not maintainer_mode
'..' / '..' / 'glib', '..' / '..' / 'untracked' / 'glib',
]
- # We need this so that we can run gendef.exe to get the .def file
- # needed for obtaining the .lib file for the giomm DLL
- gio_int_lib = static_library('giomm-int',
+ giomm_library = library(giomm_pcname, extra_giomm_objects,
built_cc_files, giomm_extra_cc_files,
+ version: glibmm_libversion,
include_directories: extra_include_dirs,
- cpp_args: '-DGIOMM_BUILD=1',
+ cpp_args: giomm_cpp_flags,
dependencies: giomm_build_dep,
link_with: glibmm_library,
- install: false,
+ install: true,
)
built_h_cc_dir = src_untracked_giomm
endif
-giomm_def = []
-giomm_extra_link_args = []
-extra_giomm_objects = []
-
-if is_msvc
- giomm_def = custom_target('giomm.def',
- output: 'giomm.def',
- depends: gio_int_lib,
- command: [ gendef,
- '@OUTPUT@',
- '@0@-@1@.dll'.format(giomm_pcname, glibmm_libversion.split('.')[0]),
- gio_int_lib.full_path(),
- ],
- install: false,
- )
- giomm_extra_link_args = ['/def:@0@'.format(giomm_def.full_path())]
-endif
-
-# Build the .rc file for Windows builds and link to it
-if is_host_windows
- windows = import('windows')
- giomm_res = windows.compile_resources(giomm_rc)
- extra_giomm_objects += giomm_res
-endif
-
-giomm_library = library(giomm_pcname, extra_giomm_objects,
- objects: gio_int_lib.extract_all_objects(),
- version: glibmm_libversion,
- dependencies: giomm_build_dep,
- link_depends: giomm_def,
- link_args: giomm_extra_link_args,
- link_with: glibmm_library,
- install: true,
-)
-
# Install built .h and _p.h files.
meson.add_install_script(
python3.path(), generate_binding_py, 'install_built_h_files',
diff --git a/gio/giommconfig.h.in b/gio/giommconfig.h.in
index 8f27b73d..b9579c6e 100644
--- a/gio/giommconfig.h.in
+++ b/gio/giommconfig.h.in
@@ -19,20 +19,17 @@
#undef GIOMM_STATIC_LIB
// Enable DLL-specific stuff only when not building a static library
-#if !defined(__CYGWIN__) && defined(__MINGW32__) && !defined(GIOMM_STATIC_LIB)
+#if !defined(__CYGWIN__) && (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(GIOMM_STATIC_LIB)
# define GIOMM_DLL 1
#endif
#ifdef GIOMM_DLL
-# if defined(GIOMM_BUILD) && defined(_WINDLL)
- /* Do not dllexport as it is handled by gendef on MSVC */
-# define GIOMM_API
-# elif !defined(GIOMM_BUILD)
-# define GIOMM_API __declspec(dllimport)
+# if defined(GIOMM_BUILD)
+# define GIOMM_API __declspec(dllexport)
# else
- /* Build a static library */
-# define GIOMM_API
-# endif /* GIOMM_BUILD - _WINDLL */
+# define GIOMM_API __declspec(dllimport)
+# endif
+/* Build a static library or non-native-Windows library */
#else
# define GIOMM_API
#endif /* GIOMM_DLL */
diff --git a/gio/giommconfig.h.meson b/gio/giommconfig.h.meson
index 82aedddf..9ac31c6d 100644
--- a/gio/giommconfig.h.meson
+++ b/gio/giommconfig.h.meson
@@ -19,20 +19,17 @@
#mesondefine GIOMM_STATIC_LIB
// Enable DLL-specific stuff only when not building a static library
-#if !defined(__CYGWIN__) && defined(__MINGW32__) && !defined(GIOMM_STATIC_LIB)
+#if !defined(__CYGWIN__) && (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(GIOMM_STATIC_LIB)
# define GIOMM_DLL 1
#endif
#ifdef GIOMM_DLL
-# if defined(GIOMM_BUILD) && defined(_WINDLL)
- /* Do not dllexport as it is handled by gendef on MSVC */
-# define GIOMM_API
-# elif !defined(GIOMM_BUILD)
-# define GIOMM_API __declspec(dllimport)
+# if defined(GIOMM_BUILD)
+# define GIOMM_API __declspec(dllexport)
# else
- /* Build a static library */
-# define GIOMM_API
-# endif /* GIOMM_BUILD - _WINDLL */
+# define GIOMM_API __declspec(dllimport)
+# endif
+/* Build a static library or non-native-Windows library */
#else
# define GIOMM_API
#endif /* GIOMM_DLL */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]