ffi-nats-core 0.2.2 → 0.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/.gitmodules +3 -0
- data/Rakefile +17 -0
- data/ext/ffi/nats/core/Rakefile +66 -0
- data/ffi-nats-core.gemspec +2 -1
- data/lib/ffi/nats/core.rb +14 -4
- data/lib/ffi/nats/core/version.rb +1 -1
- metadata +19 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 043c01bc38fc465f9821578a42577235e5ab4991
|
4
|
+
data.tar.gz: ed03d81c41b868b9c694800364cd2b0ceef7739c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 136c51044e57100eabc6357e48795185058a9006ba057dde970786fb35d6aaccaff4605511cb131b8807b9b27636c0a5cddccc46bc5860cce696f69d5b0b85a0
|
7
|
+
data.tar.gz: 51460c9f09582ef1f9eae1120cee8054150d5a424e3adf91b834a16d991cf72a05787f81f89d4b71e0cc715e8603ed64c4e07490df0981c9bf18c640768e6652
|
data/.gitmodules
ADDED
data/Rakefile
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
|
+
import "ext/ffi/nats/core/Rakefile"
|
4
|
+
|
5
|
+
namespace :cnats do
|
6
|
+
desc "build cnats"
|
7
|
+
task :compile do
|
8
|
+
Rake::Task[:compile_cnats].invoke
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "checkout cnats source"
|
12
|
+
task :checkout do
|
13
|
+
unless ::File.directory?("vendor/cnats/build")
|
14
|
+
sh "git submodule update --init"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
Rake::Task["cnats:compile"].prerequisites.insert(0, "cnats:checkout")
|
3
19
|
|
4
20
|
Rake::TestTask.new(:test) do |t|
|
5
21
|
t.libs << "test"
|
6
22
|
t.libs << "lib"
|
7
23
|
t.test_files = FileList['test/**/*_test.rb']
|
8
24
|
end
|
25
|
+
Rake::Task[:test].prerequisites << "cnats:compile"
|
9
26
|
|
10
27
|
task :default => :test
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "fileutils"
|
3
|
+
require "ffi"
|
4
|
+
|
5
|
+
# Copied fom mkmf
|
6
|
+
def find_executable(bin, path = nil)
|
7
|
+
executable_file = proc do |name|
|
8
|
+
begin
|
9
|
+
stat = File.stat(name)
|
10
|
+
rescue SystemCallError
|
11
|
+
else
|
12
|
+
next name if stat.file? and stat.executable?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if File.expand_path(bin) == bin
|
17
|
+
return bin if executable_file.call(bin)
|
18
|
+
return nil
|
19
|
+
end
|
20
|
+
if path ||= ENV['PATH']
|
21
|
+
path = path.split(File::PATH_SEPARATOR)
|
22
|
+
else
|
23
|
+
path = %w[/usr/local/bin /usr/ucb /usr/bin /bin]
|
24
|
+
end
|
25
|
+
file = nil
|
26
|
+
path.each do |dir|
|
27
|
+
return file if executable_file.call(file = File.join(dir, bin))
|
28
|
+
end
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def sys(cmd)
|
33
|
+
puts " -- #{cmd}"
|
34
|
+
unless ret = system(cmd)
|
35
|
+
raise "ERROR: '#{cmd}' failed"
|
36
|
+
end
|
37
|
+
ret
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Build the cnats shared lib"
|
41
|
+
task :compile_cnats do
|
42
|
+
# Do not attempt to install if we want to use the system nats lib
|
43
|
+
next if ENV.key?("NATS_USE_SYSTEM_LIB")
|
44
|
+
|
45
|
+
if !find_executable("cmake")
|
46
|
+
abort "ERROR: CMake is required to build ffi-nats-core."
|
47
|
+
end
|
48
|
+
|
49
|
+
CWD = ::File.expand_path(::File.dirname(__FILE__))
|
50
|
+
CNATS_DIR = ::File.join(CWD, "..", "..", "..", "..", "vendor", "cnats")
|
51
|
+
|
52
|
+
::Dir.chdir(CNATS_DIR) do
|
53
|
+
::Dir.mkdir("build") unless ::Dir.exists?("build")
|
54
|
+
|
55
|
+
::Dir.chdir("build") do
|
56
|
+
sys("cmake ..")
|
57
|
+
sys("make nats")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
unless ::File.exist?(::File.join(CNATS_DIR, "build", "src", "libnats.#{::FFI::Platform::LIBSUFFIX}"))
|
62
|
+
abort "ERROR: Failed to build nats"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
task :default => :compile_cnats
|
data/ffi-nats-core.gemspec
CHANGED
@@ -17,13 +17,14 @@ Gem::Specification.new do |spec|
|
|
17
17
|
f.match(%r{^(test|spec|features)/})
|
18
18
|
end
|
19
19
|
spec.bindir = "exe"
|
20
|
+
spec.extensions = "ext/ffi/nats/core/Rakefile"
|
20
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
22
|
spec.require_paths = ["lib"]
|
22
23
|
|
23
24
|
spec.add_dependency "ffi"
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.13"
|
27
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
26
28
|
spec.add_development_dependency "pry"
|
27
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
29
30
|
end
|
data/lib/ffi/nats/core.rb
CHANGED
@@ -27,7 +27,8 @@ module FFI
|
|
27
27
|
begin
|
28
28
|
# bias the library discovery to a path inside the gem first, then
|
29
29
|
# to the usual system paths
|
30
|
-
|
30
|
+
gem_base = File.join(File.dirname(__FILE__), '..', '..', '..')
|
31
|
+
inside_gem = File.join(gem_base, 'ext')
|
31
32
|
local_path = FFI::Platform::IS_WINDOWS ? ENV['PATH'].split(';') : ENV['PATH'].split(':')
|
32
33
|
env_path = [ ENV['NATS_LIB_PATH'] ].compact
|
33
34
|
rbconfig_path = RbConfig::CONFIG["libdir"]
|
@@ -51,9 +52,18 @@ module FFI
|
|
51
52
|
ENV['RUBYOPT'] = rubyopt
|
52
53
|
|
53
54
|
# Search for libnats in the following order...
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
nats_lib_paths =
|
56
|
+
if ENV.key?("NATS_USE_SYSTEM_LIB")
|
57
|
+
[inside_gem] + env_path + local_path + [rbconfig_path] + [
|
58
|
+
'/usr/local/lib', '/opt/local/lib', homebrew_path, '/usr/lib64'
|
59
|
+
]
|
60
|
+
else
|
61
|
+
[File.join(gem_base, "vendor/cnats/build/src")]
|
62
|
+
end
|
63
|
+
|
64
|
+
NATS_LIB_PATHS = nats_lib_paths.
|
65
|
+
compact.map{|path| "#{path}/libnats.#{FFI::Platform::LIBSUFFIX}"}
|
66
|
+
|
57
67
|
ffi_lib(NATS_LIB_PATHS + %w{libnats})
|
58
68
|
|
59
69
|
rescue LoadError => error
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-nats-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dewitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -39,61 +39,64 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '5.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '5.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '10.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '10.0'
|
83
83
|
description: " core ffi bindings for ffi-nats "
|
84
84
|
email:
|
85
85
|
- brandonsdewitt@gmail.com
|
86
86
|
executables: []
|
87
|
-
extensions:
|
87
|
+
extensions:
|
88
|
+
- ext/ffi/nats/core/Rakefile
|
88
89
|
extra_rdoc_files: []
|
89
90
|
files:
|
90
91
|
- ".gitignore"
|
92
|
+
- ".gitmodules"
|
91
93
|
- ".travis.yml"
|
92
94
|
- Gemfile
|
93
95
|
- README.md
|
94
96
|
- Rakefile
|
95
97
|
- bin/console
|
96
98
|
- bin/setup
|
99
|
+
- ext/ffi/nats/core/Rakefile
|
97
100
|
- ffi-nats-core.gemspec
|
98
101
|
- lib/ffi/nats/core.rb
|
99
102
|
- lib/ffi/nats/core/version.rb
|