diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | CONTRIBUTING.md | 4 | ||||
-rw-r--r-- | Gemfile | 3 | ||||
-rw-r--r-- | Gemfile.lock | 17 | ||||
-rw-r--r-- | Rakefile | 31 | ||||
-rw-r--r-- | ext/libyajl2/Makefile | 7 | ||||
-rw-r--r-- | ext/libyajl2/extconf.rb | 67 | ||||
m--------- | ext/libyajl2/vendor/yajl | 0 | ||||
-rw-r--r-- | lib/libyajl2.rb | 13 | ||||
-rw-r--r-- | lib/libyajl2/vendored-libyajl2/.gitkeep | 0 | ||||
-rw-r--r-- | lib/libyajl2/version.rb | 3 | ||||
-rw-r--r-- | libyajl2.gemspec | 26 |
12 files changed, 174 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..07a1edc --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ext/libyajl2/vendor/yajl"] + path = ext/libyajl2/vendor/yajl + url = https://github.com/lloyd/yajl.git diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ad306d8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +# Contributing + +No contributions from outside of Chef Software, Inc. for now. + @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gemspec diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..47b5996 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,17 @@ +PATH + remote: . + specs: + libyajl2 (0.0.1) + +GEM + remote: https://rubygems.org/ + specs: + rake (10.2.2) + +PLATFORMS + ruby + +DEPENDENCIES + bundler (~> 1.5) + libyajl2! + rake diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..4864073 --- /dev/null +++ b/Rakefile @@ -0,0 +1,31 @@ +require 'rubygems' +require 'rake' + +require 'rubygems/package_task' + +GEM_NAME="libyajl2" + +gemspec = eval(File.read('libyajl2.gemspec')) + +Gem::PackageTask.new(gemspec) do |pkg| + pkg.need_tar = true +end + +task :install => :repackage do + sh %{gem install pkg/#{GEM_NAME}-#{Libyajl2::VERSION}.gem --no-rdoc --no-ri} +end + +task :uninstall do + sh %{gem uninstall #{GEM_NAME} -x -v #{Libyajl2::VERSION} } +end + +task :compile do + cd "ext/libyajl2" + ruby "extconf.rb" +end + +task :clean do + sh "git clean -fdx" + cd "ext/libyajl2/vendor/yajl" + sh "git clean -fdx" +end diff --git a/ext/libyajl2/Makefile b/ext/libyajl2/Makefile new file mode 100644 index 0000000..215b8c1 --- /dev/null +++ b/ext/libyajl2/Makefile @@ -0,0 +1,7 @@ +# We do all the work in extconf.rb, so we just have a dummy makefile here to +# make rubygems happy. + +all: + +install: + diff --git a/ext/libyajl2/extconf.rb b/ext/libyajl2/extconf.rb new file mode 100644 index 0000000..64c34a0 --- /dev/null +++ b/ext/libyajl2/extconf.rb @@ -0,0 +1,67 @@ +exit(0) if ENV["USE_SYSTEM_LIBYAJL2"] + +require 'pp' + +module Libyajl2Build + class BuildError < StandardError; end + + LIBYAJL2_VENDOR_DIR = File.expand_path("../vendor/yajl", __FILE__).freeze + + PREFIX = File.expand_path("../../../lib/libyajl2/vendored-libyajl2", __FILE__).freeze + + def self.windows? + !!(RUBY_PLATFORM =~ /mswin|mingw|windows/) + end + + def self.libyajl2_vendor_dir + LIBYAJL2_VENDOR_DIR + end + + def self.configure + File.join(LIBYAJL2_VENDOR_DIR, "configure") + end + + def self.prefix + PREFIX + end + + def self.configure_cmd + args = %W[ + sh + #{configure} + --prefix=#{prefix} + ] + end + + def self.setup_env + if windows? + ENV['CC'] = 'gcc' + ENV['CXX'] = 'g++' + end + end + + def self.system(*args) + print("-> #{args.join(' ')}\n") + super(*args) + end + + def self.run_build_commands + setup_env + puts `pwd` + puts `env` + puts configure_cmd + system(*configure_cmd) && + system("make", "clean") && + system("make", "-j", "5") && + system("make", "install") + end + + def self.run + Dir.chdir(libyajl2_vendor_dir) do + run_build_commands or raise BuildError, "Failed to build libyajl2 library." + end + end + +end + +Libyajl2Build.run diff --git a/ext/libyajl2/vendor/yajl b/ext/libyajl2/vendor/yajl new file mode 160000 +Subproject 12ee82ae5138ac86252c41f3ae8f9fd9880e428 diff --git a/lib/libyajl2.rb b/lib/libyajl2.rb new file mode 100644 index 0000000..904a7e3 --- /dev/null +++ b/lib/libyajl2.rb @@ -0,0 +1,13 @@ +require "libyajl2/version" + +module Libyajl2 + VENDORED_LIBYAJL2_DIR = File.expand_path("../libyajl2/vendored-libyajl2", __FILE__) + + def self.opt_path + File.join(VENDORED_LIBYAJL2_DIR, "lib") + end + + def self.include_path + File.join(VENDORED_LIBYAJL2_DIR, "include") + end +end diff --git a/lib/libyajl2/vendored-libyajl2/.gitkeep b/lib/libyajl2/vendored-libyajl2/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/libyajl2/vendored-libyajl2/.gitkeep diff --git a/lib/libyajl2/version.rb b/lib/libyajl2/version.rb new file mode 100644 index 0000000..1cc30c5 --- /dev/null +++ b/lib/libyajl2/version.rb @@ -0,0 +1,3 @@ +module Libyajl2 + VERSION = "0.0.1" +end diff --git a/libyajl2.gemspec b/libyajl2.gemspec new file mode 100644 index 0000000..a6b42d9 --- /dev/null +++ b/libyajl2.gemspec @@ -0,0 +1,26 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'libyajl2/version' + +Gem::Specification.new do |spec| + spec.name = "libyajl2" + spec.version = Libyajl2::VERSION + spec.authors = ["lamont-granquist"] + spec.email = ["lamont@scriptkiddie.org"] + spec.summary = %q{Installs a vendored copy of libyajl2 for distributions which lack it} + spec.description = spec.summary + spec.homepage = "" + spec.licenses = ["Apache 2.0"] + + spec.files = `git ls-files -z`.split("\x0") + + `find ext/libyajl2/vendor/yajl -type f -print0`.split("\x0") + spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ["lib"] + + spec.extensions = Dir["ext/**/extconf.rb"] + + spec.add_development_dependency "bundler", "~> 1.5" + spec.add_development_dependency "rake" +end |