setup.rb in reap-9.3.5 vs setup.rb in reap-9.4.0

- old
+ new

@@ -1,26 +1,32 @@ #!/usr/bin/env ruby + # Setup.rb v3.5.0 # Copyright (c) 2008 Minero Aoki, Trans # # This program is free software. # You can distribute/modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. -# Need the package name, and whether to generate documentation. -PACKAGE = File.read(Dir.glob('{.,meta/}unixname{,.txt}', File::FNM_CASEFOLD).first).strip -GENERATE_RDOCS = true # package developer may need to deactivate +# Need the package name. This is used to install docs in system doc/ruby-{name}/ location. +PACKAGE_NAME = File.read(Dir.glob('{.,meta/}unixname{,.txt}', File::FNM_CASEFOLD).first).strip +# Generate rdocs? Package developer may want to deactivate this. +GENERATE_RDOC = true + require 'optparse' require 'rbconfig' class SetupError < StandardError; end # Typical installation procedure: # # $ ./setup.rb # +# Which is the same al +# +# # -- or -- # # $ ./setup.rb config # $ ./setup.rb setup # $ ./setup.rb install @@ -31,12 +37,13 @@ # # TODO: Update shebangs on install of binaries. # TODO: Make cleaning more comprehensive (?) module Setup - Version = "3.5.0" + Version = "3.5.1" + Copyright = "Copyright (c) 2000,2008 Minero Aoki, Trans" # ConfigTable stores platform information. class ConfigTable @@ -250,10 +257,11 @@ makeprog = 'make' end parameterize = lambda do |path| val = RBCONFIG[path] + raise "Unknown path -- #{path}" if val.nil? val.sub(/\A#{Regexp.quote(prefix)}/, '$prefix') end self.prefix = prefix self.bindir = parameterize['bindir'] @@ -319,12 +327,19 @@ def show fmt = "%-20s %s\n" OPTIONS.each do |name| value = self[name] reslv = __send__(name) - reslv = "(none)" if String===reslv && reslv.empty? - printf fmt, name, reslv if value + case reslv + when String + reslv = "(none)" if reslv.empty? + when false, nil + reslv = "no" + when true + reslv = "yes" + end + printf fmt, name, reslv end end # @@ -371,19 +386,19 @@ TASK_DESCRIPTIONS = [ [ 'all', 'do config, setup, then install' ], [ 'config', 'saves your configurations' ], [ 'show', 'shows current configuration' ], [ 'setup', 'compiles ruby extentions and others' ], - [ 'doc', 'generate html documentation' ], - [ 'index', 'generate index documentation' ], + [ 'rdoc', 'generate rdoc documentation' ], + [ 'ri', 'generate ri documentation' ], [ 'install', 'installs files' ], [ 'test', 'run all tests in test/' ], [ 'clean', "does `make clean' for each extention" ], [ 'distclean',"does `make distclean' for each extention" ] ] - TASKS = %w(all config show setup test install uninstall doc index clean distclean) + TASKS = %w(all config show setup test install uninstall rdoc ri clean distclean) # Configuration attr :config attr_writer :no_harm @@ -445,15 +460,15 @@ task :setup do exec_setup end desc 'Runs unit tests' task :test do exec_test end - desc 'Generate html api docs' - task :doc do exec_doc end + desc 'Generate rdoc documentation' + task :rdoc do exec_rdoc end - desc 'Generate api index docs' - task :index do exec_index end + desc 'Generate ri documentation' + task :ri do exec_ri end desc 'Installs files' task :install do exec_install end desc 'Uninstalls files' @@ -507,12 +522,13 @@ # def exec_all exec_config exec_setup - exec_test # TODO: we need to stop here if tests fail (how?) - exec_doc if GENERATE_RDOCS && !config.without_doc? + exec_test # TODO: we need to stop here if tests fail (how?) + exec_rdoc unless config.without_doc? if GENERATE_RDOC + exec_ri unless config.without_doc? exec_install end # # TASK config @@ -704,16 +720,16 @@ # MAYBE: We could traverse and run each test independently (?) #def test_dir_test #end # - # TASK doc + # TASK rdoc # - def exec_doc - output = File.join('doc', PACKAGE, 'rdoc') - title = (PACKAGE.capitalize + " API").strip + def exec_rdoc + output = File.join('doc', 'rdoc') + title = (PACKAGE_NAME.capitalize + " API").strip main = Dir.glob("README{,.txt}", File::FNM_CASEFOLD).first template = config.doctemplate || 'html' opt = [] opt << "-U" @@ -742,61 +758,53 @@ require 'rdoc/rdoc' ::RDoc::RDoc.new.document(opt) end end - # - # TASK index - # - # TODO: Totally deprecate stadard ri support in favor of fastri. + # TASK ri - def exec_index - begin - require 'fastri/version' - fastri = true - rescue LoadError - fastri = false + def exec_ri + case config.installdirs + when 'std' + output = "--ri-system" + when 'site' + output = "--ri-site" + when 'home' + output = "--ri" + else + abort "bad config: sould not be possible -- installdirs = #{config.installdirs}" end - if fastri - if no_harm? - $stderr.puts "fastri-server -b" - else - system "fastri-server -b" - end + + if File.exist?('.document') + files = File.read('.document').split("\n") + files.reject!{ |l| l =~ /^\s*[#]/ || l !~ /\S/ } + files.collect!{ |f| f.strip } else - case config.installdirs - when 'std' - output = "--ri-system" - when 'site' - output = "--ri-site" - when 'home' - output = "--ri" - else - abort "bad config: sould not be possible -- installdirs = #{config.installdirs}" - end + files = ["lib", "ext"] + end - if File.exist?('.document') - files = File.read('.document').split("\n") - files.reject!{ |l| l =~ /^\s*[#]/ || l !~ /\S/ } - files.collect!{ |f| f.strip } - else - files = ["lib", "ext"] - end + opt = [] + opt << "-U" + opt << output + opt << files + opt = opt.flatten + if no_harm? + puts "rdoc #{opt.join(' ').strip}" + else + # Generate in system location specified + #sh "rdoc #{opt.join(' ').strip}" + require 'rdoc/rdoc' + ::RDoc::RDoc.new.document(opt) + + # Now in local directory opt = [] opt << "-U" - opt << output + opt << "--ri --op 'doc/ri'" opt << files opt = opt.flatten - - if no_harm? - puts "rdoc #{opt.join(' ').strip}" - else - #sh "rdoc #{opt.join(' ').strip}" - require 'rdoc/rdoc' - ::RDoc::RDoc.new.document(opt) - end + ::RDoc::RDoc.new.document(opt) end end # # TASK install @@ -834,13 +842,15 @@ def install_dir_man(rel) install_files targetfiles(), "#{config.mandir}/#{rel}", 0644 end + # doc installs to directory named: "ruby-#{package}" def install_dir_doc(rel) return if config.without_doc? - install_files targetfiles(), "#{config.docdir}/#{rel}", 0644 + dir = "#{config.docdir}/ruby-#{PACKAGE_NAME}/#{rel}" # "#{config.docdir}/#{rel}" + install_files targetfiles(), dir, 0644 end def install_files(list, dest, mode) mkdir_p dest, install_prefix list.each do |fname| @@ -859,11 +869,11 @@ end ents end def dllext - RBCONFIG['DLEXT'] + ConfigTable::RBCONFIG['DLEXT'] end def targetfiles mapdir(existfiles() - hookfiles()) end @@ -992,10 +1002,10 @@ alias distclean_dir_data noop alias distclean_dir_conf noop alias distclean_dir_man noop def distclean_dir_doc(rel) - if GENERATE_RDOCS + if GENERATE_RDOC rm_rf('rdoc') if File.directory?('rdoc') end end #