diff --git a/.travis.yml b/.travis.yml index 797ab53e..0e1526b2 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+QK5V1lz1l1MaJLbwS3ySyZBPGH8qUuOzQ3bLp9xhAI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ERSION=2.4.0 diff --git a/Makefile b/Makefile index e47c0c1d..42f629f8 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 c0dfb890..5d8e76d5 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 2f7c731a..d76ba1ac 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 f7ed82d6..f597909a 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 43022f71..a1397441 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 00000000..4e097360 --- /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 c6066912..5ffa7a62 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 b8c91115..d0db0d53 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 f10dc643..00000000 --- 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 9b088594..00000000 --- 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 aed00177..00000000 --- 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" -