ffi-compiler2 2.0.0 → 2.2.1

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
- SHA1:
3
- metadata.gz: 31b9ab69f716cfa4ccdbbfd43453cd4620763b74
4
- data.tar.gz: 92bb862b4bf5b7283461dfdb66891809785a3fd9
2
+ SHA256:
3
+ metadata.gz: 95124af34cb7788f67975319e8c68be47214ed3d71d9bca813e7290478bd5177
4
+ data.tar.gz: 31997daf9b703e2a34204ca25ffb622bdd2a94645b01e4ff624efa361790b84f
5
5
  SHA512:
6
- metadata.gz: 21c4caf0223071245552777b21300797699c5158fe0473bb7bd55171f023ec312141a45faec0c706d1dc90aecf627afcf1f6df37a6e93de9e732f75d59bc9961
7
- data.tar.gz: f8ab05891126e75451ed2b7e500a413f0d3bd767523bf586b310c3c73dcbc3602fea6ca034dad3c28f4e79cabd465ad6d2802a8daf2de12364bab311a7153c97
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,13 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ffi-compiler2'
3
- s.version = '2.0.0'
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}/**/*")
10
- s.has_rdoc = false
9
+ s.files = %w(ffi-compiler.gemspec Gemfile Rakefile README.md LICENSE) + Dir.glob("{lib,spec}/**/*")
11
10
  s.license = 'Apache-2.0'
12
11
  s.required_ruby_version = '>= 1.9'
13
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
@@ -9,7 +9,11 @@ module FFI
9
9
  library = Platform.system.map_library_name(name)
10
10
  root = false
11
11
  Pathname.new(start_path || caller_path(caller[0])).ascend do |path|
12
- Dir.glob("#{path}/**/{#{FFI::Platform::ARCH}-#{FFI::Platform::OS}/#{library},#{library}}") do |f|
12
+ Dir.glob("#{path}/**/#{FFI::Platform::ARCH}-#{FFI::Platform::OS}/#{library}") do |f|
13
+ return f
14
+ end
15
+
16
+ Dir.glob("#{path}/**/#{library}") do |f|
13
17
  return f
14
18
  end
15
19
 
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.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dāvis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-24 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
@@ -88,7 +89,7 @@ homepage: https://gitlab.com/davispuh/ffi-compiler
88
89
  licenses:
89
90
  - Apache-2.0
90
91
  metadata: {}
91
- post_install_message:
92
+ post_install_message:
92
93
  rdoc_options: []
93
94
  require_paths:
94
95
  - lib
@@ -103,9 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.6.4
108
- signing_key:
107
+ rubygems_version: 3.5.6
108
+ signing_key:
109
109
  specification_version: 4
110
110
  summary: Ruby FFI Rakefile generator
111
111
  test_files: []