summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-04-22 11:20:31 +0200
committerGitHub <noreply@github.com>2017-04-22 11:20:31 +0200
commit6fa281a1a4e0c99b4bcb5a95f016018ef7453cd3 (patch)
tree79f421f78af4d71993ea7c9aa20156b17ff71914
parent9396accc28a63d280b61e2206320a6b1afeafdc3 (diff)
parent883c3a5b7ada812a67ccd6519b1f817bc030028b (diff)
downloadimag-6fa281a1a4e0c99b4bcb5a95f016018ef7453cd3.zip
imag-6fa281a1a4e0c99b4bcb5a95f016018ef7453cd3.tar.gz
Merge pull request #895 from matthiasbeyer/redo-ruby-build-setup
Redo ruby build setup
-rw-r--r--Makefile9
-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.rb14
-rw-r--r--libimagruby/test/test_entries.rb27
-rw-r--r--libimagruby/test/test_ruby.rb83
-rw-r--r--libimagruby/test/test_store.rb16
11 files changed, 43 insertions, 149 deletions
diff --git a/Makefile b/Makefile
index 9d10436..838ba1c 100644
--- a/Makefile
+++ b/Makefile
@@ -47,15 +47,18 @@ bin: $(BIN_TARGETS) imag-bin
bin-test: $(BIN_TARGET_TESTS) imag-bin
-lib: $(LIB_TARGETS)
+lib: $(LIB_TARGETS) lib-imag-ruby-tarball
@$(ECHO) "\t[ALLLIB ]"
lib-test: $(LIB_TARGETS_TEST)
+lib-imag-ruby-tarball:
+ @$(MAKE) -C libimagruby tarball
+
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..bf023b9 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
+tarball: bundle
+ @$(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: tarball
+ @$(ECHO) "[TEST ] Not yet implemented. :-("
.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 a42fef1..0938c50 100644
--- a/libimagruby/lib/imag.rb
+++ b/libimagruby/lib/imag.rb
@@ -36,37 +36,37 @@ module Imag
debug = !!cfg[:debug]
verbose = !!cfg[:verbose]
color = !!cfg[:color]
- RImag.init_logger debug, verbose, color
+ ::RImag.init_logger debug, verbose, color
end
# Log text with "trace" level in imag
def self.trace msg
- RImag.trace msg
+ ::RImag.trace msg
end
# Log text with "debug" level in imag
def self.dbg msg
- RImag.dbg msg
+ ::RImag.dbg msg
end
# Log text with "debug" level in imag (alias for Imag::Logger::dbg)
def self.debug msg
- RImag.debug msg
+ ::RImag.debug msg
end
# Log text with "info" level in imag
def self.info msg
- RImag.info msg
+ ::RImag.info msg
end
# Log text with "warning" level in imag
def self.warn msg
- RImag.warn msg
+ ::RImag.warn msg
end
# Log text with "error" level in imag
def self.error msg
- RImag.error msg
+ ::RImag.error msg
end
end
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 1c777a1..0000000
--- a/libimagruby/test/test_ruby.rb
+++ /dev/null
@@ -1,83 +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 "---"
-
-[
- :RImag,
- :RStoreId,
- :RStoreHandle,
- :RFileLockEntryHandle,
- :REntryHeader,
- :REntryContent,
- :RImagError,
- :RImagObjDoesNotExistError,
- :RImagStoreError,
- :RImagStoreWriteError,
- :RImagStoreReadError,
- :RImagEntryError,
- :RImagEntryHeaderError,
- :RImagEntryHeaderReadError,
- :RImagEntryHeaderWriteError,
- :RImagTypeError,
-].each do |sym|
- if Kernel.const_defined? sym
- RImag.info "Exists: #{sym}"
- else
- RImag.error "#{sym} not defined"
- end
-end
-
-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"
-