Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move Inventory-related stuff to Inventory(-rake)

  • Loading branch information...
commit 4ec899949c1b68674a05aaa98e50b6d995c12d1d 1 parent bbe1531
Nikolai Weibull authored
Showing with 6 additions and 124 deletions.
  1. +5 −62 Rakefile
  2. +1 −62 lib/u/version.rb
View
67 Rakefile
@@ -8,13 +8,12 @@ Inventory::Rake::Tasks.define U::Version, :gem => proc{ |_, s|
s.author = 'Nikolai Weibull'
s.email = 'now@bitwi.se'
s.homepage = 'https://github.com/now/u'
- # TODO Move to Inventory::Rake::Tasks::Gem.
- s.extensions = U::Version.extensions.map{ |e| e.extconf }
}
Inventory::Rake::Tasks.unless_installing_dependencies do
require 'lookout/rake-3.0'
Lookout::Rake::Tasks::Test.new
+ Lookout::Rake::Tasks::Test.new :name => :'test:normalize', :files => %w[test/unit/normalize.rb]
require 'inventory/rake/tasks/yard-1.0'
Inventory::Rake::Tasks::YARD.new do |t|
@@ -22,67 +21,11 @@ Inventory::Rake::Tasks.unless_installing_dependencies do
t.options += %w'--plugin yard-heuristics-1.0 --plugin yard-value-1.0'
t.globals[:source_code_url] = 'https://github.com/now/%s/blob/v%s/%%s#L%%d' % [t.inventory.package, t.inventory]
end
+end
- # TODO Move to inventory-rake.
- class Inventory::Rake::Tasks::Compile
- include Rake::DSL
-
- def initialize(options = {})
- self.inventory = options.fetch(:inventory, Inventory::Rake::Tasks.inventory)
- yield self if block_given?
- define
- end
-
- def define
- desc 'Compile extensions' unless Rake::Task.task_defined? :compile
- task :compile
-
- @inventory.extensions.each do |extension|
- name = :"compile:#{extension}"
- makefile = '%s/Makefile' % extension.path
- ext_so = '%s/%s.%s' % [extension.path,
- extension.name.delete('-'),
- RbConfig::CONFIG['DLEXT']]
- lib_so = 'lib/%s/%s' % [@inventory.package_path, File.basename(ext_so)]
- task :compile => name
- task name => [makefile, lib_so]
- file makefile => [@inventory.path, extension.extconf, extension.depend] do
- Dir.chdir extension.path do
- ENV['CFLAGS'] = '-Werror' unless ENV['CFLAGS']
- ruby File.basename(extension.extconf)
- sh 'make'
- end
- end
- file ext_so => extension.source_files do
- sh 'make -C %s' % extension.path
- end
- file lib_so => ext_so do
- install ext_so, lib_so
- end
- tags = '%s/TAGS' % extension.path
- file tags => extension.source_files do
- sh 'make -C %s tags' % extension.path
- end
- %w'clean distclean'.each do |rule|
- clean_name = :"#{rule}:#{extension}"
- task :clean => clean_name
- desc 'Clean files build for %s extension' % extension
- task clean_name do
- sh 'make -C %s' % rule
- end
- end
- end
-
- # TODO :check instead? Argh, this is a bit complicated
- task :test => :compile if Rake::Task.task_defined? :test
- end
-
- attr_writer :inventory
- end
-
- Inventory::Rake::Tasks::Compile.new
-
- Lookout::Rake::Tasks::Test.new :name => :'test:normalize', :files => %w[test/unit/normalize.rb]
+file 'TAGS' => U::Version.extensions.map(&:source_files).flatten do
+ rm_f 'TAGS'
+ sh 'etags %s' % U::Version.extensions.map(&:source_files).flatten.join(' ')
end
# TODO: Move to U::Version::Unicode
View
63 lib/u/version.rb
@@ -2,72 +2,11 @@
require 'inventory-1.0'
-# TODO Move to inventory.
-class Inventory::Extension
- def initialize(name)
- @name = name
- instance_exec(&Proc.new) if block_given?
- end
-
- def path
- 'ext/%s' % name
- end
-
- def extconf
- '%s/extconf.rb' % path
- end
-
- def depend
- '%s/depend' % path
- end
-
- def sources
- []
- end
-
- def source_files
- sources.map{ |e| '%s/%s' % [path, e] }
- end
-
- def additional_files
- []
- end
-
- def files
- [extconf, depend] + source_files + additional_files
- end
-
- def to_a
- files
- end
-
- def to_s
- name
- end
-
- def inspect
- '#<%s: %s %s>' % [self.class, name, path]
- end
-
- attr_reader :name
-end
-
-class Inventory
- def extensions
- []
- end
-
- undef files
- def files
- lib_files + test_files + additional_files + extensions.map{ |e| e.files }.flatten
- end
-end
-
module U
Version = Inventory.new(1, 0, 0){
def dependencies
super + Inventory::Dependencies.new{
- development 'inventory-rake', 1, 3, 0
+ development 'inventory-rake', 1, 4, 0
development 'inventory-rake-tasks-yard', 1, 3, 0
development 'lookout-rake', 3, 0, 0
development 'yard', 0, 8, 0
Please sign in to comment.
Something went wrong with that request. Please try again.