serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1834948 - in /serf/trunk: CMakeLists.txt build/SerfWindowsToolkit.cmake
Date Tue, 03 Jul 2018 11:42:06 GMT
Author: brane
Date: Tue Jul  3 11:42:06 2018
New Revision: 1834948

URL: http://svn.apache.org/viewvc?rev=1834948&view=rev
Log:
In the CMake build, make sure that the DLL import library is generated.

* CMakeLists.txt: Define the export blacklist as in SConstruct.
   Generate a Windows DEF file and add it to the shared-lib sources.
* build/SerfWindowsToolkit.cmake (SerfWindowsGenDef): New function.
   Generates the DEF file, apparently just like build/gen_def.py.

Modified:
    serf/trunk/CMakeLists.txt
    serf/trunk/build/SerfWindowsToolkit.cmake

Modified: serf/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/serf/trunk/CMakeLists.txt?rev=1834948&r1=1834947&r2=1834948&view=diff
==============================================================================
--- serf/trunk/CMakeLists.txt (original)
+++ serf/trunk/CMakeLists.txt Tue Jul  3 11:42:06 2018
@@ -115,7 +115,14 @@ set(SOURCES
 )
 
 if(SERF_WINDOWS)
-  set(SHARED_SOURCES "serf.rc")
+  list(APPEND EXPORTS_BLACKLIST
+       "serf_connection_switch_protocol"
+       "serf_http_protocol_create"
+       "serf_https_protocol_create"
+       "serf_http_request_queue"
+  )
+  SerfWindowsGenDef("${EXPORTS_BLACKLIST}" "${CMAKE_BINARY_DIR}/serf.def" ${HEADERS})
+  set(SHARED_SOURCES "serf.rc" "${CMAKE_BINARY_DIR}/serf.def")
 
   # Static OpenSSL, APR and APR-Util need additional libraries that are not
   # linked by default by CMake. These will be ignored by the linker if they're

Modified: serf/trunk/build/SerfWindowsToolkit.cmake
URL: http://svn.apache.org/viewvc/serf/trunk/build/SerfWindowsToolkit.cmake?rev=1834948&r1=1834947&r2=1834948&view=diff
==============================================================================
--- serf/trunk/build/SerfWindowsToolkit.cmake (original)
+++ serf/trunk/build/SerfWindowsToolkit.cmake Tue Jul  3 11:42:06 2018
@@ -33,3 +33,37 @@ function(SerfWindowsProcessZLIB)
   if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
   endif()
 endfunction(SerfWindowsProcessZLIB)
+
+# Generate a Windows DLL .def file from a list of headers.
+function(SerfWindowsGenDef blacklist_ target_)
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+    set(func_search_rx_ "^(([a-zA-Z_0-9]+|\\*) )+\\*?(serf_[a-z][a-zA-Z_0-9]*)\\(")
+    set(type_search_rx_ "^extern const serf_bucket_type_t (serf_[a-z_]*);")
+    set(func_rx_ "^(([a-zA-Z_0-9]+|\\*) )+\\*?(serf_[a-z][a-zA-Z_0-9]*).*$")
+    set(type_rx_ "^extern const serf_bucket_type_t (serf_[a-z_]*).*$")
+
+    foreach(file_ ${ARGN})
+      message(STATUS "Looking for exports in ${file_}")
+      file(STRINGS ${file_} funcs_ REGEX "${func_search_rx_}")
+      file(STRINGS ${file_} types_ REGEX "${type_search_rx_}")
+      foreach(sym_ ${funcs_})
+        string(REGEX REPLACE "${func_rx_}" "\\3" def_ ${sym_})
+        list(APPEND defs_ ${def_})
+      endforeach()
+      foreach(sym_ ${types_})
+        string(REGEX REPLACE "${type_rx_}" "\\1" def_ ${sym_})
+        list(APPEND defs_ ${def_})
+      endforeach()
+    endforeach()
+
+    list(SORT defs_)
+    list(REMOVE_DUPLICATES defs_)
+    file(WRITE ${target_} "EXPORTS\n")
+    foreach(def_ ${defs_})
+      list(FIND blacklist_ "${def_}" skip_)
+      if(skip_ LESS 0)
+        file(APPEND ${target_} "${def_}\n")
+      endif()
+    endforeach()
+  endif()
+endfunction(SerfWindowsGenDef)



Mime
View raw message