helix_runtime 0.5.0.alpha.1 → 0.5.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/helix +6 -0
- data/ext/helix_runtime/native/extconf.rb +7 -7
- data/ext/helix_runtime/native/helix_runtime.c +145 -145
- data/ext/helix_runtime/native/helix_runtime.h +103 -103
- data/helix_runtime.gemspec +5 -4
- data/lib/helix_runtime.rb +52 -0
- data/lib/helix_runtime/build_task.rb +30 -108
- data/lib/helix_runtime/cli.rb +17 -0
- data/lib/helix_runtime/cli/bootstrap.rb +73 -0
- data/lib/helix_runtime/cli/templates/Cargo.toml +9 -0
- data/lib/helix_runtime/cli/templates/Gemfile +3 -0
- data/lib/helix_runtime/cli/templates/gem.gemspec +14 -0
- data/lib/helix_runtime/cli/templates/gitignore +4 -0
- data/lib/helix_runtime/cli/templates/helix_runtime.rake +5 -0
- data/lib/helix_runtime/cli/templates/lib.rb +7 -0
- data/lib/helix_runtime/cli/templates/lib.rs +10 -0
- data/lib/helix_runtime/parent_build_task.rb +35 -0
- data/lib/helix_runtime/parent_project.rb +40 -0
- data/lib/helix_runtime/project.rb +147 -0
- data/lib/helix_runtime/version.rb +2 -1
- metadata +35 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab00e046b76ca504ff8caff613845ff820e9fcbb
|
4
|
+
data.tar.gz: d6356cc4e6458241ba777668f88a13c482038ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ea5cf554df32877b5bacb969b7829d54d082ae54f5bf11b6272d812eaaff83f41ba03703400fd752a92cd1dc0e2979b6b356296717913058721574b12564dd4
|
7
|
+
data.tar.gz: 3bfef6858197cfc99908131fa100bba9d9fc9c6ac17bb47bf78de327a45315341f622a95d651b84b074285a6e5e48d6044cc4287f73d31d9963afe3374583a60
|
data/README.md
CHANGED
@@ -1 +1 @@
|
|
1
|
-
# Helix Runtime
|
1
|
+
# Helix Runtime
|
data/bin/helix
ADDED
@@ -1,7 +1,7 @@
|
|
1
|
-
require "mkmf"
|
2
|
-
|
3
|
-
if RUBY_PLATFORM =~ /mingw/
|
4
|
-
system "rake native_def_file"
|
5
|
-
end
|
6
|
-
|
7
|
-
create_makefile "helix_runtime/native"
|
1
|
+
require "mkmf"
|
2
|
+
|
3
|
+
if RUBY_PLATFORM =~ /mingw/
|
4
|
+
system "rake native_def_file"
|
5
|
+
end
|
6
|
+
|
7
|
+
create_makefile "helix_runtime/native"
|
@@ -1,145 +1,145 @@
|
|
1
|
-
#define BUILDING_DLL
|
2
|
-
|
3
|
-
#include <ruby.h>
|
4
|
-
#include <ruby/intern.h>
|
5
|
-
#include <stdbool.h>
|
6
|
-
#include <helix_runtime.h>
|
7
|
-
|
8
|
-
// Update with version.rb
|
9
|
-
const char* HELIX_RUNTIME_VERSION = "0.5.0
|
10
|
-
|
11
|
-
const char* HELIX_PRIsVALUE = PRIsVALUE;
|
12
|
-
const char* HELIX_SPRINTF_TO_S = "%" PRIsVALUE;
|
13
|
-
const char* HELIX_SPRINTF_INSPECT = "%+" PRIsVALUE;
|
14
|
-
|
15
|
-
VALUE HELIX_Qtrue = Qtrue;
|
16
|
-
VALUE HELIX_Qfalse = Qfalse;
|
17
|
-
VALUE HELIX_Qnil = Qnil;
|
18
|
-
|
19
|
-
long HELIX_RSTRING_LEN(VALUE string) {
|
20
|
-
return RSTRING_LEN(string);
|
21
|
-
}
|
22
|
-
|
23
|
-
const char* HELIX_RSTRING_PTR(VALUE string) {
|
24
|
-
return RSTRING_PTR(string);
|
25
|
-
}
|
26
|
-
|
27
|
-
long HELIX_RARRAY_LEN(VALUE array) {
|
28
|
-
return RARRAY_LEN(array);
|
29
|
-
}
|
30
|
-
|
31
|
-
void* HELIX_RARRAY_PTR(VALUE array) {
|
32
|
-
return RARRAY_PTR(array);
|
33
|
-
}
|
34
|
-
|
35
|
-
const void* HELIX_RARRAY_CONST_PTR(VALUE array) {
|
36
|
-
return RARRAY_CONST_PTR(array);
|
37
|
-
}
|
38
|
-
|
39
|
-
bool HELIX_RB_TYPE_P(VALUE v, int type) {
|
40
|
-
return RB_TYPE_P(v, type);
|
41
|
-
}
|
42
|
-
|
43
|
-
VALUE HELIX_INT2FIX(int c_int) {
|
44
|
-
return INT2FIX(c_int);
|
45
|
-
}
|
46
|
-
|
47
|
-
VALUE HELIX_FIX2INT(VALUE v) {
|
48
|
-
return FIX2INT(v);
|
49
|
-
}
|
50
|
-
|
51
|
-
VALUE HELIX_rb_utf8_str_new(const char* str, long len) {
|
52
|
-
return rb_utf8_str_new(str, len);
|
53
|
-
}
|
54
|
-
|
55
|
-
VALUE HELIX_Data_Wrap_Struct(VALUE klass, HELIX_RUBY_DATA_FUNC mark, HELIX_RUBY_DATA_FUNC free, void* data) {
|
56
|
-
return Data_Wrap_Struct(klass, mark, free, data);
|
57
|
-
}
|
58
|
-
|
59
|
-
RUST_U64 HELIX_NUM2U64(VALUE obj) {
|
60
|
-
return NUM2ULL(obj);
|
61
|
-
}
|
62
|
-
|
63
|
-
VALUE HELIX_U642NUM(RUST_U64 num) {
|
64
|
-
return ULL2NUM(num);
|
65
|
-
}
|
66
|
-
|
67
|
-
RUST_I64 HELIX_NUM2I64(VALUE obj) {
|
68
|
-
return NUM2LL(obj);
|
69
|
-
}
|
70
|
-
|
71
|
-
VALUE HELIX_I642NUM(RUST_I64 num) {
|
72
|
-
return LL2NUM(num);
|
73
|
-
}
|
74
|
-
|
75
|
-
RUST_U32 HELIX_NUM2U32(VALUE obj) {
|
76
|
-
return NUM2UINT(obj);
|
77
|
-
}
|
78
|
-
|
79
|
-
VALUE HELIX_U322NUM(RUST_U32 num) {
|
80
|
-
return UINT2NUM(num);
|
81
|
-
}
|
82
|
-
|
83
|
-
RUST_I32 HELIX_NUM2I32(VALUE obj) {
|
84
|
-
return NUM2INT(obj);
|
85
|
-
}
|
86
|
-
|
87
|
-
VALUE HELIX_I322NUM(RUST_I32 num) {
|
88
|
-
return INT2NUM(num);
|
89
|
-
}
|
90
|
-
|
91
|
-
RUST_F64 HELIX_NUM2F64(VALUE obj) {
|
92
|
-
return NUM2DBL(obj);
|
93
|
-
}
|
94
|
-
|
95
|
-
VALUE HELIX_F642NUM(RUST_F64 num) {
|
96
|
-
return DBL2NUM(num);
|
97
|
-
}
|
98
|
-
|
99
|
-
void* HELIX_Data_Get_Struct_Value(VALUE obj) {
|
100
|
-
void* data;
|
101
|
-
Data_Get_Struct(obj, void*, data);
|
102
|
-
return data;
|
103
|
-
}
|
104
|
-
|
105
|
-
void HELIX_Data_Set_Struct_Value(VALUE obj, void* data) {
|
106
|
-
DATA_PTR(obj) = data;
|
107
|
-
}
|
108
|
-
|
109
|
-
// void HELIX_rb_define_alloc_func(VALUE klass, HELIX_rb_alloc_func_t func) {
|
110
|
-
// rb_define_alloc_func(klass, func);
|
111
|
-
// }
|
112
|
-
|
113
|
-
int HELIX_TYPE(VALUE v) {
|
114
|
-
return TYPE(v);
|
115
|
-
}
|
116
|
-
|
117
|
-
int HELIX_T_NONE = T_NONE;
|
118
|
-
int HELIX_T_NIL = T_NIL;
|
119
|
-
int HELIX_T_OBJECT = T_OBJECT;
|
120
|
-
int HELIX_T_CLASS = T_CLASS;
|
121
|
-
int HELIX_T_ICLASS = T_ICLASS;
|
122
|
-
int HELIX_T_MODULE = T_MODULE;
|
123
|
-
int HELIX_T_FLOAT = T_FLOAT;
|
124
|
-
int HELIX_T_STRING = T_STRING;
|
125
|
-
int HELIX_T_REGEXP = T_REGEXP;
|
126
|
-
int HELIX_T_ARRAY = T_ARRAY;
|
127
|
-
int HELIX_T_HASH = T_HASH;
|
128
|
-
int HELIX_T_STRUCT = T_STRUCT;
|
129
|
-
int HELIX_T_BIGNUM = T_BIGNUM;
|
130
|
-
int HELIX_T_FILE = T_FILE;
|
131
|
-
int HELIX_T_FIXNUM = T_FIXNUM;
|
132
|
-
int HELIX_T_TRUE = T_TRUE;
|
133
|
-
int HELIX_T_FALSE = T_FALSE;
|
134
|
-
int HELIX_T_DATA = T_DATA;
|
135
|
-
int HELIX_T_MATCH = T_MATCH;
|
136
|
-
int HELIX_T_SYMBOL = T_SYMBOL;
|
137
|
-
int HELIX_T_RATIONAL = T_RATIONAL;
|
138
|
-
int HELIX_T_COMPLEX = T_COMPLEX;
|
139
|
-
int HELIX_T_UNDEF = T_UNDEF;
|
140
|
-
int HELIX_T_NODE = T_NODE;
|
141
|
-
int HELIX_T_ZOMBIE = T_ZOMBIE;
|
142
|
-
int HELIX_T_MASK = T_MASK;
|
143
|
-
// int HELIX_T_IMEMO = T_IMEMO;
|
144
|
-
|
145
|
-
void Init_native() {}
|
1
|
+
#define BUILDING_DLL
|
2
|
+
|
3
|
+
#include <ruby.h>
|
4
|
+
#include <ruby/intern.h>
|
5
|
+
#include <stdbool.h>
|
6
|
+
#include <helix_runtime.h>
|
7
|
+
|
8
|
+
// Update with version.rb
|
9
|
+
const char* HELIX_RUNTIME_VERSION = "0.5.0-alpha-2";
|
10
|
+
|
11
|
+
const char* HELIX_PRIsVALUE = PRIsVALUE;
|
12
|
+
const char* HELIX_SPRINTF_TO_S = "%" PRIsVALUE;
|
13
|
+
const char* HELIX_SPRINTF_INSPECT = "%+" PRIsVALUE;
|
14
|
+
|
15
|
+
VALUE HELIX_Qtrue = Qtrue;
|
16
|
+
VALUE HELIX_Qfalse = Qfalse;
|
17
|
+
VALUE HELIX_Qnil = Qnil;
|
18
|
+
|
19
|
+
long HELIX_RSTRING_LEN(VALUE string) {
|
20
|
+
return RSTRING_LEN(string);
|
21
|
+
}
|
22
|
+
|
23
|
+
const char* HELIX_RSTRING_PTR(VALUE string) {
|
24
|
+
return RSTRING_PTR(string);
|
25
|
+
}
|
26
|
+
|
27
|
+
long HELIX_RARRAY_LEN(VALUE array) {
|
28
|
+
return RARRAY_LEN(array);
|
29
|
+
}
|
30
|
+
|
31
|
+
void* HELIX_RARRAY_PTR(VALUE array) {
|
32
|
+
return RARRAY_PTR(array);
|
33
|
+
}
|
34
|
+
|
35
|
+
const void* HELIX_RARRAY_CONST_PTR(VALUE array) {
|
36
|
+
return RARRAY_CONST_PTR(array);
|
37
|
+
}
|
38
|
+
|
39
|
+
bool HELIX_RB_TYPE_P(VALUE v, int type) {
|
40
|
+
return RB_TYPE_P(v, type);
|
41
|
+
}
|
42
|
+
|
43
|
+
VALUE HELIX_INT2FIX(int c_int) {
|
44
|
+
return INT2FIX(c_int);
|
45
|
+
}
|
46
|
+
|
47
|
+
VALUE HELIX_FIX2INT(VALUE v) {
|
48
|
+
return FIX2INT(v);
|
49
|
+
}
|
50
|
+
|
51
|
+
VALUE HELIX_rb_utf8_str_new(const char* str, long len) {
|
52
|
+
return rb_utf8_str_new(str, len);
|
53
|
+
}
|
54
|
+
|
55
|
+
VALUE HELIX_Data_Wrap_Struct(VALUE klass, HELIX_RUBY_DATA_FUNC mark, HELIX_RUBY_DATA_FUNC free, void* data) {
|
56
|
+
return Data_Wrap_Struct(klass, mark, free, data);
|
57
|
+
}
|
58
|
+
|
59
|
+
RUST_U64 HELIX_NUM2U64(VALUE obj) {
|
60
|
+
return NUM2ULL(obj);
|
61
|
+
}
|
62
|
+
|
63
|
+
VALUE HELIX_U642NUM(RUST_U64 num) {
|
64
|
+
return ULL2NUM(num);
|
65
|
+
}
|
66
|
+
|
67
|
+
RUST_I64 HELIX_NUM2I64(VALUE obj) {
|
68
|
+
return NUM2LL(obj);
|
69
|
+
}
|
70
|
+
|
71
|
+
VALUE HELIX_I642NUM(RUST_I64 num) {
|
72
|
+
return LL2NUM(num);
|
73
|
+
}
|
74
|
+
|
75
|
+
RUST_U32 HELIX_NUM2U32(VALUE obj) {
|
76
|
+
return NUM2UINT(obj);
|
77
|
+
}
|
78
|
+
|
79
|
+
VALUE HELIX_U322NUM(RUST_U32 num) {
|
80
|
+
return UINT2NUM(num);
|
81
|
+
}
|
82
|
+
|
83
|
+
RUST_I32 HELIX_NUM2I32(VALUE obj) {
|
84
|
+
return NUM2INT(obj);
|
85
|
+
}
|
86
|
+
|
87
|
+
VALUE HELIX_I322NUM(RUST_I32 num) {
|
88
|
+
return INT2NUM(num);
|
89
|
+
}
|
90
|
+
|
91
|
+
RUST_F64 HELIX_NUM2F64(VALUE obj) {
|
92
|
+
return NUM2DBL(obj);
|
93
|
+
}
|
94
|
+
|
95
|
+
VALUE HELIX_F642NUM(RUST_F64 num) {
|
96
|
+
return DBL2NUM(num);
|
97
|
+
}
|
98
|
+
|
99
|
+
void* HELIX_Data_Get_Struct_Value(VALUE obj) {
|
100
|
+
void* data;
|
101
|
+
Data_Get_Struct(obj, void*, data);
|
102
|
+
return data;
|
103
|
+
}
|
104
|
+
|
105
|
+
void HELIX_Data_Set_Struct_Value(VALUE obj, void* data) {
|
106
|
+
DATA_PTR(obj) = data;
|
107
|
+
}
|
108
|
+
|
109
|
+
// void HELIX_rb_define_alloc_func(VALUE klass, HELIX_rb_alloc_func_t func) {
|
110
|
+
// rb_define_alloc_func(klass, func);
|
111
|
+
// }
|
112
|
+
|
113
|
+
int HELIX_TYPE(VALUE v) {
|
114
|
+
return TYPE(v);
|
115
|
+
}
|
116
|
+
|
117
|
+
int HELIX_T_NONE = T_NONE;
|
118
|
+
int HELIX_T_NIL = T_NIL;
|
119
|
+
int HELIX_T_OBJECT = T_OBJECT;
|
120
|
+
int HELIX_T_CLASS = T_CLASS;
|
121
|
+
int HELIX_T_ICLASS = T_ICLASS;
|
122
|
+
int HELIX_T_MODULE = T_MODULE;
|
123
|
+
int HELIX_T_FLOAT = T_FLOAT;
|
124
|
+
int HELIX_T_STRING = T_STRING;
|
125
|
+
int HELIX_T_REGEXP = T_REGEXP;
|
126
|
+
int HELIX_T_ARRAY = T_ARRAY;
|
127
|
+
int HELIX_T_HASH = T_HASH;
|
128
|
+
int HELIX_T_STRUCT = T_STRUCT;
|
129
|
+
int HELIX_T_BIGNUM = T_BIGNUM;
|
130
|
+
int HELIX_T_FILE = T_FILE;
|
131
|
+
int HELIX_T_FIXNUM = T_FIXNUM;
|
132
|
+
int HELIX_T_TRUE = T_TRUE;
|
133
|
+
int HELIX_T_FALSE = T_FALSE;
|
134
|
+
int HELIX_T_DATA = T_DATA;
|
135
|
+
int HELIX_T_MATCH = T_MATCH;
|
136
|
+
int HELIX_T_SYMBOL = T_SYMBOL;
|
137
|
+
int HELIX_T_RATIONAL = T_RATIONAL;
|
138
|
+
int HELIX_T_COMPLEX = T_COMPLEX;
|
139
|
+
int HELIX_T_UNDEF = T_UNDEF;
|
140
|
+
int HELIX_T_NODE = T_NODE;
|
141
|
+
int HELIX_T_ZOMBIE = T_ZOMBIE;
|
142
|
+
int HELIX_T_MASK = T_MASK;
|
143
|
+
// int HELIX_T_IMEMO = T_IMEMO;
|
144
|
+
|
145
|
+
void Init_native() {}
|
@@ -1,103 +1,103 @@
|
|
1
|
-
#include <ruby.h>
|
2
|
-
#include <ruby/intern.h>
|
3
|
-
#include <stdbool.h>
|
4
|
-
|
5
|
-
#if defined _WIN32 || defined __CYGWIN__
|
6
|
-
#ifdef BUILDING_DLL
|
7
|
-
#define HELIX_EXTERN __declspec(dllexport)
|
8
|
-
#else
|
9
|
-
#define HELIX_EXTERN __declspec(dllimport)
|
10
|
-
#endif
|
11
|
-
#else
|
12
|
-
#define HELIX_EXTERN extern
|
13
|
-
#endif
|
14
|
-
|
15
|
-
#ifndef HELIXRUNTIME_H
|
16
|
-
#define HELIXRUNTIME_H
|
17
|
-
|
18
|
-
#define RUST_U64 uint64_t
|
19
|
-
#define RUST_I64 int64_t
|
20
|
-
|
21
|
-
#define RUST_U32 uint32_t
|
22
|
-
#define RUST_I32 int32_t
|
23
|
-
|
24
|
-
#define RUST_F64 double
|
25
|
-
|
26
|
-
HELIX_EXTERN const char* HELIX_RUNTIME_VERSION;
|
27
|
-
|
28
|
-
HELIX_EXTERN const char* HELIX_PRIsVALUE;
|
29
|
-
HELIX_EXTERN const char* HELIX_SPRINTF_TO_S;
|
30
|
-
HELIX_EXTERN const char* HELIX_SPRINTF_INSPECT;
|
31
|
-
|
32
|
-
HELIX_EXTERN RUST_U64 HELIX_NUM2U64(VALUE);
|
33
|
-
HELIX_EXTERN VALUE HELIX_U642NUM(RUST_U64);
|
34
|
-
|
35
|
-
HELIX_EXTERN RUST_I64 HELIX_NUM2I64(VALUE);
|
36
|
-
HELIX_EXTERN VALUE HELIX_I642NUM(RUST_I64);
|
37
|
-
|
38
|
-
HELIX_EXTERN RUST_U32 HELIX_NUM2U32(VALUE);
|
39
|
-
HELIX_EXTERN VALUE HELIX_U322NUM(RUST_U32);
|
40
|
-
|
41
|
-
HELIX_EXTERN RUST_I32 HELIX_NUM2I32(VALUE);
|
42
|
-
HELIX_EXTERN VALUE HELIX_I322NUM(RUST_I32);
|
43
|
-
|
44
|
-
HELIX_EXTERN RUST_F64 HELIX_NUM2F64(VALUE);
|
45
|
-
HELIX_EXTERN VALUE HELIX_F642NUM(RUST_F64);
|
46
|
-
|
47
|
-
HELIX_EXTERN VALUE HELIX_Qtrue;
|
48
|
-
HELIX_EXTERN VALUE HELIX_Qfalse;
|
49
|
-
HELIX_EXTERN VALUE HELIX_Qnil;
|
50
|
-
|
51
|
-
HELIX_EXTERN long HELIX_RSTRING_LEN(VALUE string);
|
52
|
-
HELIX_EXTERN const char* HELIX_RSTRING_PTR(VALUE string);
|
53
|
-
|
54
|
-
HELIX_EXTERN long HELIX_RARRAY_LEN(VALUE array);
|
55
|
-
HELIX_EXTERN void* HELIX_RARRAY_PTR(VALUE array);
|
56
|
-
HELIX_EXTERN const void* HELIX_RARRAY_CONST_PTR(VALUE array);
|
57
|
-
|
58
|
-
HELIX_EXTERN bool HELIX_RB_TYPE_P(VALUE v, int type);
|
59
|
-
HELIX_EXTERN int HELIX_TYPE(VALUE v);
|
60
|
-
|
61
|
-
HELIX_EXTERN VALUE HELIX_INT2FIX(int c_int);
|
62
|
-
HELIX_EXTERN VALUE HELIX_FIX2INT(VALUE fix);
|
63
|
-
|
64
|
-
HELIX_EXTERN VALUE HELIX_rb_utf8_str_new(const char* str, long len);
|
65
|
-
|
66
|
-
// typedef VALUE (*HELIX_rb_alloc_func_t)(VALUE);
|
67
|
-
// void HELIX_rb_define_alloc_func(VALUE klass, HELIX_rb_alloc_func_t func);
|
68
|
-
|
69
|
-
typedef void (*HELIX_RUBY_DATA_FUNC)(void*);
|
70
|
-
|
71
|
-
HELIX_EXTERN VALUE HELIX_Data_Wrap_Struct(VALUE klass, HELIX_RUBY_DATA_FUNC mark, HELIX_RUBY_DATA_FUNC free, void* data);
|
72
|
-
HELIX_EXTERN void* HELIX_Data_Get_Struct_Value(VALUE obj);
|
73
|
-
HELIX_EXTERN void HELIX_Data_Set_Struct_Value(VALUE obj, void* data);
|
74
|
-
|
75
|
-
HELIX_EXTERN int HELIX_T_NONE;
|
76
|
-
HELIX_EXTERN int HELIX_T_NIL;
|
77
|
-
HELIX_EXTERN int HELIX_T_OBJECT;
|
78
|
-
HELIX_EXTERN int HELIX_T_CLASS;
|
79
|
-
HELIX_EXTERN int HELIX_T_ICLASS;
|
80
|
-
HELIX_EXTERN int HELIX_T_MODULE;
|
81
|
-
HELIX_EXTERN int HELIX_T_FLOAT;
|
82
|
-
HELIX_EXTERN int HELIX_T_STRING;
|
83
|
-
HELIX_EXTERN int HELIX_T_REGEXP;
|
84
|
-
HELIX_EXTERN int HELIX_T_ARRAY;
|
85
|
-
HELIX_EXTERN int HELIX_T_HASH;
|
86
|
-
HELIX_EXTERN int HELIX_T_STRUCT;
|
87
|
-
HELIX_EXTERN int HELIX_T_BIGNUM;
|
88
|
-
HELIX_EXTERN int HELIX_T_FILE;
|
89
|
-
HELIX_EXTERN int HELIX_T_FIXNUM;
|
90
|
-
HELIX_EXTERN int HELIX_T_TRUE;
|
91
|
-
HELIX_EXTERN int HELIX_T_FALSE;
|
92
|
-
HELIX_EXTERN int HELIX_T_DATA;
|
93
|
-
HELIX_EXTERN int HELIX_T_MATCH;
|
94
|
-
HELIX_EXTERN int HELIX_T_SYMBOL;
|
95
|
-
HELIX_EXTERN int HELIX_T_RATIONAL;
|
96
|
-
HELIX_EXTERN int HELIX_T_COMPLEX;
|
97
|
-
HELIX_EXTERN int HELIX_T_UNDEF;
|
98
|
-
HELIX_EXTERN int HELIX_T_NODE;
|
99
|
-
HELIX_EXTERN int HELIX_T_ZOMBIE;
|
100
|
-
HELIX_EXTERN int HELIX_T_MASK;
|
101
|
-
// HELIX_EXTERN int HELIX_T_IMEMO = T_IMEMO;
|
102
|
-
|
103
|
-
#endif /* HELIXRUNTIME_H */
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <ruby/intern.h>
|
3
|
+
#include <stdbool.h>
|
4
|
+
|
5
|
+
#if defined _WIN32 || defined __CYGWIN__
|
6
|
+
#ifdef BUILDING_DLL
|
7
|
+
#define HELIX_EXTERN __declspec(dllexport)
|
8
|
+
#else
|
9
|
+
#define HELIX_EXTERN __declspec(dllimport)
|
10
|
+
#endif
|
11
|
+
#else
|
12
|
+
#define HELIX_EXTERN extern
|
13
|
+
#endif
|
14
|
+
|
15
|
+
#ifndef HELIXRUNTIME_H
|
16
|
+
#define HELIXRUNTIME_H
|
17
|
+
|
18
|
+
#define RUST_U64 uint64_t
|
19
|
+
#define RUST_I64 int64_t
|
20
|
+
|
21
|
+
#define RUST_U32 uint32_t
|
22
|
+
#define RUST_I32 int32_t
|
23
|
+
|
24
|
+
#define RUST_F64 double
|
25
|
+
|
26
|
+
HELIX_EXTERN const char* HELIX_RUNTIME_VERSION;
|
27
|
+
|
28
|
+
HELIX_EXTERN const char* HELIX_PRIsVALUE;
|
29
|
+
HELIX_EXTERN const char* HELIX_SPRINTF_TO_S;
|
30
|
+
HELIX_EXTERN const char* HELIX_SPRINTF_INSPECT;
|
31
|
+
|
32
|
+
HELIX_EXTERN RUST_U64 HELIX_NUM2U64(VALUE);
|
33
|
+
HELIX_EXTERN VALUE HELIX_U642NUM(RUST_U64);
|
34
|
+
|
35
|
+
HELIX_EXTERN RUST_I64 HELIX_NUM2I64(VALUE);
|
36
|
+
HELIX_EXTERN VALUE HELIX_I642NUM(RUST_I64);
|
37
|
+
|
38
|
+
HELIX_EXTERN RUST_U32 HELIX_NUM2U32(VALUE);
|
39
|
+
HELIX_EXTERN VALUE HELIX_U322NUM(RUST_U32);
|
40
|
+
|
41
|
+
HELIX_EXTERN RUST_I32 HELIX_NUM2I32(VALUE);
|
42
|
+
HELIX_EXTERN VALUE HELIX_I322NUM(RUST_I32);
|
43
|
+
|
44
|
+
HELIX_EXTERN RUST_F64 HELIX_NUM2F64(VALUE);
|
45
|
+
HELIX_EXTERN VALUE HELIX_F642NUM(RUST_F64);
|
46
|
+
|
47
|
+
HELIX_EXTERN VALUE HELIX_Qtrue;
|
48
|
+
HELIX_EXTERN VALUE HELIX_Qfalse;
|
49
|
+
HELIX_EXTERN VALUE HELIX_Qnil;
|
50
|
+
|
51
|
+
HELIX_EXTERN long HELIX_RSTRING_LEN(VALUE string);
|
52
|
+
HELIX_EXTERN const char* HELIX_RSTRING_PTR(VALUE string);
|
53
|
+
|
54
|
+
HELIX_EXTERN long HELIX_RARRAY_LEN(VALUE array);
|
55
|
+
HELIX_EXTERN void* HELIX_RARRAY_PTR(VALUE array);
|
56
|
+
HELIX_EXTERN const void* HELIX_RARRAY_CONST_PTR(VALUE array);
|
57
|
+
|
58
|
+
HELIX_EXTERN bool HELIX_RB_TYPE_P(VALUE v, int type);
|
59
|
+
HELIX_EXTERN int HELIX_TYPE(VALUE v);
|
60
|
+
|
61
|
+
HELIX_EXTERN VALUE HELIX_INT2FIX(int c_int);
|
62
|
+
HELIX_EXTERN VALUE HELIX_FIX2INT(VALUE fix);
|
63
|
+
|
64
|
+
HELIX_EXTERN VALUE HELIX_rb_utf8_str_new(const char* str, long len);
|
65
|
+
|
66
|
+
// typedef VALUE (*HELIX_rb_alloc_func_t)(VALUE);
|
67
|
+
// void HELIX_rb_define_alloc_func(VALUE klass, HELIX_rb_alloc_func_t func);
|
68
|
+
|
69
|
+
typedef void (*HELIX_RUBY_DATA_FUNC)(void*);
|
70
|
+
|
71
|
+
HELIX_EXTERN VALUE HELIX_Data_Wrap_Struct(VALUE klass, HELIX_RUBY_DATA_FUNC mark, HELIX_RUBY_DATA_FUNC free, void* data);
|
72
|
+
HELIX_EXTERN void* HELIX_Data_Get_Struct_Value(VALUE obj);
|
73
|
+
HELIX_EXTERN void HELIX_Data_Set_Struct_Value(VALUE obj, void* data);
|
74
|
+
|
75
|
+
HELIX_EXTERN int HELIX_T_NONE;
|
76
|
+
HELIX_EXTERN int HELIX_T_NIL;
|
77
|
+
HELIX_EXTERN int HELIX_T_OBJECT;
|
78
|
+
HELIX_EXTERN int HELIX_T_CLASS;
|
79
|
+
HELIX_EXTERN int HELIX_T_ICLASS;
|
80
|
+
HELIX_EXTERN int HELIX_T_MODULE;
|
81
|
+
HELIX_EXTERN int HELIX_T_FLOAT;
|
82
|
+
HELIX_EXTERN int HELIX_T_STRING;
|
83
|
+
HELIX_EXTERN int HELIX_T_REGEXP;
|
84
|
+
HELIX_EXTERN int HELIX_T_ARRAY;
|
85
|
+
HELIX_EXTERN int HELIX_T_HASH;
|
86
|
+
HELIX_EXTERN int HELIX_T_STRUCT;
|
87
|
+
HELIX_EXTERN int HELIX_T_BIGNUM;
|
88
|
+
HELIX_EXTERN int HELIX_T_FILE;
|
89
|
+
HELIX_EXTERN int HELIX_T_FIXNUM;
|
90
|
+
HELIX_EXTERN int HELIX_T_TRUE;
|
91
|
+
HELIX_EXTERN int HELIX_T_FALSE;
|
92
|
+
HELIX_EXTERN int HELIX_T_DATA;
|
93
|
+
HELIX_EXTERN int HELIX_T_MATCH;
|
94
|
+
HELIX_EXTERN int HELIX_T_SYMBOL;
|
95
|
+
HELIX_EXTERN int HELIX_T_RATIONAL;
|
96
|
+
HELIX_EXTERN int HELIX_T_COMPLEX;
|
97
|
+
HELIX_EXTERN int HELIX_T_UNDEF;
|
98
|
+
HELIX_EXTERN int HELIX_T_NODE;
|
99
|
+
HELIX_EXTERN int HELIX_T_ZOMBIE;
|
100
|
+
HELIX_EXTERN int HELIX_T_MASK;
|
101
|
+
// HELIX_EXTERN int HELIX_T_IMEMO = T_IMEMO;
|
102
|
+
|
103
|
+
#endif /* HELIXRUNTIME_H */
|
data/helix_runtime.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'helix_runtime/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "helix_runtime"
|
8
|
-
spec.version = HelixRuntime::
|
8
|
+
spec.version = HelixRuntime::GEM_VERSION
|
9
9
|
spec.authors = ["Yehuda Katz", "Godfrey Chan"]
|
10
10
|
spec.email = ["wycats@gmail.com", "godfreykfc@gmail.com"]
|
11
11
|
|
@@ -13,12 +13,13 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/tildeio/helix"
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
-
spec.bindir = "
|
16
|
+
spec.bindir = "bin"
|
17
17
|
spec.extensions = ["ext/helix_runtime/native/extconf.rb"]
|
18
|
-
spec.executables = spec.files.grep(%r{^
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "rake", "
|
21
|
+
spec.add_dependency "rake", ">= 10.0"
|
22
|
+
spec.add_dependency "thor", "~> 0.19.4"
|
22
23
|
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.10"
|
24
25
|
spec.add_development_dependency "rspec", "~> 3.4"
|
data/lib/helix_runtime.rb
CHANGED
@@ -1,2 +1,54 @@
|
|
1
1
|
require "helix_runtime/version"
|
2
2
|
require "helix_runtime/native"
|
3
|
+
require "helix_runtime/platform"
|
4
|
+
require 'helix_runtime/project'
|
5
|
+
require 'helix_runtime/parent_project'
|
6
|
+
|
7
|
+
module HelixRuntime
|
8
|
+
IS_WINDOWS = RUBY_PLATFORM =~ /mingw/
|
9
|
+
|
10
|
+
class MissingDllError < RuntimeError; end
|
11
|
+
|
12
|
+
@@dll_filename = "helix-runtime-#{VERSION.gsub('.', '-')}.#{Platform.libext}"
|
13
|
+
@@dll_path_searched = false
|
14
|
+
|
15
|
+
def self.dll_filename
|
16
|
+
@@dll_filename
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.dll_path
|
20
|
+
return nil unless IS_WINDOWS
|
21
|
+
return @@dll_path if @@dll_path_searched
|
22
|
+
|
23
|
+
dir = ENV['PATH'].split(';').find do |dir|
|
24
|
+
File.exist?(File.expand_path("#{dir}/#{dll_filename}", __FILE__))
|
25
|
+
end
|
26
|
+
|
27
|
+
@@dll_path_searched = true
|
28
|
+
@@dll_path = dir ? File.join(dir, dll_filename) : nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.ensure_dll!
|
32
|
+
if IS_WINDOWS
|
33
|
+
unless dll_path
|
34
|
+
raise MissingDllError, "Unable to find #{dll_filename} in $PATH."
|
35
|
+
end
|
36
|
+
else
|
37
|
+
# No-op
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.copy_dll
|
42
|
+
if IS_WINDOWS
|
43
|
+
so_path = File.expand_path("../native.#{Platform.dlext}", __FILE__)
|
44
|
+
raise "Unable to find native bundle at #{so_path}" unless File.exists?(so_path)
|
45
|
+
|
46
|
+
bindir = RbConfig::CONFIG['bindir']
|
47
|
+
raise "Unable to determine Ruby bindir" unless bindir
|
48
|
+
|
49
|
+
FileUtils.cp so_path, File.join(bindir, dll_filename)
|
50
|
+
else
|
51
|
+
# No-op
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,18 +1,24 @@
|
|
1
1
|
require 'rake/tasklib'
|
2
|
-
require '
|
3
|
-
require 'helix_runtime/version'
|
4
|
-
require 'helix_runtime/platform'
|
2
|
+
require 'helix_runtime'
|
5
3
|
|
6
4
|
module HelixRuntime
|
7
5
|
class BuildTask < Rake::TaskLib
|
8
6
|
|
9
|
-
|
7
|
+
def self.delegate_attr(getter, to:)
|
8
|
+
setter = "#{getter}="
|
9
|
+
define_method(getter, -> { send(to).send(getter) })
|
10
|
+
define_method(setter, -> (val) { send(to).send(setter, val) })
|
11
|
+
end
|
12
|
+
|
13
|
+
def project
|
14
|
+
@project ||= Project.new(Dir.pwd)
|
15
|
+
end
|
16
|
+
|
17
|
+
delegate_attr :name, to: :project
|
18
|
+
delegate_attr :helix_lib_dir, to: :project
|
19
|
+
delegate_attr :debug_rust, to: :project
|
20
|
+
delegate_attr :build_root, to: :project
|
10
21
|
|
11
|
-
attr_accessor :name
|
12
|
-
attr_accessor :debug_rust
|
13
|
-
attr_accessor :build_root
|
14
|
-
attr_accessor :lib_path
|
15
|
-
attr_accessor :helix_lib_dir
|
16
22
|
attr_accessor :pre_build
|
17
23
|
|
18
24
|
def initialize(name = nil, gem_spec = nil)
|
@@ -23,17 +29,6 @@ module HelixRuntime
|
|
23
29
|
|
24
30
|
def init(name = nil, gem_spec = nil)
|
25
31
|
@name = name
|
26
|
-
@debug_rust = ENV['DEBUG_RUST']
|
27
|
-
@build_root = nil
|
28
|
-
@lib_path = "lib/#{name}"
|
29
|
-
end
|
30
|
-
|
31
|
-
def debug_rust?
|
32
|
-
!!@debug_rust
|
33
|
-
end
|
34
|
-
|
35
|
-
def build_path
|
36
|
-
File.expand_path(debug_rust? ? 'target/debug' : 'target/release', build_root)
|
37
32
|
end
|
38
33
|
|
39
34
|
def define
|
@@ -45,90 +40,35 @@ module HelixRuntime
|
|
45
40
|
end
|
46
41
|
|
47
42
|
task "helix:check_path" do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
else
|
54
|
-
# No-op
|
43
|
+
begin
|
44
|
+
HelixRuntime.ensure_dll!
|
45
|
+
rescue HelixRuntime::MissingDllError => e
|
46
|
+
puts e.message
|
47
|
+
abort "Run `rake helix:copy_dll` to copy to your Ruby bin dir."
|
55
48
|
end
|
56
49
|
end
|
57
50
|
|
58
51
|
task "helix:copy_dll" do
|
59
|
-
|
60
|
-
so_path = File.expand_path("../native.#{Platform.dlext}", __FILE__)
|
61
|
-
abort "Unable to find native bundle at #{so_path}" unless File.exists?(so_path)
|
62
|
-
|
63
|
-
bindir = RbConfig::CONFIG['bindir']
|
64
|
-
abort "Unable to determine Ruby bindir" unless bindir
|
65
|
-
|
66
|
-
cp so_path, File.join(bindir, dll_filename)
|
67
|
-
else
|
68
|
-
# No-op
|
69
|
-
end
|
52
|
+
HelixRuntime.copy_dll
|
70
53
|
end
|
71
54
|
|
72
|
-
# Checking the path isn't a real dependency, but this is a good time to do it
|
73
55
|
task "cargo:build" => ["helix:pre_build", "helix:check_path"] do
|
74
|
-
|
75
|
-
link_args = if IS_WINDOWS
|
76
|
-
# SAFESEH is added to i686 Rust hosts
|
77
|
-
# https://github.com/rust-lang/rust/blob/1.15.1/src/librustc_back/target/i686_pc_windows_msvc.rs#L25
|
78
|
-
if `rustc -vV` =~ /host:\s+i686/
|
79
|
-
'/SAFESEH:NO' # Can't use SAFESEH with .libs from dlltool
|
80
|
-
end
|
81
|
-
else
|
82
|
-
# Allowing all methods to be undefined is a bit risky, would be nice to have a specific list.
|
83
|
-
'-Wl,-undefined,dynamic_lookup'
|
84
|
-
end
|
85
|
-
|
86
|
-
env = {}
|
87
|
-
env['HELIX_LIB_DIR'] = helix_lib_dir if helix_lib_dir
|
88
|
-
|
89
|
-
cargo_args = []
|
90
|
-
rustc_args = []
|
91
|
-
|
92
|
-
if ENV['DEBUG_RUST_MACROS']
|
93
|
-
rustc_args << "--pretty expanded"
|
94
|
-
rustc_args << "-Z unstable-options"
|
95
|
-
end
|
96
|
-
unless debug_rust?
|
97
|
-
cargo_args << ["--release"]
|
98
|
-
end
|
99
|
-
if ENV['VERBOSE']
|
100
|
-
cargo_args << " --verbose"
|
101
|
-
end
|
102
|
-
if link_args
|
103
|
-
rustc_args << "-C link-args=#{link_args}"
|
104
|
-
end
|
105
|
-
|
106
|
-
unless rustc_args.empty?
|
107
|
-
cargo_args << "-- #{rustc_args.join(' ')}"
|
108
|
-
end
|
109
|
-
|
110
|
-
sh env, "cargo rustc #{cargo_args.join(' ')}"
|
56
|
+
project.cargo_build
|
111
57
|
end
|
112
58
|
|
113
59
|
task "cargo:clean" do
|
114
|
-
|
60
|
+
project.cargo_clean
|
115
61
|
end
|
116
62
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
libfile_prefix = IS_WINDOWS ? '' : 'lib'
|
122
|
-
native_path = "#{lib_path}/native.#{Platform.dlext}"
|
123
|
-
native_lib = "#{libfile_prefix}#{name}.#{Platform.libext}"
|
124
|
-
|
125
|
-
file native_path => [lib_path, "cargo:build"] do
|
126
|
-
cp "#{build_path}/#{native_lib}", native_path
|
63
|
+
desc "Build #{name}"
|
64
|
+
task :build => ["helix:pre_build", "helix:check_path"] do
|
65
|
+
project.build
|
127
66
|
end
|
128
|
-
CLOBBER.include(native_path)
|
129
67
|
|
130
|
-
desc "
|
131
|
-
task :
|
68
|
+
desc "Remove build artifacts"
|
69
|
+
task :clobber do
|
70
|
+
project.clobber
|
71
|
+
end
|
132
72
|
|
133
73
|
desc "Launch an IRB console for #{name}"
|
134
74
|
task :irb => :build do
|
@@ -136,23 +76,5 @@ module HelixRuntime
|
|
136
76
|
end
|
137
77
|
end
|
138
78
|
|
139
|
-
private
|
140
|
-
|
141
|
-
def dll_filename
|
142
|
-
@dll_filename ||= "helix-runtime-#{VERSION.gsub('.', '-')}.#{Platform.libext}"
|
143
|
-
end
|
144
|
-
|
145
|
-
def dll_path
|
146
|
-
return nil unless IS_WINDOWS
|
147
|
-
return @dll_path if @dll_path_searched
|
148
|
-
|
149
|
-
dir = ENV['PATH'].split(';').find do |dir|
|
150
|
-
File.exist?(File.expand_path("#{dir}/#{dll_filename}", __FILE__))
|
151
|
-
end
|
152
|
-
|
153
|
-
@dll_path_searched = true
|
154
|
-
@dll_path = dir ? File.join(dir, dll_filename) : nil
|
155
|
-
end
|
156
|
-
|
157
79
|
end
|
158
80
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helix_runtime/cli/bootstrap'
|
2
|
+
|
3
|
+
module HelixRuntime
|
4
|
+
module CLI
|
5
|
+
class Base < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
register CLI::Bootstrap, "bootstrap", "bootstrap PATH [NAME]", "Bootstrap Helix"
|
9
|
+
|
10
|
+
desc "add_crate NAME", "Add child project"
|
11
|
+
def add_crate(name)
|
12
|
+
bootstrap("crates/#{name}", name)
|
13
|
+
append_to_file "Gemfile", "gem '#{name}', path: 'crates/#{name}'\n"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module HelixRuntime
|
4
|
+
module CLI
|
5
|
+
class Bootstrap < Thor::Group
|
6
|
+
argument :path, type: :string
|
7
|
+
argument :name, type: :string, optional: true
|
8
|
+
class_option :skip_bundle, type: :boolean, default: false
|
9
|
+
|
10
|
+
include Thor::Actions
|
11
|
+
|
12
|
+
desc "Bootstrap Helix"
|
13
|
+
source_root File.expand_path("../templates", __FILE__)
|
14
|
+
|
15
|
+
# NOTE: Instead of using destination_root, we include the full path so
|
16
|
+
# that we see the path relative to the root of where we're running the command.
|
17
|
+
|
18
|
+
def create_cargo_toml
|
19
|
+
template "Cargo.toml", "#{base_path}/Cargo.toml"
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_rust_lib_file
|
23
|
+
copy_file "lib.rs", "#{base_path}/src/lib.rs"
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_gemspec
|
27
|
+
template "gem.gemspec", "#{base_path}/#{app_name}.gemspec"
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_gemfile
|
31
|
+
template "Gemfile", "#{base_path}/Gemfile"
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_rake_task
|
35
|
+
template "helix_runtime.rake", "#{base_path}/lib/tasks/helix_runtime.rake"
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_ruby_lib_file
|
39
|
+
template "lib.rb", "#{base_path}/lib/#{app_name}.rb"
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_gitignore
|
43
|
+
template "gitignore", "#{base_path}/.gitignore"
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_rakefile
|
47
|
+
unless File.exists?("#{base_path}/Rakefile")
|
48
|
+
create_file "#{base_path}/Rakefile", "require 'bundler/setup'\n"
|
49
|
+
end
|
50
|
+
|
51
|
+
append_to_file "#{base_path}/Rakefile", "import 'lib/tasks/helix_runtime.rake'\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
def bundle
|
55
|
+
unless options.skip_bundle
|
56
|
+
inside path do
|
57
|
+
run "bundle"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def base_path
|
65
|
+
File.expand_path(path)
|
66
|
+
end
|
67
|
+
|
68
|
+
def app_name
|
69
|
+
name || File.basename(base_path)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = '<%= app_name %>'
|
5
|
+
s.version = '1.0.0'
|
6
|
+
s.authors = ['Ruby Developer']
|
7
|
+
s.summary = "A Helix project"
|
8
|
+
s.files = Dir['{lib/**/*,[A-Z]*}']
|
9
|
+
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.require_path = 'lib'
|
12
|
+
|
13
|
+
s.add_dependency 'helix_runtime', '~> <%= HelixRuntime::GEM_VERSION %>'
|
14
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
require 'helix_runtime'
|
3
|
+
|
4
|
+
module HelixRuntime
|
5
|
+
# FIXME: I don't like this name
|
6
|
+
class ParentBuildTask < Rake::TaskLib
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
define
|
10
|
+
end
|
11
|
+
|
12
|
+
def define
|
13
|
+
task :build do
|
14
|
+
project.projects.each do |p|
|
15
|
+
puts "Building #{p.name}"
|
16
|
+
p.build
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
task :clobber do
|
21
|
+
project.projects.each do |p|
|
22
|
+
puts "Clobbering #{p.name}"
|
23
|
+
p.clobber
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def project
|
31
|
+
@project ||= ParentProject.new(Dir.pwd)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module HelixRuntime
|
2
|
+
class ParentProject
|
3
|
+
|
4
|
+
attr_accessor :root
|
5
|
+
|
6
|
+
def initialize(root)
|
7
|
+
@root = find_root(root)
|
8
|
+
end
|
9
|
+
|
10
|
+
def projects
|
11
|
+
@projects ||= Dir["#{root}/crates/*"]
|
12
|
+
.select{|f| File.directory?(f) }
|
13
|
+
.map{|d| Project.new(d) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def ensure_built!
|
17
|
+
projects.each(&:ensure_built!)
|
18
|
+
end
|
19
|
+
|
20
|
+
def outdated_build?
|
21
|
+
projects.any?(&:outdated_build?)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def find_root(root)
|
27
|
+
root = File.expand_path(root)
|
28
|
+
dir = root
|
29
|
+
loop do
|
30
|
+
return dir if !Dir["#{dir}/{Gemfile,*.gemspec}"].empty?
|
31
|
+
|
32
|
+
new_dir = File.dirname(dir)
|
33
|
+
raise "Unable to find root for #{root}" if new_dir == dir
|
34
|
+
|
35
|
+
dir = new_dir
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
module HelixRuntime
|
2
|
+
class Project
|
3
|
+
|
4
|
+
class OutdatedBuildError < StandardError
|
5
|
+
def initialize(name)
|
6
|
+
super("\n\nHelix crate '#{name}' is outdated. To resolve this issue, run `rake build` and restart your server.\n\n")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_accessor :root
|
11
|
+
attr_accessor :name
|
12
|
+
attr_accessor :helix_lib_dir
|
13
|
+
attr_accessor :debug_rust
|
14
|
+
attr_accessor :build_root
|
15
|
+
|
16
|
+
def initialize(root)
|
17
|
+
@root = find_root(root)
|
18
|
+
@name = File.basename(@root)
|
19
|
+
@debug_rust = ENV['DEBUG_RUST']
|
20
|
+
@build_root = @root
|
21
|
+
end
|
22
|
+
|
23
|
+
def debug_rust?
|
24
|
+
!!debug_rust
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_path
|
28
|
+
File.expand_path(debug_rust? ? 'target/debug' : 'target/release', build_root)
|
29
|
+
end
|
30
|
+
|
31
|
+
def lib_path
|
32
|
+
"#{root}/lib/#{name}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def libfile_prefix
|
36
|
+
IS_WINDOWS ? '' : 'lib'
|
37
|
+
end
|
38
|
+
|
39
|
+
def native_path
|
40
|
+
"#{lib_path}/native.#{Platform.dlext}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def native_lib
|
44
|
+
"#{libfile_prefix}#{name}.#{Platform.libext}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def outdated_build?
|
48
|
+
mtime = Dir["#{root}/src/**/*.rs"].map{|file| File.mtime(file) }.max
|
49
|
+
native = "#{root}/lib/#{name}/native.#{Platform.dlext}"
|
50
|
+
!File.exist?(native) || File.mtime(native) < mtime
|
51
|
+
end
|
52
|
+
|
53
|
+
def ensure_built!
|
54
|
+
raise OutdatedBuildError.new(name) if outdated_build?
|
55
|
+
end
|
56
|
+
|
57
|
+
def autobuild
|
58
|
+
build if outdated_build?
|
59
|
+
end
|
60
|
+
|
61
|
+
def cargo_build
|
62
|
+
HelixRuntime.ensure_dll!
|
63
|
+
|
64
|
+
# We have to do this here since Cargo has no internal means of specifying `-C` flags
|
65
|
+
link_args = if IS_WINDOWS
|
66
|
+
# SAFESEH is added to i686 Rust hosts
|
67
|
+
# https://github.com/rust-lang/rust/blob/1.15.1/src/librustc_back/target/i686_pc_windows_msvc.rs#L25
|
68
|
+
if `rustc -vV` =~ /host:\s+i686/
|
69
|
+
'/SAFESEH:NO' # Can't use SAFESEH with .libs from dlltool
|
70
|
+
end
|
71
|
+
else
|
72
|
+
# Allowing all methods to be undefined is a bit risky, would be nice to have a specific list.
|
73
|
+
'-Wl,-undefined,dynamic_lookup'
|
74
|
+
end
|
75
|
+
|
76
|
+
env = {}
|
77
|
+
env['HELIX_LIB_DIR'] = helix_lib_dir if helix_lib_dir
|
78
|
+
|
79
|
+
cargo_args = []
|
80
|
+
rustc_args = []
|
81
|
+
|
82
|
+
if ENV['DEBUG_RUST_MACROS']
|
83
|
+
rustc_args << "--pretty expanded"
|
84
|
+
rustc_args << "-Z unstable-options"
|
85
|
+
end
|
86
|
+
unless debug_rust?
|
87
|
+
cargo_args << ["--release"]
|
88
|
+
end
|
89
|
+
if ENV['VERBOSE']
|
90
|
+
cargo_args << " --verbose"
|
91
|
+
end
|
92
|
+
if link_args
|
93
|
+
rustc_args << "-C link-args=#{link_args}"
|
94
|
+
end
|
95
|
+
|
96
|
+
unless rustc_args.empty?
|
97
|
+
cargo_args << "-- #{rustc_args.join(' ')}"
|
98
|
+
end
|
99
|
+
|
100
|
+
run env, "cargo rustc #{cargo_args.join(' ')}"
|
101
|
+
end
|
102
|
+
|
103
|
+
def cargo_clean
|
104
|
+
run("cargo clean")
|
105
|
+
end
|
106
|
+
|
107
|
+
def copy_native
|
108
|
+
source = "#{build_path}/#{native_lib}"
|
109
|
+
raise "native source doesn't exist, run `cargo_build` first; source=#{source}" unless File.exist?(source)
|
110
|
+
FileUtils.mkdir_p(File.dirname(native_path))
|
111
|
+
FileUtils.cp source, native_path
|
112
|
+
end
|
113
|
+
|
114
|
+
def build
|
115
|
+
cargo_build
|
116
|
+
copy_native
|
117
|
+
end
|
118
|
+
|
119
|
+
def clobber
|
120
|
+
cargo_clean
|
121
|
+
FileUtils.rm_f native_path
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def run(*args)
|
127
|
+
Dir.chdir(root) do
|
128
|
+
puts *args
|
129
|
+
system(*args)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def find_root(root)
|
134
|
+
root = File.expand_path(root)
|
135
|
+
dir = root
|
136
|
+
loop do
|
137
|
+
return dir if File.exist?("#{dir}/Cargo.toml")
|
138
|
+
|
139
|
+
new_dir = File.dirname(dir)
|
140
|
+
raise "Unable to find root for #{root}" if new_dir == dir
|
141
|
+
|
142
|
+
dir = new_dir
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
metadata
CHANGED
@@ -1,30 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helix_runtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0.alpha.
|
4
|
+
version: 0.5.0.alpha.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
8
8
|
- Godfrey Chan
|
9
9
|
autorequire:
|
10
|
-
bindir:
|
10
|
+
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-04-
|
12
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '10.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '10.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: thor
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.19.4
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.19.4
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: bundler
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,7 +85,8 @@ description:
|
|
71
85
|
email:
|
72
86
|
- wycats@gmail.com
|
73
87
|
- godfreykfc@gmail.com
|
74
|
-
executables:
|
88
|
+
executables:
|
89
|
+
- helix
|
75
90
|
extensions:
|
76
91
|
- ext/helix_runtime/native/extconf.rb
|
77
92
|
extra_rdoc_files: []
|
@@ -81,6 +96,7 @@ files:
|
|
81
96
|
- Gemfile
|
82
97
|
- README.md
|
83
98
|
- Rakefile
|
99
|
+
- bin/helix
|
84
100
|
- ext/helix_runtime/extconf.rb
|
85
101
|
- ext/helix_runtime/native/extconf.rb
|
86
102
|
- ext/helix_runtime/native/helix_runtime.c
|
@@ -88,7 +104,19 @@ files:
|
|
88
104
|
- helix_runtime.gemspec
|
89
105
|
- lib/helix_runtime.rb
|
90
106
|
- lib/helix_runtime/build_task.rb
|
107
|
+
- lib/helix_runtime/cli.rb
|
108
|
+
- lib/helix_runtime/cli/bootstrap.rb
|
109
|
+
- lib/helix_runtime/cli/templates/Cargo.toml
|
110
|
+
- lib/helix_runtime/cli/templates/Gemfile
|
111
|
+
- lib/helix_runtime/cli/templates/gem.gemspec
|
112
|
+
- lib/helix_runtime/cli/templates/gitignore
|
113
|
+
- lib/helix_runtime/cli/templates/helix_runtime.rake
|
114
|
+
- lib/helix_runtime/cli/templates/lib.rb
|
115
|
+
- lib/helix_runtime/cli/templates/lib.rs
|
116
|
+
- lib/helix_runtime/parent_build_task.rb
|
117
|
+
- lib/helix_runtime/parent_project.rb
|
91
118
|
- lib/helix_runtime/platform.rb
|
119
|
+
- lib/helix_runtime/project.rb
|
92
120
|
- lib/helix_runtime/version.rb
|
93
121
|
homepage: https://github.com/tildeio/helix
|
94
122
|
licenses: []
|
@@ -109,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
137
|
version: 1.3.1
|
110
138
|
requirements: []
|
111
139
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.6.
|
140
|
+
rubygems_version: 2.6.11
|
113
141
|
signing_key:
|
114
142
|
specification_version: 4
|
115
143
|
summary: The Helix Runtime
|