ffi-compiler2 2.2.1 → 2.2.2
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/README.md +0 -0
- data/Rakefile +0 -0
- data/ffi-compiler.gemspec +1 -1
- data/lib/ffi-compiler/compile_task.rb +17 -17
- data/lib/ffi-compiler/export_task.rb +0 -0
- data/lib/ffi-compiler/exporter.rb +0 -0
- data/lib/ffi-compiler/fake_ffi/ffi-compiler/loader.rb +0 -0
- data/lib/ffi-compiler/platform.rb +0 -0
- data/lib/ffi-compiler/shell.rb +24 -0
- data/lib/ffi-compiler/task.rb +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7298668a9fdd9774299a0e8f7db5f707a5ddfe07dec06fa4386a01bcee7db5a5
|
4
|
+
data.tar.gz: ce654d24c586edaa2dc571d7a71548bd15a64576367ae8b0e0a97df44e29454f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bee061257b683286b3caea10927543ca3d554500facb5f6465710652c23dd0ebbc287ac0e4abed006a6cdc27b5c3eeb1645cda97e325468316d508b89bf6f360
|
7
|
+
data.tar.gz: 98550ca8ca4c4ba8bcb8ccc7b979b8365143037d87169f7ca821d74fe4a61c45d2a969ef21f9d1e92da59e3ffcb8302872b25c657e351224c88860ac0a4eafad
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/ffi-compiler.gemspec
CHANGED
@@ -2,10 +2,10 @@ require 'rake'
|
|
2
2
|
require 'rake/tasklib'
|
3
3
|
require 'rake/clean'
|
4
4
|
require 'ffi'
|
5
|
-
require 'shellwords'
|
6
5
|
require 'tmpdir'
|
7
6
|
require 'rbconfig'
|
8
7
|
require_relative 'platform'
|
8
|
+
require_relative 'shell'
|
9
9
|
|
10
10
|
module FFI
|
11
11
|
module Compiler
|
@@ -22,7 +22,7 @@ module FFI
|
|
22
22
|
|
23
23
|
def <<(flag)
|
24
24
|
if @raw
|
25
|
-
@flags += flag.to_s
|
25
|
+
@flags += shellsplit(flag.to_s)
|
26
26
|
else
|
27
27
|
@flags << flag
|
28
28
|
end
|
@@ -33,7 +33,7 @@ module FFI
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def to_s
|
36
|
-
@flags
|
36
|
+
shelljoin(@flags)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -52,9 +52,9 @@ module FFI
|
|
52
52
|
@libraries = []
|
53
53
|
@headers = []
|
54
54
|
@functions = []
|
55
|
-
@cflags = Flags.new(ENV['CFLAGS']
|
56
|
-
@cxxflags = Flags.new(ENV['CXXFLAGS']
|
57
|
-
@ldflags = Flags.new(ENV['LDFLAGS']
|
55
|
+
@cflags = Flags.new(shellsplit(ENV['CFLAGS']) || DEFAULT_CFLAGS.dup)
|
56
|
+
@cxxflags = Flags.new(shellsplit(ENV['CXXFLAGS']) || DEFAULT_CFLAGS.dup)
|
57
|
+
@ldflags = Flags.new(shellsplit(ENV['LDFLAGS']) || DEFAULT_LDFLAGS.dup)
|
58
58
|
@libs = []
|
59
59
|
@platform = Platform.system
|
60
60
|
@exports = []
|
@@ -119,7 +119,7 @@ module FFI
|
|
119
119
|
else
|
120
120
|
so_flags << '-shared'
|
121
121
|
end
|
122
|
-
so_flags = so_flags
|
122
|
+
so_flags = shelljoin(so_flags)
|
123
123
|
|
124
124
|
out_dir = "#{@platform.arch}-#{@platform.os}"
|
125
125
|
if @ext_dir != '.'
|
@@ -135,10 +135,10 @@ module FFI
|
|
135
135
|
@defines += @functions.uniq.map { |f| "-DHAVE_#{f.upcase}=1" }
|
136
136
|
@defines += @headers.uniq.map { |h| "-DHAVE_#{h.upcase.sub(/\./, '_')}=1" }
|
137
137
|
|
138
|
-
cflags = (@cflags.to_a + pic_flags + iflags + @defines)
|
139
|
-
cxxflags = (@cxxflags.to_a + @cflags.to_a + pic_flags + iflags + @defines)
|
140
|
-
ld_flags = (@library_paths.map { |path| "-L#{path}" } + @ldflags.to_a)
|
141
|
-
libs = (@libraries.map { |l| "-l#{l}" } + @libs)
|
138
|
+
cflags = shelljoin(@cflags.to_a + pic_flags + iflags + @defines)
|
139
|
+
cxxflags = shelljoin(@cxxflags.to_a + @cflags.to_a + pic_flags + iflags + @defines)
|
140
|
+
ld_flags = shelljoin(@library_paths.map { |path| "-L#{path}" } + @ldflags.to_a)
|
141
|
+
libs = shelljoin(@libraries.map { |l| "-l#{l}" } + @libs)
|
142
142
|
|
143
143
|
src_files = []
|
144
144
|
obj_files = []
|
@@ -156,12 +156,12 @@ module FFI
|
|
156
156
|
obj_file = obj_files[index]
|
157
157
|
if src =~ /\.c$/
|
158
158
|
file obj_file => [ src, File.dirname(obj_file) ] do |t|
|
159
|
-
sh "#{cc} #{cflags} -o #{t.name} -c #{t.prerequisites[0]}"
|
159
|
+
sh "#{cc} #{cflags} -o #{shellescape(t.name)} -c #{shellescape(t.prerequisites[0])}"
|
160
160
|
end
|
161
161
|
|
162
162
|
else
|
163
163
|
file obj_file => [ src, File.dirname(obj_file) ] do |t|
|
164
|
-
sh "#{cxx} #{cxxflags} -o #{t.name} -c #{t.prerequisites[0]}"
|
164
|
+
sh "#{cxx} #{cxxflags} -o #{shellescape(t.name)} -c #{shellescape(t.prerequisites[0])}"
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
@@ -176,14 +176,14 @@ module FFI
|
|
176
176
|
|
177
177
|
desc "Build dynamic library"
|
178
178
|
file lib_name => obj_files do |t|
|
179
|
-
sh "#{ld} #{so_flags} -o #{t.name} #{t.prerequisites
|
179
|
+
sh "#{ld} #{so_flags} -o #{shellescape(t.name)} #{shelljoin(t.prerequisites)} #{ld_flags} #{libs}"
|
180
180
|
end
|
181
181
|
CLEAN.include(lib_name)
|
182
182
|
|
183
183
|
@exports.each do |e|
|
184
184
|
desc "Export #{e[:rb_file]}"
|
185
185
|
file e[:header] => [ e[:rb_file] ] do |t|
|
186
|
-
ruby "-I#{File.join(File.dirname(__FILE__), 'fake_ffi')} -I#{File.dirname(t.prerequisites[0])} #{File.join(File.dirname(__FILE__), 'exporter.rb')} #{t.prerequisites[0]} #{t.name}"
|
186
|
+
ruby "-I#{File.join(File.dirname(__FILE__), 'fake_ffi')} -I#{File.dirname(t.prerequisites[0])} #{File.join(File.dirname(__FILE__), 'exporter.rb')} #{shellescape(t.prerequisites[0])} #{shellescape(t.name)}"
|
187
187
|
end
|
188
188
|
|
189
189
|
obj_files.each { |o| file o => [ e[:header] ] }
|
@@ -247,10 +247,10 @@ module FFI
|
|
247
247
|
File.open(path, 'w') do |f|
|
248
248
|
f << src
|
249
249
|
end
|
250
|
-
cflags = opts
|
250
|
+
cflags = shelljoin(opts)
|
251
251
|
output = File.join(dir, 'ffi-test')
|
252
252
|
begin
|
253
|
-
return system "#{cc} #{cflags} -o #{output} -c #{path} > #{path}.log 2>&1"
|
253
|
+
return system "#{cc} #{cflags} -o #{shellescape(output)} -c #{shellescape(path)} > #{shellescape(path)}.log 2>&1"
|
254
254
|
rescue
|
255
255
|
return false
|
256
256
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
def shellescape(str)
|
5
|
+
return str unless str
|
6
|
+
if FFI::Platform::OS == 'windows'
|
7
|
+
'"' + str.gsub('"', '""') + '"'
|
8
|
+
else
|
9
|
+
str.shellescape
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def shelljoin(args)
|
14
|
+
if FFI::Platform::OS == 'windows'
|
15
|
+
args.reduce { |cmd, arg| cmd + ' "' + arg.gsub('"', '""') + '"' }
|
16
|
+
else
|
17
|
+
args.shelljoin
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def shellsplit(str)
|
22
|
+
return str unless str
|
23
|
+
str.shellsplit
|
24
|
+
end
|
data/lib/ffi-compiler/task.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-compiler2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dāvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/ffi-compiler/fake_ffi/ffi.rb
|
85
85
|
- lib/ffi-compiler/loader.rb
|
86
86
|
- lib/ffi-compiler/platform.rb
|
87
|
+
- lib/ffi-compiler/shell.rb
|
87
88
|
- lib/ffi-compiler/task.rb
|
88
89
|
homepage: https://gitlab.com/davispuh/ffi-compiler
|
89
90
|
licenses:
|