ffi-compiler2 2.0.1 → 2.2.1

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: c8549789704a6cca51363e043802e3da1509e6db8e8cb04e3371fbd1d353d719
4
- data.tar.gz: d59762c7609d6e148c6dda92ceb2067875e5c8b73c9802b68180fbbc6c941aba
3
+ metadata.gz: 95124af34cb7788f67975319e8c68be47214ed3d71d9bca813e7290478bd5177
4
+ data.tar.gz: 31997daf9b703e2a34204ca25ffb622bdd2a94645b01e4ff624efa361790b84f
5
5
  SHA512:
6
- metadata.gz: 4938d40f72c31d3d280952c99964091215ee50991292466bca16d7e8dea9e8d525c5399f289cd6d025ccc26aa0745faca437a6b5db96757b93205cbc569e9277
7
- data.tar.gz: f70c97cf7e3cd83a06d901393c331e7e52cb8f174f9548807bad3cdd175cd50f00c87b6e9686398ee3531c498baa395f1a09f34f535806f2a8a7081c1d2107e4
6
+ metadata.gz: 1086f6129c55b966fd72b0422fc95e6e6ff8daa3532d4400ae285f306f21659440596983fc21b56c25070d277e60736ccc27845abf68cdee139e42b63bc25aee
7
+ data.tar.gz: 3732effb97e9773f2634adf07190e9f4293e8d3c7e00cfcd160c57b08c0c403d2f7f3b488ba080714f7ef37a07aa481d45676fd5afbb8c93481959a58892b049
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE CHANGED
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright [yyyy] [name of copyright owner]
190
+ Copyright 2020 FFI
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/ffi-compiler.gemspec CHANGED
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ffi-compiler2'
3
- s.version = '2.0.1'
3
+ s.version = '2.2.1'
4
4
  s.author = 'Dāvis'
5
5
  s.email = 'davispuh@gmail.com'
6
6
  s.homepage = 'https://gitlab.com/davispuh/ffi-compiler'
7
7
  s.summary = 'Ruby FFI Rakefile generator'
8
8
  s.description = 'Ruby FFI library'
9
- s.files = %w(ffi-compiler.gemspec README.md Rakefile LICENSE) + Dir.glob("{lib,spec}/**/*")
9
+ s.files = %w(ffi-compiler.gemspec Gemfile Rakefile README.md LICENSE) + Dir.glob("{lib,spec}/**/*")
10
10
  s.license = 'Apache-2.0'
11
11
  s.required_ruby_version = '>= 1.9'
12
12
  s.add_dependency 'rake'
@@ -2,6 +2,7 @@ require 'rake'
2
2
  require 'rake/tasklib'
3
3
  require 'rake/clean'
4
4
  require 'ffi'
5
+ require 'shellwords'
5
6
  require 'tmpdir'
6
7
  require 'rbconfig'
7
8
  require_relative 'platform'
@@ -11,6 +12,31 @@ module FFI
11
12
  DEFAULT_CFLAGS = %w(-fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing)
12
13
  DEFAULT_LDFLAGS = %w(-fexceptions)
13
14
 
15
+ class Flags
16
+ attr_accessor :raw
17
+
18
+ def initialize(flags)
19
+ @flags = flags
20
+ @raw = true # For backward compatibility
21
+ end
22
+
23
+ def <<(flag)
24
+ if @raw
25
+ @flags += flag.to_s.shellsplit
26
+ else
27
+ @flags << flag
28
+ end
29
+ end
30
+
31
+ def to_a
32
+ @flags
33
+ end
34
+
35
+ def to_s
36
+ @flags.shelljoin
37
+ end
38
+ end
39
+
14
40
  class CompileTask < Rake::TaskLib
15
41
  attr_reader :cflags, :cxxflags, :ldflags, :libs, :platform
16
42
  attr_accessor :name, :ext_dir, :source_dirs, :exclude
@@ -26,9 +52,9 @@ module FFI
26
52
  @libraries = []
27
53
  @headers = []
28
54
  @functions = []
29
- @cflags = DEFAULT_CFLAGS.dup
30
- @cxxflags = DEFAULT_CFLAGS.dup
31
- @ldflags = DEFAULT_LDFLAGS.dup
55
+ @cflags = Flags.new(ENV['CFLAGS']&.shellsplit || DEFAULT_CFLAGS.dup)
56
+ @cxxflags = Flags.new(ENV['CXXFLAGS']&.shellsplit || DEFAULT_CFLAGS.dup)
57
+ @ldflags = Flags.new(ENV['LDFLAGS']&.shellsplit || DEFAULT_LDFLAGS.dup)
32
58
  @libs = []
33
59
  @platform = Platform.system
34
60
  @exports = []
@@ -93,7 +119,7 @@ module FFI
93
119
  else
94
120
  so_flags << '-shared'
95
121
  end
96
- so_flags = so_flags.join(' ')
122
+ so_flags = so_flags.shelljoin
97
123
 
98
124
  out_dir = "#{@platform.arch}-#{@platform.os}"
99
125
  if @ext_dir != '.'
@@ -106,13 +132,13 @@ module FFI
106
132
  lib_name = File.join(out_dir, Platform.system.map_library_name(@name))
107
133
 
108
134
  iflags = @include_paths.uniq.map { |p| "-I#{p}" }
109
- @defines << @functions.uniq.map { |f| "-DHAVE_#{f.upcase}=1" }
110
- @defines << @headers.uniq.map { |h| "-DHAVE_#{h.upcase.sub(/\./, '_')}=1" }
135
+ @defines += @functions.uniq.map { |f| "-DHAVE_#{f.upcase}=1" }
136
+ @defines += @headers.uniq.map { |h| "-DHAVE_#{h.upcase.sub(/\./, '_')}=1" }
111
137
 
112
- cflags = (@cflags + pic_flags + iflags + @defines).join(' ')
113
- cxxflags = (@cxxflags + @cflags + pic_flags + iflags + @defines).join(' ')
114
- ld_flags = (@library_paths.map { |path| "-L#{path}" } + @ldflags).join(' ')
115
- libs = (@libraries.map { |l| "-l#{l}" } + @libs).join(' ')
138
+ cflags = (@cflags.to_a + pic_flags + iflags + @defines).shelljoin
139
+ cxxflags = (@cxxflags.to_a + @cflags.to_a + pic_flags + iflags + @defines).shelljoin
140
+ ld_flags = (@library_paths.map { |path| "-L#{path}" } + @ldflags.to_a).shelljoin
141
+ libs = (@libraries.map { |l| "-l#{l}" } + @libs).shelljoin
116
142
 
117
143
  src_files = []
118
144
  obj_files = []
@@ -150,7 +176,7 @@ module FFI
150
176
 
151
177
  desc "Build dynamic library"
152
178
  file lib_name => obj_files do |t|
153
- sh "#{ld} #{so_flags} -o #{t.name} #{t.prerequisites.join(' ')} #{ld_flags} #{libs}"
179
+ sh "#{ld} #{so_flags} -o #{t.name} #{t.prerequisites.shelljoin} #{ld_flags} #{libs}"
154
180
  end
155
181
  CLEAN.include(lib_name)
156
182
 
@@ -221,7 +247,7 @@ module FFI
221
247
  File.open(path, 'w') do |f|
222
248
  f << src
223
249
  end
224
- cflags = opts.join(' ')
250
+ cflags = opts.shelljoin
225
251
  output = File.join(dir, 'ffi-test')
226
252
  begin
227
253
  return system "#{cc} #{cflags} -o #{output} -c #{path} > #{path}.log 2>&1"
File without changes
File without changes
File without changes
File without changes
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.0.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dāvis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2024-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -72,6 +72,7 @@ executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
+ - Gemfile
75
76
  - LICENSE
76
77
  - README.md
77
78
  - Rakefile
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubygems_version: 3.1.4
107
+ rubygems_version: 3.5.6
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: Ruby FFI Rakefile generator