Skip to content
Snippets Groups Projects
Rakefile 12 KiB
Newer Older
  • Learn to ignore specific revisions
  • 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
    require 'hoe'
    
    # FXRuby version number
    PKG_VERSION = "1.6.6"
    
    # Minimum version of FOX required for compatibility
    FOX_VERSION = "1.6.0"
    
    # Path to local installation of FOX (Windows only)
    FOX_INSTALL_DIR = "c:\\src\\fox-1.6.20"
    
    # Path to local installation of FXScintilla (Windows only)
    FXSCINTILLA_INSTALL_DIR = "c:\\src\\fxscintilla"
    
    # Path to local installation of InnoSetup command-line compiler
    ISCC = "C:\\Progra~1\\InnoSe~1\\ISCC.exe"
    
    # Generate Hoe tasks
    =begin
    Hoe.new('FXRuby', PKG_VERSION) do |p|
      p.url = "http://www.fxruby.org/"
      p.author = "Lyle Johnson"
      p.email = "lyle@rubyforge.org"
      p.changes = "See the change history at http://www.fxruby.org/doc/changes.html"
      p.description = "FXRuby is the Ruby binding to the FOX GUI toolkit."
      p.summary = "FXRuby is the Ruby binding to the FOX GUI toolkit."
      p.clean_globs = %w{config.save InstalledFiles ext/**/*.o ext/**/*.bundle}
      p.test_globs = ['tests/**/TC_*.rb']
      p.rdoc_pattern = /^(lib|bin)|txt$/
      p.extra_deps = []
      p.spec_extras = {}
      p.need_tar = true
      p.need_zip = false
      p.spec_extras = {
        'require_paths' => ['ext/fox16', 'lib'],
        'rdoc_options' => ['--main', File.join('rdoc-sources', 'README.rdoc'), '--exclude', 'ext/fox16'],
        'extensions' => ["ext/fox16/extconf.rb"],
        'extra_rdoc_files' => ['rdoc-sources', File.join('rdoc-sources', 'README.rdoc')],
        'test_suite_file' => "tests/TS_All.rb"
      }
    end
    =end
    
    DISTFILES = [
      "ANNOUNCE",
      "LICENSE",
      "README",
      "README.win32.txt",
      "pre-config.rb",
      "install.rb",
      "doap.rdf",
      "FXRuby-ruby1.6-i586-mswin32.iss",
      "FXRuby-ruby1.8.2-i386-msvcrt.iss",
      "FXRuby-ruby1.8.4-i386-msvcrt.iss",
      "FXRuby-ruby1.8.5-i386-msvcrt.iss",
      "Rakefile",
      "index.html",
      "doc/*.css",
      "doc/*.html",
      "doc/images/*.png",
      "examples/README",
      "examples/*.rb",
      "examples/*.xml",
      "examples/icons/*.png",
      "examples/icons/*.ico",
      "examples/textedit/*.rb",
      "lib/fox16/*.rb",
      "ext/fox16/MANIFEST",
      "ext/fox16/extconf.rb",
      "ext/fox16/*.c",
      "ext/fox16/*.cpp",
      "ext/fox16/include/*.h",
      "swig-interfaces/README",
      "swig-interfaces/Makefile",
      "swig-interfaces/swig.sed",
      "swig-interfaces/*.i",
      "tests/README",
      "tests/*.rb",
      "tests/*.ps",
      "web/*.html",
      "web/*.css",
      "web/art/*.png",
      "web/art/*.gif",
      "rdoc-sources/*.rb",
      "rdoc-sources/README.rdoc",
      "scripts/make-installers.rb"
    ]
    
    def distdir
      "FXRuby-#{PKG_VERSION}"
    end
    
    task :distdir => [:swig, :docs, :setversions] do
      rm_rf "#{distdir}"
      mkdir "#{distdir}"
      chmod(0777, distdir)
      DISTFILES.each do |filespec|
        Dir.glob(filespec) { |filename|
          mkdir_p "#{distdir}/#{File.dirname(filename)}"
          File.syscopy(filename, "#{distdir}/#{File.dirname(filename)}")
        }
      end
      rm_f "#{distdir}/lib/fox16/acceltable.rb"
      rm_f "#{distdir}/lib/fox16/canvas.rb"
      rm_f "#{distdir}/lib/fox16/html.rb"
      rm_f "#{distdir}/lib/fox16/sugar.rb"
      rm_f "#{distdir}/lib/fox16/tkcompat.rb"
      rm_f "#{distdir}/examples/canvasdemo.rb"
      rm_f "#{distdir}/examples/examples.rb"
      rm_f "#{distdir}/examples/gdchart.rb"
      rm_f "#{distdir}/examples/rapt-gui.rb"
      rm_f "#{distdir}/examples/WhatAQuietStiff.rb"
      rm_f "#{distdir}/examples/gembrowser.rb"
      rm_f "#{distdir}/examples/tablenew.rb"
    end
    
    desc "Build the source tarball."
    task :dist => [:distdir] do
      system "chmod -R a+r #{distdir}"
      system "tar czf #{distdir}.tar.gz #{distdir}"
      system "rm -rf #{distdir}"
    end
    
    desc "Run the test battery."
    task :check do
      cd "tests"
      ruby %{-I../ext/fox16 -I../lib TS_All.rb}
    end
    
    desc "Run SWIG to generate the wrapper files."
    task :swig do
      cd "swig-interfaces"
      system %{touch dependencies}
      system %{make depend; make}
      cd ".."
    end
    
    desc "Update the web site."
    task :website => [:doap] do
      system %{scp -Cq doc/*.css lyle@rubyforge.org:/var/www/gforge-projects/fxruby/1.6/doc}
      system %{scp -Cq doc/*.html lyle@rubyforge.org:/var/www/gforge-projects/fxruby/1.6/doc}
      system %{scp -Cq doc/images/*.png lyle@rubyforge.org:/var/www/gforge-projects/fxruby/1.6/doc/images}
      system %{scp -Cq examples/*.rb lyle@rubyforge.org:/var/www/gforge-projects/fxruby/1.6/examples}
      system %{scp -Cq index.html lyle@rubyforge.org:/var/www/gforge-projects/fxruby}
      system %{scp -Cq web/*.html lyle@rubyforge.org:/var/www/gforge-projects/fxruby/web}
      system %{scp -Cq web/art/*.gif web/art/*.png lyle@rubyforge.org:/var/www/gforge-projects/fxruby/web/art}
    end
    
    desc "Upload the DOAP file to the Web site"
    task :doap => [:setversions] do
      system %{scp -Cq doap.rdf lyle@rubyforge.org:/var/www/gforge-projects/fxruby}
    end
    
    desc "Upload the RDocs"
    task :upload_rdoc do
      system %{scp -Cqr doc/api lyle@rubyforge.org:/var/www/gforge-projects/fxruby/1.6/doc}
    end
    
    desc "Generate all of the documentation files."
    task :doc do
      cd "doc"
      system %{make}
      cd ".."
    end
    
    #
    # This task (:rdoc) provides its own description and
    # also creates the clobber_rdoc and rerdoc tasks.
    #
    Rake::RDocTask.new do |rdoc|
      rdoc.rdoc_dir = "doc/api"
      rdoc.main = "rdoc-sources/README.rdoc"
      rdoc.rdoc_files.add("rdoc-sources/README.rdoc")
      rdoc.rdoc_files.add("rdoc-sources/*.rb")
      rdoc.rdoc_files.add("lib/fox16/calendar.rb",
                          "lib/fox16/chore.rb",
                          "lib/fox16/core.rb",
                          "lib/fox16/execute_nonmodal.rb",
                          "lib/fox16/glgroup.rb",
                          "lib/fox16/glshapes.rb",
                          "lib/fox16/input.rb",
                          "lib/fox16/iterators.rb",
                          "lib/fox16/responder2.rb",
                          "lib/fox16/scintilla.rb",
                          "lib/fox16/signal.rb",
                          "lib/fox16/splashscreen.rb",
                          "lib/fox16/timeout.rb",
                          "lib/fox16/undolist.rb",
                          "lib/fox16/version.rb"
                         )
    end
    
    task :docs => [:doc, :rdoc] do
    end
    
    desc "Install it."
    task :install => [:build] do
      ruby "install.rb install"
    end
    
    desc "Clean"
    task :clean do
      ruby "install.rb clean"
    end
    
    def make_impl
      cd "ext/fox16"
      ruby "make_impl.rb"
      cd "../.."
    end
    
    task :configure => [:scintilla, :setversions, :generate_kwargs_lib] do
      unless File.exist?("config.save")
    #   ruby "install.rb config -- --with-fxscintilla-include=/usr/include/fxscintilla --with-fxscintilla-lib=/usr/lib"
    #   ruby "install.rb config -- --without-fxscintilla"
        ruby "install.rb config"
        make_impl
      end
    end
    
    desc "Build it."
    task :build => [:configure] do
      ruby "install.rb setup"
    end
    
    task :scintilla do
      ruby "scripts/iface.rb -i ~/src/fxscintilla/scintilla/include/Scintilla.iface -o lib/fox16/scintilla.rb"
    end
    
    def setversions(filename)
      substitutions = {
        "@@DATE@@" => "#{Date.today}",
        "@@FOX_VERSION@@" => FOX_VERSION,
        "@@FXRUBY_VERSION@@" => PKG_VERSION,
        "@@FXRUBY_HOME_URL@@" => "http://www.fxruby.org",
        "@@FOX_HOME_URL@@" => "http://www.fox-toolkit.com",
      }
      text = nil
      File.open(filename + ".in", "rb") do |inp|
        text = inp.read
      end
      substitutions.each { |pattern, replacement|
        text.gsub!(pattern, replacement)
      }
      File.open(filename, "wb") do |out|
        out.write(text)
      end
    end
    
    desc "Set versions"
    task :setversions => [ :create_installer_scripts ] do
      setversions("FXRuby.spec")
      setversions("Makefile")
      setversions("pre-config.rb")
      setversions("ext/fox16/extconf.rb")
      setversions("FXRuby-ruby1.6-i586-mswin32.iss")
      setversions("FXRuby-ruby1.8.2-i386-msvcrt.iss")
      setversions("FXRuby-ruby1.8.4-i386-msvcrt.iss")
      setversions("FXRuby-ruby1.8.5-i386-msvcrt.iss")
      setversions("lib/fox16/version.rb")
      setversions("doap.rdf")
      setversions("scripts/make-installers.rb")
    end
    
    desc "Create INNO Setup Installer Scripts from Template"
    task :create_installer_scripts do
      output_filenames = {
        "FXRuby-ruby1.6-i586-mswin32.iss.in" => ["1.6", "ruby168", "i586-mswin32"],
        "FXRuby-ruby1.8.2-i386-msvcrt.iss.in" =>  ["1.8", "ruby182", "i386-msvcrt"],
        "FXRuby-ruby1.8.4-i386-msvcrt.iss.in" =>  ["1.8", "ruby184", "i386-msvcrt"],
        "FXRuby-ruby1.8.5-i386-msvcrt.iss.in" =>  ["1.8", "ruby185", "i386-msvcrt"]
      }
    
      output_filenames.each do |output_filename, info|
        File.open("scripts/FXRuby.iss.in", "rb") do |input_file|
          contents = input_file.read
          contents.gsub!(/@@RUBY_VERSION@@/, info[0])
          contents.gsub!(/@@RUBYVER@@/, info[1])
          contents.gsub!(/@@TARGET@@/, info[2])
          File.open(output_filename, "wb") do |output_file|
            output_file.write(contents)
          end
        end
      end
    end
    
    # These library files aren't ready for distribution yet.
    COOKER_LIBS = %w{acceltable.rb bitmapview.rb canvas.rb html.rb sugar.rb tkcompat.rb}
    
    # These example programs aren't ready for distribution yet.
    COOKER_EXAMPLES = %w{canvasdemo.rb WhatAQuietStiff.rb examples.rb gdchart.rb gembrowser.rb rapt-gui.rb tablenew.rb}
    
    # Return the Gem specification for the source Gem
    def create_gemspec
      pkg_files = [
            "ANNOUNCE",
    	"LICENSE",
    	"README",
    	"index.html",
    	"doc/*.css",
    	"doc/*.html",
    	"doc/images/*.png",
    	"examples/README",
    	"examples/*.rb",
    	"examples/*.xml",
    	"examples/icons/*.png",
    	"examples/icons/*.ico",
    	"examples/textedit/*.rb",
    	"lib/fox16/*.rb",
    	"tests/README",
    	"tests/*.rb",
    	"tests/*.ps",
    	"web/*.html",
    	"web/*.css",
    	"web/art/*.png",
    	"web/art/*.gif",
    	"rdoc-sources/*.rb",
    	"rdoc-sources/README.rdoc"
      ]
    
      Gem::Specification.new do |s|
        s.name = 'fxruby'
        s.version = PKG_VERSION
        s.description = "FXRuby is the Ruby binding to the FOX GUI toolkit."
        s.requirements << "FOX library version 1.6.0 or higher"
        s.summary = "FXRuby is the Ruby binding to the FOX GUI toolkit."
    
        s.files = []
        pkg_files.each do |pat|
          s.files += Dir.glob(pat).delete_if { |item|
            COOKER_LIBS.include?(File.basename(item)) || COOKER_EXAMPLES.include?(File.basename(item))
          }
        end
        
        s.require_paths = ['ext/fox16', 'lib']
    
        s.has_rdoc = true
        s.rdoc_options = [
                        '--main', File.join('rdoc-sources', 'README.rdoc'),
                        '--exclude', 'ext/fox16'
                       ]
        s.extra_rdoc_files = [
                            'rdoc-sources',
                            File.join('rdoc-sources', 'README.rdoc')
                           ]
    
        s.test_suite_file = "tests/TS_All.rb"
    
        s.author = "Lyle Johnson"
        s.email = "lyle@knology.net"
        s.homepage = "http://www.fxruby.org"
      end
    end
    
    desc "Build source Gem"
    task :build_src_gem do
      spec = create_gemspec
      spec.platform = Gem::Platform::RUBY
      spec.files += [
        "ext/fox16/MANIFEST",
        "ext/fox16/extconf.rb"
        ] +
        Dir.glob("ext/fox16/*.c") +
        Dir.glob("ext/fox16/*.cpp") +
        Dir.glob("ext/fox16/include/*.h")
      spec.extensions = ["ext/fox16/extconf.rb"]
      Gem::Builder.new(spec).build
    end
    
    # Given the distribution tarball, build the installer for Win32
    desc "Build Win32 installer"
    task :build_win32 do
      if File.exist? "config.save"
        ruby "install.rb clean"
      end
      ruby "install.rb config --make-prog=nmake -- --with-fox-include=#{FOX_INSTALL_DIR}\\include --with-fox-lib=#{FOX_INSTALL_DIR}\\lib --with-fxscintilla-include=#{FXSCINTILLA_INSTALL_DIR}\\include --with-fxscintilla-lib=#{FXSCINTILLA_INSTALL_DIR}\\lib"
    # ruby "install.rb config --make-prog=nmake -- --with-fox-include=#{FOX_INSTALL_DIR}\\include --with-fox-lib=#{FOX_INSTALL_DIR}\\lib"
      ruby "install.rb setup"
    end
    
    desc "Build Win32 installer using INNO Setup"
    task :build_win32_installer => [:build_win32] do
      iss_script_name = nil
      case VERSION
        when /1.6/
          iss_script_name = "FXRuby-ruby1.6-i586-mswin32.iss"
        when /1.8.2/
          iss_script_name = "FXRuby-ruby1.8.2-i386-msvcrt.iss"
        when /1.8.4/
          iss_script_name = "FXRuby-ruby1.8.4-i386-msvcrt.iss"
        when /1.8.5/
          iss_script_name = "FXRuby-ruby1.8.5-i386-msvcrt.iss"
      end
      system(ISCC, iss_script_name)
    end
    
    desc "Build Win32 binary Gem"
    task :build_win32_gem => [:build_win32] do
      spec = create_gemspec
      spec.platform = Gem::Platform::WIN32
      spec.files += ["ext/fox16/fox16.so"]
      Gem::Builder.new(spec).build
    end
    
    desc "Build Win32 binary installer and Gem"
    task :release_win32 => [:build_win32_installer, :build_win32_gem] do
    end
    
    task :generate_kwargs_lib do
      ruby 'scripts/generate_kwargs_lib.rb'
    end
    
    # Default task is build
    task :default => [:build] do
    end