Rakefile in gogyou-0.2.2 vs Rakefile in gogyou-0.2.3
- old
+ new
@@ -1,106 +1,149 @@
require "rake/clean"
-DOC = FileList["{README,LICENSE,CHANGELOG,Changelog}{,.ja}{,.txt,.rd,.rdoc,.md,.markdown}"] +
- FileList["ext/**/{README,LICENSE,CHANGELOG,Changelog}{,.ja}{,.txt,.rd,.rdoc,.md,.markdown}"]
+DOC = FileList["{README,LICENSE,CHANGELOG,Changelog,HISTORY}{,.ja}{,.txt,.rd,.rdoc,.md,.markdown}"] +
+ FileList["{contrib,ext}/**/{README,LICENSE,CHANGELOG,Changelog,HISTORY}{,.ja}{,.txt,.rd,.rdoc,.md,.markdown}"] +
+ FileList["ext/**/*.{c,C,cc,cxx,cpp,h,H,hh}"]
#EXT = FileList["ext/**/*.{h,hh,c,cc,cpp,cxx}"] +
# FileList["ext/externals/**/*"]
EXT = FileList["ext/**/*"]
BIN = FileList["bin/*"]
LIB = FileList["lib/**/*.rb"]
SPEC = FileList["spec/**/*"]
+TEST = FileList["test/**/*"]
EXAMPLE = FileList["examples/**/*"]
-RAKEFILE = [File.basename(__FILE__), "gemstub.rb"]
+GEMSTUB_SRC = "gemstub.rb"
+RAKEFILE = [File.basename(__FILE__), GEMSTUB_SRC]
EXTRA = []
-load "gemstub.rb"
+load GEMSTUB_SRC
EXTCONF = FileList["ext/extconf.rb"]
EXTCONF.reject! { |n| !File.file?(n) }
GEMSTUB.extensions += EXTCONF
GEMSTUB.executables += FileList["bin/*"].map { |n| File.basename n }
+GEMSTUB.executables.sort!
GEMFILE = "#{GEMSTUB.name}-#{GEMSTUB.version}.gem"
GEMSPEC = "#{GEMSTUB.name}.gemspec"
-GEMSTUB.files += DOC + EXT + EXTCONF + BIN + LIB + SPEC + EXAMPLE + RAKEFILE + EXTRA
+GEMSTUB.files += DOC + EXT + EXTCONF + BIN + LIB + SPEC + TEST + EXAMPLE + RAKEFILE + EXTRA
+GEMSTUB.files.sort!
GEMSTUB.rdoc_options ||= %w(--charset UTF-8)
GEMSTUB.extra_rdoc_files += DOC + LIB + EXT.reject { |n| n.include?("/externals/") || !%w(.h .hh .c .cc .cpp .cxx).include?(File.extname(n)) }
+GEMSTUB.extra_rdoc_files.sort!
CLEAN << GEMSPEC
CLOBBER << GEMFILE
task :default => :all
-task :all => GEMFILE
-task :rdoc => DOC + EXT + LIB do
- sh *(%w(rdoc) + GEMSTUB.rdoc_options + DOC + EXT + LIB)
-end
+unless EXTCONF.empty?
+ RUBYSET ||= (ENV["RUBYSET"] || "").split(",")
-file GEMFILE => DOC + EXT + EXTCONF + BIN + LIB + SPEC + EXAMPLE + RAKEFILE + [GEMSPEC] do
- sh "gem build #{GEMSPEC}"
-end
+ if RUBYSET.nil? || RUBYSET.empty?
+ $stderr.puts <<-EOS
+#{__FILE__}:
+|
+| If you want binary gem package, launch rake with ``RUBYSET`` enviroment
+| variable for set ruby interpreters by comma separated.
+|
+| e.g.) $ rake RUBYSET=ruby
+| or) $ rake RUBYSET=ruby20,ruby21,ruby22
+|
+ EOS
+ else
+ platforms = RUBYSET.map { |ruby| `#{ruby} --disable gems -rrbconfig -e "puts RbConfig::CONFIG['arch']"`.chomp }
+ platforms1 = platforms.uniq
+ unless platforms1.size == 1 && !platforms1[0].empty?
+ raise "different platforms (#{Hash[*RUBYSET.zip(platforms).flatten].inspect})"
+ end
+ PLATFORM = platforms1[0]
-file GEMSPEC => RAKEFILE do
- File.write(GEMSPEC, GEMSTUB.to_ruby, mode: "wb")
-end
+ RUBY_VERSIONS = RUBYSET.map do |ruby|
+ ver = `#{ruby} --disable gem -rrbconfig -e "puts RbConfig::CONFIG['ruby_version']"`.slice(/\d+\.\d+/)
+ raise "failed ruby checking - ``#{ruby}''" unless $?.success?
+ [ver, ruby]
+ end
+ SOFILES_SET = RUBY_VERSIONS.map { |(ver, ruby)| ["lib/#{ver}/#{GEMSTUB.name}.so", ruby] }
+ SOFILES = SOFILES_SET.map { |(lib, ruby)| lib }
+ GEMSTUB_NATIVE = GEMSTUB.dup
+ GEMSTUB_NATIVE.files += SOFILES
+ GEMSTUB_NATIVE.platform = Gem::Platform.new(PLATFORM).to_s
+ GEMSTUB_NATIVE.extensions.clear
+ GEMFILE_NATIVE = "#{GEMSTUB_NATIVE.name}-#{GEMSTUB_NATIVE.version}-#{GEMSTUB_NATIVE.platform}.gem"
+ GEMSPEC_NATIVE = "#{GEMSTUB_NATIVE.name}-#{GEMSTUB_NATIVE.platform}.gemspec"
-RUBYSET ||= nil
+ task :all => ["native-gem", GEMFILE]
-if RUBYSET && !RUBYSET.empty? && !EXTCONF.empty?
- RUBY_VERSIONS = RUBYSET.map do |ruby|
- ver = `#{ruby} --disable gem -rrbconfig -e "puts RbConfig::CONFIG['ruby_version']"`.chomp
- raise "failed ruby checking - ``#{ruby}''" unless $?.success?
- [ver, ruby]
- end
- SOFILES_SET = RUBY_VERSIONS.map { |(ver, ruby)| ["lib/#{ver}/#{GEMSTUB.name}.so", ruby] }
- SOFILES = SOFILES_SET.map { |(lib, ruby)| lib }
- platforms = RUBYSET.map { |ruby| `#{ruby} -rubygems -e "puts Gem::Platform.local.to_s"`.chomp }
- platforms.uniq!
- platforms.compact!
- unless platforms.size == 1
- raise "wrong platforms (#{RUBYSET.inspect} => #{platforms.inspect})"
- end
+ desc "build binary gem package"
+ task "native-gem" => GEMFILE_NATIVE
- GEMSTUB_NATIVE = GEMSTUB.dup
- GEMSTUB_NATIVE.files += SOFILES
- GEMSTUB_NATIVE.platform = platforms[0]
- GEMFILE_NATIVE = "#{GEMSTUB_NATIVE.name}-#{GEMSTUB_NATIVE.version}-#{GEMSTUB_NATIVE.platform}.gem"
- GEMSPEC_NATIVE = "#{GEMSTUB_NATIVE.name}-#{GEMSTUB_NATIVE.platform}.gemspec"
+ desc "generate binary gemspec"
+ task "native-gemspec" => GEMSPEC_NATIVE
- task :all => [GEMFILE, :native]
+ file GEMFILE_NATIVE => DOC + EXT + EXTCONF + BIN + LIB + SPEC + TEST + EXAMPLE + SOFILES + RAKEFILE + [GEMSPEC_NATIVE] do
+ sh "gem build #{GEMSPEC_NATIVE}"
+ end
- task :native => GEMFILE_NATIVE
+ file GEMSPEC_NATIVE => RAKEFILE do
+ File.write(GEMSPEC_NATIVE, GEMSTUB_NATIVE.to_ruby, mode: "wb")
+ end
- file GEMFILE_NATIVE => DOC + EXT + [EXTCONF] + BIN + LIB + SPEC + EXAMPLE + SOFILES + RAKEFILE + [GEMSPEC_NATIVE] do
- sh "gem build #{GEMSPEC_NATIVE}"
- end
+ desc "build c-extension libraries"
+ task "sofiles" => SOFILES
- file GEMSPEC_NATIVE => __FILE__ do
- File.write(GEMSPEC_NATIVE, GEMSTUB_NATIVE.to_ruby, mode: "wb")
- end
+ SOFILES_SET.each do |(soname, ruby)|
+ sodir = File.dirname(soname)
+ makefile = File.join(sodir, "Makefile")
- SOFILES_SET.each do |(soname, ruby)|
- sodir = File.dirname(soname)
- makefile = File.join(sodir, "Makefile")
+ CLEAN << GEMSPEC_NATIVE << sodir
+ CLOBBER << GEMFILE_NATIVE
- CLEAN << GEMSPEC_NATIVE << sodir
- CLOBBER << GEMFILE_NATIVE
+ directory sodir
- directory sodir
-
- file soname => [makefile] + EXT do
- cd sodir do
- sh "make"
+ desc "generate Makefile for binary extension library"
+ file makefile => [sodir] + EXTCONF do
+ cd sodir do
+ sh "#{ruby} ../../#{EXTCONF[0]} \"--ruby=#{ruby}\""
+ end
end
- end
- file makefile => [sodir] + [EXTCONF] do
- cd sodir do
- sh "#{ruby} ../../#{EXTCONF} \"--ruby=#{ruby}\""
+ desc "build binary extension library"
+ file soname => [makefile] + EXT do
+ cd sodir do
+ sh "make"
+ end
end
end
end
+end
+
+
+task :all => GEMFILE
+
+desc "generate local rdoc"
+task :rdoc => DOC + LIB do
+ sh *(%w(rdoc) + GEMSTUB.rdoc_options + DOC + LIB)
+end
+
+desc "launch rspec"
+task rspec: :all do
+ sh "rspec"
+end
+
+desc "build gem package"
+task gem: GEMFILE
+
+desc "generate gemspec"
+task gemspec: GEMSPEC
+
+file GEMFILE => DOC + EXT + EXTCONF + BIN + LIB + SPEC + TEST + EXAMPLE + RAKEFILE + [GEMSPEC] do
+ sh "gem build #{GEMSPEC}"
+end
+
+file GEMSPEC => RAKEFILE do
+ File.write(GEMSPEC, GEMSTUB.to_ruby, mode: "wb")
end