From ce5c85f4fe22cbe2e837366bdbe29a76df56c0c3 Mon Sep 17 00:00:00 2001 From: Mikhail Paulyshka Date: Sun, 12 Mar 2017 05:12:36 +0300 Subject: [PATCH] [botan] add version 2.0.1. Resolves #355 --- ports/botan/0001-fix-crt-linking.patch | 56 ++++++++++++++ ports/botan/CONTROL | 3 + ports/botan/portfile.cmake | 101 +++++++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 ports/botan/0001-fix-crt-linking.patch create mode 100644 ports/botan/CONTROL create mode 100644 ports/botan/portfile.cmake diff --git a/ports/botan/0001-fix-crt-linking.patch b/ports/botan/0001-fix-crt-linking.patch new file mode 100644 index 0000000000..d1fdc2d709 --- /dev/null +++ b/ports/botan/0001-fix-crt-linking.patch @@ -0,0 +1,56 @@ +From b41cc93b63c99525e71291424466cdd45d92f770 Mon Sep 17 00:00:00 2001 +From: Mikhail Paulyshka +Date: Sun, 12 Mar 2017 04:34:10 +0300 +Subject: [PATCH] fix CRT linking for static library for MSVC + +--- + configure.py | 15 +++++++++++++++ + src/build-data/cc/msvc.txt | 8 ++++++-- + 2 files changed, 21 insertions(+), 2 deletions(-) + +diff --git a/configure.py b/configure.py +index faf5120c5..9c545cf5f 100755 +--- a/configure.py ++++ b/configure.py +@@ -976,6 +976,21 @@ class CompilerInfo(object): + if flag != None and flag != '' and flag not in abi_link: + abi_link.append(flag) + ++ if options.build_shared_lib: ++ if options.with_debug_info: ++ if 'dynamic-debug' in self.mach_abi_linking: ++ abi_link.append(self.mach_abi_linking['dynamic-debug']) ++ else: ++ if 'dynamic' in self.mach_abi_linking: ++ abi_link.append(self.mach_abi_linking['dynamic']) ++ else: ++ if options.with_debug_info: ++ if 'static-debug' in self.mach_abi_linking: ++ abi_link.append(self.mach_abi_linking['static-debug']) ++ else: ++ if 'static' in self.mach_abi_linking: ++ abi_link.append(self.mach_abi_linking['static']) ++ + if options.with_coverage_info: + if self.coverage_flags == '': + raise ConfigureError('No coverage handling for %s' % (self.basename)) +diff --git a/src/build-data/cc/msvc.txt b/src/build-data/cc/msvc.txt +index c1b820b91..e6182b0fa 100644 +--- a/src/build-data/cc/msvc.txt ++++ b/src/build-data/cc/msvc.txt +@@ -53,6 +53,10 @@ default-debug -> "$(LINKER) /DEBUG" + + + +-all -> "/MD /bigobj" +-all-debug -> "/MDd /bigobj" ++all -> "/bigobj" ++all-debug -> "/bigobj" ++static -> "/MT" ++static-debug -> "/MTd" ++dynamic -> "/MD" ++dynamic-debug -> "/MDd" + +-- +2.11.0.windows.1 + diff --git a/ports/botan/CONTROL b/ports/botan/CONTROL new file mode 100644 index 0000000000..1ff0101186 --- /dev/null +++ b/ports/botan/CONTROL @@ -0,0 +1,3 @@ +Source: botan +Version: 2.0.1 +Description: A cryptography library written in C++11 \ No newline at end of file diff --git a/ports/botan/portfile.cmake b/ports/botan/portfile.cmake new file mode 100644 index 0000000000..72a34985bf --- /dev/null +++ b/ports/botan/portfile.cmake @@ -0,0 +1,101 @@ +include(vcpkg_common_functions) + +set(BOTAN_VERSION 2.0.1) +set(BOTAN_HASH c5062ce92a6e6e333b4e6af095ed54d0c4ffacefc6ac87ec651dd1e0937793c9956b7c9c0d3acf49f059505526584168364e01c55ab72c953ad255e8396aed35) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/Botan-${BOTAN_VERSION}) + +vcpkg_download_distfile(ARCHIVE + URLS "https://botan.randombit.net/releases/Botan-${BOTAN_VERSION}.tgz" + FILENAME "Botan-${BOTAN_VERSION}.tgz" + SHA512 ${BOTAN_HASH} +) +vcpkg_extract_source_archive(${ARCHIVE}) +vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES "${CMAKE_CURRENT_LIST_DIR}/0001-fix-crt-linking.patch") + +vcpkg_find_acquire_program(JOM) +vcpkg_find_acquire_program(PYTHON3) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + set(BOTAN_FLAG_SHARED --disable-shared) +endif() + +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(BOTAN_FLAG_CPU x86) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(BOTAN_FLAG_CPU x86_64) +else() + message(FATAL_ERROR "Unsupported architecture") +endif() + +function(BOTAN_BUILD BOTAN_BUILD_TYPE) + + if(BOTAN_BUILD_TYPE STREQUAL "dbg") + set(BOTAN_FLAG_PREFIX ${CURRENT_PACKAGES_DIR}/debug) + set(BOTAN_FLAG_DEBUGMODE --debug-mode) + set(BOTAN_DEBUG_PREFIX d) + else() + set(BOTAN_FLAG_PREFIX ${CURRENT_PACKAGES_DIR}) + endif() + + message(STATUS "Configure ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}") + + vcpkg_execute_required_process( + COMMAND "${PYTHON3}" "configure.py" + --cc=msvc + --cpu=${BOTAN_FLAG_CPU} + ${BOTAN_FLAG_SHARED} + ${BOTAN_FLAG_DEBUGMODE} + --makefile-style=nmake + --with-pkcs11 + --prefix=${BOTAN_FLAG_PREFIX} + --link-method=copy + WORKING_DIRECTORY "${SOURCE_PATH}" + LOGNAME configure-${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}) + message(STATUS "Configure ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE} done") + + message(STATUS "Build ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}") + vcpkg_execute_required_process( + COMMAND ${JOM} + WORKING_DIRECTORY "${SOURCE_PATH}" + LOGNAME jom-build-${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}) + message(STATUS "Build ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE} done") + + message(STATUS "Package ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}") + vcpkg_execute_required_process( + COMMAND "${PYTHON3}" "src/scripts/install.py" + --destdir=${BOTAN_FLAG_PREFIX} + --build-dir=build + --docdir=share + WORKING_DIRECTORY "${SOURCE_PATH}" + LOGNAME install-${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE}) + + file(MAKE_DIRECTORY ${BOTAN_FLAG_PREFIX}/tools/) + file(RENAME ${BOTAN_FLAG_PREFIX}/bin/botan-cli.exe ${BOTAN_FLAG_PREFIX}/tools/botan-cli.exe) + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(RENAME ${BOTAN_FLAG_PREFIX}/lib/botan${BOTAN_DEBUG_PREFIX}.dll ${BOTAN_FLAG_PREFIX}/bin/botan${BOTAN_DEBUG_PREFIX}.dll) + if(BOTAN_BUILD_TYPE STREQUAL dbg) + file(COPY ${SOURCE_PATH}/botan${BOTAN_DEBUG_PREFIX}.pdb DESTINATION ${BOTAN_FLAG_PREFIX}/bin/) + endif() + endif() + + message(STATUS "Package ${TARGET_TRIPLET}-${BOTAN_BUILD_TYPE} done") +endfunction() + +BOTAN_BUILD(rel) +BOTAN_BUILD(dbg) + +file(REMOVE_RECURSE + ${CURRENT_PACKAGES_DIR}/debug/include + ${CURRENT_PACKAGES_DIR}/debug/share + ${CURRENT_PACKAGES_DIR}/share/botan-${BOTAN_VERSION}/manual) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + file(REMOVE_RECURSE + ${CURRENT_PACKAGES_DIR}/bin + ${CURRENT_PACKAGES_DIR}/debug/bin) +endif() + +file(RENAME ${CURRENT_PACKAGES_DIR}/share/botan-${BOTAN_VERSION}/ ${CURRENT_PACKAGES_DIR}/share/botan/) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/botan/license.txt ${CURRENT_PACKAGES_DIR}/share/botan/copyright)