[atkmm/use-dllexport-2-28: 4/4] NMake Makefiles: Export using compiler directives if possible



commit 99d40c460c068ef9bd52312292bf04e7861f58c2
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Apr 1 19:05:38 2020 +0800

    NMake Makefiles: Export using compiler directives if possible
    
    Check the gmmproc-generated sources to see whether they are generated
    with a new-enough gmmproc by checking on one of the generated headers,
    so that we can tell whether the generated headers have class, function
    and method definitions marked with ATKMM_API as needed.
    
    If the headers were generated with a recent enough gmmproc, we define
    ATKMM_BUILD and ATKMM_DLL to set ATKMM_API as __declspec(dllexport) to
    export the symbols directly during compilation and linking without
    building and using gendef.exe, otherwise we fall back to running
    gendef.exe on the built object files as we did before.

 MSVC_NMake/build-rules-msvc.mak  |  4 ++--
 MSVC_NMake/create-lists-msvc.mak | 15 +++++++++++++++
 MSVC_NMake/filelist.am           |  1 +
 MSVC_NMake/get-gmmproc-ver.bat   | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+), 2 deletions(-)
---
diff --git a/MSVC_NMake/build-rules-msvc.mak b/MSVC_NMake/build-rules-msvc.mak
index 0c87c31..0d02128 100644
--- a/MSVC_NMake/build-rules-msvc.mak
+++ b/MSVC_NMake/build-rules-msvc.mak
@@ -42,8 +42,8 @@ $(ATKMM_LIB): $(ATKMM_DLL)
 # $(dependent_objects)
 # <<
 #      @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
-$(ATKMM_DLL): vs$(PDBVER)\$(CFG)\$(PLAT)\atkmm\atkmm.def $(atkmm_OBJS)
-       link /DLL $(LDFLAGS_NOLTCG) $(ATK_LIBS) $(GLIBMM_LIB) $(LIBSIGC_LIB) /implib:$(ATKMM_LIB) 
/def:vs$(PDBVER)\$(CFG)\$(PLAT)\atkmm\atkmm.def -out:$@ @<<
+$(ATKMM_DLL): $(ATKMM_INT_TARGET) $(atkmm_OBJS)
+       link /DLL $(LDFLAGS_NOLTCG) $(ATK_LIBS) $(GLIBMM_LIB) $(LIBSIGC_LIB) /implib:$(ATKMM_LIB) 
$(ATKMM_DEF_LDFLAG) -out:$@ @<<
 $(atkmm_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 2b76314..accbec6 100644
--- a/MSVC_NMake/create-lists-msvc.mak
+++ b/MSVC_NMake/create-lists-msvc.mak
@@ -63,7 +63,22 @@ atkmm_files_extra_ph_int = $(atkmm_files_extra_ph:/=\)
 !if [call create-lists.bat footer atkmm.mak]
 !endif
 
+!if [for %f in (atkmm\action.h) do @if not exist ..\atk\%f if not exist vs$(PDBVER)\$(CFG)\$(PLAT)\%f (md 
vs$(PDBVER)\$(CFG)\$(PLAT)\atkmm\private) & ($(PERL) -- $(GMMPROC_DIR)/gmmproc -I ../tools/m4 --defs 
../atk/src action ../atk/src vs$(PDBVER)/$(CFG)/$(PLAT)/atkmm)]
+!endif
+
+!if [for %d in (vs$(PDBVER)\$(CFG)\$(PLAT)\atkmm ..\atk\atkmm ..\untracked\atk\atkmm) do @if exist 
%d\action.h call get-gmmproc-ver %d\action.h>>atkmm.mak]
+!endif
+
 !include atkmm.mak
 
 !if [del /f /q atkmm.mak]
 !endif
+
+!if "$(GMMPROC_VER)" >= "2.64.0"
+ATKMM_INT_TARGET = vs$(PDBVER)\$(CFG)\$(PLAT)\atkmm
+ATKMM_DEF_LDFLAG =
+!else
+ATKMM_INT_TARGET = vs$(PDBVER)\$(CFG)\$(PLAT)\atkmm\atkmm.def
+ATKMM_DEF_LDFLAG = /def:$(ATKMM_INT_TARGET)
+ATKMM_BASE_CFLAGS = $(ATKMM_BASE_CFLAGS) /DATKMM_USE_GENDEF
+!endif
diff --git a/MSVC_NMake/filelist.am b/MSVC_NMake/filelist.am
index 5c0f4c2..d882693 100644
--- a/MSVC_NMake/filelist.am
+++ b/MSVC_NMake/filelist.am
@@ -10,6 +10,7 @@ msvc_nmake_data =                     \
        create-lists.bat                \
        detectenv-msvc.mak              \
        generate-msvc.mak               \
+       get-gmmproc-ver.bat             \
        info-msvc.mak                   \
        install.mak                     \
        Makefile.vc
diff --git a/MSVC_NMake/get-gmmproc-ver.bat b/MSVC_NMake/get-gmmproc-ver.bat
new file mode 100644
index 0000000..fa4e808
--- /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^>


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