Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recipe for aws-c-s3 #15187

Merged
merged 2 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions recipes/aws-c-s3/0001-Find-LibCrypto-on-Linux.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
From 02574dd9a92f38b3282e89f6e384bd8a1e17a52a Mon Sep 17 00:00:00 2001
From: "Uwe L. Korn" <[email protected]>
Date: Thu, 10 Jun 2021 22:04:22 +0200
Subject: [PATCH] Find LibCrypto on Linux

---
CMakeLists.txt | 2 +
cmake/modules/FindLibCrypto.cmake | 107 ++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+)
create mode 100644 cmake/modules/FindLibCrypto.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 318b299..9b4e7cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,6 +53,8 @@ if (WIN32)
set(PLATFORM_LIBS "")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(PLATFORM_LIBS "")
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
+ find_package(LibCrypto REQUIRED)
elseif (APPLE)
set(PLATFORM_LIBS "")
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
diff --git a/cmake/modules/FindLibCrypto.cmake b/cmake/modules/FindLibCrypto.cmake
new file mode 100644
index 0000000..1eb66fe
--- /dev/null
+++ b/cmake/modules/FindLibCrypto.cmake
@@ -0,0 +1,107 @@
+# - Try to find LibCrypto include dirs and libraries
+#
+# Usage of this module as follows:
+#
+# find_package(LibCrypto)
+#
+# Variables used by this module, they can change the default behaviour and need
+# to be set before calling find_package:
+#
+# Variables defined by this module:
+#
+# LibCrypto_FOUND System has libcrypto, include and library dirs found
+# LibCrypto_INCLUDE_DIR The crypto include directories.
+# LibCrypto_LIBRARY The crypto library, depending on the value of BUILD_SHARED_LIBS.
+# LibCrypto_SHARED_LIBRARY The path to libcrypto.so
+# LibCrypto_STATIC_LIBRARY The path to libcrypto.a
+
+find_package(crypto QUIET)
+
+if (crypto_FOUND)
+ get_target_property(crypto_INCLUDE_DIR crypto INTERFACE_INCLUDE_DIRECTORIES)
+ message(STATUS "S2N found target: crypto")
+ message(STATUS "crypto Include Dir: ${crypto_INCLUDE_DIR}")
+ set(LIBCRYPTO_FOUND true)
+ set(LibCrypto_FOUND true)
+else()
+ find_path(LibCrypto_INCLUDE_DIR
+ NAMES openssl/crypto.h
+ HINTS
+ ${CMAKE_PREFIX_PATH}/include
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+ find_library(LibCrypto_SHARED_LIBRARY
+ NAMES libcrypto.so libcrypto.dylib
+ HINTS
+ ${CMAKE_PREFIX_PATH}/build/crypto
+ ${CMAKE_PREFIX_PATH}/build
+ ${CMAKE_PREFIX_PATH}
+ ${CMAKE_PREFIX_PATH}/lib64
+ ${CMAKE_PREFIX_PATH}/lib
+ ${CMAKE_INSTALL_PREFIX}/build/crypto
+ ${CMAKE_INSTALL_PREFIX}/build
+ ${CMAKE_INSTALL_PREFIX}
+ ${CMAKE_INSTALL_PREFIX}/lib64
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+ find_library(LibCrypto_STATIC_LIBRARY
+ NAMES libcrypto.a
+ HINTS
+ ${CMAKE_PREFIX_PATH}/build/crypto
+ ${CMAKE_PREFIX_PATH}/build
+ ${CMAKE_PREFIX_PATH}
+ ${CMAKE_PREFIX_PATH}/lib64
+ ${CMAKE_PREFIX_PATH}/lib
+ ${CMAKE_INSTALL_PREFIX}/build/crypto
+ ${CMAKE_INSTALL_PREFIX}/build
+ ${CMAKE_INSTALL_PREFIX}
+ ${CMAKE_INSTALL_PREFIX}/lib64
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ if (BUILD_SHARED_LIBS)
+ set(LibCrypto_LIBRARY ${LibCrypto_SHARED_LIBRARY})
+ else()
+ set(LibCrypto_LIBRARY ${LibCrypto_STATIC_LIBRARY})
+ endif()
+
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LibCrypto DEFAULT_MSG
+ LibCrypto_LIBRARY
+ LibCrypto_INCLUDE_DIR
+ )
+
+ mark_as_advanced(
+ LibCrypto_ROOT_DIR
+ LibCrypto_INCLUDE_DIR
+ LibCrypto_LIBRARY
+ LibCrypto_SHARED_LIBRARY
+ LibCrypto_STATIC_LIBRARY
+ )
+
+ # some versions of cmake have a super esoteric bug around capitalization differences between
+ # find dependency and find package, just avoid that here by checking and
+ # setting both.
+ if(LIBCRYPTO_FOUND OR LibCrypto_FOUND)
+ set(LIBCRYPTO_FOUND true)
+ set(LibCrypto_FOUND true)
+
+ message(STATUS "LibCrypto Include Dir: ${LibCrypto_INCLUDE_DIR}")
+ message(STATUS "LibCrypto Shared Lib: ${LibCrypto_SHARED_LIBRARY}")
+ message(STATUS "LibCrypto Static Lib: ${LibCrypto_STATIC_LIBRARY}")
+ if (NOT TARGET LibCrypto::Crypto AND
+ (EXISTS "${LibCrypto_LIBRARY}")
+ )
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
+ find_package(Threads REQUIRED)
+ add_library(LibCrypto::Crypto UNKNOWN IMPORTED)
+ set_target_properties(LibCrypto::Crypto PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${LibCrypto_INCLUDE_DIR}")
+ set_target_properties(LibCrypto::Crypto PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${LibCrypto_LIBRARY}")
+ add_dependencies(LibCrypto::Crypto Threads::Threads)
+ endif()
+ endif()
+endif()
--
2.30.2

19 changes: 19 additions & 0 deletions recipes/aws-c-s3/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
mkdir "%SRC_DIR%"\build
pushd "%SRC_DIR%"\build

cmake -G "Ninja" ^
-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
-DCMAKE_INSTALL_LIBDIR=lib ^
-DCMAKE_BUILD_TYPE=Release ^
-DBUILD_SHARED_LIBS=ON ^
-DBUILD_TESTING=OFF ^
..
if errorlevel 1 exit 1

ninja install
if errorlevel 1 exit 1

@rem Tests don't work without S3 credentials
@rem ninja test
@rem if errorlevel 1 exit 1
20 changes: 20 additions & 0 deletions recipes/aws-c-s3/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -ex

mkdir build
pushd build
cmake ${CMAKE_ARGS} -GNinja \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTING=OFF \
..
ninja install
# if [[ "${CONDA_BUILD_CROSS_COMPILATION:-0}" != "1" ]]; then
# Tests don't work without S3 credentials
# ninja test
# fi
popd
47 changes: 47 additions & 0 deletions recipes/aws-c-s3/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% set name = "aws-c-s3" %}
{% set version = "0.1.19" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://github.com/awslabs/{{ name }}/archive/v{{ version }}.tar.gz
sha256: 30e17e31eed18e8d621cd3d3978b2e6eeeee5557bfc3a9d701d0d3e1c4a8a74d
patches:
- 0001-Find-LibCrypto-on-Linux.patch

build:
number: 0
run_exports:
- {{ pin_subpackage("aws-c-s3", max_pin="x.x.x") }}

requirements:
build:
- cmake
- {{ compiler('c') }}
- ninja
host:
- aws-c-auth
- aws-c-common
- aws-c-http
- aws-c-io
- openssl # [linux]

test:
commands:
- test -f $PREFIX/lib/libaws-c-s3${SHLIB_EXT} # [unix]
- test -f $PREFIX/include/aws/s3/s3.h # [unix]
- if not exist %LIBRARY_INC%\\aws\\s3\\s3.h exit 1 # [win]
- if not exist %PREFIX%\\Library\\bin\\aws-c-s3.dll exit 1 # [win]

about:
home: https://github.com/awslabs/aws-c-s3
license: Apache-2.0
license_family: Apache
license_file: LICENSE
summary: C99 library implementation for communicating with the S3 service.

extra:
recipe-maintainers:
- xhochy