/Rakefile.old

https://bitbucket.org/laika/thingfish · Unknown · 151 lines · 121 code · 30 blank · 0 comment · 0 complexity · 9007c42b9bec9fe8293df038dbfd7114 MD5 · raw file

  1. #!rake -*- ruby -*-
  2. #
  3. # ThingFish rakefile
  4. #
  5. # Based on Ben Bleything's Rakefile for Linen (URL?)
  6. #
  7. # Copyright (c) 2007-2009, Michael Granger and Mahlon E. Smith
  8. #
  9. # Mistakes:
  10. # * Michael Granger <ged@FaerieMUD.org>
  11. #
  12. BEGIN {
  13. require 'pathname'
  14. basedir = Pathname.new( __FILE__ ).dirname
  15. libdir = basedir + 'lib'
  16. docsdir = basedir + 'docs'
  17. $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
  18. $LOAD_PATH.unshift( docsdir.to_s ) unless $LOAD_PATH.include?( docsdir.to_s )
  19. }
  20. require 'rake'
  21. require 'tmpdir'
  22. require 'pathname'
  23. $dryrun = false
  24. # Pathname constants
  25. BASEDIR = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd )
  26. BINDIR = BASEDIR + 'bin'
  27. LIBDIR = BASEDIR + 'lib'
  28. EXTDIR = BASEDIR + 'ext'
  29. DOCSDIR = BASEDIR + 'docs'
  30. VARDIR = BASEDIR + 'var'
  31. MISCDIR = BASEDIR + 'misc'
  32. WWWDIR = VARDIR + 'www'
  33. STATICWWWDIR = WWWDIR + 'static'
  34. MANUALDIR = DOCSDIR + 'manual'
  35. MANUALOUTPUTDIR = STATICWWWDIR + 'manual'
  36. RDOCDIR = MANUALOUTPUTDIR + 'api'
  37. PKGDIR = BASEDIR + 'pkg'
  38. ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || '' )
  39. RAKE_TASKDIR = MISCDIR + 'rake'
  40. TEXT_FILES = %w( Rakefile README LICENSE QUICKSTART ).
  41. collect {|filename| BASEDIR + filename }
  42. SPECDIR = BASEDIR + 'spec'
  43. SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).
  44. delete_if {|item| item =~ /\.svn/ }
  45. # Ideally, this should be automatically generated.
  46. SPEC_EXCLUDES = 'spec,monkeypatches,/Library/Ruby,/var/lib,/usr/local/lib'
  47. BIN_FILES = Pathname.glob( BINDIR + '*').
  48. delete_if {|item| item =~ /\.svn/ }
  49. LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb').
  50. delete_if {|item| item =~ /\.svn/ }
  51. RELEASE_FILES = BIN_FILES + TEXT_FILES + LIB_FILES + SPEC_FILES
  52. # Plugin constants
  53. PLUGINDIR = BASEDIR + 'plugins'
  54. PLUGINS = Pathname.glob( PLUGINDIR + '*' ).select {|path| path.directory? }
  55. PLUGIN_LIBS = PLUGINS.collect {|dir| Pathname.glob(dir + 'lib/**/*.rb') }.flatten
  56. PLUGIN_RAKEFILES = PLUGINS.collect {|dir| dir + 'Rakefile' }
  57. PLUGIN_SPECFILES = PLUGINS.collect {|dir| Pathname.glob(dir + 'spec/**/*_spec.rb') }.flatten
  58. require RAKE_TASKDIR + 'helpers.rb'
  59. ### Package constants
  60. PKG_NAME = 'thingfish'
  61. PKG_VERSION = find_pattern_in_file( /VERSION = '(\d+\.\d+\.\d+)'/, LIBDIR + 'thingfish.rb' ).first
  62. PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
  63. RELEASE_NAME = "REL #{PKG_VERSION}"
  64. if Rake.application.options.trace
  65. $trace = true
  66. log "$trace is enabled"
  67. end
  68. if Rake.application.options.dryrun
  69. $dryrun = true
  70. log "$dryrun is enabled"
  71. Rake.application.options.dryrun = false
  72. end
  73. ### Load task libraries
  74. require RAKE_TASKDIR + 'svn.rb'
  75. require RAKE_TASKDIR + 'verifytask.rb'
  76. Pathname.glob( RAKE_TASKDIR + '*.rb' ).each do |tasklib|
  77. next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$}
  78. begin
  79. require tasklib
  80. rescue ScriptError => err
  81. fail "Task library '%s' failed to load: %s: %s" %
  82. [ tasklib, err.class.name, err.message ]
  83. trace "Backtrace: \n " + err.backtrace.join( "\n " )
  84. rescue => err
  85. log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
  86. [ tasklib, err.class.name, err.message ]
  87. trace "Backtrace: \n " + err.backtrace.join( "\n " )
  88. end
  89. end
  90. ### Default task
  91. task :default => [:clean, :build, :spec, :verify, :package]
  92. ### Task: clean
  93. desc "Clean pkg, coverage, and rdoc; remove .bak files"
  94. task :clean => [ :clobber_rdoc, :clobber_package, :clobber_coverage, :clobber_manual ] do
  95. files = FileList['**/*.bak']
  96. files.clear_exclude
  97. File.rm( files ) unless files.empty?
  98. FileUtils.rm_rf( 'artifacts' )
  99. end
  100. ### Task: docs -- Convenience task for rebuilding dynamic docs, including coverage, api
  101. ### docs, and manual
  102. multitask :docs => [ :manual, :coverage, :rdoc ] do
  103. log "All documentation built."
  104. end
  105. ### Task: generate ctags
  106. ### This assumes exuberant ctags, since ctags 'native' doesn't support ruby anyway.
  107. desc "Generate a ctags 'tags' file from ThingFish source"
  108. task :ctags do
  109. run %w{ ctags -R lib plugins misc }
  110. end
  111. ### Cruisecontrol task
  112. desc "Cruisecontrol build"
  113. task :cruise => [:clean, 'spec:text', :package] do |task|
  114. raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
  115. artifact_dir = ARTIFACTS_DIR.cleanpath
  116. artifact_dir.mkpath
  117. $stderr.puts "Copying coverage stats..."
  118. FileUtils.cp_r( 'coverage', artifact_dir )
  119. $stderr.puts "Copying packages..."
  120. FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
  121. end