Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 104 lines (90 sloc) 2.281 kb
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
require 'rubygems'
require 'rake/gempackagetask'
require 'rake/testtask'

#so we can: ssh host rake -f $hudson_workspace/sigar/Rakefile
Dir.chdir(File.dirname(__FILE__))

props = {}
File.open("version.properties").each { |line|
  next if line =~ /^#/
  line.chomp!
  line.strip!
  next if line.empty?
  key,val = line.split('=')
  props[key] = val
}

GEM = props['project.name']
MAKE = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'

spec = Gem::Specification.new do |s|
  s.name = GEM
# s.version = props['version.major'] + '.' + props['version.minor'] + '.' + props['version.maint']
# '0.7.x' until the sigar-1.7.0 release
  s.version = '0' + '.' + props['version.minor'] + '.' + '0'
  s.summary = props['project.summary']
  s.description = s.summary
  s.author = props['project.author']
  s.email = props['project.email']
  s.homepage = props['project.homepage']
  s.platform = Gem::Platform::RUBY
  s.has_rdoc = false
  s.extensions = 'bindings/ruby/extconf.rb'
  s.files =
    %w(COPYING EXCEPTIONS README Rakefile version.properties) +
    %w(bindings/SigarWrapper.pm bindings/SigarBuild.pm) +
    Dir.glob("bindings/ruby/**/*") +
    Dir.glob("include/*.h") +
    Dir.glob("src/**/*.[ch]") +
    Dir.glob("src/**/*.in")
end

Rake::GemPackageTask.new(spec) do |pkg|
  pkg.gem_spec = spec
end

task :default => :test

def in_ext()
  ext = 'bindings/ruby'
  Dir.chdir(ext) if File.directory? ext
end

desc 'Build sigar extension'
task :build do
  in_ext();
  unless File.exists? "Makefile"
    unless system("ruby extconf.rb")
      STDERR.puts "Failed to configure"
      break
    end
  end
  unless system(MAKE)
    STDERR.puts 'Failed to ' + MAKE
    break
  end
end

Rake::TestTask.new do |t|
  t.pattern = 'test/*_test.rb'
end

task :test => [:build] do
  in_ext()
end

desc 'Clean sigar extension'
task :clean do
  in_ext()
  system(MAKE + ' clean')
end

desc 'Dist Clean sigar extension'
task :distclean do
  in_ext()
  system(MAKE + ' distclean')
end

desc 'Run sigar examples (test)'
task :examples => [:build] do
  in_ext()
  Dir["examples/*.rb"].each do |file|
    cmd = "ruby #{file}"
    print cmd + "\n"
    system(cmd)
  end
end

desc "create a gemspec file"
task :make_spec do
  File.open("#{GEM}.gemspec", "w") do |file|
    file.puts spec.to_ruby
  end
end
Something went wrong with that request. Please try again.