aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiy Shapkin <arkady.shapkin@gmail.com>2017-05-10 03:07:04 +0300
committerArkadiy Shapkin <arkady.shapkin@gmail.com>2017-05-11 21:26:52 +0300
commit727be4b538a7433f4c321cdd6a38a6f72b465f51 (patch)
tree54780a99067b52a46374e72185e21515ef6ef3a6
parent05e682a19d40036c9a34c2c7a94e6325fb7e9f1c (diff)
downloadvcpkg-727be4b538a7433f4c321cdd6a38a6f72b465f51.tar.gz
vcpkg-727be4b538a7433f4c321cdd6a38a6f72b465f51.zip
[jemalloc] Initial commit for jemalloc library
-rw-r--r--ports/jemalloc/CONTROL4
-rw-r--r--ports/jemalloc/fix-cmakelists.patch36
-rw-r--r--ports/jemalloc/fix-utilities.patch30
-rw-r--r--ports/jemalloc/portfile.cmake58
4 files changed, 128 insertions, 0 deletions
diff --git a/ports/jemalloc/CONTROL b/ports/jemalloc/CONTROL
new file mode 100644
index 000000000..e3c808657
--- /dev/null
+++ b/ports/jemalloc/CONTROL
@@ -0,0 +1,4 @@
+Source: jemalloc
+Version: 4.3.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..0094a15f5
--- /dev/null
+++ b/ports/jemalloc/fix-cmakelists.patch
@@ -0,0 +1,36 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 06e83ef..17526b0 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)
+@@ -825,6 +826,17 @@ if(C_UTIL_INTEGRATION_DEFS)
+ "${C_UTIL_INTEGRATION_DEFS}")
+ endif()
+
++install(FILES include/jemalloc/jemalloc${install_suffix}.h
++ DESTINATION include/jemalloc)
++
++install(TARGETS ${LIBJEMALLOCSO}
++ EXPORT JemallocTargets
++ RUNTIME DESTINATION bin
++ LIBRARY DESTINATION lib
++ ARCHIVE DESTINATION lib)
++install(EXPORT JemallocTargets NAMESPACE jemalloc:: DESTINATION share/jemalloc)
++
++if (build-tests)
+ ##################################################################
+ # Common source for Unit, Integration and stress test libraries
+ set(C_TESTLIB_SRCS
+@@ -1028,4 +1040,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..22aa76f08
--- /dev/null
+++ b/ports/jemalloc/portfile.cmake
@@ -0,0 +1,58 @@
+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)
+
+set(GIT_URL "https://github.com/jemalloc/jemalloc-cmake.git")
+set(GIT_REF "jemalloc-cmake.4.3.1")
+
+if(NOT EXISTS "${DOWNLOADS}/jemalloc-cmake.git")
+ message(STATUS "Cloning")
+ vcpkg_execute_required_process(
+ COMMAND ${GIT} clone --bare ${GIT_URL} ${DOWNLOADS}/jemalloc-cmake.git
+ WORKING_DIRECTORY ${DOWNLOADS}
+ LOGNAME clone
+ )
+endif()
+
+set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src)
+
+if(NOT EXISTS "${SOURCE_PATH}/.git")
+ message(STATUS "Adding worktree")
+ file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR})
+ vcpkg_execute_required_process(
+ COMMAND ${GIT} worktree add -f --detach ${SOURCE_PATH} ${GIT_REF}
+ WORKING_DIRECTORY ${DOWNLOADS}/jemalloc-cmake.git
+ LOGNAME worktree
+ )
+ message(STATUS "Patching")
+ vcpkg_apply_patches(
+ SOURCE_PATH ${SOURCE_PATH}
+ PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-cmakelists.patch"
+ PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-utilities.patch"
+ )
+endif()
+
+# jemalloc uses git to get it version
+find_program(GIT NAMES git git.cmd)
+get_filename_component(GIT_EXE_PATH ${GIT} DIRECTORY)
+set(ENV{PATH} "${GIT_EXE_PATH};$ENV{PATH}")
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+)
+
+vcpkg_install_cmake()
+
+vcpkg_copy_pdbs()
+
+vcpkg_fixup_cmake_targets()
+
+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)