PageRenderTime 23ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/drillbit/Resources/tests/ruby/markaby/tools/rakehelp.rb

http://github.com/appcelerator/titanium_desktop
Ruby | 106 lines | 83 code | 23 blank | 0 comment | 0 complexity | a4eb28da91d7af72c01ad6c36b2fdd72 MD5 | raw file
Possible License(s): Apache-2.0
  1. def make(makedir)
  2. Dir.chdir(makedir) do
  3. sh 'make'
  4. end
  5. end
  6. def extconf(dir)
  7. Dir.chdir(dir) do ruby "extconf.rb" end
  8. end
  9. def setup_tests
  10. Rake::TestTask.new do |t|
  11. t.libs << "test"
  12. t.test_files = FileList['test/test*.rb']
  13. t.verbose = true
  14. end
  15. end
  16. def setup_clean otherfiles
  17. files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
  18. CLEAN.include(files)
  19. end
  20. def setup_rdoc files
  21. Rake::RDocTask.new do |rdoc|
  22. rdoc.rdoc_dir = 'doc/rdoc'
  23. rdoc.options << '--line-numbers'
  24. rdoc.rdoc_files.add(files)
  25. end
  26. end
  27. def setup_extension(dir, extension)
  28. ext = "ext/#{dir}"
  29. ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
  30. ext_files = FileList[
  31. "#{ext}/*.c",
  32. "#{ext}/*.h",
  33. "#{ext}/extconf.rb",
  34. "#{ext}/Makefile",
  35. "lib"
  36. ]
  37. task "lib" do
  38. directory "lib"
  39. end
  40. desc "Builds just the #{extension} extension"
  41. task extension.to_sym => ["#{ext}/Makefile", ext_so ]
  42. file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
  43. extconf "#{ext}"
  44. end
  45. file ext_so => ext_files do
  46. make "#{ext}"
  47. cp ext_so, "lib"
  48. end
  49. end
  50. def setup_gem(pkg_name, pkg_version, author, summary, dependencies, test_file)
  51. pkg_version = pkg_version
  52. pkg_name = pkg_name
  53. pkg_file_name = "#{pkg_name}-#{pkg_version}"
  54. spec = Gem::Specification.new do |s|
  55. s.name = pkg_name
  56. s.version = pkg_version
  57. s.platform = Gem::Platform::RUBY
  58. s.author = author
  59. s.summary = summary
  60. s.test_file = test_file
  61. s.has_rdoc = true
  62. s.extra_rdoc_files = [ "README" ]
  63. dependencies.each do |dep|
  64. s.add_dependency(*dep)
  65. end
  66. s.files = %w(README Rakefile setup.rb) +
  67. Dir.glob("{bin,doc,test,lib}/**/*") +
  68. Dir.glob("ext/**/*.{h,c,rb}") +
  69. Dir.glob("examples/**/*.rb") +
  70. Dir.glob("tools/*.rb")
  71. s.require_path = "lib"
  72. s.extensions = FileList["ext/**/extconf.rb"].to_a
  73. s.bindir = "bin"
  74. end
  75. Rake::GemPackageTask.new(spec) do |p|
  76. p.gem_spec = spec
  77. p.need_tar = true
  78. end
  79. task :install do
  80. sh %{rake package}
  81. sh %{gem install pkg/#{pkg_name}-#{pkg_version}}
  82. end
  83. end