class GNOME2::Rake::NativeBinaryBuildTask

Public Class Methods

new(package) click to toggle source
# File lib/gnome2/rake/native-binary-build-task.rb, line 25
def initialize(package)
  @package = package
end

Public Instance Methods

define() click to toggle source
# File lib/gnome2/rake/native-binary-build-task.rb, line 29
def define
  namespace :native do
    namespace :builder do
      task :before
      define_build_tasks
      build_tasks = build_packages.collect do |package|
        "native:builder:build:#{package.name}"
      end
      task :build => build_tasks
      task :after
    end

    desc "Build binaries for build environment"
    task :build => [
      "native:builder:before",
      "native:builder:build",
      "native:builder:after",
    ]
  end
end

Private Instance Methods

build_packages() click to toggle source
# File lib/gnome2/rake/native-binary-build-task.rb, line 92
def build_packages
  @package.external_packages.select do |package|
    package.native.build?
  end
end
define_build_tasks() click to toggle source
# File lib/gnome2/rake/native-binary-build-task.rb, line 51
def define_build_tasks
  namespace :build do
    build_packages.each do |package|
      download_task = "source:downloader:download:#{package.name}"
      desc "Build #{package.label} and install it into #{dist_dir}."
      task package.name => [download_task] do
        package_tmp_dir = @package.tmp_dir + package.name
        rm_rf(package_tmp_dir)
        mkdir_p(package_tmp_dir)

        tar_full_path = @package.download_dir + package.archive_base_name
        Dir.chdir(package_tmp_dir.to_s) do
          sh("tar", "xf", tar_full_path.to_s) or exit(false)
        end

        Dir.chdir((package_tmp_dir + package.base_name).to_s) do
          package.native.patches.each do |patch|
            sh("patch -p1 < #{@package.patches_dir}/#{patch}")
          end
          sh("./autogen.sh") if package.native.need_autogen?
          sh("autoreconf --install") if package.native.need_autoreconf?
          sh("./configure",
             "PKG_CONFIG_PATH=#{pkg_config_path}",
             "--prefix=#{dist_dir}",
             *package.native.configure_args) or exit(false)
          common_make_args = []
          common_make_args << "GLIB_COMPILE_SCHEMAS=glib-compile-schemas"
          build_make_args = common_make_args.dup
          install_make_args = common_make_args.dup
          if package.native.build_concurrently?
            make_n_jobs = ENV["MAKE_N_JOBS"]
            build_make_args << "-j#{make_n_jobs}" if make_n_jobs
          end
          sh("nice", "make", *build_make_args) or exit(false)
          sh("make", "install", *install_make_args) or exit(false)
        end
      end
    end
  end
end
dist_dir() click to toggle source
# File lib/gnome2/rake/native-binary-build-task.rb, line 98
def dist_dir
  @package.native.absolute_binary_dir
end
pkg_config_path() click to toggle source
# File lib/gnome2/rake/native-binary-build-task.rb, line 102
def pkg_config_path
  dist_dir + "lib/pkgconfig"
end