aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/argon2
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/argon2')
-rw-r--r--vcpkg/ports/argon2/CMakeLists.txt75
-rw-r--r--vcpkg/ports/argon2/portfile.cmake48
-rw-r--r--vcpkg/ports/argon2/thread-header.patch12
-rw-r--r--vcpkg/ports/argon2/unofficial-argon2-config.cmake4
-rw-r--r--vcpkg/ports/argon2/unofficial-libargon2-config.cmake4
-rw-r--r--vcpkg/ports/argon2/usage4
-rw-r--r--vcpkg/ports/argon2/vcpkg.json27
-rw-r--r--vcpkg/ports/argon2/visibility-for-tool.patch13
-rw-r--r--vcpkg/ports/argon2/visibility.patch16
9 files changed, 203 insertions, 0 deletions
diff --git a/vcpkg/ports/argon2/CMakeLists.txt b/vcpkg/ports/argon2/CMakeLists.txt
new file mode 100644
index 0000000..c42eec5
--- /dev/null
+++ b/vcpkg/ports/argon2/CMakeLists.txt
@@ -0,0 +1,75 @@
+cmake_minimum_required(VERSION 3.25)
+
+project(argon2 LANGUAGES C)
+
+option(WITH_OPTIMIZATIONS "Enable SSE2/AVX2/AVX512 optimizations")
+option(BUILD_TOOL "Build the tool" OFF)
+
+if(BUILD_SHARED_LIBS)
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+ endif()
+endif()
+
+find_package(Threads REQUIRED)
+
+set(ARGON2_HEADERS
+ include/argon2.h
+)
+
+set (ARGON2_SRC
+ src/argon2.c
+ src/core.c
+ src/blake2/blake2b.c
+ src/thread.c
+ src/encoding.c
+)
+if (WITH_OPTIMIZATIONS)
+ list(APPEND ARGON2_SRC src/opt.c)
+else()
+ list(APPEND ARGON2_SRC src/ref.c)
+endif()
+
+add_library(libargon2 ${ARGON2_SRC})
+set_target_properties(libargon2 PROPERTIES OUTPUT_NAME argon2)
+target_include_directories(libargon2 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> PRIVATE src)
+target_link_libraries(libargon2 PRIVATE Threads::Threads)
+if(BUILD_SHARED_LIBS)
+ if(WIN32)
+ target_compile_definitions(libargon2 PRIVATE "BUILDING_ARGON2_DLL" INTERFACE "USING_ARGON2_DLL")
+ else()
+ target_compile_definitions(libargon2 PRIVATE "A2_VISCTL")
+ endif()
+endif()
+
+install(TARGETS libargon2
+ EXPORT unofficial-argon2-targets
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+
+if(BUILD_TOOL)
+ add_executable(argon2 src/run.c)
+ target_link_libraries(argon2 PRIVATE libargon2)
+ set_target_properties(argon2 PROPERTIES PDB_NAME "argon2${CMAKE_EXECUTABLE_SUFFIX}.pdb")
+
+ install(TARGETS argon2 RUNTIME DESTINATION bin)
+endif()
+
+install(FILES ${ARGON2_HEADERS} DESTINATION include)
+
+install(EXPORT unofficial-argon2-targets
+ NAMESPACE unofficial::argon2::
+ DESTINATION "share/unofficial-argon2"
+)
+
+function(make_pc_file)
+ set(PREFIX "${CMAKE_INSTALL_PREFIX}")
+ set(INCLUDE "include")
+ set(HOST_MULTIARCH "lib")
+ set(EXTRA_LIBS "")
+ configure_file ("${CMAKE_SOURCE_DIR}/libargon2.pc.in" "${PROJECT_BINARY_DIR}/libargon2.pc" @ONLY)
+endfunction()
+make_pc_file()
+install (FILES "${CMAKE_CURRENT_BINARY_DIR}/libargon2.pc" DESTINATION "lib/pkgconfig")
diff --git a/vcpkg/ports/argon2/portfile.cmake b/vcpkg/ports/argon2/portfile.cmake
new file mode 100644
index 0000000..2cc0c11
--- /dev/null
+++ b/vcpkg/ports/argon2/portfile.cmake
@@ -0,0 +1,48 @@
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO P-H-C/phc-winner-argon2
+ REF 20190702
+ SHA512 0a4cb89e8e63399f7df069e2862ccd05308b7652bf4ab74372842f66bcc60776399e0eaf979a7b7e31436b5e6913fe5b0a6949549d8c82ebd06e0629b106e85f
+ HEAD_REF master
+ PATCHES
+ visibility.patch
+ visibility-for-tool.patch
+ thread-header.patch
+)
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ FEATURES
+ hwopt WITH_OPTIMIZATIONS
+ tool BUILD_TOOL
+)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ ${FEATURE_OPTIONS}
+ -DUPSTREAM_VER=${VERSION}
+ OPTIONS_DEBUG
+ -DBUILD_TOOL=OFF
+)
+
+vcpkg_cmake_install()
+vcpkg_copy_pdbs()
+vcpkg_fixup_pkgconfig()
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-argon2-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-argon2")
+vcpkg_cmake_config_fixup(CONFIG_PATH share/unofficial-argon2 PACKAGE_NAME unofficial-argon2)
+# Migration path
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-libargon2-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-libargon2")
+
+if(BUILD_TOOL)
+ vcpkg_copy_tools(TOOL_NAMES argon2 AUTO_CLEAN)
+endif()
+
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
+ vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/argon2.h" "defined(USING_ARGON2_DLL)" "1")
+endif()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
+
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
diff --git a/vcpkg/ports/argon2/thread-header.patch b/vcpkg/ports/argon2/thread-header.patch
new file mode 100644
index 0000000..4edcf7a
--- /dev/null
+++ b/vcpkg/ports/argon2/thread-header.patch
@@ -0,0 +1,12 @@
+diff --git a/src/thread.h b/src/thread.h
+index d4ca10c..43bd542 100644
+--- a/src/thread.h
++++ b/src/thread.h
+@@ -19,6 +19,7 @@
+ #define ARGON2_THREAD_H
+
+ #if !defined(ARGON2_NO_THREADS)
++#include <stdint.h>
+
+ /*
+ Here we implement an abstraction layer for the simpĺe requirements
diff --git a/vcpkg/ports/argon2/unofficial-argon2-config.cmake b/vcpkg/ports/argon2/unofficial-argon2-config.cmake
new file mode 100644
index 0000000..9034d40
--- /dev/null
+++ b/vcpkg/ports/argon2/unofficial-argon2-config.cmake
@@ -0,0 +1,4 @@
+include(CMakeFindDependencyMacro)
+find_dependency(Threads)
+
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-argon2-targets.cmake")
diff --git a/vcpkg/ports/argon2/unofficial-libargon2-config.cmake b/vcpkg/ports/argon2/unofficial-libargon2-config.cmake
new file mode 100644
index 0000000..dfe78b5
--- /dev/null
+++ b/vcpkg/ports/argon2/unofficial-libargon2-config.cmake
@@ -0,0 +1,4 @@
+file(READ "${CMAKE_CURRENT_LIST_DIR}/../argon2/usage" usage)
+message(WARNING "find_package(unofficial-libargon2) is deprecated.\n${usage}")
+include(CMakeFindDependencyMacro)
+find_dependency(unofficial-argon2 CONFIG)
diff --git a/vcpkg/ports/argon2/usage b/vcpkg/ports/argon2/usage
new file mode 100644
index 0000000..f874d57
--- /dev/null
+++ b/vcpkg/ports/argon2/usage
@@ -0,0 +1,4 @@
+argon2 provides CMake targets:
+
+ find_package(unofficial-argon2 CONFIG REQUIRED)
+ target_link_libraries(main PRIVATE unofficial::argon2::libargon2)
diff --git a/vcpkg/ports/argon2/vcpkg.json b/vcpkg/ports/argon2/vcpkg.json
new file mode 100644
index 0000000..74bc563
--- /dev/null
+++ b/vcpkg/ports/argon2/vcpkg.json
@@ -0,0 +1,27 @@
+{
+ "name": "argon2",
+ "version": "20190702",
+ "port-version": 1,
+ "description": "Password-hashing library.",
+ "homepage": "https://github.com/P-H-C/phc-winner-argon2",
+ "license": "Apache-2.0 OR CC0-1.0",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ],
+ "features": {
+ "hwopt": {
+ "description": "Enable SSE2/AVX2/AVX512 optimizations",
+ "supports": "x86 | x64"
+ },
+ "tool": {
+ "description": "Install the argon2 tool"
+ }
+ }
+}
diff --git a/vcpkg/ports/argon2/visibility-for-tool.patch b/vcpkg/ports/argon2/visibility-for-tool.patch
new file mode 100644
index 0000000..8635305
--- /dev/null
+++ b/vcpkg/ports/argon2/visibility-for-tool.patch
@@ -0,0 +1,13 @@
+diff --git a/src/core.h b/src/core.h
+index 78000ba..91c7bcf 100644
+--- a/src/core.h
++++ b/src/core.h
+@@ -135,7 +135,7 @@ void secure_wipe_memory(void *v, size_t n);
+ * @param mem Pointer to the memory
+ * @param s Memory size in bytes
+ */
+-void clear_internal_memory(void *v, size_t n);
++ARGON2_PUBLIC void clear_internal_memory(void *v, size_t n);
+
+ /*
+ * Computes absolute position of reference block in the lane following a skewed
diff --git a/vcpkg/ports/argon2/visibility.patch b/vcpkg/ports/argon2/visibility.patch
new file mode 100644
index 0000000..d6e9951
--- /dev/null
+++ b/vcpkg/ports/argon2/visibility.patch
@@ -0,0 +1,16 @@
+diff --git a/include/argon2.h b/include/argon2.h
+index fc8682c..1401051 100644
+--- a/include/argon2.h
++++ b/include/argon2.h
+@@ -30,7 +30,10 @@ extern "C" {
+ #ifdef A2_VISCTL
+ #define ARGON2_PUBLIC __attribute__((visibility("default")))
+ #define ARGON2_LOCAL __attribute__ ((visibility ("hidden")))
+-#elif _MSC_VER
++#elif defined(_WIN32) && defined(USING_ARGON2_DLL)
++#define ARGON2_PUBLIC __declspec(dllimport)
++#define ARGON2_LOCAL
++#elif defined(_WIN32) && defined(BUILDING_ARGON2_DLL)
+ #define ARGON2_PUBLIC __declspec(dllexport)
+ #define ARGON2_LOCAL
+ #else