sass-embedded 1.62.0-x64-mingw-ucrt → 1.62.1-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0d9f4329752fdd576bcfc2dd8a1b3143a646359c1692251d25219547e171252
4
- data.tar.gz: 536f045042f6e18f7b32bec707effec0637f38e4236e3ef0f00e34340aa4c729
3
+ metadata.gz: 97fd40c87c1f0cc6ff66818796d0a8564f31f694b5c72f1e8f67221690b1edbb
4
+ data.tar.gz: 986536ab1654550ae9d27120354bfe1f874b576492d0b8e932a50c417887529a
5
5
  SHA512:
6
- metadata.gz: ad6555f7d6fa75722cde2e926411eb64352b6325a1bc935fbada644d3fe0796ff5ccf827356decb14bc978400aabdb56f0247dcb4c954d11d7f28f04b503002d
7
- data.tar.gz: 15b37ba38999dd5c175aa3314989c47b263014de0d70b387f77719fcedcd80677d175151d7702a96a767a2c9f2876171de4b9ff2fe289185c668341376c7c8ac
6
+ metadata.gz: 3470cdee4803028e4ba34baefaa379e005d81579e33a3a4d47fb4721450483096ba7cb448300b03ed7c6192d92cbee5694e27b85e5f23ca07ca79b72df9d8838
7
+ data.tar.gz: 004d94640760ba560cb95ac7fa163e4bee929b0215ca394f5d8f38f3f9eb3ca3055d1723db9eb0d7bd96e689082ae50f260ce2e0c35ee6d66595646371121907
@@ -9,7 +9,16 @@ module Sass
9
9
  # It runs the `dart-sass-embedded` process.
10
10
  class Compiler
11
11
  def initialize
12
- @stdin, @stdout, @stderr, @wait_thread = Open3.popen3(*COMMAND, chdir: __dir__)
12
+ @stdin, @stdout, @stderr, @wait_thread = begin
13
+ Open3.popen3(*COMMAND, chdir: __dir__)
14
+ rescue Errno::ENOENT
15
+ require_relative 'elf'
16
+
17
+ raise if ELF::INTERPRETER.nil?
18
+
19
+ Open3.popen3(ELF::INTERPRETER, *COMMAND, chdir: __dir__)
20
+ end
21
+
13
22
  @stdin.binmode
14
23
  @stdout.binmode
15
24
  @stdin_mutex = Mutex.new
@@ -0,0 +1,275 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ class Embedded
5
+ # The {ELF} class.
6
+ #
7
+ # It parses ELF header to extract interpreter.
8
+ # @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h
9
+ # @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c
10
+ class ELF
11
+ # rubocop:disable Naming/ConstantName
12
+
13
+ # 32-bit ELF base types.
14
+ Elf32_Addr = :__u32
15
+ Elf32_Half = :__u16
16
+ Elf32_Off = :__u32
17
+ Elf32_Sword = :__s32
18
+ Elf32_Word = :__u32
19
+
20
+ # 64-bit ELF base types.
21
+ Elf64_Addr = :__u64
22
+ Elf64_Half = :__u16
23
+ Elf64_SHalf = :__s16
24
+ Elf64_Off = :__u64
25
+ Elf64_Sword = :__s32
26
+ Elf64_Word = :__u32
27
+ Elf64_Xword = :__u64
28
+ Elf64_Sxword = :__s64
29
+
30
+ # rubocop:enable Naming/ConstantName
31
+
32
+ # These constants are for the segment types stored in the image headers
33
+ PT_NULL = 0
34
+ PT_LOAD = 1
35
+ PT_DYNAMIC = 2
36
+ PT_INTERP = 3
37
+ PT_NOTE = 4
38
+ PT_SHLIB = 5
39
+ PT_PHDR = 6
40
+ PT_TLS = 7
41
+ PT_LOOS = 0x60000000
42
+ PT_HIOS = 0x6fffffff
43
+ PT_LOPROC = 0x70000000
44
+ PT_HIPROC = 0x7fffffff
45
+ PT_GNU_EH_FRAME = (PT_LOOS + 0x474e550)
46
+ PT_GNU_STACK = (PT_LOOS + 0x474e551)
47
+ PT_GNU_RELRO = (PT_LOOS + 0x474e552)
48
+ PT_GNU_PROPERTY = (PT_LOOS + 0x474e553)
49
+
50
+ # These constants define the different elf file types
51
+ ET_NONE = 0
52
+ ET_REL = 1
53
+ ET_EXEC = 2
54
+ ET_DYN = 3
55
+ ET_CORE = 4
56
+ ET_LOPROC = 0xff00
57
+ ET_HIPROC = 0xffff
58
+
59
+ EI_NIDENT = 16
60
+
61
+ # rubocop:disable Naming/ConstantName
62
+
63
+ Elf32_Ehdr = [
64
+ [:unsigned_char, :e_ident, EI_NIDENT],
65
+ [Elf32_Half, :e_type],
66
+ [Elf32_Half, :e_machine],
67
+ [Elf32_Word, :e_version],
68
+ [Elf32_Addr, :e_entry],
69
+ [Elf32_Off, :e_phoff],
70
+ [Elf32_Off, :e_shoff],
71
+ [Elf32_Word, :e_flags],
72
+ [Elf32_Half, :e_ehsize],
73
+ [Elf32_Half, :e_phentsize],
74
+ [Elf32_Half, :e_phnum],
75
+ [Elf32_Half, :e_shentsize],
76
+ [Elf32_Half, :e_shnum],
77
+ [Elf32_Half, :e_shstrndx]
78
+ ].freeze
79
+
80
+ Elf64_Ehdr = [
81
+ [:unsigned_char, :e_ident, EI_NIDENT],
82
+ [Elf64_Half, :e_type],
83
+ [Elf64_Half, :e_machine],
84
+ [Elf64_Word, :e_version],
85
+ [Elf64_Addr, :e_entry],
86
+ [Elf64_Off, :e_phoff],
87
+ [Elf64_Off, :e_shoff],
88
+ [Elf64_Word, :e_flags],
89
+ [Elf64_Half, :e_ehsize],
90
+ [Elf64_Half, :e_phentsize],
91
+ [Elf64_Half, :e_phnum],
92
+ [Elf64_Half, :e_shentsize],
93
+ [Elf64_Half, :e_shnum],
94
+ [Elf64_Half, :e_shstrndx]
95
+ ].freeze
96
+
97
+ Elf32_Phdr = [
98
+ [Elf32_Word, :p_type],
99
+ [Elf32_Off, :p_offset],
100
+ [Elf32_Addr, :p_vaddr],
101
+ [Elf32_Addr, :p_paddr],
102
+ [Elf32_Word, :p_filesz],
103
+ [Elf32_Word, :p_memsz],
104
+ [Elf32_Word, :p_flags],
105
+ [Elf32_Word, :p_align]
106
+ ].freeze
107
+
108
+ Elf64_Phdr = [
109
+ [Elf64_Word, :p_type],
110
+ [Elf64_Word, :p_flags],
111
+ [Elf64_Off, :p_offset],
112
+ [Elf64_Addr, :p_vaddr],
113
+ [Elf64_Addr, :p_paddr],
114
+ [Elf64_Xword, :p_filesz],
115
+ [Elf64_Xword, :p_memsz],
116
+ [Elf64_Xword, :p_align]
117
+ ].freeze
118
+
119
+ # rubocop:enable Naming/ConstantName
120
+
121
+ # e_ident[] indexes
122
+ EI_MAG0 = 0
123
+ EI_MAG1 = 1
124
+ EI_MAG2 = 2
125
+ EI_MAG3 = 3
126
+ EI_CLASS = 4
127
+ EI_DATA = 5
128
+ EI_VERSION = 6
129
+ EI_OSABI = 7
130
+ EI_PAD = 8
131
+
132
+ # EI_MAG
133
+ ELFMAG0 = 0x7f
134
+ ELFMAG1 = 'E'.ord
135
+ ELFMAG2 = 'L'.ord
136
+ ELFMAG3 = 'F'.ord
137
+ ELFMAG = [ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3].pack('C*')
138
+ SELFMAG = 4
139
+
140
+ # e_ident[EI_CLASS]
141
+ ELFCLASSNONE = 0
142
+ ELFCLASS32 = 1
143
+ ELFCLASS64 = 2
144
+ ELFCLASSNUM = 3
145
+
146
+ # e_ident[EI_DATA]
147
+ ELFDATANONE = 0
148
+ ELFDATA2LSB = 1
149
+ ELFDATA2MSB = 2
150
+
151
+ def initialize(buffer)
152
+ @buffer = buffer
153
+ @ehdr = read_ehdr
154
+ @buffer.seek(@ehdr[:e_phoff], :SET)
155
+ @proghdrs = Array.new(@ehdr[:e_phnum]) do
156
+ read_phdr
157
+ end
158
+ end
159
+
160
+ def relocatable?
161
+ @ehdr[:e_type] == ET_REL
162
+ end
163
+
164
+ def executable?
165
+ @ehdr[:e_type] == ET_EXEC
166
+ end
167
+
168
+ def shared_object?
169
+ @ehdr[:e_type] == ET_DYN
170
+ end
171
+
172
+ def core?
173
+ @ehdr[:e_type] == ET_CORE
174
+ end
175
+
176
+ def interpreter
177
+ phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP }
178
+ return if phdr.nil?
179
+
180
+ @buffer.seek(phdr[:p_offset], :SET)
181
+ interpreter = @buffer.read(phdr[:p_filesz])
182
+ raise ArgumentError unless interpreter.end_with?("\0")
183
+
184
+ interpreter.chomp("\0")
185
+ end
186
+
187
+ private
188
+
189
+ def file_class
190
+ @ehdr[:e_ident][EI_CLASS]
191
+ end
192
+
193
+ def data_encoding
194
+ @ehdr[:e_ident][EI_DATA]
195
+ end
196
+
197
+ def read_ehdr
198
+ @ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') }
199
+ raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG
200
+
201
+ case file_class
202
+ when ELFCLASS32
203
+ Elf32_Ehdr
204
+ when ELFCLASS64
205
+ Elf64_Ehdr
206
+ else
207
+ raise ArgumentError
208
+ end.drop(1).to_h do |field|
209
+ [field[1], read1(field[0])]
210
+ end.merge!(@ehdr)
211
+ end
212
+
213
+ def read_phdr
214
+ case file_class
215
+ when ELFCLASS32
216
+ Elf32_Phdr
217
+ when ELFCLASS64
218
+ Elf64_Phdr
219
+ else
220
+ raise ArgumentError
221
+ end.to_h do |field|
222
+ [field[1], read1(field[0])]
223
+ end
224
+ end
225
+
226
+ def read1(type)
227
+ case data_encoding
228
+ when ELFDATA2LSB
229
+ case type
230
+ when :__u16
231
+ @buffer.read(2).unpack1('v*')
232
+ when :__u32
233
+ @buffer.read(4).unpack1('V*')
234
+ when :__u64
235
+ buffer = @buffer.read(8).unpack('V*')
236
+ (buffer[1] << 32) | buffer[0]
237
+ else
238
+ raise ArgumentError
239
+ end
240
+ when ELFDATA2MSB
241
+ case type
242
+ when :__u16
243
+ @buffer.read(2).unpack1('n*')
244
+ when :__u32
245
+ @buffer.read(4).unpack1('N*')
246
+ when :__u64
247
+ buffer = @buffer.read(8).unpack('N*')
248
+ (buffer[0] << 32) | buffer[1]
249
+ else
250
+ raise ArgumentError
251
+ end
252
+ else
253
+ raise ArgumentError
254
+ end
255
+ end
256
+
257
+ INTERPRETER = proc do
258
+ proc_self_exe = '/proc/self/exe'
259
+ if File.exist?(proc_self_exe)
260
+ File.open(proc_self_exe, 'rb') do |exe|
261
+ elf = ELF.new(exe)
262
+ interpreter = elf.interpreter
263
+ if interpreter.nil? && elf.shared_object?
264
+ File.readlink(proc_self_exe)
265
+ else
266
+ interpreter
267
+ end
268
+ end
269
+ end
270
+ end.call
271
+ end
272
+
273
+ private_constant :ELF
274
+ end
275
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '1.62.0'
5
+ VERSION = '1.62.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.62.0
4
+ version: 1.62.1
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-12 00:00:00.000000000 Z
11
+ date: 2023-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.19.0
103
+ version: 2.20.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 2.19.0
110
+ version: 2.20.0
111
111
  description: A Ruby library that will communicate with Embedded Dart Sass using the
112
112
  Embedded Sass protocol.
113
113
  email:
@@ -132,6 +132,7 @@ files:
132
132
  - lib/sass/embedded/channel.rb
133
133
  - lib/sass/embedded/compiler.rb
134
134
  - lib/sass/embedded/dispatcher.rb
135
+ - lib/sass/embedded/elf.rb
135
136
  - lib/sass/embedded/host.rb
136
137
  - lib/sass/embedded/host/function_registry.rb
137
138
  - lib/sass/embedded/host/importer_registry.rb
@@ -161,8 +162,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
161
162
  licenses:
162
163
  - MIT
163
164
  metadata:
164
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.62.0
165
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.62.0
165
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.62.1
166
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.62.1
166
167
  funding_uri: https://github.com/sponsors/ntkme
167
168
  post_install_message:
168
169
  rdoc_options: []