aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-08-08 15:11:19 -0700
committerGitHub <noreply@github.com>2017-08-08 15:11:19 -0700
commitb77fea694822c744471df43ae887dd2868f3b1fc (patch)
tree4509f7fd36537baeb912417e364e60e23a5744e4
parent4e0d84063f6b0b0036963213e93bc23dcef1647b (diff)
parent7399ea0d6ee6095266c8aa7d4c7706c53e30e5d1 (diff)
downloadvcpkg-b77fea694822c744471df43ae887dd2868f3b1fc.tar.gz
vcpkg-b77fea694822c744471df43ae887dd2868f3b1fc.zip
Merge pull request #1062 from KindDragon/jemalloc
[jemalloc] Initial commit for jemalloc library
-rw-r--r--ports/jemalloc/CONTROL4
-rw-r--r--ports/jemalloc/fix-cmakelists.patch67
-rw-r--r--ports/jemalloc/fix-utilities.patch30
-rw-r--r--ports/jemalloc/portfile.cmake36
4 files changed, 137 insertions, 0 deletions
diff --git a/ports/jemalloc/CONTROL b/ports/jemalloc/CONTROL
new file mode 100644
index 000000000..c867b4573
--- /dev/null
+++ b/ports/jemalloc/CONTROL
@@ -0,0 +1,4 @@
+Source: jemalloc
+Version: 4.3.1-1
+Description: jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support
+Build-Depends:
diff --git a/ports/jemalloc/fix-cmakelists.patch b/ports/jemalloc/fix-cmakelists.patch
new file mode 100644
index 000000000..a19cb4050
--- /dev/null
+++ b/ports/jemalloc/fix-cmakelists.patch
@@ -0,0 +1,67 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 06e83ef..229e17a 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -57,6 +57,7 @@ option(enable-lazy-lock "Enable lazy locking (only lock when multi-threaded" OFF
+ option(force_lazy_lock "Forcing lazy-lock to avoid allocator/threading bootstrap issues" OFF)
+ # install_prefix - installation directory prefix
+ # with-xslroot=<path> XSL stylesheet root path
++option(build-tests "Build tests" OFF)
+
+ set (PACKAGE_NAME "jemalloc")
+ project (${PACKAGE_NAME} C)
+@@ -711,12 +712,8 @@ endif()
+
+ # The original library, delivery product
+ set(LIBJEMALLOCLIB jemalloc${install_suffix})
+-add_library(${LIBJEMALLOCLIB} STATIC ${C_SRCS})
+-
+-# Now add shared library. Needed for integration tests
+-# and a benchmark
+-set(LIBJEMALLOCSO jemallocso${install_suffix})
+-add_library(${LIBJEMALLOCSO} SHARED ${C_SRCS})
++set(LIBJEMALLOCSO ${LIBJEMALLOCLIB})
++add_library(${LIBJEMALLOCLIB} ${C_SRCS})
+
+ if(WIN32)
+ # May want to replace /d2Zi+ to /Zo
+@@ -745,8 +745,6 @@ if(WIN32)
+ # either impport or export which is both wrong for a static library
+ set_target_properties(${LIBJEMALLOCLIB}
+ PROPERTIES
+- COMPILE_DEFINITIONS
+- "JEMALLOC_EXPORT="
+ CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG
+ ${PROJECT_BINARY_DIR}/Debug
+ CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_RELEASE
+@@ -754,6 +752,9 @@ if(WIN32)
+ COMPILE_PDB_NAME
+ ${LIBJEMALLOCLIB}
+ )
++ if(NOT BUILD_SHARED_LIBS)
++ target_compile_definitions(${LIBJEMALLOCLIB} "JEMALLOC_EXPORT=")
++ endif()
+
+ endif()
+
+@@ -825,6 +822,14 @@ if(C_UTIL_INTEGRATION_DEFS)
+ "${C_UTIL_INTEGRATION_DEFS}")
+ endif()
+
++install(FILES include/jemalloc/jemalloc${install_suffix}.h
++ DESTINATION include/jemalloc)
++
++install(TARGETS ${LIBJEMALLOCSO}
++ RUNTIME DESTINATION bin
++ LIBRARY DESTINATION lib
++ ARCHIVE DESTINATION lib)
++if (build-tests)
+ ##################################################################
+ # Common source for Unit, Integration and stress test libraries
+ set(C_TESTLIB_SRCS
+@@ -1028,4 +1033,4 @@ foreach(sourcefile ${TESTS_INTEGRATION})
+ add_test(NAME ${exename} COMMAND ${exename})
+ add_dependencies(check ${exename})
+ endforeach(sourcefile ${TESTS_UNIT})
+-
++endif()
diff --git a/ports/jemalloc/fix-utilities.patch b/ports/jemalloc/fix-utilities.patch
new file mode 100644
index 000000000..32c39e0b3
--- /dev/null
+++ b/ports/jemalloc/fix-utilities.patch
@@ -0,0 +1,30 @@
+diff --git a/Utilities.cmake b/Utilities.cmake
+index 562e948..d2d3530 100644
+--- a/Utilities.cmake
++++ b/Utilities.cmake
+@@ -633,9 +633,11 @@ file(TO_NATIVE_PATH "${file_path}" ntv_file_path)
+ # This converts #undefs into #cmakedefines so configure_file can handle it
+ set(PS_CMD
+ "Get-Content \"${ntv_file_path}\" |
+-ForEach {
++ForEach {
+ if($_ -match '^#undef[ \t]*[^ \t]*')
+- { $_ -replace '^#undef[ \t]*([^ \t]*)','#cmakedefine $1 @$1@' } else {$_}}"
++ { $_ -replace '^#undef[ \t]*([^ \t]*)','#cmakedefine $1 @$1@' } else {$_}
++} |
++Set-Content \"${ntv_file_path}.cmake\""
+ )
+
+ if(EXISTS ${file_path})
+@@ -646,9 +648,8 @@ if(EXISTS ${file_path})
+ # Convert autoconf .in into a cmake .in
+ execute_process(COMMAND powershell -Command "${PS_CMD}"
+ RESULT_VARIABLE error_level
+- ERROR_VARIABLE error_output
+- OUTPUT_FILE ${file_path}.cmake)
+-
++ ERROR_VARIABLE error_output)
++
+ if(NOT ${error_level} EQUAL 0)
+ message(FATAL_ERROR "Powershell completed with ${error_level} : ${error_output}")
+ endif()
diff --git a/ports/jemalloc/portfile.cmake b/ports/jemalloc/portfile.cmake
new file mode 100644
index 000000000..3fe6fdbb7
--- /dev/null
+++ b/ports/jemalloc/portfile.cmake
@@ -0,0 +1,36 @@
+if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
+ message(STATUS "Warning: Static building not supported yet. Building dynamic.")
+ set(VCPKG_LIBRARY_LINKAGE dynamic)
+endif()
+
+include(vcpkg_common_functions)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO jemalloc/jemalloc-cmake
+ REF jemalloc-cmake.4.3.1
+ SHA512 e94b62ec3a53acc0ab5acb247d7646bc172108e80f592bb41c2dd50d181cbbeb33d623adf28415ffc0a0e2de3818af2dfe4c04af75ac891ef5042bc5bb186886
+ HEAD_REF master
+)
+vcpkg_apply_patches(
+ SOURCE_PATH ${SOURCE_PATH}
+ PATCHES
+ "${CMAKE_CURRENT_LIST_DIR}/fix-cmakelists.patch"
+ "${CMAKE_CURRENT_LIST_DIR}/fix-utilities.patch"
+)
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+ OPTIONS -DGIT_FOUND=OFF -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON
+)
+
+vcpkg_install_cmake()
+
+vcpkg_copy_pdbs()
+
+file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
+
+# Handle copyright
+file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/jemalloc)
+file(RENAME ${CURRENT_PACKAGES_DIR}/share/jemalloc/COPYING ${CURRENT_PACKAGES_DIR}/share/jemalloc/copyright)