ffi-yajl 2.3.0-universal-java → 2.3.1-universal-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -73
- data/Rakefile +55 -96
- data/bin/ffi-yajl-bench +7 -7
- data/ext/ffi_yajl/ext/dlopen/extconf.rb +5 -5
- data/ext/ffi_yajl/ext/encoder/extconf.rb +12 -12
- data/ext/ffi_yajl/ext/parser/extconf.rb +12 -12
- data/lib/ffi_yajl.rb +7 -7
- data/lib/ffi_yajl/benchmark.rb +5 -5
- data/lib/ffi_yajl/benchmark/encode.rb +8 -8
- data/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb +9 -9
- data/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb +11 -11
- data/lib/ffi_yajl/benchmark/encode_profile.rb +5 -5
- data/lib/ffi_yajl/benchmark/http.rb +12 -12
- data/lib/ffi_yajl/benchmark/parse.rb +8 -8
- data/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb +10 -10
- data/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb +11 -11
- data/lib/ffi_yajl/benchmark/parse_profile.rb +5 -5
- data/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb +4 -4
- data/lib/ffi_yajl/benchmark/parse_stream.rb +9 -9
- data/lib/ffi_yajl/encoder.rb +2 -2
- data/lib/ffi_yajl/ext.rb +9 -9
- data/lib/ffi_yajl/ffi.rb +8 -8
- data/lib/ffi_yajl/ffi/encoder.rb +9 -27
- data/lib/ffi_yajl/ffi/parser.rb +5 -5
- data/lib/ffi_yajl/map_library_name.rb +3 -3
- data/lib/ffi_yajl/parser.rb +2 -2
- data/lib/ffi_yajl/version.rb +2 -2
- data/spec/ffi_yajl/encoder_spec.rb +10 -10
- data/spec/ffi_yajl/map_library_name_spec.rb +2 -2
- data/spec/ffi_yajl/parser_spec.rb +7 -7
- data/spec/spec_helper.rb +4 -4
- metadata +12 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01b8e633247c26837a72ce063704dc765647f35b
|
4
|
+
data.tar.gz: 35178ecea062849647eb0ebcdb174e70b31c3c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 786980d4c810fbfa7251310e4f63f8a367270c733c18a579201f16645de9abe288288390766975aefb2637e384934bd08f1783243a5fd7dcd5e8ce541e63a9da
|
7
|
+
data.tar.gz: 9b4137b8cd49ff37b49b474f442c350bd0ca2c4d767ae45cb39163a6c5b6a5ee59e5909d43d7e556a860ed253503ee882a21551ca46e97b18d7d65052820434f
|
data/README.md
CHANGED
@@ -1,13 +1,8 @@
|
|
1
|
-
|
2
|
-
[![Build Status](https://travis-ci.org/chef/ffi-yajl.png)](https://travis-ci.org/chef/ffi-yajl) [![Code Climate](https://codeclimate.com/github/chef/ffi-yajl.png)](https://codeclimate.com/github/chef/ffi-yajl)
|
3
|
-
|
4
1
|
# FFI YAJL
|
5
2
|
|
6
|
-
ffi-yajl
|
7
|
-
|
8
|
-
extension mechanisms, including both MRI native extensions and FFI in
|
9
|
-
order to be compatible with as many Ruby implementations as possible
|
10
|
-
while providing good performance where possible.
|
3
|
+
[![Build Status](https://travis-ci.org/chef/ffi-yajl.svg?branch=master)](https://travis-ci.org/chef/ffi-yajl) [![Gem Version](https://badge.fury.io/rb/ffi-yajl.svg)](https://badge.fury.io/rb/ffi-yajl)
|
4
|
+
|
5
|
+
ffi-yajl is a Ruby adapter for the [yajl](http://lloyd.github.io/yajl/) JSON parser/generator library. ffi-yajl supports multiple Ruby C extension mechanisms, including both MRI native extensions and FFI in order to be compatible with as many Ruby implementations as possible while providing good performance where possible.
|
11
6
|
|
12
7
|
## How to Install
|
13
8
|
|
@@ -25,20 +20,20 @@ gem 'ffi-yajl'
|
|
25
20
|
|
26
21
|
## Supported Ruby VMs:
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
- Ruby MRI 1.9.3/2.0.0/2.1.x/2.2.x
|
24
|
+
- rbx 2.2.x (possibly earlier)
|
25
|
+
- Jruby 1.7.x (possibly earlier)
|
31
26
|
|
32
27
|
Ruby 1.8.7 support was dropped in 2.2.0
|
33
28
|
|
34
29
|
## Supported Distros:
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
- Ubuntu 10.04 through 14.10
|
32
|
+
- Debian 7.x
|
33
|
+
- RHEL/CentOS/Oracle 5.x/6.x/7.x
|
34
|
+
- Solaris 9/10/11 (gcc, sun compiler untested)
|
35
|
+
- AIX 6.x/7.x (gcc or xlc)
|
36
|
+
- Windows 2008r2/2012 (and Win2k/2k3 and consumer versions should work)
|
42
37
|
|
43
38
|
## Basic Usage
|
44
39
|
|
@@ -68,81 +63,44 @@ hash = parser.parse( json )
|
|
68
63
|
|
69
64
|
## Parser Options
|
70
65
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
are repeated in hashes in the input JSON. Without this, repeated keys will
|
80
|
-
silently replace the previous key.
|
66
|
+
- `:check_utf8`
|
67
|
+
- `:dont_validate_strings`
|
68
|
+
- `:symbolize_keys` (default = false): JSON keys are parsed into symbols instead of strings.
|
69
|
+
- `:symbolize_names` (default = false): Alias for `:symbolize_keys`.
|
70
|
+
- `:allow_trailing_garbage`
|
71
|
+
- `:allow_multiple_values`
|
72
|
+
- `:allow_partial_values`
|
73
|
+
- `:unique_key_checking` (default = false): Will raise an exception if keys are repeated in hashes in the input JSON. Without this, repeated keys will silently replace the previous key.
|
81
74
|
|
82
75
|
## Encoder Options
|
83
76
|
|
84
|
-
|
85
|
-
|
86
|
-
encode strings that are invalid UTF-8. When set to false this still will
|
87
|
-
produce valid UTF-8 JSON but will replace invalid characters.
|
77
|
+
- `:pretty` (default = false): Produces more human readable 'pretty' output.
|
78
|
+
- `:validate_utf8` (default = true): Will raise an exception when trying to encode strings that are invalid UTF-8\. When set to false this still will produce valid UTF-8 JSON but will replace invalid characters.
|
88
79
|
|
89
80
|
## Forcing FFI or C Extension
|
90
81
|
|
91
|
-
You can set the environment variable `FORCE_FFI_YAJL` to `ext` or `ffi` to
|
92
|
-
control if the C extension or FFI bindings are used.
|
82
|
+
You can set the environment variable `FORCE_FFI_YAJL` to `ext` or `ffi` to control if the C extension or FFI bindings are used.
|
93
83
|
|
94
84
|
## Yajl Library Packaging
|
95
85
|
|
96
|
-
This library prefers to use the embedded yajl 2.x C library packaged in the
|
97
|
-
libyajl2 gem. In order to use the operating system yajl library (which must be
|
98
|
-
yajl 2.x) the environment variable `USE_SYSTEM_LIBYAJL2` can be set before
|
99
|
-
installing or bundling libyajl2. This will force the libyajl2 gem to skip
|
100
|
-
compiling its embedded library and the ffi-yajl gem will fallback to using the
|
101
|
-
system yajl library.
|
86
|
+
This library prefers to use the embedded yajl 2.x C library packaged in the libyajl2 gem. In order to use the operating system yajl library (which must be yajl 2.x) the environment variable `USE_SYSTEM_LIBYAJL2` can be set before installing or bundling libyajl2\. This will force the libyajl2 gem to skip compiling its embedded library and the ffi-yajl gem will fallback to using the system yajl library.
|
102
87
|
|
103
88
|
## No JSON Gem Compatiblity layer
|
104
89
|
|
105
|
-
This library does not offer a feature to patch `#to_json` methods into all
|
106
|
-
the ruby classes similarly to the JSON gem or yajl-ruby's `yajl/json_gem`
|
107
|
-
compatibility API. The differences in encoding between the JSON gem and the
|
108
|
-
Yajl C library can produce different output on different systems and makes
|
109
|
-
testing brittle. Such a feature will not be included. It was removed in
|
110
|
-
this pull request and could be easily extracted to its own gem (we have
|
111
|
-
no interest in maintaining that gem):
|
90
|
+
This library does not offer a feature to patch `#to_json` methods into all the ruby classes similarly to the JSON gem or yajl-ruby's `yajl/json_gem` compatibility API. The differences in encoding between the JSON gem and the Yajl C library can produce different output on different systems and makes testing brittle. Such a feature will not be included. It was removed in this pull request and could be easily extracted to its own gem (we have no interest in maintaining that gem):
|
112
91
|
|
113
|
-
https://github.com/chef/ffi-yajl/pull/47/files
|
92
|
+
<https://github.com/chef/ffi-yajl/pull/47/files>
|
114
93
|
|
115
94
|
## Why This Instead of X?
|
116
95
|
|
117
|
-
yajl is the only JSON library we've found that has error messages that
|
118
|
-
|
119
|
-
|
120
|
-
1234," which are probably fine for server use, but in
|
121
|
-
[chef](https://github.com/chef/chef) we frequently deal with
|
122
|
-
user-written JSON documents, which means we need a good user experience
|
123
|
-
when encountering malformed JSON.
|
124
|
-
|
125
|
-
We previously used brianmario's
|
126
|
-
[yajl-ruby](https://github.com/brianmario/yajl-ruby) project, but we
|
127
|
-
wanted to be able to fallback to using FFI bindings to the C code (so we
|
128
|
-
could support non-MRI rubies) and we also needed some bug fixes in
|
129
|
-
yajl2, but the maintainer wasn't able to devote enough time to the
|
130
|
-
project to make these updates in a timeframe that worked for us.
|
96
|
+
yajl is the only JSON library we've found that has error messages that meet our requirements. The stdlib json gem and oj (at the time we started this project) have error messages like "invalid token at byte 1234," which are probably fine for server use, but in [chef](https://github.com/chef/chef) we frequently deal with user-written JSON documents, which means we need a good user experience when encountering malformed JSON.
|
97
|
+
|
98
|
+
We previously used brianmario's [yajl-ruby](https://github.com/brianmario/yajl-ruby) project, but we wanted to be able to fallback to using FFI bindings to the C code (so we could support non-MRI rubies) and we also needed some bug fixes in yajl2, but the maintainer wasn't able to devote enough time to the project to make these updates in a timeframe that worked for us.
|
131
99
|
|
132
100
|
## Thanks
|
133
101
|
|
134
|
-
This was initially going to be a clean rewrite of an ffi ruby wrapper around
|
135
|
-
yajl2, but as it progressed more and more code was pulled in from brianmario's
|
136
|
-
existing yajl-ruby gem, particularly all the c extension code, lots of specs
|
137
|
-
and the benchmarks. And the process of writing this would have been much more
|
138
|
-
difficult without being able to draw heavily from already solved problems in
|
139
|
-
yajl-ruby.
|
102
|
+
This was initially going to be a clean rewrite of an ffi ruby wrapper around yajl2, but as it progressed more and more code was pulled in from brianmario's existing yajl-ruby gem, particularly all the c extension code, lots of specs and the benchmarks. And the process of writing this would have been much more difficult without being able to draw heavily from already solved problems in yajl-ruby.
|
140
103
|
|
141
104
|
## License
|
142
105
|
|
143
|
-
Given that this draws heavily from the yajl-ruby sources, and could be
|
144
|
-
considered a derivative work, the MIT License from that project has been
|
145
|
-
preserved and this source code has deliberately not been dual licensed under
|
146
|
-
Chef's typical Apache License. See the
|
147
|
-
[LICENSE](https://github.com/chef/ffi-yajl/blob/master/LICENSE) file in this
|
148
|
-
project.
|
106
|
+
Given that this draws heavily from the yajl-ruby sources, and could be considered a derivative work, the MIT License from that project has been preserved and this source code has deliberately not been dual licensed under Chef's typical Apache License. See the [LICENSE](https://github.com/chef/ffi-yajl/blob/master/LICENSE) file in this project.
|
data/Rakefile
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
$LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "lib"))
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require 'github_changelog_generator/task'
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
require "rubygems/package_task"
|
5
|
+
require "rake/extensiontask"
|
6
|
+
require "ffi_yajl/version"
|
8
7
|
|
9
8
|
Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
|
10
9
|
gemspec = eval(IO.read(gemspec_path))
|
11
10
|
Gem::PackageTask.new(gemspec).define
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
begin
|
14
|
+
require "github_changelog_generator/task"
|
15
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
16
|
+
config.issues = false
|
17
|
+
config.since_tag = "1.0.1"
|
18
|
+
config.exclude_labels = %w{duplicate question invalid wontfix changelog_skip}
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
puts "no github-changelog-generator"
|
18
22
|
end
|
19
23
|
|
20
24
|
desc "Build it and ship it"
|
@@ -42,26 +46,26 @@ task install: [:package] do
|
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
45
|
-
spec = Gem::Specification.load(
|
49
|
+
spec = Gem::Specification.load("ffi-yajl.gemspec")
|
46
50
|
|
47
51
|
Rake::ExtensionTask.new do |ext|
|
48
|
-
ext.name =
|
49
|
-
ext.lib_dir =
|
50
|
-
ext.ext_dir =
|
52
|
+
ext.name = "encoder"
|
53
|
+
ext.lib_dir = "lib/ffi_yajl/ext"
|
54
|
+
ext.ext_dir = "ext/ffi_yajl/ext/encoder"
|
51
55
|
ext.gem_spec = spec
|
52
56
|
end
|
53
57
|
|
54
58
|
Rake::ExtensionTask.new do |ext|
|
55
|
-
ext.name =
|
56
|
-
ext.lib_dir =
|
57
|
-
ext.ext_dir =
|
59
|
+
ext.name = "parser"
|
60
|
+
ext.lib_dir = "lib/ffi_yajl/ext"
|
61
|
+
ext.ext_dir = "ext/ffi_yajl/ext/parser"
|
58
62
|
ext.gem_spec = spec
|
59
63
|
end
|
60
64
|
|
61
65
|
Rake::ExtensionTask.new do |ext|
|
62
|
-
ext.name =
|
63
|
-
ext.lib_dir =
|
64
|
-
ext.ext_dir =
|
66
|
+
ext.name = "dlopen"
|
67
|
+
ext.lib_dir = "lib/ffi_yajl/ext"
|
68
|
+
ext.ext_dir = "ext/ffi_yajl/ext/dlopen"
|
65
69
|
ext.gem_spec = spec
|
66
70
|
end
|
67
71
|
|
@@ -80,101 +84,56 @@ end
|
|
80
84
|
namespace :spec do
|
81
85
|
desc "Run all specs against ffi extension"
|
82
86
|
RSpec::Core::RakeTask.new(:ffi) do |t|
|
83
|
-
ENV[
|
84
|
-
t.pattern = FileList[
|
87
|
+
ENV["FORCE_FFI_YAJL"] = "ffi"
|
88
|
+
t.pattern = FileList["spec/**/*_spec.rb"]
|
85
89
|
end
|
86
90
|
if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
|
87
91
|
desc "Run all specs again c extension"
|
88
92
|
RSpec::Core::RakeTask.new(:ext) do |t|
|
89
|
-
ENV[
|
90
|
-
t.pattern = FileList[
|
93
|
+
ENV["FORCE_FFI_YAJL"] = "ext"
|
94
|
+
t.pattern = FileList["spec/**/*_spec.rb"]
|
91
95
|
end
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
rescue LoadError
|
100
|
-
task :vagrant do
|
101
|
-
puts "test-kitchen gem is not installed"
|
102
|
-
end
|
103
|
-
task :cloud do
|
104
|
-
puts "test-kitchen gem is not installed"
|
105
|
-
end
|
106
|
-
else
|
107
|
-
desc 'Run Test Kitchen with Vagrant'
|
108
|
-
task :vagrant do
|
109
|
-
Kitchen.logger = Kitchen.default_file_logger
|
110
|
-
Kitchen::Config.new.instances.each do |instance|
|
111
|
-
instance.test(:always)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
desc 'Run Test Kitchen with cloud plugins'
|
116
|
-
task :cloud do
|
117
|
-
if ENV['TRAVIS_PULL_REQUEST'] != 'true'
|
118
|
-
ENV['KITCHEN_YAML'] = '.kitchen.cloud.yml'
|
119
|
-
sh "kitchen test --concurrency 4"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
namespace :style do
|
125
|
-
desc 'Run Ruby style checks'
|
126
|
-
begin
|
127
|
-
require 'rubocop/rake_task'
|
128
|
-
rescue LoadError
|
129
|
-
task :rubocop do
|
130
|
-
puts "rubocop gem is not installed"
|
131
|
-
end
|
132
|
-
else
|
133
|
-
RuboCop::RakeTask.new(:rubocop) do |t|
|
134
|
-
t.fail_on_error = false
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
desc 'Run Ruby smell checks'
|
139
|
-
begin
|
140
|
-
require 'reek/rake/task'
|
141
|
-
rescue LoadError
|
142
|
-
task :reek do
|
143
|
-
puts "reek gem is not installed"
|
144
|
-
end
|
145
|
-
else
|
146
|
-
Reek::Rake::Task.new(:reek) do |t|
|
147
|
-
t.fail_on_error = false
|
148
|
-
# t.config_files = '.reek.yml'
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
else
|
153
|
-
namespace :integration do
|
99
|
+
namespace :integration do
|
100
|
+
begin
|
101
|
+
require "kitchen"
|
102
|
+
rescue LoadError
|
154
103
|
task :vagrant do
|
155
|
-
puts "test-kitchen
|
104
|
+
puts "test-kitchen gem is not installed"
|
156
105
|
end
|
157
|
-
|
158
|
-
|
106
|
+
else
|
107
|
+
desc "Run Test Kitchen with Vagrant"
|
108
|
+
task :vagrant do
|
109
|
+
Kitchen.logger = Kitchen.default_file_logger
|
110
|
+
Kitchen::Config.new.instances.each do |instance|
|
111
|
+
instance.test(:always)
|
112
|
+
end
|
159
113
|
end
|
160
114
|
end
|
161
|
-
|
115
|
+
end
|
116
|
+
namespace :style do
|
117
|
+
desc "Run Ruby style checks"
|
118
|
+
begin
|
119
|
+
require "chefstyle"
|
120
|
+
require "rubocop/rake_task"
|
121
|
+
rescue LoadError
|
162
122
|
task :rubocop do
|
163
|
-
puts "
|
123
|
+
puts "chefstyle gem is not installed"
|
164
124
|
end
|
165
|
-
|
166
|
-
|
125
|
+
else
|
126
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
127
|
+
t.fail_on_error = false
|
167
128
|
end
|
168
129
|
end
|
169
130
|
end
|
170
131
|
|
171
|
-
desc
|
172
|
-
task style: [
|
132
|
+
desc "Run all style checks"
|
133
|
+
task style: ["style:rubocop"]
|
173
134
|
|
174
|
-
desc
|
135
|
+
desc "Run style + spec tests by default on travis"
|
175
136
|
task travis: %w{style spec}
|
176
137
|
|
177
|
-
desc
|
178
|
-
task
|
179
|
-
|
180
|
-
task default: ['style', 'spec', 'integration:vagrant']
|
138
|
+
desc "Run style + spec tests by default"
|
139
|
+
task default: %w{compile style spec}
|
data/bin/ffi-yajl-bench
CHANGED
@@ -2,31 +2,31 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH << File.expand_path(File.join(File.dirname( File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ ), "../lib"))
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require "optparse"
|
6
|
+
require "ffi_yajl/benchmark"
|
7
7
|
|
8
8
|
opts = {}
|
9
9
|
optparse = OptionParser.new do |o|
|
10
10
|
o.banner = "Usage: ffi-yajl-bench"
|
11
11
|
|
12
12
|
opts[:profile] = false
|
13
|
-
o.on(
|
13
|
+
o.on( "-p", "--profile", "Run perftools.rb profiling" ) do
|
14
14
|
opts[:profile] = true
|
15
15
|
end
|
16
16
|
|
17
|
-
o.on(
|
17
|
+
o.on( "-F", "--ffi", "Force using FFI" ) do
|
18
18
|
opts[:ffi] = true
|
19
19
|
end
|
20
20
|
|
21
|
-
o.on(
|
21
|
+
o.on( "-E", "--ext", "Force using C ext" ) do
|
22
22
|
opts[:ext] = true
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
optparse.parse!
|
27
27
|
|
28
|
-
ENV[
|
29
|
-
ENV[
|
28
|
+
ENV["FORCE_FFI_YAJL"] = "ffi" if opts[:ffi]
|
29
|
+
ENV["FORCE_FFI_YAJL"] = "ext" if opts[:ext]
|
30
30
|
|
31
31
|
if opts[:profile]
|
32
32
|
FFI_Yajl::Benchmark::ParseProfileRubyProf.new.run
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# rubocop:disable Style/GlobalVars
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "mkmf"
|
3
|
+
require "rubygems"
|
4
4
|
|
5
|
-
RbConfig::MAKEFILE_CONFIG[
|
5
|
+
RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
|
6
6
|
|
7
7
|
puts $CFLAGS
|
8
8
|
puts $LDFLAGS
|
@@ -11,6 +11,6 @@ have_header("dlfcn.h")
|
|
11
11
|
|
12
12
|
have_library("dl", "dlopen")
|
13
13
|
|
14
|
-
dir_config
|
14
|
+
dir_config "dlopen"
|
15
15
|
|
16
|
-
create_makefile
|
16
|
+
create_makefile "ffi_yajl/ext/dlopen"
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# rubocop:disable Style/GlobalVars
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
2
|
+
require "mkmf"
|
3
|
+
require "rubygems"
|
4
|
+
require "libyajl2"
|
5
5
|
|
6
|
-
RbConfig::MAKEFILE_CONFIG[
|
6
|
+
RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
|
7
7
|
|
8
8
|
# pick up the vendored libyajl2 out of the libyajl2 gem
|
9
9
|
$CFLAGS = " -I#{Libyajl2.include_path} #{$CFLAGS}"
|
@@ -16,7 +16,7 @@ puts $CFLAGS
|
|
16
16
|
puts $LDFLAGS
|
17
17
|
|
18
18
|
# except if you're doing an unoptimized gcc install we're going to help you out a bit
|
19
|
-
if RbConfig::MAKEFILE_CONFIG[
|
19
|
+
if RbConfig::MAKEFILE_CONFIG["CC"] =~ /gcc|clang/
|
20
20
|
$CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
|
21
21
|
# how many people realize that -Wall is a compiler-specific flag???
|
22
22
|
# apparently not many based on reading lots of shitty extconf.rb's out there
|
@@ -34,32 +34,32 @@ end
|
|
34
34
|
|
35
35
|
# NOTE: find_library has the side effect of adding -lyajl to the flags which we are deliberately
|
36
36
|
# avoiding doing with the libyajl2-gem (allowing it to be lazily loaded with dlopen)
|
37
|
-
if !windows? && !find_header(
|
37
|
+
if !windows? && !find_header("yajl/yajl_tree.h")
|
38
38
|
puts "libyajl2 headers not found in libyajl2-gem, searching for system libraries..."
|
39
39
|
|
40
40
|
HEADER_DIRS = [
|
41
41
|
"/opt/local/include", # MacPorts
|
42
42
|
"/usr/local/include", # /usr/local
|
43
|
-
RbConfig::CONFIG[
|
43
|
+
RbConfig::CONFIG["includedir"], # Ruby
|
44
44
|
"/usr/include", # (default)
|
45
45
|
]
|
46
46
|
|
47
47
|
LIB_DIRS = [
|
48
48
|
"/opt/local/lib", # MacPorts
|
49
49
|
"/usr/local/lib", # /usr/local + Homebrew
|
50
|
-
RbConfig::CONFIG[
|
50
|
+
RbConfig::CONFIG["libdir"], # Ruby
|
51
51
|
"/usr/lib", # (default)
|
52
52
|
]
|
53
53
|
|
54
54
|
# add --with-yajl-dir, --with-yajl-include, --with-yajl-lib
|
55
|
-
dir_config(
|
55
|
+
dir_config("yajl", HEADER_DIRS, LIB_DIRS)
|
56
56
|
|
57
57
|
# here we use find_library in order to deliberately link with -lyajl as a useful side-effect
|
58
|
-
unless find_header(
|
58
|
+
unless find_header("yajl/yajl_tree.h") && find_library("yajl", "yajl_complete_parse")
|
59
59
|
abort "libyajl2 is missing. please install libyajl2"
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
dir_config
|
63
|
+
dir_config "encoder"
|
64
64
|
|
65
|
-
create_makefile
|
65
|
+
create_makefile "ffi_yajl/ext/encoder"
|