sigar-test 0.7.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/NOTICE +117 -0
  4. data/README +2 -0
  5. data/Rakefile +105 -0
  6. data/bindings/SigarBuild.pm +301 -0
  7. data/bindings/SigarWrapper.pm +3025 -0
  8. data/bindings/ruby/extconf.rb +131 -0
  9. data/bindings/ruby/rbsigar.c +888 -0
  10. data/include/sigar.h +984 -0
  11. data/include/sigar_fileinfo.h +157 -0
  12. data/include/sigar_format.h +65 -0
  13. data/include/sigar_getline.h +18 -0
  14. data/include/sigar_log.h +80 -0
  15. data/include/sigar_private.h +429 -0
  16. data/include/sigar_ptql.h +53 -0
  17. data/include/sigar_util.h +197 -0
  18. data/src/os/aix/aix_sigar.c +2168 -0
  19. data/src/os/aix/sigar_os.h +73 -0
  20. data/src/os/darwin/Info.plist.in +27 -0
  21. data/src/os/darwin/darwin_sigar.c +3718 -0
  22. data/src/os/darwin/sigar_os.h +80 -0
  23. data/src/os/hpux/hpux_sigar.c +1361 -0
  24. data/src/os/hpux/sigar_os.h +49 -0
  25. data/src/os/linux/linux_sigar.c +2810 -0
  26. data/src/os/linux/sigar_os.h +82 -0
  27. data/src/os/solaris/get_mib2.c +321 -0
  28. data/src/os/solaris/get_mib2.h +127 -0
  29. data/src/os/solaris/kstats.c +181 -0
  30. data/src/os/solaris/procfs.c +97 -0
  31. data/src/os/solaris/sigar_os.h +224 -0
  32. data/src/os/solaris/solaris_sigar.c +2732 -0
  33. data/src/os/win32/peb.c +212 -0
  34. data/src/os/win32/sigar.rc.in +40 -0
  35. data/src/os/win32/sigar_os.h +685 -0
  36. data/src/os/win32/sigar_pdh.h +47 -0
  37. data/src/os/win32/win32_sigar.c +4109 -0
  38. data/src/sigar.c +2444 -0
  39. data/src/sigar_cache.c +253 -0
  40. data/src/sigar_fileinfo.c +815 -0
  41. data/src/sigar_format.c +696 -0
  42. data/src/sigar_getline.c +1849 -0
  43. data/src/sigar_ptql.c +1976 -0
  44. data/src/sigar_signal.c +216 -0
  45. data/src/sigar_util.c +1060 -0
  46. data/src/sigar_version.c.in +22 -0
  47. data/src/sigar_version_autoconf.c.in +22 -0
  48. data/version.properties +11 -0
  49. metadata +91 -0
@@ -0,0 +1,301 @@
1
+ #
2
+ # Copyright (c) 2009 Hyperic, Inc.
3
+ # Copyright (c) 2009 SpringSource, Inc.
4
+ # Copyright (c) 2009 VMware, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ package SigarBuild;
20
+
21
+ use strict;
22
+ use Config;
23
+ use Exporter;
24
+ use File::Basename qw(basename);
25
+ use File::Copy qw(copy);
26
+ use File::Spec ();
27
+ use POSIX ();
28
+
29
+ use vars qw(@ISA @EXPORT);
30
+ @ISA = qw(Exporter);
31
+ @EXPORT = qw(cppflags ldflags libs os src inline_src version_file resource_file);
32
+
33
+ sub archname {
34
+ my $os = lc $^O;
35
+ my $vers = $Config{osvers};
36
+ my $arch = $Config{archname};
37
+
38
+ if ($os =~ /win32/) {
39
+ return 'x86-winnt';
40
+ }
41
+ elsif ($os =~ /linux/) {
42
+ if ($arch =~ /_64/) {
43
+ return 'amd64-linux';
44
+ }
45
+ else {
46
+ return 'x86-linux';
47
+ }
48
+ }
49
+ elsif ($os =~ /hpux/) {
50
+ if ($vers =~ /11\./) {
51
+ return 'pa-hpux-11';
52
+ }
53
+ }
54
+ elsif ($os =~ /aix/) {
55
+ return 'ppc-aix-5';
56
+ }
57
+ elsif ($os =~ /solaris/) {
58
+ if ($arch =~ /sun4/) {
59
+ return 'sparc-solaris';
60
+ }
61
+ elsif ($arch =~ /.86/) {
62
+ return 'x86-solaris';
63
+ }
64
+ }
65
+ elsif ($os =~ /darwin/) {
66
+ return 'universal-macosx';
67
+ }
68
+ elsif ($os =~ /freebsd/) {
69
+ if ($arch =~ /.86/) {
70
+ if($vers =~ /6\../ ) {
71
+ return 'x86-freebsd-6';
72
+ }
73
+ }
74
+ elsif ($arch =~ /amd64/) {
75
+ if ($vers =~ /6\../ ) {
76
+ return 'amd64-freebsd-6';
77
+ }
78
+ }
79
+ }
80
+
81
+ return '';
82
+ }
83
+
84
+ sub flags {
85
+ my $os = lc $^O;
86
+ my $is_win32 = 0;
87
+ my (@cppflags, @ldflags, @libs);
88
+ if ($os =~ /(win32)/) {
89
+ $os = $1;
90
+ $is_win32 = 1;
91
+ @cppflags = ('-DWIN32', '-D_CRT_SECURE_NO_DEPRECATE');
92
+ @libs = qw(kernel32 user32 advapi32 ws2_32 netapi32 shell32 pdh version comsupp wbemuuid);
93
+ }
94
+ elsif ($os =~ /(linux)/) {
95
+ $os = $1;
96
+ }
97
+ elsif ($os =~ /(hpux)/) {
98
+ $os = $1;
99
+ @libs = qw(nsl nm);
100
+ }
101
+ elsif ($os =~ /(aix)/) {
102
+ $os = $1;
103
+ @libs = qw(odm cfg perfstat);
104
+ }
105
+ elsif ($os =~ /(solaris)/) {
106
+ $os = $1;
107
+ @libs = qw(nsl socket kstat);
108
+ }
109
+ elsif ($os =~ /(darwin)/) {
110
+ $os = $1;
111
+ @cppflags = ('-DDARWIN');
112
+ @ldflags = ('-framework CoreServices', '-framework IOKit');
113
+ if (-e "/usr/local/libproc.h") {
114
+ push @cppflags, '-DDARWIN_HAS_LIBPROC_H';
115
+ }
116
+ }
117
+ elsif ($os =~ /bsd/) {
118
+ $os = 'darwin';
119
+ @libs = qw(kvm);
120
+ }
121
+
122
+ push @cppflags,
123
+ '-I../../include',
124
+ "-I../../src/os/$os";
125
+
126
+ unless ($is_win32) {
127
+ push @cppflags, '-U_FILE_OFFSET_BITS';
128
+ }
129
+
130
+ my(@src) = (<../../src/*.c>, <../../src/os/$os/*.c>, <../../src/os/$os/*.cpp>);
131
+
132
+ return {
133
+ is_win32 => $is_win32,
134
+ os => $os,
135
+ libs => \@libs,
136
+ cppflags => \@cppflags,
137
+ ldflags => \@ldflags,
138
+ src => \@src,
139
+ };
140
+ }
141
+
142
+ #perl -Mlib=.. -MSigarBuild -e cppflags
143
+ sub cppflags {
144
+ print join ' ', @{ flags()->{cppflags} };
145
+ }
146
+
147
+ sub ldflags {
148
+ print join ' ', @{ flags()->{ldflags} };
149
+ }
150
+
151
+ sub libs {
152
+ print join ' ', @{ flags()->{libs} };
153
+ }
154
+
155
+ sub os {
156
+ print flags()->{os};
157
+ }
158
+
159
+ sub src {
160
+ print join ' ', @{ flags()->{src} };
161
+ }
162
+
163
+ sub inline_src {
164
+ my $stdout = @_ ? 0 : 1;
165
+ my $flags = shift || flags();
166
+ my $src = $flags->{src};
167
+ my $dir = $flags->{build_dir} || $ARGV[0];
168
+ my(@files);
169
+ #unlink symlinks incase of nfs shared dir...
170
+ for my $file (grep { -l } <*.c>) {
171
+ unlink $file;
172
+ }
173
+ for my $file (@$src) {
174
+ my $cf = basename $file;
175
+ #sigar.c -> libsigar.c else
176
+ #sigar.o and perl Sigar.o clash on case insensitive filesystems
177
+ $cf = 'libsigar.c' if $cf eq 'sigar.c';
178
+ if ($dir) {
179
+ $cf = join '/', $dir, $cf;
180
+ $file = File::Spec->rel2abs($file);
181
+ }
182
+ push @files, $cf;
183
+ if ($flags->{is_win32}) {
184
+ copy($file, $cf);
185
+ }
186
+ else {
187
+ symlink($file, $cf) unless -e $cf;
188
+ }
189
+ }
190
+ if ($stdout) {
191
+ print join ' ', @files;
192
+ }
193
+ else {
194
+ return @files;
195
+ }
196
+ }
197
+
198
+ sub scm_revision {
199
+ my $rev;
200
+ $rev = `git rev-parse --short HEAD`;
201
+ if ($rev) {
202
+ chomp $rev;
203
+ }
204
+ else {
205
+ $rev = "exported";
206
+ }
207
+ return $rev;
208
+ }
209
+
210
+ sub build_date {
211
+ return POSIX::strftime("%m/%d/%Y %I:%M %p", localtime);
212
+ }
213
+
214
+ sub find_file {
215
+ my $file = shift;
216
+ for my $dir (qw(../.. .. .)) {
217
+ my $pfile = "$dir/$file";
218
+ return $pfile if -e $pfile;
219
+ }
220
+ return $file;
221
+ }
222
+
223
+ sub version_properties {
224
+ my $props = {};
225
+ my $file = $_[0] || find_file('version.properties');
226
+ open my $fh, $file or die "open $file: $!";
227
+ while (<$fh>) {
228
+ chomp;
229
+ my($key,$val) = split '=';
230
+ next unless $key and defined $val;
231
+ $props->{$key} = $val;
232
+ }
233
+ close $fh;
234
+
235
+ $props->{'scm.revision'} = scm_revision();
236
+
237
+ $props->{'build.date'} = build_date();
238
+
239
+ $props->{'version'} =
240
+ join '.', map $props->{"version.$_"}, qw(major minor maint);
241
+
242
+ $props->{'version.build'} = $ENV{BUILD_NUMBER} || '0';
243
+
244
+ $props->{'version.string'} =
245
+ join '.', $props->{'version'}, $props->{'version.build'};
246
+
247
+ return $props;
248
+ }
249
+
250
+ sub resource_file {
251
+ my(@args) = @_ ? @_ : @ARGV;
252
+ version_file(find_file("src/os/win32/sigar.rc.in"), "sigar.rc", @args);
253
+ }
254
+
255
+ sub version_file {
256
+ local $_;
257
+ my($source, $dest, %filters);
258
+ my(@args) = @_ ? @_ : @ARGV;
259
+ for (@args) {
260
+ if (/=/) {
261
+ my($key,$val) = split '=', $_, 2;
262
+ $filters{$key} = $val;
263
+ }
264
+ else {
265
+ if ($source) {
266
+ $dest = $_;
267
+ }
268
+ else {
269
+ $source = $_;
270
+ }
271
+ }
272
+ }
273
+ unless ($source) {
274
+ $dest = 'sigar_version.c';
275
+ $source = find_file("src/$dest.in");
276
+ }
277
+ my $props = version_properties();
278
+ while (my($key,$val) = each %$props) {
279
+ $key = uc $key;
280
+ $key =~ s/\./_/;
281
+ $filters{$key} = $val;
282
+ }
283
+ my $re = join '|', keys %filters;
284
+ open my $in, $source or die "open $source: $!";
285
+ my $out;
286
+ if ($dest) {
287
+ open $out, '>', $dest or die "open $dest: $!";
288
+ }
289
+ else {
290
+ $out = \*STDOUT;
291
+ }
292
+ while (<$in>) {
293
+ s/\@\@($re)\@\@/$filters{$1}/go;
294
+ print $out $_;
295
+ }
296
+ close $in;
297
+ close $out if $dest;
298
+ }
299
+
300
+ 1;
301
+ __END__