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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e50289aa4e577c8954a17b6ee720629448716ba51e93673ff49bce3d065e8260
4
- data.tar.gz: 8df23e9c5de9299d05456f52752a6db9f6099234ed958e3f8a49dbd5ab0eff6c
3
+ metadata.gz: 402efb8aa7a769848889c0f2fe39021d05fa1b8f9e2d8afcf14cddcb7943943e
4
+ data.tar.gz: d0da71131143282090b06512548c1b02d163d2d1c06115e41c0115e07c1c17d7
5
5
  SHA512:
6
- metadata.gz: 1ee8df7d64fdea9f032435f67f886d622f63fbea47dd9f5156a03c45834d446177d807ee4c4ba7ddf3282c65790e695f2a641455fd3a0abd48319d3ee58181a7
7
- data.tar.gz: 7acd5509656ba24800a87dcc2d8f6e20e53faeecc8a1bb1d253d21849266c1be9b3cae44c00f9b45d821fe282e850656b1309b0c17d645d27a7b28406ca62e19
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-compiler/compile_task"
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
- Rake::TestTask.new(:test) do |t|
101
- t.libs << "lib"
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]