summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-02-06 14:35:43 +0100
committerGitHub <noreply@github.com>2017-02-06 14:35:43 +0100
commitc43538d517855d5d8f6b961de8465ba942917350 (patch)
treedcb13c8cb94000278fa9d763b6311730d19ff3a0
parent4d1282d1631e8ff50d9e4ab5bc01590649c712d7 (diff)
parent44e02ff8185c5ad3da6448b6caff9d2a3a9b332f (diff)
downloadimag-c43538d517855d5d8f6b961de8465ba942917350.zip
imag-c43538d517855d5d8f6b961de8465ba942917350.tar.gz
Merge pull request #871 from matthiasbeyer/ruby-build-setup
Ruby build setup
-rw-r--r--.travis.yml46
-rw-r--r--Makefile4
-rw-r--r--default.nix2
-rw-r--r--libimagruby/.gitignore2
-rw-r--r--libimagruby/Makefile26
-rw-r--r--libimagruby/Rakefile5
-rw-r--r--libimagruby/ext/Rakefile5
-rw-r--r--libimagruby/imag.gemspec3
-rw-r--r--libimagruby/lib/imag.rb7
-rw-r--r--libimagruby/test/test_entries.rb27
-rw-r--r--libimagruby/test/test_ruby.rb58
-rw-r--r--libimagruby/test/test_store.rb16
12 files changed, 78 insertions, 123 deletions
diff --git a/.travis.yml b/.travis.yml
index 797ab53..0e1526b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,14 +1,40 @@
sudo: false
+os:
+ - linux
+
+dist:
+ - trusty
+
language: rust
-rust:
-- 1.13.0
-- beta
-- stable
-cache: cargo
+
+matrix:
+ include:
+ - rust: 1.13.0
+ env: IMAG_RUBY_VERSION=2.3.3
+ - rust: beta
+ env: IMAG_RUBY_VERSION=2.3.3
+ - rust: stable
+ env: IMAG_RUBY_VERSION=2.3.3
+
+cache:
+ cargo: true
+ directories:
+ - $TRAVIS_BUILD_DIR/libimagruby/vendor/bundle
+
+before_install:
+- |
+ rvm install "$IMAG_RUBY_VERSION"
+ rvm use "$IMAG_RUBY_VERSION"
+ ruby --version
+ pushd libimagruby
+ bundle install --jobs=3 --retry=3 --path=$TRAVIS_BUILD_DIR/libimagruby/vendor/bundle
+ popd
+
before_script:
- |
pip install 'travis-cargo<0.2' --user &&
export PATH=$HOME/.local/bin:$PATH
+
script:
- |
make all test
@@ -25,12 +51,14 @@ addons:
- tree
sources:
- kalakris-cmake
+
after_success:
- |
pushd .imag-documentation &&
travis-cargo --only stable doc &&
travis-cargo --only stable doc-upload
popd
+
notifications:
email:
on_success: never
@@ -39,7 +67,11 @@ notifications:
- chat.freenode.net#imag
template:
- "%{repository_name} (%{branch} @ %{commit} by %{author}): %{result}"
+
env:
global:
- - TRAVIS_CARGO_NIGHTLY_FEATURE=dev
- - secure: D+3exBnbvzFvk7fvLOxkF7UotCc4gBbvvOW4xGr9u6dDjEjV5y6CdDy/OQAkhfKhvSou+lIC22g5MuCBQXFEf/ua7A1XzwBAFeVLK4cWZSa7+ql6LdHKqOg3oF6pQlh095WeWr8S2PYJFFJFg8RGUPnbjqdu1J4KSXqe/7GoZ3lYS69mx7D5Hb93KEN084/KGfBuvyJtMjO1fK3spltL2zV8oqegFpv0gLG5GY4LsJ/7ij4Mc6wepXSyyQbaiA1eKMMwQZDvoi4V1mCulo/jeC3pucGxvgnMV5DZs8aa8R7votltGvSpHCgU78LW19dg8oZqwShQQ+XUYw27H+QK5V1lz1l1MaJLbwS3ySyZBPGH8qUuOzQ3bLp9xhAIRgCui3kX/UDhmeME7nJI6k3UZydh+/ydNB1BZHTKn76XS/yFj0Gcibxg7f5fcAYA6Ge5Sg+YPozuwbcKnKe6IpN2M7qNgWa+6MCSXJ1v4BgPb7kN74EynJUM8+yWEFN7MZtWEUQ4ZsHdCs8Pub4C/zHpYGV8qGenZwQzosAFq56YwoGCvJezz35yg4BDd3IMKenOzNnXLBrdxxqX8ySgwt5B3zBqwve/64Lx6OXjae2m8wZKlsmeqad/s6K7nx0zG15/qqRIzyvgcLXq3jwBaHkteq49FRFWvHQFpBQcsPZ2uH4=
+ - THERMITE_DEBUG_FILENAME=/tmp/thermite-debug.log
+ - secure: D+3exBnbvzFvk7fvLOxkF7UotCc4gBbvvOW4xGr9u6dDjEjV5y6CdDy/OQAkhfKhvSou+lIC22g5MuCBQXFEf/ua7A1XzwBAFeVLK4cWZSa7+ql6LdHKqOg3oF6pQlh095WeWr8S2PYJFFJFg8RGUPnbjqdu1J4KSXqe/7GoZ3lYS69mx7D5Hb93KEN084/KGfBuvyJtMjO1fK3spltL2zV8oqegFpv0gLG5GY4LsJ/7ij4Mc6wepXSyyQbaiA1eKMMwQZDvoi4V1mCulo/jeC3pucGxvgnMV5DZs8aa8R7votltGvSpHCgU78LW19dg8oZqwShQQ+XUYw27H+QK5V1lz1l1MaJLbwS3ySyZBPGH8qUuOzQ3bLp9xhAIRgCui3kX/UDhmeME7nJI6k3UZydh+/ydNB1BZHTKn76XS/yFj0Gcibxg7f5fcAYA6Ge5Sg+YPozuwbcKnKe6IpN2M7qNgWa+6MCSXJ1v4BgPb7kN74EynJUM8+yWEFN7MZtWEUQ4ZsHdCs8Pub4C/zHpYGV8qGenZwQzosAFq56YwoGCvJezz35yg4BDd3IMKenOzNnXLBrdxxqX8ySgwt5B3zBqwve/64Lx6OXjae2m8wZKlsmeqad/s6K7nx0zG15/qqRIzyvgcLXq3jwBaHkteq49FRFWvHQFpBQcsPZ2uH4=
+ matrix:
+ - IMAG_RUBY_VERSION=2.3.3
+ - IMAG_RUBY_VERSION=2.4.0
diff --git a/Makefile b/Makefile
index e47c0c1..42f629f 100644
--- a/Makefile
+++ b/Makefile
@@ -68,9 +68,9 @@ lib: $(LIB_TARGETS)
lib-test: $(LIB_TARGETS_TEST)
lib-imag-ruby-test:
- @$(MAKE) -C libimagruby
+ @$(MAKE) -C libimagruby test
-test: bin-test lib-test
+test: bin-test lib-test lib-imag-ruby-test
install: $(INSTALL_TARGETS) imag-bin-install
@$(ECHO) "\t[INSTALL]"
diff --git a/default.nix b/default.nix
index c0dfb89..5d8e76d 100644
--- a/default.nix
+++ b/default.nix
@@ -7,6 +7,8 @@ let
];
dependencies = with pkgs; [
+ ruby
+ bundler
cmake
curl
gcc
diff --git a/libimagruby/.gitignore b/libimagruby/.gitignore
index 2f7c731..d76ba1a 100644
--- a/libimagruby/.gitignore
+++ b/libimagruby/.gitignore
@@ -1,3 +1,5 @@
.bundle
Gemfile.lock
+lib/liblibimagruby.so
vendor/bundle
+libimagruby*.tar.gz
diff --git a/libimagruby/Makefile b/libimagruby/Makefile
index f7ed82d..f597909 100644
--- a/libimagruby/Makefile
+++ b/libimagruby/Makefile
@@ -1,20 +1,22 @@
ECHO=$(shell which echo) -e
RUBY=$(shell which ruby)
-RUBY_TESTS=$(shell find ./test -maxdepth 1 -name "*.rb" -type f)
-RUBY_TEST_TARGETS=$(foreach x,$(subst ,,$(RUBY_TESTS)),$(x))
+BUNDLE=$(shell which bundle)
-all: lib
+all:
+ @$(ECHO) "There is no default target here"
-lib:
- $(MAKE) -C .. libimagruby
+bundle:
+ @$(ECHO) "[BUNDLE]"
+ @$(BUNDLE) install --path vendor/bundle
-lib-release:
- $(MAKE) -C .. libimagruby-release
+bundle-rake-thermite-test:
+ @$(ECHO) "[RAKE ][thermite]"
+ @CARGO_TARGET=debug $(BUNDLE) exec rake thermite:tarball
-test: lib $(RUBY_TEST_TARGETS)
-
-$(RUBY_TEST_TARGETS): %: lib .FORCE
- @$(ECHO) "\t[TEST ]:\t$@"
- @$(RUBY) $(subst -test,,$@)
+test: lib bundle-rake-thermite-test
+ @$(ECHO) "[TEST ]"
.FORCE:
+
+.PHONY: all
+
diff --git a/libimagruby/Rakefile b/libimagruby/Rakefile
index 43022f7..a139744 100644
--- a/libimagruby/Rakefile
+++ b/libimagruby/Rakefile
@@ -1,2 +1,5 @@
require "bundler/gem_tasks"
-task :default => :spec
+require 'thermite/tasks'
+
+Thermite::Tasks.new(cargo_project_path: "..", cargo_workspace_member: "libimagruby")
+
diff --git a/libimagruby/ext/Rakefile b/libimagruby/ext/Rakefile
new file mode 100644
index 0000000..4e09736
--- /dev/null
+++ b/libimagruby/ext/Rakefile
@@ -0,0 +1,5 @@
+require 'thermite/tasks'
+
+Thermite::Tasks.new(cargo_project_path: "..", cargo_workspace_member: "libimagruby")
+task default: %w(thermite:build)
+
diff --git a/libimagruby/imag.gemspec b/libimagruby/imag.gemspec
index c606691..5ffa7a6 100644
--- a/libimagruby/imag.gemspec
+++ b/libimagruby/imag.gemspec
@@ -23,4 +23,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.13"
spec.add_development_dependency "rake", "~> 10.0"
+ spec.add_development_dependency 'thermite', "~> 0.11", ">= 0.11.1"
+
+ spec.extensions << 'ext/Rakefile'
end
diff --git a/libimagruby/lib/imag.rb b/libimagruby/lib/imag.rb
index b8c9111..d0db0d5 100644
--- a/libimagruby/lib/imag.rb
+++ b/libimagruby/lib/imag.rb
@@ -1,5 +1,12 @@
#!/usr/bin/env ruby
+require 'thermite/fiddle'
+
+toplevel_dir = File.dirname(File.dirname(__FILE__))
+Thermite::Fiddle.load_module('init_imag',
+ cargo_project_path: toplevel_dir,
+ ruby_project_path: toplevel_dir)
+
module Imag
IMAG_INIT_FN_NAME = 'imag_ruby_initialize'
diff --git a/libimagruby/test/test_entries.rb b/libimagruby/test/test_entries.rb
deleted file mode 100644
index f10dc64..0000000
--- a/libimagruby/test/test_entries.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env ruby
-
-require "../target/debug/liblibimagruby.so"
-
-color = true
-verbose = true
-debug = false
-
-RImag.init_logger debug, verbose, color
-
-store_handle = RStoreHandle::new(false, "/tmp/store")
-id = RStoreId::new_baseless("test")
-test_handle = store_handle.retrieve(id)
-puts "Header: #{test_handle.header.to_s}"
-puts "Content: '#{test_handle.content}'"
-
-test_handle.content = "Foo"
-test_handle.header = {
- "imag" => {
- "links" => [],
- "version" => "0.2.0"
- },
- "example" => {
- "test" => "foo"
- }
-}
-
diff --git a/libimagruby/test/test_ruby.rb b/libimagruby/test/test_ruby.rb
deleted file mode 100644
index 9b08859..0000000
--- a/libimagruby/test/test_ruby.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env ruby
-
-require "../target/debug/liblibimagruby.so"
-
-color = true
-verbose = true
-debug = true
-
-RImag.init_logger debug, verbose, color
-
-RImag.trace "Trace-Hello from Ruby"
-RImag.dbg "Debug-Hello from Ruby"
-RImag.debug "Debug-Hello from Ruby"
-RImag.info "Info-Hello from Ruby"
-RImag.warn "Warn-Hello from Ruby"
-RImag.error "Error-Hello from Ruby"
-
-def works name, b
- if b
- RImag.info "Works: #{name}"
- else
- RImag.error "Fails: #{name}"
- end
-end
-
-def has_instance_method klass, meth
- works "#{klass}.instance_methods.include? #{meth}",
- (klass.instance_methods.include? meth)
-end
-
-puts "---"
-
-works "RStoreId.new_baseless", (not RStoreId.new_baseless("test").nil?)
-
-works "RStoreHandle.respond_to? :new", (RStoreHandle.respond_to? :new)
-
-has_instance_method RStoreHandle, :create
-has_instance_method RStoreHandle, :get
-has_instance_method RStoreHandle, :retrieve
-has_instance_method RStoreHandle, :delete
-has_instance_method RStoreHandle, :update
-has_instance_method RStoreHandle, :move_by_id
-has_instance_method RStoreHandle, :save_as
-has_instance_method RStoreHandle, :save_to
-
-has_instance_method RFileLockEntryHandle, :content
-has_instance_method RFileLockEntryHandle, :content=
-has_instance_method RFileLockEntryHandle, :header
-has_instance_method RFileLockEntryHandle, :header=
-
-has_instance_method REntryHeader, :read
-has_instance_method REntryHeader, :[]
-has_instance_method REntryHeader, :set
-has_instance_method REntryHeader, :[]=
-has_instance_method REntryHeader, :insert
-
-works "REntryContent.superclass == String", (REntryContent.superclass == String)
-
diff --git a/libimagruby/test/test_store.rb b/libimagruby/test/test_store.rb
deleted file mode 100644
index aed0017..0000000
--- a/libimagruby/test/test_store.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env ruby
-
-require "../target/debug/liblibimagruby.so"
-
-color = true
-verbose = true
-debug = true
-
-RImag.init_logger debug, verbose, color
-
-store_handle = RStoreHandle::new(false, "/tmp/store")
-id = RStoreId::new_baseless("test")
-test_handle = store_handle.create(id)
-
-RImag.info "Created #{test_handle.location.to_str} from Ruby"
-