ffi-compiler2 2.2.1 → 2.3.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/README.md +0 -0
- data/Rakefile +0 -0
- data/ffi-compiler.gemspec +1 -1
- data/lib/ffi-compiler/compile_task.rb +20 -18
- 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/multi_file_task.rb +41 -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 +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c39f8a30b5d7c8773de4df502f0dd5224979e2a6371f5e7eae81df1d2e83c60
|
4
|
+
data.tar.gz: f873026f6d59717dfeee11bde7de662a17ccdf66b5f1ad62a608aa3073acaadd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6db63080494ace5f42104d55e273c9e1f977d80ea0122873eac11b1e7c13671e01fed458026dbba2602fa3392fdf7706354067b23cf79bda22873b9880a101e
|
7
|
+
data.tar.gz: 37ed00181d8e1572f6504295af54e855fbd08e5a4adedf38449dbe12d0943126adc801683c6290072c49102a17b00a803357f6d0c4d38d3d66119a316cc64c38
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/ffi-compiler.gemspec
CHANGED
@@ -2,10 +2,11 @@ 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
|
+
require_relative 'multi_file_task'
|
9
10
|
|
10
11
|
module FFI
|
11
12
|
module Compiler
|
@@ -22,7 +23,7 @@ module FFI
|
|
22
23
|
|
23
24
|
def <<(flag)
|
24
25
|
if @raw
|
25
|
-
@flags += flag.to_s
|
26
|
+
@flags += shellsplit(flag.to_s)
|
26
27
|
else
|
27
28
|
@flags << flag
|
28
29
|
end
|
@@ -33,7 +34,7 @@ module FFI
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def to_s
|
36
|
-
@flags
|
37
|
+
shelljoin(@flags)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -52,9 +53,9 @@ module FFI
|
|
52
53
|
@libraries = []
|
53
54
|
@headers = []
|
54
55
|
@functions = []
|
55
|
-
@cflags = Flags.new(ENV['CFLAGS']
|
56
|
-
@cxxflags = Flags.new(ENV['CXXFLAGS']
|
57
|
-
@ldflags = Flags.new(ENV['LDFLAGS']
|
56
|
+
@cflags = Flags.new(shellsplit(ENV['CFLAGS']) || DEFAULT_CFLAGS.dup)
|
57
|
+
@cxxflags = Flags.new(shellsplit(ENV['CXXFLAGS']) || DEFAULT_CFLAGS.dup)
|
58
|
+
@ldflags = Flags.new(shellsplit(ENV['LDFLAGS']) || DEFAULT_LDFLAGS.dup)
|
58
59
|
@libs = []
|
59
60
|
@platform = Platform.system
|
60
61
|
@exports = []
|
@@ -119,7 +120,7 @@ module FFI
|
|
119
120
|
else
|
120
121
|
so_flags << '-shared'
|
121
122
|
end
|
122
|
-
so_flags = so_flags
|
123
|
+
so_flags = shelljoin(so_flags)
|
123
124
|
|
124
125
|
out_dir = "#{@platform.arch}-#{@platform.os}"
|
125
126
|
if @ext_dir != '.'
|
@@ -135,10 +136,10 @@ module FFI
|
|
135
136
|
@defines += @functions.uniq.map { |f| "-DHAVE_#{f.upcase}=1" }
|
136
137
|
@defines += @headers.uniq.map { |h| "-DHAVE_#{h.upcase.sub(/\./, '_')}=1" }
|
137
138
|
|
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)
|
139
|
+
cflags = shelljoin(@cflags.to_a + pic_flags + iflags + @defines)
|
140
|
+
cxxflags = shelljoin(@cxxflags.to_a + @cflags.to_a + pic_flags + iflags + @defines)
|
141
|
+
ld_flags = shelljoin(@library_paths.map { |path| "-L#{path}" } + @ldflags.to_a)
|
142
|
+
libs = shelljoin(@libraries.map { |l| "-l#{l}" } + @libs)
|
142
143
|
|
143
144
|
src_files = []
|
144
145
|
obj_files = []
|
@@ -156,12 +157,12 @@ module FFI
|
|
156
157
|
obj_file = obj_files[index]
|
157
158
|
if src =~ /\.c$/
|
158
159
|
file obj_file => [ src, File.dirname(obj_file) ] do |t|
|
159
|
-
sh "#{cc} #{cflags} -o #{t.name} -c #{t.prerequisites[0]}"
|
160
|
+
sh "#{cc} #{cflags} -o #{shellescape(t.name)} -c #{shellescape(t.prerequisites[0])}"
|
160
161
|
end
|
161
162
|
|
162
163
|
else
|
163
164
|
file obj_file => [ src, File.dirname(obj_file) ] do |t|
|
164
|
-
sh "#{cxx} #{cxxflags} -o #{t.name} -c #{t.prerequisites[0]}"
|
165
|
+
sh "#{cxx} #{cxxflags} -o #{shellescape(t.name)} -c #{shellescape(t.prerequisites[0])}"
|
165
166
|
end
|
166
167
|
end
|
167
168
|
|
@@ -175,15 +176,16 @@ module FFI
|
|
175
176
|
obj_files.map { |f| File.dirname(f) }.sort.uniq.map { |d| directory d }
|
176
177
|
|
177
178
|
desc "Build dynamic library"
|
178
|
-
|
179
|
-
|
179
|
+
MultiFileTask.define_task(lib_name => src_files + obj_files) do |t|
|
180
|
+
objs = t.prerequisites.select { |file| file.end_with?('.o') }
|
181
|
+
sh "#{ld} #{so_flags} -o #{shellescape(t.name)} #{shelljoin(objs)} #{ld_flags} #{libs}"
|
180
182
|
end
|
181
183
|
CLEAN.include(lib_name)
|
182
184
|
|
183
185
|
@exports.each do |e|
|
184
186
|
desc "Export #{e[:rb_file]}"
|
185
187
|
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}"
|
188
|
+
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
189
|
end
|
188
190
|
|
189
191
|
obj_files.each { |o| file o => [ e[:header] ] }
|
@@ -247,10 +249,10 @@ module FFI
|
|
247
249
|
File.open(path, 'w') do |f|
|
248
250
|
f << src
|
249
251
|
end
|
250
|
-
cflags = opts
|
252
|
+
cflags = shelljoin(opts)
|
251
253
|
output = File.join(dir, 'ffi-test')
|
252
254
|
begin
|
253
|
-
return system "#{cc} #{cflags} -o #{output} -c #{path} > #{path}.log 2>&1"
|
255
|
+
return system "#{cc} #{cflags} -o #{shellescape(output)} -c #{shellescape(path)} > #{shellescape(path)}.log 2>&1"
|
254
256
|
rescue
|
255
257
|
return false
|
256
258
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
module FFI
|
4
|
+
module Compiler
|
5
|
+
class MultiFileTask < Rake::MultiTask
|
6
|
+
def needed?
|
7
|
+
begin
|
8
|
+
@application.options.build_all || out_of_date?(File.mtime(name))
|
9
|
+
rescue Errno::ENOENT
|
10
|
+
true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def timestamp
|
15
|
+
begin
|
16
|
+
File.mtime(name)
|
17
|
+
rescue Errno::ENOENT
|
18
|
+
Rake::LATE
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def invoke_with_call_chain(task_args, invocation_chain)
|
23
|
+
return unless needed?
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def out_of_date?(timestamp)
|
30
|
+
all_prerequisite_tasks.any? do |prereq|
|
31
|
+
prereq_task = application[prereq, @scope]
|
32
|
+
if prereq_task.instance_of?(Rake::FileTask)
|
33
|
+
File.exist?(prereq_task.name) && prereq_task.timestamp > timestamp
|
34
|
+
else
|
35
|
+
prereq_task.needed?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
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 + ' ' + shellescape(arg) }
|
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.
|
4
|
+
version: 2.3.0
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -83,7 +83,9 @@ files:
|
|
83
83
|
- lib/ffi-compiler/fake_ffi/ffi-compiler/loader.rb
|
84
84
|
- lib/ffi-compiler/fake_ffi/ffi.rb
|
85
85
|
- lib/ffi-compiler/loader.rb
|
86
|
+
- lib/ffi-compiler/multi_file_task.rb
|
86
87
|
- lib/ffi-compiler/platform.rb
|
88
|
+
- lib/ffi-compiler/shell.rb
|
87
89
|
- lib/ffi-compiler/task.rb
|
88
90
|
homepage: https://gitlab.com/davispuh/ffi-compiler
|
89
91
|
licenses:
|