xcrypt 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +4 -100
- data/ext/libxcrypt/build-aux/m4/libtool.m4 +8488 -0
- data/ext/libxcrypt/build-aux/m4/ltoptions.m4 +467 -0
- data/ext/libxcrypt/build-aux/m4/ltsugar.m4 +124 -0
- data/ext/libxcrypt/build-aux/m4/ltversion.m4 +24 -0
- data/ext/libxcrypt/build-aux/m4/lt~obsolete.m4 +99 -0
- data/lib/xcrypt/ffi.rb +12 -8
- data/lib/xcrypt/version.rb +1 -1
- data/lib/xcrypt/yescrypt.rb +219 -0
- data/lib/xcrypt.rb +69 -12
- metadata +16 -11
- data/ext/xcrypt/xcrypt.c +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 402efb8aa7a769848889c0f2fe39021d05fa1b8f9e2d8afcf14cddcb7943943e
|
|
4
|
+
data.tar.gz: d0da71131143282090b06512548c1b02d163d2d1c06115e41c0115e07c1c17d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c42d280869fc94f7d601bdc94e38bf217f10aa63a2238c76171135c9cba4564b09d9e09ab318384ef866f833374ce79d5ca638ed2f6df8616577a346f99a5de
|
|
7
|
+
data.tar.gz: 712c3353ae07cc080e8e7ae34f528b44d5011959974f60e59ab147ced9bc2cad77921f420a61a21e02b826de8fd144df434881fa6dd0a6aee76c276b28b2c963
|
data/Rakefile
CHANGED
|
@@ -1,106 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "rake/testtask"
|
|
4
3
|
require "rake/clean"
|
|
5
|
-
require "ffi
|
|
6
|
-
require "ffi-compiler/platform"
|
|
7
|
-
require "fileutils"
|
|
8
|
-
require "etc"
|
|
4
|
+
require "ffi"
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
# Paths
|
|
12
|
-
# ---------------------------------------------------------------------------
|
|
13
|
-
|
|
14
|
-
LIBXCRYPT_SRC_DIR = File.join(__dir__, "ext", "libxcrypt").freeze
|
|
15
|
-
LIBXCRYPT_BUILD_DIR = File.join(__dir__, "tmp", "libxcrypt").freeze
|
|
16
|
-
LIBXCRYPT_STATIC = File.join(LIBXCRYPT_BUILD_DIR, ".libs", "libcrypt.a").freeze
|
|
17
|
-
|
|
18
|
-
# Arch/OS label used by ffi-compiler for its output subdirectory.
|
|
19
|
-
XCRYPT_ARCH_OS = "#{FFI::Platform::ARCH}-#{FFI::Platform::OS}".freeze
|
|
20
|
-
|
|
21
|
-
# Path to the compiled xcrypt bundle.
|
|
22
|
-
XCRYPT_LIB = File.join(
|
|
23
|
-
"lib", "xcrypt", XCRYPT_ARCH_OS,
|
|
24
|
-
FFI::Compiler::Platform.system.map_library_name("xcrypt")
|
|
25
|
-
).freeze
|
|
26
|
-
|
|
27
|
-
# Path to the compiled object file — needs crypt.h which is generated by
|
|
28
|
-
# the libxcrypt configure step, so it must depend on libxcrypt:build too.
|
|
29
|
-
XCRYPT_OBJ = File.join("lib", "xcrypt", XCRYPT_ARCH_OS, "xcrypt.o").freeze
|
|
30
|
-
|
|
31
|
-
CLEAN.include("tmp/")
|
|
32
|
-
CLOBBER.include(File.dirname(XCRYPT_LIB))
|
|
33
|
-
|
|
34
|
-
# ---------------------------------------------------------------------------
|
|
35
|
-
# libxcrypt — build static library from the submodule
|
|
36
|
-
# ---------------------------------------------------------------------------
|
|
37
|
-
|
|
38
|
-
namespace :libxcrypt do
|
|
39
|
-
desc "Build libxcrypt as a static, position-independent library"
|
|
40
|
-
task :build do
|
|
41
|
-
# The submodule has no pre-generated configure script; generate it first.
|
|
42
|
-
unless File.exist?(File.join(LIBXCRYPT_SRC_DIR, "configure"))
|
|
43
|
-
sh "autoreconf -fiv #{LIBXCRYPT_SRC_DIR}"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
unless File.exist?(LIBXCRYPT_STATIC)
|
|
47
|
-
FileUtils.mkdir_p(LIBXCRYPT_BUILD_DIR)
|
|
48
|
-
sh <<~SH
|
|
49
|
-
cd #{LIBXCRYPT_BUILD_DIR} && \
|
|
50
|
-
#{LIBXCRYPT_SRC_DIR}/configure \
|
|
51
|
-
--enable-static \
|
|
52
|
-
--disable-shared \
|
|
53
|
-
CFLAGS='-fPIC -O2'
|
|
54
|
-
SH
|
|
55
|
-
sh "make -C #{LIBXCRYPT_BUILD_DIR} -j#{Etc.nprocessors}"
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# ---------------------------------------------------------------------------
|
|
61
|
-
# xcrypt extension — compile ext/xcrypt/xcrypt.c and link against libcrypt.a
|
|
62
|
-
# ---------------------------------------------------------------------------
|
|
63
|
-
#
|
|
64
|
-
# ffi-compiler outputs:
|
|
65
|
-
# lib/xcrypt/<arch>-<os>/libxcrypt.bundle (macOS)
|
|
66
|
-
# lib/xcrypt/<arch>-<os>/libxcrypt.so (Linux)
|
|
67
|
-
#
|
|
68
|
-
# The name 'lib/xcrypt/xcrypt' sets ext_dir = 'lib/xcrypt' so the output
|
|
69
|
-
# lands in lib/xcrypt/<arch>-<os>/ where FFI::Compiler::Loader can find it.
|
|
70
|
-
|
|
71
|
-
FFI::Compiler::CompileTask.new("lib/xcrypt/xcrypt") do |t|
|
|
72
|
-
t.source_dirs = ["ext/xcrypt"]
|
|
73
|
-
|
|
74
|
-
# crypt.h is generated by ./configure and placed in the build directory.
|
|
75
|
-
t.cflags << "-I#{LIBXCRYPT_BUILD_DIR}"
|
|
76
|
-
|
|
77
|
-
# Link ALL symbols from libcrypt.a into the shared library so that
|
|
78
|
-
# Ruby-FFI can bind to them at runtime without any direct C references.
|
|
79
|
-
if FFI::Platform.mac?
|
|
80
|
-
t.ldflags << "-Wl,-force_load,#{LIBXCRYPT_STATIC}"
|
|
81
|
-
else
|
|
82
|
-
t.ldflags << "-Wl,--whole-archive,#{LIBXCRYPT_STATIC},--no-whole-archive"
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# crypt.h is generated during the libxcrypt configure step, so the .c
|
|
87
|
-
# compilation must wait for libxcrypt:build before it can find the header.
|
|
88
|
-
Rake::Task[XCRYPT_OBJ].enhance(["libxcrypt:build"])
|
|
89
|
-
|
|
90
|
-
# Ensure libxcrypt.a is ready before the final link step too.
|
|
91
|
-
Rake::Task[XCRYPT_LIB].enhance(["libxcrypt:build"])
|
|
92
|
-
|
|
93
|
-
desc "Compile the XCrypt native extension"
|
|
94
|
-
task compile: XCRYPT_LIB
|
|
95
|
-
|
|
96
|
-
# ---------------------------------------------------------------------------
|
|
97
|
-
# Tests
|
|
98
|
-
# ---------------------------------------------------------------------------
|
|
6
|
+
task default: [:compile, :test]
|
|
99
7
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
t.pattern = "test/**/test_*.rb"
|
|
103
|
-
t.verbose = true
|
|
8
|
+
if FFI::Platform.mac?
|
|
9
|
+
task default: "test:linux"
|
|
104
10
|
end
|
|
105
|
-
|
|
106
|
-
task default: [:compile, :test]
|