Merge branch 'ruby-version-properties'
This commit is contained in:
commit
1a9eaa800f
5
Rakefile
5
Rakefile
|
@ -5,7 +5,7 @@ require 'rake/gempackagetask'
|
|||
Dir.chdir(File.dirname(__FILE__))
|
||||
|
||||
props = {}
|
||||
File.open("bindings/java/version.properties").each { |line|
|
||||
File.open("version.properties").each { |line|
|
||||
next if line =~ /^#/
|
||||
line.chomp!
|
||||
line.strip!
|
||||
|
@ -29,10 +29,9 @@ spec = Gem::Specification.new do |s|
|
|||
s.has_rdoc = false
|
||||
s.extensions = 'bindings/ruby/extconf.rb'
|
||||
s.files =
|
||||
%w(COPYING EXCEPTIONS README Rakefile) +
|
||||
%w(COPYING EXCEPTIONS README Rakefile version.properties) +
|
||||
%w(bindings/SigarWrapper.pm) +
|
||||
Dir.glob("bindings/ruby/**/*") +
|
||||
Dir.glob("bindings/java/version.properties") +
|
||||
Dir.glob("include/*.h") +
|
||||
Dir.glob("src/**/*.[ch]")
|
||||
end
|
||||
|
|
|
@ -1,14 +1,67 @@
|
|||
package SigarBuild;
|
||||
|
||||
use strict;
|
||||
use Config;
|
||||
use Exporter;
|
||||
use File::Basename qw(basename);
|
||||
use File::Copy qw(copy);
|
||||
use File::Spec ();
|
||||
use POSIX ();
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(cppflags ldflags libs os src inline_src);
|
||||
@EXPORT = qw(cppflags ldflags libs os src inline_src version_file);
|
||||
|
||||
sub archname {
|
||||
my $os = lc $^O;
|
||||
my $vers = $Config{osvers};
|
||||
my $arch = $Config{archname};
|
||||
|
||||
if ($os =~ /win32/) {
|
||||
return 'x86-winnt';
|
||||
}
|
||||
elsif ($os =~ /linux/) {
|
||||
if ($arch =~ /_64/) {
|
||||
return 'amd64-linux';
|
||||
}
|
||||
else {
|
||||
return 'x86-linux';
|
||||
}
|
||||
}
|
||||
elsif ($os =~ /hpux/) {
|
||||
if ($vers =~ /11\./) {
|
||||
return 'pa-hpux-11';
|
||||
}
|
||||
}
|
||||
elsif ($os =~ /aix/) {
|
||||
return 'ppc-aix-5';
|
||||
}
|
||||
elsif ($os =~ /solaris/) {
|
||||
if ($arch =~ /sun4/) {
|
||||
return 'sparc-solaris';
|
||||
}
|
||||
elsif ($arch =~ /.86/) {
|
||||
return 'x86-solaris';
|
||||
}
|
||||
}
|
||||
elsif ($os =~ /darwin/) {
|
||||
return 'universal-macosx';
|
||||
}
|
||||
elsif ($os =~ /freebsd/) {
|
||||
if ($arch =~ /.86/) {
|
||||
if($vers =~ /6\../ ) {
|
||||
return 'x86-freebsd-6';
|
||||
}
|
||||
}
|
||||
elsif ($arch =~ /amd64/) {
|
||||
if ($vers =~ /6\../ ) {
|
||||
return 'amd64-freebsd-6';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
sub flags {
|
||||
my $os = lc $^O;
|
||||
|
@ -138,5 +191,102 @@ sub inline_src {
|
|||
}
|
||||
}
|
||||
|
||||
sub scm_revision {
|
||||
my $rev;
|
||||
$rev = `git rev-parse --short HEAD`;
|
||||
if ($rev) {
|
||||
chomp $rev;
|
||||
}
|
||||
else {
|
||||
$rev = "exported";
|
||||
}
|
||||
return $rev;
|
||||
}
|
||||
|
||||
sub build_date {
|
||||
return POSIX::strftime("%m/%d/%Y %I:%M %p", localtime);
|
||||
}
|
||||
|
||||
sub find_file {
|
||||
my $file = shift;
|
||||
for my $dir (qw(../.. .. .)) {
|
||||
my $pfile = "$dir/$file";
|
||||
return $pfile if -e $pfile;
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
sub version_properties {
|
||||
my $props = {};
|
||||
my $file = $_[0] || find_file('version.properties');
|
||||
open my $fh, $file or die "open $file: $!";
|
||||
while (<$fh>) {
|
||||
chomp;
|
||||
my($key,$val) = split '=';
|
||||
next unless $key and defined $val;
|
||||
$props->{$key} = $val;
|
||||
}
|
||||
close $fh;
|
||||
|
||||
$props->{'scm.revision'} = scm_revision();
|
||||
|
||||
$props->{'build.date'} = build_date();
|
||||
|
||||
$props->{'version'} =
|
||||
join '.', map $props->{"version.$_"}, qw(major minor maint);
|
||||
|
||||
$props->{'version.build'} = $ENV{BUILD_NUMBER} || '0';
|
||||
|
||||
$props->{'version.string'} =
|
||||
join '.', $props->{'version'}, $props->{'version.build'};
|
||||
|
||||
return $props;
|
||||
}
|
||||
|
||||
sub version_file {
|
||||
local $_;
|
||||
my($source, $dest, %filters);
|
||||
my(@args) = @_ ? @_ : @ARGV;
|
||||
for (@args) {
|
||||
if (/=/) {
|
||||
my($key,$val) = split '=', $_, 2;
|
||||
$filters{$key} = $val;
|
||||
}
|
||||
else {
|
||||
if ($source) {
|
||||
$dest = $_;
|
||||
}
|
||||
else {
|
||||
$source = $_;
|
||||
}
|
||||
}
|
||||
}
|
||||
unless ($source) {
|
||||
$dest = 'sigar_version.c';
|
||||
$source = find_file("src/$dest.in");
|
||||
}
|
||||
my $props = version_properties();
|
||||
while (my($key,$val) = each %$props) {
|
||||
$key = uc $key;
|
||||
$key =~ s/\./_/;
|
||||
$filters{$key} = $val;
|
||||
}
|
||||
my $re = join '|', keys %filters;
|
||||
open my $in, $source or die "open $source: $!";
|
||||
my $out;
|
||||
if ($dest) {
|
||||
open $out, '>', $dest or die "open $dest: $!";
|
||||
}
|
||||
else {
|
||||
$out = \*STDOUT;
|
||||
}
|
||||
while (<$in>) {
|
||||
s/\@\@($re)\@\@/$filters{$1}/go;
|
||||
print $out $_;
|
||||
}
|
||||
close $in;
|
||||
close $out if $dest;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package SigarWrapper;
|
||||
|
||||
use strict;
|
||||
use Config;
|
||||
use Cwd;
|
||||
use Exporter;
|
||||
use File::Path;
|
||||
|
@ -12,57 +11,6 @@ use vars qw(@ISA @EXPORT);
|
|||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(generate);
|
||||
|
||||
sub archname {
|
||||
my $os = lc $^O;
|
||||
my $vers = $Config{osvers};
|
||||
my $arch = $Config{archname};
|
||||
|
||||
if ($os =~ /win32/) {
|
||||
return 'x86-winnt';
|
||||
}
|
||||
elsif ($os =~ /linux/) {
|
||||
if ($arch =~ /_64/) {
|
||||
return 'amd64-linux';
|
||||
}
|
||||
else {
|
||||
return 'x86-linux';
|
||||
}
|
||||
}
|
||||
elsif ($os =~ /hpux/) {
|
||||
if ($vers =~ /11\./) {
|
||||
return 'pa-hpux-11';
|
||||
}
|
||||
}
|
||||
elsif ($os =~ /aix/) {
|
||||
return 'ppc-aix-5';
|
||||
}
|
||||
elsif ($os =~ /solaris/) {
|
||||
if ($arch =~ /sun4/) {
|
||||
return 'sparc-solaris';
|
||||
}
|
||||
elsif ($arch =~ /.86/) {
|
||||
return 'x86-solaris';
|
||||
}
|
||||
}
|
||||
elsif ($os =~ /darwin/) {
|
||||
return 'universal-macosx';
|
||||
}
|
||||
elsif ($os =~ /freebsd/) {
|
||||
if($arch =~ /.86/) {
|
||||
if($vers =~ /6\../ ) {
|
||||
return 'x86-freebsd-6';
|
||||
}
|
||||
}
|
||||
elsif( $arch =~ /amd64/) {
|
||||
if($vers =~ /6\../ ) {
|
||||
return 'amd64-freebsd-6';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
my %platforms = (
|
||||
A => "AIX",
|
||||
D => "Darwin",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<project name="Sigar" default="build" basedir=".">
|
||||
|
||||
<property file="version.properties"/>
|
||||
<property file="../../version.properties"/>
|
||||
|
||||
<property name="sigar.version"
|
||||
value="${version.major}.${version.minor}.${version.maint}"/>
|
||||
|
@ -548,6 +548,7 @@
|
|||
|
||||
<copy toDir="${dist.src}">
|
||||
<fileset dir="../..">
|
||||
<include name="version.properties"/>
|
||||
<include name="include/*.h"/>
|
||||
<include name="src/**/*.h"/>
|
||||
<include name="src/**/*.c"/>
|
||||
|
@ -559,7 +560,6 @@
|
|||
<include name="bindings/java/**/*.h"/>
|
||||
<include name="bindings/java/**/*.pl"/>
|
||||
<include name="bindings/java/**/build.xml"/>
|
||||
<include name="bindings/java/version.properties"/>
|
||||
<include name="bindings/java/.classpath"/>
|
||||
<include name="bindings/java/.project"/>
|
||||
<include name="bindings/java/.sigar_shellrc"/>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
require 'rbsigar'
|
||||
require 'rbconfig'
|
||||
|
||||
puts "Sigar version......." + Sigar::VERSION
|
||||
puts "Build date.........." + Sigar::BUILD_DATE
|
||||
puts "SCM rev............." + Sigar::SCM_REVISION
|
||||
|
||||
sys = Sigar.new.sys_info
|
||||
puts "OS description......" + sys.description
|
||||
puts "OS name............." + sys.name
|
||||
puts "OS arch............." + sys.arch
|
||||
puts "OS machine.........." + sys.machine
|
||||
puts "OS version.........." + sys.version
|
||||
puts "OS patch level......" + sys.patch_level
|
||||
puts "OS vendor..........." + sys.vendor
|
||||
puts "OS vendor version..." + sys.vendor_version
|
||||
if (sys.vendor_code_name != nil)
|
||||
puts "OS code name........" + sys.vendor_code_name
|
||||
end
|
||||
|
||||
puts "Ruby version........" + RUBY_VERSION
|
||||
puts "Ruby build vendor..." + ::Config::CONFIG['build_vendor']
|
||||
puts "Ruby archdir........" + ::Config::CONFIG['archdir']
|
|
@ -1,4 +1,5 @@
|
|||
require 'mkmf'
|
||||
require 'rbconfig'
|
||||
|
||||
extension_name = 'rbsigar'
|
||||
|
||||
|
@ -84,8 +85,13 @@ unless is_win32
|
|||
end
|
||||
|
||||
system('perl -Mlib=.. -MSigarWrapper -e generate Ruby .')
|
||||
libname = extension_name + '.' + CONFIG['DLEXT']
|
||||
system('perl -Mlib=.. -MSigarBuild -e version_file ' +
|
||||
'ARCHNAME=' + RUBY_PLATFORM + ' ' +
|
||||
'ARCHLIB=' + libname + ' ' +
|
||||
'BINNAME=' + libname)
|
||||
|
||||
$distcleanfiles = ['rbsigar_generated.rx']
|
||||
$distcleanfiles = ['rbsigar_generated.rx','sigar_version.c']
|
||||
#XXX seems mkmf forces basename on srcs
|
||||
#XXX should be linking against libsigar anyhow
|
||||
(Dir["../../src/*.c"] + Dir["#{osdir}/*.c"]).each do |file|
|
||||
|
|
|
@ -536,6 +536,9 @@ static VALUE rb_sigar_proc_env(VALUE obj, VALUE pid)
|
|||
#define RB_SIGAR_CONST_INT(name) \
|
||||
rb_define_const(rclass, #name, INT2FIX(SIGAR_##name))
|
||||
|
||||
#define RB_SIGAR_DEFINE_CONST_STR(name, value) \
|
||||
rb_define_const(rclass, name, rb_obj_freeze(rb_str_new2(value)))
|
||||
|
||||
#define RB_SIGAR_CONST_STR(name) \
|
||||
rb_define_const(rclass, #name, rb_obj_freeze(rb_str_new2(SIGAR_##name)))
|
||||
|
||||
|
@ -582,6 +585,14 @@ static void Init_rbsigar_constants(VALUE rclass)
|
|||
RB_SIGAR_CONST_STR(NULL_HWADDR);
|
||||
}
|
||||
|
||||
static void Init_rbsigar_version(VALUE rclass)
|
||||
{
|
||||
sigar_version_t *sv = sigar_version_get();
|
||||
RB_SIGAR_DEFINE_CONST_STR("BUILD_DATE", sv->build_date);
|
||||
RB_SIGAR_DEFINE_CONST_STR("SCM_REVISION", sv->scm_revision);
|
||||
RB_SIGAR_DEFINE_CONST_STR("VERSION", sv->version);
|
||||
}
|
||||
|
||||
void Init_rbsigar(void)
|
||||
{
|
||||
VALUE rclass = rb_define_class("Sigar", rb_cObject);
|
||||
|
@ -609,6 +620,7 @@ void Init_rbsigar(void)
|
|||
rb_sigar_net_connection_state_to_s, 1);
|
||||
|
||||
Init_rbsigar_constants(rclass);
|
||||
Init_rbsigar_version(rclass);
|
||||
|
||||
/* generated */
|
||||
rb_sigar_define_module_methods(rclass);
|
||||
|
|
|
@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|||
s.description = %q{System Information Gatherer And Reporter}
|
||||
s.email = %q{sigar-users@hyperic.org}
|
||||
s.extensions = ["bindings/ruby/extconf.rb"]
|
||||
s.files = ["COPYING", "EXCEPTIONS", "README", "Rakefile", "bindings/SigarWrapper.pm", "bindings/ruby/extconf.rb", "bindings/ruby/examples", "bindings/ruby/examples/netstat.rb", "bindings/ruby/examples/df.rb", "bindings/ruby/examples/pargs.rb", "bindings/ruby/examples/who.rb", "bindings/ruby/examples/ifconfig.rb", "bindings/ruby/examples/penv.rb", "bindings/ruby/examples/cpu_info.rb", "bindings/ruby/examples/free.rb", "bindings/ruby/examples/route.rb", "bindings/ruby/rbsigar.c", "bindings/java/version.properties", "include/sigar.h", "include/sigar_util.h", "include/sigar_ptql.h", "include/sigar_private.h", "include/sigar_fileinfo.h", "include/sigar_format.h", "include/sigar_getline.h", "include/sigar_log.h", "src/sigar_util.c", "src/sigar.c", "src/sigar_fileinfo.c", "src/sigar_cache.c", "src/sigar_format.c", "src/os/netware/netware_sigar.c", "src/os/netware/sigar_os.h", "src/os/darwin/darwin_sigar.c", "src/os/darwin/sigar_os.h", "src/os/aix/aix_sigar.c", "src/os/aix/sigar_os.h", "src/os/win32/win32_sigar.c", "src/os/win32/peb.c", "src/os/win32/sigar_pdh.h", "src/os/win32/sigar_os.h", "src/os/hpux/dlpi.c", "src/os/hpux/hpux_sigar.c", "src/os/hpux/sigar_os.h", "src/os/linux/linux_sigar.c", "src/os/linux/sigar_os.h", "src/os/osf1/osf1_sigar.c", "src/os/osf1/sigar_os.h", "src/os/solaris/solaris_sigar.c", "src/os/solaris/get_mib2.c", "src/os/solaris/get_mib2.h", "src/os/solaris/kstats.c", "src/os/solaris/procfs.c", "src/os/solaris/hmekstat.h", "src/os/solaris/sigar_os.h", "src/os/stub/stub_sigar.c", "src/os/stub/sigar_os.h", "src/sigar_getline.c", "src/sigar_ptql.c", "src/sigar_signal.c"]
|
||||
s.files = ["COPYING", "EXCEPTIONS", "README", "Rakefile", "bindings/SigarWrapper.pm", "bindings/ruby/extconf.rb", "bindings/ruby/examples", "bindings/ruby/examples/netstat.rb", "bindings/ruby/examples/df.rb", "bindings/ruby/examples/pargs.rb", "bindings/ruby/examples/who.rb", "bindings/ruby/examples/ifconfig.rb", "bindings/ruby/examples/penv.rb", "bindings/ruby/examples/cpu_info.rb", "bindings/ruby/examples/free.rb", "bindings/ruby/examples/route.rb", "bindings/ruby/rbsigar.c", "version.properties", "include/sigar.h", "include/sigar_util.h", "include/sigar_ptql.h", "include/sigar_private.h", "include/sigar_fileinfo.h", "include/sigar_format.h", "include/sigar_getline.h", "include/sigar_log.h", "src/sigar_util.c", "src/sigar.c", "src/sigar_fileinfo.c", "src/sigar_cache.c", "src/sigar_format.c", "src/os/netware/netware_sigar.c", "src/os/netware/sigar_os.h", "src/os/darwin/darwin_sigar.c", "src/os/darwin/sigar_os.h", "src/os/aix/aix_sigar.c", "src/os/aix/sigar_os.h", "src/os/win32/win32_sigar.c", "src/os/win32/peb.c", "src/os/win32/sigar_pdh.h", "src/os/win32/sigar_os.h", "src/os/hpux/dlpi.c", "src/os/hpux/hpux_sigar.c", "src/os/hpux/sigar_os.h", "src/os/linux/linux_sigar.c", "src/os/linux/sigar_os.h", "src/os/osf1/osf1_sigar.c", "src/os/osf1/sigar_os.h", "src/os/solaris/solaris_sigar.c", "src/os/solaris/get_mib2.c", "src/os/solaris/get_mib2.h", "src/os/solaris/kstats.c", "src/os/solaris/procfs.c", "src/os/solaris/hmekstat.h", "src/os/solaris/sigar_os.h", "src/os/stub/stub_sigar.c", "src/os/stub/sigar_os.h", "src/sigar_getline.c", "src/sigar_ptql.c", "src/sigar_signal.c"]
|
||||
s.homepage = %q{http://sigar.hyperic.com/}
|
||||
s.require_paths = ["lib"]
|
||||
s.rubygems_version = %q{1.3.4}
|
||||
|
|
Loading…
Reference in New Issue