[gtkmm/use-dllexport-3-24: 9/9] NMake Makefiles: Export symbols without gendef if possible



commit 16bd5d037e7b611214f8b965dd01a944a3c6029c
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Sat Apr 11 23:23:08 2020 +0800

    NMake Makefiles: Export symbols without gendef if possible
    
    We check to see whether we have a new-enough gmmproc that is capable of
    generating the headers from the .hg templates with function decorations
    at places where they need to be.  If it is, we skip building gendef and
    use __declspec(dllexport) to export the needed symbols.
    
    Otherwise, we continue to use gendef.exe to export symbols, as we did
    before.

 MSVC_NMake/build-rules-msvc.mak  |  8 ++++----
 MSVC_NMake/create-lists-msvc.mak | 18 ++++++++++++++++++
 MSVC_NMake/filelist.am           |  1 +
 MSVC_NMake/get-gmmproc-ver.bat   | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 4 deletions(-)
---
diff --git a/MSVC_NMake/build-rules-msvc.mak b/MSVC_NMake/build-rules-msvc.mak
index 86abb40c..556ad62e 100644
--- a/MSVC_NMake/build-rules-msvc.mak
+++ b/MSVC_NMake/build-rules-msvc.mak
@@ -72,14 +72,14 @@ $(GTKMM_LIB): $(GTKMM_DLL)
 # $(dependent_objects)
 # <<
 #      @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
-$(GDKMM_DLL): vs$(PDBVER)\$(CFG)\$(PLAT)\gdkmm\gdkmm.def $(gdkmm_OBJS)
-       link /DLL $(LDFLAGS_NOLTCG) $(GDKMM_DEP_LIBS) /implib:$(GDKMM_LIB) 
/def:vs$(PDBVER)\$(CFG)\$(PLAT)\gdkmm\gdkmm.def -out:$@ @<<
+$(GDKMM_DLL): $(GDKMM_INT_TARGET) $(gdkmm_OBJS)
+       link /DLL $(LDFLAGS_NOLTCG) $(GDKMM_DEP_LIBS) /implib:$(GDKMM_LIB) $(GDKMM_DEF_LDFLAG) -out:$@ @<<
 $(gdkmm_OBJS)
 <<
        @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
 
-$(GTKMM_DLL): $(GDKMM_LIB) vs$(PDBVER)\$(CFG)\$(PLAT)\gtkmm\gtkmm.def $(gtkmm_OBJS)
-       link /DLL $(LDFLAGS_NOLTCG) $(GDKMM_LIB) $(GTKMM_DEP_LIBS) /implib:$(GTKMM_LIB) 
/def:vs$(PDBVER)\$(CFG)\$(PLAT)\gtkmm\gtkmm.def -out:$@ @<<
+$(GTKMM_DLL): $(GDKMM_LIB) $(GTKMM_INT_TARGET) $(gtkmm_OBJS)
+       link /DLL $(LDFLAGS_NOLTCG) $(GDKMM_LIB) $(GTKMM_DEP_LIBS) /implib:$(GTKMM_LIB) $(GTKMM_DEF_LDFLAG) 
-out:$@ @<<
 $(gtkmm_OBJS)
 <<
        @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
diff --git a/MSVC_NMake/create-lists-msvc.mak b/MSVC_NMake/create-lists-msvc.mak
index a1b08c52..8735a653 100644
--- a/MSVC_NMake/create-lists-msvc.mak
+++ b/MSVC_NMake/create-lists-msvc.mak
@@ -141,7 +141,25 @@ gdkmm_generated_private_headers = $(files_hg:.hg=_p.h)
 !if [call create-lists.bat footer gtkmm.mak]
 !endif
 
+!if [for %f in (gdkmm\applaunchcontext.h) do @if not exist ..\gdk\%f if not exist if not exist 
vs$(PDBVER)\$(CFG)\$(PLAT)\%f (md vs$(PDBVER)\$(CFG)\$(PLAT)\gdkmm\private) & ($(PERL) -- 
$(GMMPROC_DIR)/gmmproc -I ../tools/m4 -I $(GMMPROC_PANGO_DIR) -I $(GMMPROC_ATK_DIR) --defs ../gdk/src 
applaunchcontext ../gdk/src vs$(PDBVER)/$(CFG)/$(PLAT)/gdkmm)]
+!endif
+
+!if [for %d in (vs$(PDBVER)\$(CFG)\$(PLAT)\gdkmm ..\gdk\gdkmm) do @if exist %d\applaunchcontext.h call 
get-gmmproc-ver %d\applaunchcontext.h>>gtkmm.mak]
+!endif
+
 !include gtkmm.mak
 
 !if [del /f /q gtkmm.mak]
 !endif
+
+!if "$(GMMPROC_VER)" >= "2.64.3"
+GDKMM_INT_TARGET = vs$(PDBVER)\$(CFG)\$(PLAT)\gdkmm
+GTKMM_INT_TARGET = vs$(PDBVER)\$(CFG)\$(PLAT)\gtkmm
+GDKMM_DEF_LDFLAG =
+!else
+GDKMM_INT_TARGET = vs$(PDBVER)\$(CFG)\$(PLAT)\gdkmm\gdkmm.def
+GDKMM_DEF_LDFLAG = /def:$(GDKMM_INT_TARGET)
+GDKMM_BASE_CFLAGS = $(GDKMM_BASE_CFLAGS) /DGDKMM_USE_GENDEF
+GTKMM_DEF_LDFLAG = /def:$(GDKMM_INT_TARGET:gdk=gtk)
+GTKMM_BASE_CFLAGS = $(GDKMM_BASE_CFLAGS) /DGTKMM_USE_GENDEF
+!endif
diff --git a/MSVC_NMake/filelist.am b/MSVC_NMake/filelist.am
index 0055ad2c..e8f80c04 100644
--- a/MSVC_NMake/filelist.am
+++ b/MSVC_NMake/filelist.am
@@ -10,6 +10,7 @@ msvc_nmake_data =             \
        filelist.am             \
        generate-msvc.mak       \
        gendef/gendef.cc        \
+       get-gmmproc-ver.bat     \
        gdkmm/gdkmm.rc          \
        gdkmm/gdkmmconfig.h     \
        gtkmm/gtkmm.rc          \
diff --git a/MSVC_NMake/get-gmmproc-ver.bat b/MSVC_NMake/get-gmmproc-ver.bat
new file mode 100644
index 00000000..f9b340f9
--- /dev/null
+++ b/MSVC_NMake/get-gmmproc-ver.bat
@@ -0,0 +1,34 @@
+@echo off
+REM get-gmmproc-ver: Grab first line of a gmmproc-generated
+REM .h file to see which version of gmmproc is used to
+REM generate the header
+
+if "%1" == "" goto :usage
+
+call :print_first_line %1
+goto :eof
+
+:print_first_line
+setlocal EnableDelayedExpansion
+set /a line=0
+
+for /f ^"usebackq^ eol^=^ delims^=^" %%l in (%1) do (
+  if "!line!" == "1" goto :eof
+  echo %%l>tmp.txt
+  for /f "tokens=1-5" %%a in (tmp.txt) do (
+    if not "%%a" == "//" goto :not_gmmproc
+    if not "%%b" == "Generated" goto :not_gmmproc
+    if not "%%c" == "by" goto :not_gmmproc
+    if not "%%d" == "gmmproc" goto :not_gmmproc
+    echo GMMPROC_VER=%%e
+  )
+  del /f tmp.txt
+  set /a line+=1
+)
+
+:not_gmmproc
+echo This is not a gmmproc generated file.
+goto :eof
+
+:usage
+echo Usage: get-gmmproc-ver ^<generated-header^>
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]