tebako-runtime 0.4.2 → 0.5.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: eb768706b6e2fda16611bed89a6f4cd6e52296c969cfda886f51dbb9edd516e8
4
- data.tar.gz: 1311d0ad02355fe08c374b51acca120db90f398f7942aa37c2909829a77a45b3
3
+ metadata.gz: 472fccda8a91bb1aee5a55ea9c61b9d2a18461ec8d825a2b7184bc69cd557dd9
4
+ data.tar.gz: 95e7140e5ebbbaf85badedcad10298b4ec0feb538b38989dbb9348c47eff24ca
5
5
  SHA512:
6
- metadata.gz: 3626130726d12b47ff32fb397d8650887305608854813b838b9744dcf18a91945cc97ba7c741b9c158126e5e85fe5a8f8a8741d8b783e0cf83a3c1709051cb77
7
- data.tar.gz: 6f9500c6b5639d506091831cbe60d0a2dcefa71b6820a5a92caaf51bc03d2be46e31c1869f6841f0c0dbfe5536a8a810a14a6b1af6a1276c8d17c44573bf3767
6
+ metadata.gz: e2976dc28c3793366ccc132ff020a997fc7a8c7636ee5993c6a4d9bc984d6f3dc0b7ad21aef1daff56459c9df3848a00250d6d1f376264817005b1593e51fb4f
7
+ data.tar.gz: b4d8e87877ae1526a98d90fe8bb948ec6f1f6d547dd4d07c573a0e89acfb33dd83db6e4ca4dfb66642c5924664e6bf0b61a6fc1ab1a0aa4faf2d089ccae3658c
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
4
+ # All rights reserved.
5
+ # This file is a part of tebako
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions
9
+ # are met:
10
+ # 1. Redistributions of source code must retain the above copyright
11
+ # notice, this list of conditions and the following disclaimer.
12
+ # 2. Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18
+ # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
20
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
+ # POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ module FFI
29
+ module Platform
30
+ ARCH = case RbConfig::CONFIG["host_cpu"].downcase
31
+ when /amd64|x86_64|x64/
32
+ "x86_64"
33
+ when /i\d86|x86|i86pc/
34
+ "i386"
35
+ when /ppc64|powerpc64/
36
+ "powerpc64"
37
+ when /ppc|powerpc/
38
+ "powerpc"
39
+ when /sparcv9|sparc64/
40
+ "sparcv9"
41
+ when /arm64|aarch64/ # MacOS calls it "arm64", other operating systems "aarch64"
42
+ "aarch64"
43
+ when /^arm/
44
+ if OS == "darwin" # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin
45
+ "aarch64"
46
+ else
47
+ "arm"
48
+ end
49
+ else
50
+ RbConfig::CONFIG["host_cpu"].downcase
51
+ end
52
+
53
+ OS =
54
+ case RbConfig::CONFIG["host_os"].downcase
55
+ when /linux/
56
+ "linux"
57
+ when /darwin/
58
+ "darwin"
59
+ when /freebsd/
60
+ "freebsd"
61
+ when /netbsd/
62
+ "netbsd"
63
+ when /openbsd/
64
+ "openbsd"
65
+ when /dragonfly/
66
+ "dragonflybsd"
67
+ when /sunos|solaris/
68
+ "solaris"
69
+ when /mingw|mswin/
70
+ "windows"
71
+ else
72
+ RbConfig::CONFIG["host_os"].downcase
73
+ end
74
+
75
+ LIBPREFIX = case OS
76
+ when /windows|msys/
77
+ ""
78
+ when /cygwin/
79
+ "cyg"
80
+ else
81
+ "lib"
82
+ end
83
+
84
+ LIBSUFFIX = case OS
85
+ when /darwin/
86
+ "dylib"
87
+ when /windows|cygwin|msys/
88
+ "dll"
89
+ else
90
+ # Punt and just assume a sane unix (i.e. anything but AIX)
91
+ # when /linux|bsd|solaris/
92
+ # "so"
93
+ "so"
94
+ end
95
+
96
+ PASS_THROUGH = true
97
+
98
+ def self.mac?
99
+ RUBY_PLATFORM =~ /darwin/
100
+ end
101
+ end
102
+ end
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module TebakoRuntime
29
- VERSION = "0.4.2"
29
+ VERSION = "0.5.0"
30
30
  end
@@ -65,6 +65,31 @@ module TebakoRuntime
65
65
  puts "Tebako runtime: skipped [#{name}]" if log_enabled && !res_inner
66
66
  log_enabled
67
67
  end
68
+
69
+ def self.process_all(name)
70
+ f1 = process(name, PRE_REQUIRE_MAP, "pre")
71
+ res = original_require name
72
+ f2 = process(name, POST_REQUIRE_MAP, "post")
73
+
74
+ puts "Tebako runtime: req [#{name}]" unless f1 || f2
75
+ res
76
+ end
77
+
78
+ # Very special deploy-time patching
79
+ # It targets ffi-compiler/ffi-compiler2 that use some functions of
80
+ # deployed ffi to process other gems
81
+ # THis approach is not compatible with tebako on Windows because ffi
82
+ # is deployed with (inplib) reference to target tebako package that is
83
+ # not available at deploy time
84
+ def self.process_pass_through(name)
85
+ if name == "ffi" && RUBY_PLATFORM =~ /msys|mingw|cygwin/
86
+ puts "Replacing ffi ffi-platform-stub" if log_enabled
87
+ res = original_require "tebako-runtime/pass-through/ffi-platform-stub"
88
+ else
89
+ res = original_require name
90
+ end
91
+ res
92
+ end
68
93
  end
69
94
 
70
95
  # Some would call it 'monkey patching' but in reality we are adding
@@ -72,11 +97,10 @@ end
72
97
  module Kernel
73
98
  alias original_require require
74
99
  def require(name)
75
- f1 = TebakoRuntime.process(name, TebakoRuntime::PRE_REQUIRE_MAP, "pre")
76
- res = original_require name
77
- f2 = TebakoRuntime.process(name, TebakoRuntime::POST_REQUIRE_MAP, "post")
78
-
79
- puts "Tebako runtime: req [#{name}]" unless f1 || f2
80
- res
100
+ if ENV["TEBAKO_PASS_THROUGH"]
101
+ TebakoRuntime.process_pass_through name
102
+ else
103
+ TebakoRuntime.process_all name
104
+ end
81
105
  end
82
106
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
3
+ # Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
5
  # This file is a part of tebako
6
6
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tebako-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-15 00:00:00.000000000 Z
11
+ date: 2024-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -160,6 +160,7 @@ files:
160
160
  - lib/tebako-runtime/adapters/net-http.rb
161
161
  - lib/tebako-runtime/adapters/sassc.rb
162
162
  - lib/tebako-runtime/memfs.rb
163
+ - lib/tebako-runtime/pass-through/ffi-platform-stub.rb
163
164
  - lib/tebako-runtime/pre/seven-zip.rb
164
165
  - lib/tebako-runtime/string.rb
165
166
  - lib/tebako-runtime/version.rb