class GNOME2::Rake::PackageTask - glib2-2.2.0 Documentation

# class GNOME2::Rake::PackageTask

### Attributes

author[RW]
description[RW]
email[RW]
homepage[RW]
name[RW]
post_install_message[RW]
required_ruby_version[RW]
root_dir[R]
summary[RW]

### Public Class Methods

new() { |self| ... } click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 26
    def initialize
      initialize_variables
      initialize_configurations
      file, line, method = caller[1].scan(/^(.*):(\d+)(?::.*`(.*)')?\Z/).first
      @package = Package.new(File.dirname(file))
      @packages = FileList["#{@package.root_dir.parent}/*"].map{|f| File.directory?(f) ? File.basename(f) : nil}.compact
      @name = @package.name
      @cross_compiling_hooks = []
      yield(self) if block_given?
    end

### Public Instance Methods

cross_compiling(&block) click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 37
    def cross_compiling(&block)
      @cross_compiling_hooks << block
    end

define() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 41
    def define
      task :default => :build
      define_spec
      define_source_tasks
      define_native_tasks
      define_win32_tasks
      define_package_tasks
    end

define_tasks() click to toggle source

Deprecated. Use define instead.

    # File lib/gnome2/rake/package-task.rb, line 51
    def define_tasks
      define
    end

dependency() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 59
    def dependency
      @dependency_configuration
    end

external_packages=(packages) click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 96
    def external_packages=(packages)
      @package.external_packages = packages
    end

guess_version() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 84
    def guess_version
      versions = {}
      File.open("#{@package.glib2_root_dir}/ext/glib2/rbglib.h") do |rbglib_h|
        rbglib_h.each_line do |line|
          if /#define\s+RBGLIB_([A-Z]+)_VERSION\s+(\d+)/ =~ line
            versions[$1.downcase] = $2.to_i
          end
        end
      end
      ["major", "minor", "micro"].collect {|type| versions[type]}.compact.join(".")
    end

native() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 76
    def native
      @package.native
    end

package() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 63
    def package
      @package
    end

ruby_gnome2_package?(name) click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 55
    def ruby_gnome2_package?(name)
      @packages.include?(name)
    end

version() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 80
    def version
      ENV["VERSION"] || guess_version
    end

win32() click to toggle source

For backward compatibility

    # File lib/gnome2/rake/package-task.rb, line 72
    def win32
      windows
    end

windows() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 67
    def windows
      @package.windows
    end

### Private Instance Methods

define_native_build_tasks() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 153
    def define_native_build_tasks
      task = NativeBinaryBuildTask.new(@package)
      task.define
    end

define_native_tasks() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 149
    def define_native_tasks
      define_native_build_tasks
    end

define_package_tasks() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 209
    def define_package_tasks
      Gem::PackageTask.new(@spec) do |pkg|
      end
    end

define_source_download_tasks() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 144
    def define_source_download_tasks
      task = SourceDownloadTask.new(@package)
      task.define
    end

define_source_tasks() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 140
    def define_source_tasks
      define_source_download_tasks
    end

define_spec() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 114
    def define_spec
      @spec = Gem::Specification.new do |s|
        s.name                  = @name
        s.summary               = @summary
        s.description           = @description
        s.author                = @author
        s.email                 = @email
        s.homepage              = @homepage
        s.licenses              = ["LGPLv2.1 or later"]
        s.version               = version
        extensions              = FileList["ext/#{@name}/extconf.rb"]
        extensions.existing!
        s.extensions            = extensions
        s.require_paths         = ["lib"]
        files                   = FileList["ChangeLog", "README",
                                           "Rakefile", "extconf.rb",
                                           "lib/**/*.rb",
                                           "{ext,sample,test,test-unit}/**/*"]
        files.existing!
        s.files                 = files
        s.required_ruby_version = @required_ruby_version || ">= 1.9.3"
        s.post_install_message  = @post_install_message
        @dependency_configuration.apply(s)
      end
    end

define_win32_build_task() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 204
    def define_win32_build_task
      GNOME2Win32BinaryBuildTask.new(@package)
    end

define_win32_download_task() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 200
    def define_win32_download_task
      GNOME2Win32BinaryDownloadTask.new(@package)
    end

define_win32_extension_task() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 168
    def define_win32_extension_task
      ::Rake::ExtensionTask.new(so_base_name, @spec) do |ext|
        ext.ext_dir = "ext/#{@name}"
        ext.cross_compile = true
        ext.cross_compiling do |spec|
          if /mingw|mswin/ =~ spec.platform.to_s
            win32_binary_dir = @package.windows.relative_binary_dir
            win32_files = []
            if win32_binary_dir.exist?
              Find.find(win32_binary_dir.to_s) do |path|
                next unless File.file?(path)
                next if /\.zip\z/ =~ path
                win32_files << path
              end
            end
            spec.files += win32_files
            stage_path = "#{ext.tmp_dir}/#{ext.cross_platform}/stage"
            win32_files.each do |win32_file|
              stage_win32_file = "#{stage_path}/#{win32_file}"
              stage_win32_binary_dir = File.dirname(stage_win32_file)
              directory stage_win32_binary_dir
              file stage_win32_file => [stage_win32_binary_dir, win32_file] do
                cp win32_file, stage_win32_file
              end
            end
          end
          @cross_compiling_hooks.each do |hook|
            hook.call(spec)
          end
        end
      end

      def define_win32_download_task
        GNOME2Win32BinaryDownloadTask.new(@package)
      end

      def define_win32_build_task
        GNOME2Win32BinaryBuildTask.new(@package)
      end
    end

define_win32_tasks() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 158
    def define_win32_tasks
      define_win32_extension_task
      define_win32_download_task
      define_win32_build_task
    end

initialize_configurations() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 110
    def initialize_configurations
      @dependency_configuration = DependencyConfiguration.new(self)
    end

initialize_variables() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 101
    def initialize_variables
      @summary = ""
      @description = ""
      @author = "The Ruby-GNOME2 Project Team"
      @email = "ruby-gnome2-devel-en@lists.sourceforge.net"
      @homepage = "http://ruby-gnome2.sourceforge.jp/"
      @external_packages = []
    end

so_base_name() click to toggle source

    # File lib/gnome2/rake/package-task.rb, line 164
    def so_base_name
      @name.gsub(/-/, "_")
    end