Merge pull request #895 from matthiasbeyer/redo-ruby-build-setup

Redo ruby build setup
This commit is contained in:
Matthias Beyer 2017-04-22 11:20:31 +02:00 committed by GitHub
commit 6fa281a1a4
11 changed files with 44 additions and 150 deletions

View file

@ -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-test:
@$(MAKE) -C libimagruby
lib-imag-ruby-tarball:
@$(MAKE) -C libimagruby tarball
test: bin-test lib-test
lib-imag-ruby-test:
@$(MAKE) -C libimagruby test
test: bin-test lib-test lib-imag-ruby-test
install: $(INSTALL_TARGETS) imag-bin-install
@$(ECHO) "\t[INSTALL]"

View file

@ -7,6 +7,8 @@ let
];
dependencies = with pkgs; [
ruby
bundler
cmake
curl
gcc

View file

@ -1,3 +1,5 @@
.bundle
Gemfile.lock
lib/liblibimagruby.so
vendor/bundle
libimagruby*.tar.gz

View file

@ -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

View file

@ -1,2 +1,5 @@
require "bundler/gem_tasks"
task :default => :spec
require 'thermite/tasks'
Thermite::Tasks.new(cargo_project_path: "..", cargo_workspace_member: "libimagruby")

5
libimagruby/ext/Rakefile Normal file
View file

@ -0,0 +1,5 @@
require 'thermite/tasks'
Thermite::Tasks.new(cargo_project_path: "..", cargo_workspace_member: "libimagruby")
task default: %w(thermite:build)

View file

@ -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

View file

@ -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

View file

@ -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"
}
}

View file

@ -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)

View file

@ -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"