devel/rubygem-aws-crt: Update to 0.2.1

- Unbundle aws-crt-ffi

Changes:	https://github.com/awslabs/aws-crt-ruby/releases
This commit is contained in:
Po-Chuan Hsieh 2024-06-18 12:01:09 +08:00
parent 69268d566f
commit e3b1d664b5
No known key found for this signature in database
GPG key ID: 9A4BD10F002DD04B
7 changed files with 116 additions and 39 deletions

View file

@ -1,5 +1,5 @@
PORTNAME= aws-crt
PORTVERSION= 0.2.0
PORTVERSION= 0.2.1
CATEGORIES= devel rubygems
MASTER_SITES= RG
@ -10,14 +10,14 @@ WWW= https://github.com/awslabs/aws-crt-ruby
LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE.txt
LIB_DEPENDS= libaws-crt-ffi.so:devel/aws-crt-ffi
RUN_DEPENDS= rubygem-ffi>=0:devel/rubygem-ffi
USES= cmake:indirect gem python:env shebangfix
USES= gem
SHEBANG_GLOB= *.py *.sh
post-install:
${RM} -r ${STAGEDIR}${PREFIX}/${GEM_LIB_DIR}/tmp/
${REINPLACE_CMD} -e '/${GEM_LIB_DIR}\/tmp\//d' ${TMPPLIST}
post-patch:
@${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|' ${WRKSRC}/ext/compile.rb
# Clean up bundled libraries
@${RM} -r ${WRKSRC}/aws-crt-ffi/
.include <bsd.port.mk>

View file

@ -1,3 +1,3 @@
TIMESTAMP = 1701363754
SHA256 (rubygem/aws-crt-0.2.0.gem) = 6b49f9cb665aa114526ab9ba7378f05cd60dad1f7027bc12b9082a84aab57586
SIZE (rubygem/aws-crt-0.2.0.gem) = 85287424
TIMESTAMP = 1718580158
SHA256 (rubygem/aws-crt-0.2.1.gem) = d85302f92506a840c758b900f0b295f77b358bb8368819bd30c22da7224b6499
SIZE (rubygem/aws-crt-0.2.1.gem) = 87073280

View file

@ -1,13 +0,0 @@
--- aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.c.orig 2022-07-30 03:57:28 UTC
+++ aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.c
@@ -25,6 +25,10 @@
#define _GNU_SOURCE
#endif
+#if !defined(__BSD_VISIBLE)
+#define __BSD_VISIBLE 1
+#endif
+
#include <sys/mman.h>
/* Not always defined for Darwin */

View file

@ -0,0 +1,83 @@
--- ext/compile.rb.orig 2024-06-15 17:30:56 UTC
+++ ext/compile.rb
@@ -6,31 +6,6 @@ require_relative '../lib/aws-crt/platforms'
require 'shellwords'
require_relative '../lib/aws-crt/platforms'
-CMAKE_PATH = find_executable('cmake3') || find_executable('cmake')
-abort 'Missing cmake' unless CMAKE_PATH
-CMAKE = File.basename(CMAKE_PATH)
-
-def cmake_version
- version_str = `#{CMAKE} --version`
- match = /(\d+)\.(\d+)\.(\d+)/.match(version_str)
- [match[1].to_i, match[2].to_i, match[3].to_i]
-end
-
-CMAKE_VERSION = cmake_version
-
-# whether installed cmake supports --parallel build flag
-def cmake_has_parallel_flag?
- (CMAKE_VERSION <=> [3, 12]) >= 0
-end
-
-def run_cmd(args)
- # use shellwords.join() for printing, don't pass that string to system().
- # system() does better cross-platform when the args array is passed in.
- cmd_str = Shellwords.join(args)
- puts cmd_str
- system(*args) || raise("Error running: #{cmd_str}")
-end
-
def find_file(name, search_dirs, base_dir)
search_dirs.each do |search_dir|
dir = File.expand_path(search_dir, base_dir)
@@ -43,47 +18,10 @@ def compile_bin(cpu = host_cpu)
# Compile bin to expected location
def compile_bin(cpu = host_cpu)
platform = target_platform(cpu)
- native_dir = File.expand_path('../aws-crt-ffi', File.dirname(__FILE__))
tmp_dir = File.expand_path("../tmp/#{platform.cpu}", File.dirname(__FILE__))
tmp_build_dir = File.expand_path('build', tmp_dir)
- # We need cmake to "install" aws-crt-ffi so that the binaries end up in a
- # predictable location. But cmake still adds subdirectories we don't want,
- # so we'll "install" under tmp, and manually copy to bin/ after that.
- tmp_install_dir = File.expand_path('install', tmp_dir)
-
- build_type = 'RelWithDebInfo'
-
- config_cmd = [
- CMAKE,
- "-H#{native_dir}",
- "-B#{tmp_build_dir}",
- "-DCMAKE_INSTALL_PREFIX=#{tmp_install_dir}",
- "-DCMAKE_BUILD_TYPE=#{build_type}",
- '-DBUILD_TESTING=OFF',
- ]
-
- # macOS can cross-compile for arm64 or x86_64.
- # This lets us prepare both types of gems from either type of machine.
- if platform.os == 'darwin'
- config_cmd.append("-DCMAKE_OSX_ARCHITECTURES=#{platform.cpu}")
- end
-
- build_cmd = [
- CMAKE,
- '--build', tmp_build_dir,
- '--target', 'install',
- '--config', build_type,
- ]
-
- # Build using all processors
- if cmake_has_parallel_flag?
- build_cmd.append('--parallel')
- build_cmd.append(Etc.nprocessors.to_s)
- end
-
- run_cmd(config_cmd)
- run_cmd(build_cmd)
+ tmp_install_dir = '%%LOCALBASE%%'
# Move file to bin/, instead of where cmake installed it under tmp/
bin_dir = crt_bin_dir(platform)

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
--- lib/aws-crt/platforms.rb.orig 2024-06-15 18:32:30 UTC
+++ lib/aws-crt/platforms.rb
@@ -3,6 +3,7 @@ OS_BINARIES = {
# Maps OS name to crt binary name.
OS_BINARIES = {
'darwin' => 'libaws-crt-ffi.dylib',
+ 'freebsd' => 'libaws-crt-ffi.so',
'linux' => 'libaws-crt-ffi.so',
'mingw32' => 'aws-crt-ffi.dll'
}.freeze

View file

@ -1,16 +0,0 @@
Reference: https://cgit.freebsd.org/ports/commit/?id=f08b67611f0b19c0ee8d9053ee4d22e09b03f2b1
--- aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/cpucap/cpu_ppc64le.c.orig 2023-10-20 20:00:18 UTC
+++ aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/cpucap/cpu_ppc64le.c
@@ -27,7 +27,11 @@
extern uint8_t OPENSSL_cpucap_initialized;
void OPENSSL_cpuid_setup(void) {
+#if defined(__linux__)
OPENSSL_ppc64le_hwcap2 = getauxval(AT_HWCAP2);
+#elif defined(__FreeBSD__)
+ elf_aux_info(AT_HWCAP2, &OPENSSL_ppc64le_hwcap2, sizeof(OPENSSL_ppc64le_hwcap2));
+#endif
OPENSSL_cpucap_initialized = 1;
}