cmetrics 0.1.7 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/apt.yml +39 -0
- data/.github/workflows/yum.yml +39 -0
- data/Gemfile +7 -1
- data/ci/apt-test.sh +40 -0
- data/ci/yum-test.sh +77 -0
- data/cmetrics-ruby.gemspec +1 -1
- data/ext/cmetrics/cmetrics_serde.c +161 -4
- data/ext/cmetrics/extconf.rb +26 -8
- data/lib/cmetrics/version.rb +1 -1
- metadata +9 -6
- data/ext/cmetrics-master.tar.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2886740550218bbb68b6248676ffefa606939d2c2f6fabb5043e9b08f2cb152f
|
4
|
+
data.tar.gz: 4b73350710d2c56349fdb83af9e45565e4e38cffb62f48344f25244c27688cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e93ebcde84cfd9c2835f68516891f6616c3c77785b789d195c3bf0fe2d5b384314c700f34413f640680da91190cbe16f03961f540dd326515647dc754237265
|
7
|
+
data.tar.gz: b1c4c88fb1416047862f5d5027ce7c92bed28fe0e1172707fa3394af947cc320a64833ab9cbbcfa510ced7f14201ab4ea6b9958a16b5af9fd28a1be26bd00d98
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: Apt based Linux
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
pull_request:
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: Build
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
label:
|
12
|
+
- Debian GNU/Linux Bullseye amd64
|
13
|
+
- Debian GNU/Linux Buster amd64
|
14
|
+
- Ubuntu Bionic amd64
|
15
|
+
- Ubuntu Focal amd64
|
16
|
+
include:
|
17
|
+
- label: Debian GNU/Linux Bullseye amd64
|
18
|
+
test-docker-image: debian:bullseye
|
19
|
+
test-script: ci/apt-test.sh
|
20
|
+
- label: Debian GNU/Linux Buster amd64
|
21
|
+
test-docker-image: debian:buster
|
22
|
+
test-script: ci/apt-test.sh
|
23
|
+
- label: Ubuntu Bionic amd64
|
24
|
+
test-docker-image: ubuntu:bionic
|
25
|
+
test-script: ci/apt-test.sh
|
26
|
+
- label: Ubuntu Focal amd64
|
27
|
+
test-docker-image: ubuntu:focal
|
28
|
+
test-script: ci/apt-test.sh
|
29
|
+
runs-on: ubuntu-latest
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@master
|
32
|
+
- name: rake compile & rake test
|
33
|
+
run: |
|
34
|
+
docker run \
|
35
|
+
--rm \
|
36
|
+
--tty \
|
37
|
+
--volume ${PWD}:/cmetrics-ruby \
|
38
|
+
${{ matrix.test-docker-image }} \
|
39
|
+
/cmetrics-ruby/${{ matrix.test-script }}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: Yum based Linux
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
pull_request:
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: Build
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
label:
|
12
|
+
- CentOS 7 x86_64
|
13
|
+
- CentOS 8 x86_64
|
14
|
+
- Fedora 34 x86_64
|
15
|
+
- AmazonLinux 2 x86_64
|
16
|
+
include:
|
17
|
+
- label: CentOS 7 x86_64
|
18
|
+
test-docker-image: centos:7
|
19
|
+
test-script: ci/yum-test.sh
|
20
|
+
- label: CentOS 8 x86_64
|
21
|
+
test-docker-image: centos:8
|
22
|
+
test-script: ci/yum-test.sh
|
23
|
+
- label: Fedora 34 x86_64
|
24
|
+
test-docker-image: fedora:34
|
25
|
+
test-script: ci/yum-test.sh
|
26
|
+
- label: AmazonLinux 2 x86_64
|
27
|
+
test-docker-image: amazonlinux:2
|
28
|
+
test-script: ci/yum-test.sh
|
29
|
+
runs-on: ubuntu-latest
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@master
|
32
|
+
- name: rake compile & rake test
|
33
|
+
run: |
|
34
|
+
docker run \
|
35
|
+
--rm \
|
36
|
+
--tty \
|
37
|
+
--volume ${PWD}:/cmetrics-ruby \
|
38
|
+
${{ matrix.test-docker-image }} \
|
39
|
+
/cmetrics-ruby/${{ matrix.test-script }}
|
data/Gemfile
CHANGED
@@ -7,4 +7,10 @@ gemspec
|
|
7
7
|
|
8
8
|
gem "rake", "~> 13.0"
|
9
9
|
|
10
|
-
gem "test-unit", "~> 3.
|
10
|
+
gem "test-unit", "~> 3.4"
|
11
|
+
|
12
|
+
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
|
13
|
+
if File.exist?(local_gemfile)
|
14
|
+
puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
|
15
|
+
instance_eval File.read(local_gemfile)
|
16
|
+
end
|
data/ci/apt-test.sh
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -exu
|
4
|
+
|
5
|
+
export DEBIAN_FRONTEND=noninteractive
|
6
|
+
|
7
|
+
if [ -f /etc/lsb-release ]; then
|
8
|
+
. /etc/lsb-release
|
9
|
+
distribution=$DISTRIB_ID
|
10
|
+
version=${DISTRIB_RELEASE%%.*}
|
11
|
+
codename=${DISTRIB_CODENAME%%.*}
|
12
|
+
else
|
13
|
+
distribution="Debian"
|
14
|
+
version=$(cat /etc/debian_version | cut -d'.' -f1)
|
15
|
+
fi
|
16
|
+
|
17
|
+
apt update
|
18
|
+
|
19
|
+
case "$distribution" in
|
20
|
+
"Ubuntu")
|
21
|
+
case "$codename" in
|
22
|
+
"bionic")
|
23
|
+
apt install -V -y wget gpg
|
24
|
+
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null && \
|
25
|
+
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ bionic main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
|
26
|
+
apt update
|
27
|
+
;;
|
28
|
+
*)
|
29
|
+
;;
|
30
|
+
esac
|
31
|
+
;;
|
32
|
+
esac
|
33
|
+
|
34
|
+
apt install -V -y lsb-release
|
35
|
+
|
36
|
+
apt install -V -y ruby-dev git build-essential pkg-config cmake
|
37
|
+
cd /cmetrics-ruby && \
|
38
|
+
gem install bundler --no-document && \
|
39
|
+
bundle install && \
|
40
|
+
bundle exec rake
|
data/ci/yum-test.sh
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -exu
|
4
|
+
|
5
|
+
USE_SCL=0
|
6
|
+
USE_AMZN_EXT=0
|
7
|
+
|
8
|
+
distribution=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f2)
|
9
|
+
version=$(cat /etc/system-release-cpe | awk '{print substr($0, index($1, "o"))}' | cut -d: -f4)
|
10
|
+
USE_SCL=0
|
11
|
+
USE_AMZN_EXT=0
|
12
|
+
|
13
|
+
case ${distribution} in
|
14
|
+
amazon)
|
15
|
+
case ${version} in
|
16
|
+
2)
|
17
|
+
DNF=yum
|
18
|
+
USE_AMZN_EXT=1
|
19
|
+
;;
|
20
|
+
esac
|
21
|
+
;;
|
22
|
+
centos)
|
23
|
+
case ${version} in
|
24
|
+
7)
|
25
|
+
DNF=yum
|
26
|
+
USE_SCL=1
|
27
|
+
;;
|
28
|
+
*)
|
29
|
+
DNF="dnf --enablerepo=powertools"
|
30
|
+
;;
|
31
|
+
esac
|
32
|
+
;;
|
33
|
+
fedoraproject)
|
34
|
+
case ${version} in
|
35
|
+
33|34)
|
36
|
+
DNF=yum
|
37
|
+
;;
|
38
|
+
esac
|
39
|
+
;;
|
40
|
+
esac
|
41
|
+
|
42
|
+
${DNF} groupinstall -y "Development Tools"
|
43
|
+
|
44
|
+
if [ $USE_SCL -eq 1 ]; then
|
45
|
+
${DNF} install -y centos-release-scl && \
|
46
|
+
${DNF} install -y epel-release && \
|
47
|
+
${DNF} install -y \
|
48
|
+
rh-ruby26-ruby-devel \
|
49
|
+
rh-ruby26-rubygems \
|
50
|
+
rh-ruby26-rubygem-rake \
|
51
|
+
rpm-build \
|
52
|
+
cmake3
|
53
|
+
elif [ $USE_AMZN_EXT -eq 1 ]; then
|
54
|
+
yum update -y && \
|
55
|
+
yum install -y yum-utils && \
|
56
|
+
yum-config-manager --enable epel && \
|
57
|
+
amazon-linux-extras install -y ruby2.6 && \
|
58
|
+
${DNF} install -y ruby-devel \
|
59
|
+
cmake3
|
60
|
+
else
|
61
|
+
${DNF} install -y ruby-devel \
|
62
|
+
rubygems \
|
63
|
+
rpm-build \
|
64
|
+
cmake \
|
65
|
+
libarchive
|
66
|
+
fi
|
67
|
+
|
68
|
+
if [ $USE_SCL -eq 1 ]; then
|
69
|
+
# For unbound variable error
|
70
|
+
export MANPATH=
|
71
|
+
cd /cmetrics-ruby && source /opt/rh/rh-ruby26/enable && gem install bundler --no-document && bundle install && bundle exec rake
|
72
|
+
else
|
73
|
+
if [ $USE_AMZN_EXT -eq 1 ]; then
|
74
|
+
echo 'gem "io-console"' > /cmetrics-ruby/Gemfile.local
|
75
|
+
fi
|
76
|
+
cd /cmetrics-ruby && gem install bundler --no-document && bundle install && bundle exec rake
|
77
|
+
fi
|
data/cmetrics-ruby.gemspec
CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "rake-compiler", "~> 1.0"
|
31
31
|
spec.add_development_dependency "rake-compiler-dock", "~> 1.0"
|
32
32
|
|
33
|
-
spec.add_dependency 'mini_portile2', '~> 2.
|
33
|
+
spec.add_dependency 'mini_portile2', '~> 2.7'
|
34
34
|
end
|
@@ -18,6 +18,8 @@
|
|
18
18
|
*/
|
19
19
|
|
20
20
|
#include "cmetrics_c.h"
|
21
|
+
#include <cmetrics/cmt_map.h>
|
22
|
+
#include <cmetrics/cmt_metric.h>
|
21
23
|
|
22
24
|
VALUE rb_cSerde;
|
23
25
|
|
@@ -111,7 +113,11 @@ rb_cmetrics_serde_from_msgpack(int argc, VALUE *argv, VALUE self)
|
|
111
113
|
rb_raise(rb_eRuntimeError, "offset should be smaller than msgpack buffer size.");
|
112
114
|
}
|
113
115
|
|
114
|
-
|
116
|
+
if (!NIL_P(rb_msgpack_buffer)) {
|
117
|
+
ret = cmt_decode_msgpack_create(&cmt, StringValuePtr(rb_msgpack_buffer), msgpack_length, &offset);
|
118
|
+
} else {
|
119
|
+
rb_raise(rb_eArgError, "nil is not valid value for buffer");
|
120
|
+
}
|
115
121
|
|
116
122
|
if (ret == 0) {
|
117
123
|
cmetricsSerde->instance = cmt;
|
@@ -129,13 +135,14 @@ rb_cmetrics_serde_from_msgpack_feed_each_impl(VALUE self, VALUE rb_msgpack_buffe
|
|
129
135
|
struct CMetricsSerde* cmetricsSerde;
|
130
136
|
struct cmt *cmt = NULL;
|
131
137
|
int ret = 0;
|
138
|
+
size_t offset = 0;
|
132
139
|
|
133
140
|
RETURN_ENUMERATOR(self, 0, 0);
|
134
141
|
|
135
142
|
TypedData_Get_Struct(
|
136
143
|
self, struct CMetricsSerde, &rb_cmetrics_serde_type, cmetricsSerde);
|
137
144
|
|
138
|
-
for (
|
145
|
+
for (offset = 0; offset <= msgpack_length; ) {
|
139
146
|
ret = cmt_decode_msgpack_create(&cmt, StringValuePtr(rb_msgpack_buffer), msgpack_length, &offset);
|
140
147
|
if (ret == 0) {
|
141
148
|
cmetricsSerde->instance = cmt;
|
@@ -154,8 +161,11 @@ static VALUE
|
|
154
161
|
rb_cmetrics_serde_from_msgpack_feed_each(VALUE self, VALUE rb_data)
|
155
162
|
{
|
156
163
|
RETURN_ENUMERATOR(self, 0, 0);
|
157
|
-
|
158
|
-
|
164
|
+
if (!NIL_P(rb_data)) {
|
165
|
+
return rb_cmetrics_serde_from_msgpack_feed_each_impl(self, rb_data, RSTRING_LEN(rb_data));
|
166
|
+
} else {
|
167
|
+
rb_raise(rb_eArgError, "nil is not valid value for buffer");
|
168
|
+
}
|
159
169
|
}
|
160
170
|
|
161
171
|
static VALUE
|
@@ -237,6 +247,151 @@ rb_cmetrics_serde_to_text(VALUE self)
|
|
237
247
|
return text;
|
238
248
|
}
|
239
249
|
|
250
|
+
static VALUE
|
251
|
+
append_metric_value(struct cmt_map *map,
|
252
|
+
VALUE rbHash, struct cmt_metric *metric)
|
253
|
+
{
|
254
|
+
uint64_t ts;
|
255
|
+
double val;
|
256
|
+
struct cmt_opts *opts;
|
257
|
+
|
258
|
+
opts = map->opts;
|
259
|
+
|
260
|
+
/* Retrieve metric value */
|
261
|
+
val = cmt_metric_get_value(metric);
|
262
|
+
|
263
|
+
ts = cmt_metric_get_timestamp(metric);
|
264
|
+
|
265
|
+
rb_hash_aset(rbHash, rb_str_new2("name"), rb_str_new2(opts->name));
|
266
|
+
rb_hash_aset(rbHash, rb_str_new2("description"), rb_str_new2(opts->description));
|
267
|
+
rb_hash_aset(rbHash, rb_str_new2("value"), DBL2NUM(val));
|
268
|
+
rb_hash_aset(rbHash, rb_str_new2("timestamp"), DBL2NUM(ts/1000000000.0));
|
269
|
+
|
270
|
+
return rbHash;
|
271
|
+
}
|
272
|
+
|
273
|
+
static VALUE
|
274
|
+
format_metric(struct cmt *cmt, struct cmt_map *map,
|
275
|
+
struct cmt_metric *metric)
|
276
|
+
{
|
277
|
+
int n;
|
278
|
+
int static_labels = 0;
|
279
|
+
struct cmt_map_label *label_k;
|
280
|
+
struct cmt_map_label *label_v;
|
281
|
+
struct mk_list *head;
|
282
|
+
struct cmt_opts *opts;
|
283
|
+
struct cmt_label *slabel;
|
284
|
+
VALUE rb_hash = rb_hash_new();
|
285
|
+
VALUE shash = rb_hash_new();
|
286
|
+
VALUE lhash = rb_hash_new();
|
287
|
+
|
288
|
+
opts = map->opts;
|
289
|
+
|
290
|
+
/* Measurement */
|
291
|
+
rb_hash_aset(rb_hash, rb_str_new2("namespace"), rb_str_new2(opts->ns));
|
292
|
+
rb_hash_aset(rb_hash, rb_str_new2("subsystem"), rb_str_new2(opts->subsystem));
|
293
|
+
|
294
|
+
/* Static labels (tags) */
|
295
|
+
static_labels = cmt_labels_count(cmt->static_labels);
|
296
|
+
if (static_labels > 0) {
|
297
|
+
mk_list_foreach(head, &cmt->static_labels->list) {
|
298
|
+
slabel = mk_list_entry(head, struct cmt_label, _head);
|
299
|
+
rb_hash_aset(shash, rb_str_new2(slabel->key), rb_str_new2(slabel->val));
|
300
|
+
}
|
301
|
+
rb_hash_aset(rb_hash, rb_str_new2("static_labels"), shash);
|
302
|
+
}
|
303
|
+
|
304
|
+
/* Labels / Tags */
|
305
|
+
n = mk_list_size(&metric->labels);
|
306
|
+
if (n > 0) {
|
307
|
+
label_k = mk_list_entry_first(&map->label_keys, struct cmt_map_label, _head);
|
308
|
+
|
309
|
+
mk_list_foreach(head, &metric->labels) {
|
310
|
+
label_v = mk_list_entry(head, struct cmt_map_label, _head);
|
311
|
+
|
312
|
+
rb_hash_aset(lhash, rb_str_new2(label_k->name), rb_str_new2(label_v->name));
|
313
|
+
|
314
|
+
label_k = mk_list_entry_next(&label_k->_head, struct cmt_map_label,
|
315
|
+
_head, &map->label_keys);
|
316
|
+
}
|
317
|
+
rb_hash_aset(rb_hash, rb_str_new2("labels"), lhash);
|
318
|
+
}
|
319
|
+
|
320
|
+
rb_hash = append_metric_value(map, rb_hash, metric);
|
321
|
+
|
322
|
+
return rb_hash;
|
323
|
+
}
|
324
|
+
|
325
|
+
static VALUE
|
326
|
+
format_metrics(struct cmt *cmt,
|
327
|
+
struct cmt_map *map, int add_timestamp)
|
328
|
+
{
|
329
|
+
VALUE rbMetrics = rb_ary_new();
|
330
|
+
VALUE rbMetric;
|
331
|
+
struct mk_list *head;
|
332
|
+
struct cmt_metric *metric;
|
333
|
+
|
334
|
+
/* Simple metric, no labels */
|
335
|
+
if (map->metric_static_set == 1) {
|
336
|
+
rbMetric = format_metric(cmt, map, &map->metric);
|
337
|
+
rb_ary_push(rbMetrics, rbMetric);
|
338
|
+
}
|
339
|
+
|
340
|
+
mk_list_foreach(head, &map->metrics) {
|
341
|
+
metric = mk_list_entry(head, struct cmt_metric, _head);
|
342
|
+
rbMetric = format_metric(cmt, map, metric);
|
343
|
+
rb_ary_push(rbMetrics, rbMetric);
|
344
|
+
}
|
345
|
+
|
346
|
+
return rbMetrics;
|
347
|
+
}
|
348
|
+
|
349
|
+
static VALUE
|
350
|
+
rb_cmetrics_serde_get_metrics(VALUE self)
|
351
|
+
{
|
352
|
+
VALUE rbMetrics = rb_ary_new();
|
353
|
+
VALUE rbMetricsInner = rb_ary_new();
|
354
|
+
struct CMetricsSerde* cmetricsSerde;
|
355
|
+
struct mk_list *head;
|
356
|
+
struct cmt_gauge *gauge;
|
357
|
+
struct cmt_counter *counter;
|
358
|
+
struct cmt_untyped *untyped;
|
359
|
+
struct cmt *cmt;
|
360
|
+
int add_timestamp = CMT_TRUE;
|
361
|
+
|
362
|
+
TypedData_Get_Struct(
|
363
|
+
self, struct CMetricsSerde, &rb_cmetrics_serde_type, cmetricsSerde);
|
364
|
+
|
365
|
+
cmt = cmetricsSerde->instance;
|
366
|
+
|
367
|
+
if (cmt == NULL) {
|
368
|
+
rb_raise(rb_eRuntimeError, "Invalid cmt context");
|
369
|
+
}
|
370
|
+
|
371
|
+
/* Counters */
|
372
|
+
mk_list_foreach(head, &cmt->counters) {
|
373
|
+
counter = mk_list_entry(head, struct cmt_counter, _head);
|
374
|
+
rbMetricsInner = format_metrics(cmt, counter->map, add_timestamp);
|
375
|
+
rb_ary_push(rbMetrics, rbMetricsInner);
|
376
|
+
}
|
377
|
+
|
378
|
+
/* Gauges */
|
379
|
+
mk_list_foreach(head, &cmt->gauges) {
|
380
|
+
gauge = mk_list_entry(head, struct cmt_gauge, _head);
|
381
|
+
rbMetricsInner = format_metrics(cmt, gauge->map, add_timestamp);
|
382
|
+
rb_ary_push(rbMetrics, rbMetricsInner);
|
383
|
+
}
|
384
|
+
|
385
|
+
/* Untyped */
|
386
|
+
mk_list_foreach(head, &cmt->untypeds) {
|
387
|
+
untyped = mk_list_entry(head, struct cmt_untyped, _head);
|
388
|
+
rbMetricsInner = format_metrics(cmt, untyped->map, add_timestamp);
|
389
|
+
rb_ary_push(rbMetrics, rbMetricsInner);
|
390
|
+
}
|
391
|
+
|
392
|
+
return rbMetrics;
|
393
|
+
}
|
394
|
+
|
240
395
|
void Init_cmetrics_serde(VALUE rb_mCMetrics)
|
241
396
|
{
|
242
397
|
rb_cSerde = rb_define_class_under(rb_mCMetrics, "Serde", rb_cObject);
|
@@ -250,4 +405,6 @@ void Init_cmetrics_serde(VALUE rb_mCMetrics)
|
|
250
405
|
rb_define_method(rb_cSerde, "to_msgpack", rb_cmetrics_serde_to_msgpack, 0);
|
251
406
|
rb_define_method(rb_cSerde, "feed_each", rb_cmetrics_serde_from_msgpack_feed_each, 1);
|
252
407
|
rb_define_method(rb_cSerde, "to_s", rb_cmetrics_serde_to_text, 0);
|
408
|
+
rb_define_method(rb_cSerde, "get_metrics", rb_cmetrics_serde_get_metrics, 0);
|
409
|
+
rb_define_method(rb_cSerde, "metrics", rb_cmetrics_serde_get_metrics, 0);
|
253
410
|
}
|
data/ext/cmetrics/extconf.rb
CHANGED
@@ -13,33 +13,51 @@ def windows?
|
|
13
13
|
RUBY_PLATFORM =~ /mingw|mswin/
|
14
14
|
end
|
15
15
|
|
16
|
+
def determine_preferred_command(bin, default_bin)
|
17
|
+
printf "checking for whether %s or %s is usable... ", bin, default_bin
|
18
|
+
STDOUT.flush
|
19
|
+
bin += RbConfig::CONFIG['EXEEXT']
|
20
|
+
path = ENV['PATH'].split(RbConfig::CONFIG['PATH_SEPARATOR'])
|
21
|
+
for dir in path
|
22
|
+
file = File.join(dir, bin)
|
23
|
+
if FileTest.executable?(file)
|
24
|
+
printf "%s\n", bin
|
25
|
+
return bin
|
26
|
+
else
|
27
|
+
next
|
28
|
+
end
|
29
|
+
end
|
30
|
+
printf "%s\n", default_bin
|
31
|
+
return default_bin
|
32
|
+
end
|
33
|
+
|
16
34
|
class BuildCMetrics
|
17
35
|
|
18
36
|
attr_reader :recipe
|
19
37
|
|
20
|
-
def initialize(version=nil)
|
38
|
+
def initialize(version=nil, **kwargs)
|
21
39
|
@version = if version
|
22
40
|
version
|
23
41
|
else
|
24
42
|
"master".freeze
|
25
43
|
end
|
26
|
-
@recipe = MiniPortileCMake.new("cmetrics", @version)
|
44
|
+
@recipe = MiniPortileCMake.new("cmetrics", @version, **kwargs)
|
27
45
|
@checkpoint = ".#{@recipe.name}-#{@recipe.version}.installed"
|
28
46
|
@recipe.target = File.join(ROOT, "ports")
|
29
47
|
@recipe.files << {
|
30
|
-
url: "
|
31
|
-
sha256sum: "
|
48
|
+
url: "https://codeload.github.com/calyptia/cmetrics/tar.gz/v#{version}",
|
49
|
+
sha256sum: "f0c79707ad4d18980bf0d1d64ed8cb73a40c586c36a4caf38233ae8d9a4c6cc7",
|
32
50
|
}
|
33
51
|
end
|
34
52
|
|
35
53
|
def build
|
36
54
|
unless File.exist?(@checkpoint)
|
37
55
|
@recipe.cook
|
38
|
-
libcmetrics_path = File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib
|
56
|
+
libcmetrics_path = Dir.glob(File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib*/libcmetrics.a")).first
|
39
57
|
FileUtils.cp(libcmetrics_path, File.join(ROOT, "ext", "cmetrics", "libcmetrics.a"))
|
40
|
-
libmpack_path = File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib
|
58
|
+
libmpack_path = Dir.glob(File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib*/libmpack.a")).first
|
41
59
|
FileUtils.cp(libmpack_path, File.join(ROOT, "ext", "cmetrics", "libmpack.a"))
|
42
|
-
libxxhash_path = File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib
|
60
|
+
libxxhash_path = Dir.glob(File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/lib*/libxxhash.a")).first
|
43
61
|
FileUtils.cp(libxxhash_path, File.join(ROOT, "ext", "cmetrics", "libxxhash.a"))
|
44
62
|
include_path = File.join(ROOT, "ports/#{@recipe.host}/cmetrics/#{@version}/include/")
|
45
63
|
FileUtils.cp_r(Dir.glob(File.join(include_path, "*")), File.join(ROOT, "ext", "cmetrics"))
|
@@ -52,7 +70,7 @@ class BuildCMetrics
|
|
52
70
|
end
|
53
71
|
end
|
54
72
|
|
55
|
-
cmetrics = BuildCMetrics.new
|
73
|
+
cmetrics = BuildCMetrics.new("0.2.1", cmake_command: determine_preferred_command("cmake3", "cmake"))
|
56
74
|
cmetrics.build
|
57
75
|
|
58
76
|
libdir = RbConfig::CONFIG["libdir"]
|
data/lib/cmetrics/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Hatake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '2.
|
75
|
+
version: '2.7'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '2.
|
82
|
+
version: '2.7'
|
83
83
|
description: C binding for cmetric library.
|
84
84
|
email:
|
85
85
|
- cosmo0920.oucc@gmail.com
|
@@ -88,9 +88,11 @@ extensions:
|
|
88
88
|
- ext/cmetrics/extconf.rb
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
+
- ".github/workflows/apt.yml"
|
91
92
|
- ".github/workflows/linux.yml"
|
92
93
|
- ".github/workflows/macos.yml"
|
93
94
|
- ".github/workflows/windows.yml"
|
95
|
+
- ".github/workflows/yum.yml"
|
94
96
|
- ".gitignore"
|
95
97
|
- Gemfile
|
96
98
|
- LICENSE
|
@@ -98,8 +100,9 @@ files:
|
|
98
100
|
- Rakefile
|
99
101
|
- bin/console
|
100
102
|
- bin/setup
|
103
|
+
- ci/apt-test.sh
|
104
|
+
- ci/yum-test.sh
|
101
105
|
- cmetrics-ruby.gemspec
|
102
|
-
- ext/cmetrics-master.tar.gz
|
103
106
|
- ext/cmetrics/cmetrics.c
|
104
107
|
- ext/cmetrics/cmetrics_c.h
|
105
108
|
- ext/cmetrics/cmetrics_counter.c
|
@@ -130,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
133
|
- !ruby/object:Gem::Version
|
131
134
|
version: '0'
|
132
135
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
136
|
+
rubygems_version: 3.2.22
|
134
137
|
signing_key:
|
135
138
|
specification_version: 4
|
136
139
|
summary: C binding for cmetric library.
|
data/ext/cmetrics-master.tar.gz
DELETED
Binary file
|