helix_runtime 0.5.0.alpha.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 +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +1 -0
- data/Rakefile +136 -0
- data/ext/helix_runtime/extconf.rb +0 -0
- data/ext/helix_runtime/native/extconf.rb +7 -0
- data/ext/helix_runtime/native/helix_runtime.c +145 -0
- data/ext/helix_runtime/native/helix_runtime.h +103 -0
- data/helix_runtime.gemspec +26 -0
- data/lib/helix_runtime.rb +2 -0
- data/lib/helix_runtime/build_task.rb +158 -0
- data/lib/helix_runtime/platform.rb +72 -0
- data/lib/helix_runtime/version.rb +4 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0b4438222f9794f2c145316fbec7f715f95d9e8e
|
4
|
+
data.tar.gz: 2be760bde89497aebda357c70149fb65a2e11200
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b7683df79bb1db4a26c97aa9a7e2c242aa3b9e30d3bb83182b6d4a0f8acad0e73a2a763f292a4110151a24deda7333f1dcd3f0d0789743de1deb65bd438bed60
|
7
|
+
data.tar.gz: 369f997ae6fba5d87004c969b6024d6cd304272f4d0893f8987c164a5c6dc2454b068661778323515d757a4d9f9361e4aaaa2371c3bc6178a6df689c7076552b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Helix Runtime
|
data/Rakefile
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "rake/extensiontask"
|
4
|
+
require "tmpdir"
|
5
|
+
|
6
|
+
ENV['HELIX_ROOT'] = File.expand_path("../..", __FILE__)
|
7
|
+
|
8
|
+
verbose(!!ENV['VERBOSE'])
|
9
|
+
|
10
|
+
native_header_path = File.expand_path("ext/helix_runtime/native/helix_runtime.h", __dir__)
|
11
|
+
native_def_file = File.expand_path("ext/helix_runtime/native/native.def", __dir__)
|
12
|
+
windows_build_dir = File.expand_path("windows_build", __dir__)
|
13
|
+
dll_name = "helix-runtime-#{HelixRuntime::VERSION.gsub('.', '-')}"
|
14
|
+
native_so_file = File.expand_path("lib/helix_runtime/native.so", __dir__)
|
15
|
+
native_lib_file = File.join(windows_build_dir, "#{dll_name}.lib")
|
16
|
+
native_lib_file_32 = File.join(windows_build_dir, "#{dll_name}.i386.lib")
|
17
|
+
native_lib_file_64 = File.join(windows_build_dir, "#{dll_name}.x86_64.lib")
|
18
|
+
native_dll_file = File.join(windows_build_dir, "#{dll_name}.dll")
|
19
|
+
|
20
|
+
file native_header_path
|
21
|
+
file native_def_file => native_header_path do
|
22
|
+
# Hackish way to pull exported methods out of the header
|
23
|
+
exports = []
|
24
|
+
File.readlines(native_header_path).each do |line|
|
25
|
+
if line =~ /^\w.+(HELIX_\w+)[;\(]/
|
26
|
+
exports << $1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
File.open(File.expand_path("ext/helix_runtime/native/native.def", __dir__), 'w') do |f|
|
31
|
+
f.puts "LIBRARY helix-runtime-#{HelixRuntime::VERSION.gsub('.', '-')}"
|
32
|
+
f.puts "EXPORTS"
|
33
|
+
f.puts exports
|
34
|
+
f.puts "Init_native"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
task :native_def_file => native_def_file
|
39
|
+
CLOBBER.include(native_def_file)
|
40
|
+
|
41
|
+
Rake::ExtensionTask.new do |ext|
|
42
|
+
ext.name = "native"
|
43
|
+
ext.ext_dir = "ext/helix_runtime/native"
|
44
|
+
ext.lib_dir = "lib/helix_runtime"
|
45
|
+
end
|
46
|
+
|
47
|
+
directory windows_build_dir
|
48
|
+
|
49
|
+
def dlltool
|
50
|
+
# allow override with env vars
|
51
|
+
if dlltool_env = ENV['DLLTOOL']
|
52
|
+
dlltool_env
|
53
|
+
# if on windows
|
54
|
+
elsif RUBY_PLATFORM =~ /mingw/
|
55
|
+
"dlltool.exe"
|
56
|
+
elsif system("x86_64-w64-mingw32-dlltool > /dev/null")
|
57
|
+
"x86_64-w64-mingw32-dlltool"
|
58
|
+
elsif system("i686-w64-mingw32-dlltool > /dev/null")
|
59
|
+
"i686-w64-mingw32-dlltool"
|
60
|
+
else
|
61
|
+
"dlltool"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def build_native_lib(arch, dll_name, native_def_file, target)
|
66
|
+
Dir.mktmpdir do |dir|
|
67
|
+
Dir.chdir(dir) do
|
68
|
+
# Generate and then move. Symbols include generated file name, so avoid long path.
|
69
|
+
cmd = [dlltool]
|
70
|
+
cmd << "-D #{dll_name}"
|
71
|
+
cmd << "-m #{arch}" if arch
|
72
|
+
cmd << "-d #{native_def_file}"
|
73
|
+
cmd << "-l #{dll_name}.lib"
|
74
|
+
sh cmd.join(" ")
|
75
|
+
|
76
|
+
mv "#{dll_name}.lib", target
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Build 32- and 64-bit .lib files for linking in libcruby-sys
|
82
|
+
# These file need to be copied to the libcruby-sys directory for distribution.
|
83
|
+
task :native_lib_files => [native_lib_file_64, native_lib_file_32]
|
84
|
+
file native_lib_file_64 => [windows_build_dir, native_def_file] do
|
85
|
+
begin
|
86
|
+
build_native_lib("i386:x86-64", dll_name, native_def_file, native_lib_file_64)
|
87
|
+
rescue RuntimeError
|
88
|
+
if RbConfig::CONFIG['host_cpu'] !~ /64/
|
89
|
+
warn "Unable to build 64-bit lib file. This is likely due to a 32-bit version of dlltool."
|
90
|
+
else
|
91
|
+
raise
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
file native_lib_file_32 => [windows_build_dir, native_def_file] do
|
97
|
+
build_native_lib("i386", dll_name, native_def_file, native_lib_file_32)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Build a .lib file for linking in dummy native
|
101
|
+
file native_lib_file => [windows_build_dir, native_def_file] do
|
102
|
+
build_native_lib(nil, dll_name, native_def_file, native_lib_file)
|
103
|
+
end
|
104
|
+
|
105
|
+
if RUBY_PLATFORM =~ /mingw/
|
106
|
+
file native_so_file
|
107
|
+
|
108
|
+
# Copy the native.so to the appropriately named .dll. This makes it easy to
|
109
|
+
# add the windows_build directory to PATH for testing on Windows. This file
|
110
|
+
# isn't used in any distributions.
|
111
|
+
file native_dll_file => native_so_file do
|
112
|
+
cp native_so_file, native_dll_file
|
113
|
+
end
|
114
|
+
|
115
|
+
Rake::Task["compile:native:#{RUBY_PLATFORM}"].enhance([native_lib_file, native_dll_file])
|
116
|
+
end
|
117
|
+
|
118
|
+
CLOBBER.include(windows_build_dir)
|
119
|
+
|
120
|
+
Rake::ExtensionTask.new do |ext|
|
121
|
+
ext.name = "dummy"
|
122
|
+
ext.ext_dir = "spec/support/dummy/ext/dummy"
|
123
|
+
ext.lib_dir = "spec/support/dummy/lib"
|
124
|
+
end
|
125
|
+
|
126
|
+
RSpec::Core::RakeTask.new(:rspec) do |t|
|
127
|
+
t.verbose = false
|
128
|
+
end
|
129
|
+
|
130
|
+
# On Windows, also build native_lib_files to help with dev
|
131
|
+
if RUBY_PLATFORM =~ /mingw/
|
132
|
+
task "compile:native" => :native_lib_files
|
133
|
+
end
|
134
|
+
|
135
|
+
task :rspec => :compile
|
136
|
+
task :default => :rspec
|
File without changes
|
@@ -0,0 +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.alpha.1";
|
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() {}
|
@@ -0,0 +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 */
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'helix_runtime/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "helix_runtime"
|
8
|
+
spec.version = HelixRuntime::VERSION
|
9
|
+
spec.authors = ["Yehuda Katz", "Godfrey Chan"]
|
10
|
+
spec.email = ["wycats@gmail.com", "godfreykfc@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{The Helix Runtime}
|
13
|
+
spec.homepage = "https://github.com/tildeio/helix"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.extensions = ["ext/helix_runtime/native/extconf.rb"]
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rake", "~> 10.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
25
|
+
spec.add_development_dependency "rake-compiler", "~> 0.9.7"
|
26
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'helix_runtime/version'
|
4
|
+
require 'helix_runtime/platform'
|
5
|
+
|
6
|
+
module HelixRuntime
|
7
|
+
class BuildTask < Rake::TaskLib
|
8
|
+
|
9
|
+
IS_WINDOWS = RUBY_PLATFORM =~ /mingw/
|
10
|
+
|
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
|
+
attr_accessor :pre_build
|
17
|
+
|
18
|
+
def initialize(name = nil, gem_spec = nil)
|
19
|
+
init(name, gem_spec)
|
20
|
+
yield self if block_given?
|
21
|
+
define
|
22
|
+
end
|
23
|
+
|
24
|
+
def init(name = nil, gem_spec = nil)
|
25
|
+
@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
|
+
end
|
38
|
+
|
39
|
+
def define
|
40
|
+
fail "Extension name must be provided." if @name.nil?
|
41
|
+
@name = @name.to_s
|
42
|
+
|
43
|
+
task "helix:pre_build" do
|
44
|
+
pre_build.call if pre_build
|
45
|
+
end
|
46
|
+
|
47
|
+
task "helix:check_path" do
|
48
|
+
if IS_WINDOWS
|
49
|
+
unless dll_path
|
50
|
+
abort "Unable to find #{dll_filename} in $PATH.\n" \
|
51
|
+
"Run `rake helix:copy_dll` to copy to your Ruby bin dir or manually copy #{File.expand_path("../native.so", __FILE__)} to #{dll_filename} at a location in your $PATH"
|
52
|
+
end
|
53
|
+
else
|
54
|
+
# No-op
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
task "helix:copy_dll" do
|
59
|
+
if IS_WINDOWS
|
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
|
70
|
+
end
|
71
|
+
|
72
|
+
# Checking the path isn't a real dependency, but this is a good time to do it
|
73
|
+
task "cargo:build" => ["helix:pre_build", "helix:check_path"] do
|
74
|
+
# We have to do this here since Cargo has no internal means of specifying `-C` flags
|
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(' ')}"
|
111
|
+
end
|
112
|
+
|
113
|
+
task "cargo:clean" do
|
114
|
+
sh "cargo clean"
|
115
|
+
end
|
116
|
+
|
117
|
+
directory lib_path
|
118
|
+
|
119
|
+
task :clobber => "cargo:clean"
|
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
|
127
|
+
end
|
128
|
+
CLOBBER.include(native_path)
|
129
|
+
|
130
|
+
desc "Build #{name}"
|
131
|
+
task :build => native_path
|
132
|
+
|
133
|
+
desc "Launch an IRB console for #{name}"
|
134
|
+
task :irb => :build do
|
135
|
+
exec "bundle exec irb -r#{name} -Ilib"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
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
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
module HelixRuntime
|
4
|
+
module Platform
|
5
|
+
# Normalize the platform OS
|
6
|
+
OS = case os = RbConfig::CONFIG['host_os'].downcase
|
7
|
+
when /linux/
|
8
|
+
# The official ruby-alpine Docker containers pre-build Ruby. As a result,
|
9
|
+
# Ruby doesn't know that it's on a musl-based platform. `ldd` is the
|
10
|
+
# only reliable way to detect musl that we've found.
|
11
|
+
# See https://github.com/skylightio/skylight-ruby/issues/92
|
12
|
+
if ENV['SKYLIGHT_MUSL'] || `ldd --version 2>&1` =~ /musl/
|
13
|
+
"linux-musl"
|
14
|
+
else
|
15
|
+
"linux"
|
16
|
+
end
|
17
|
+
when /darwin/
|
18
|
+
"darwin"
|
19
|
+
when /freebsd/
|
20
|
+
"freebsd"
|
21
|
+
when /netbsd/
|
22
|
+
"netbsd"
|
23
|
+
when /openbsd/
|
24
|
+
"openbsd"
|
25
|
+
when /sunos|solaris/
|
26
|
+
"solaris"
|
27
|
+
when /mingw|mswin/
|
28
|
+
"windows"
|
29
|
+
else
|
30
|
+
os
|
31
|
+
end
|
32
|
+
|
33
|
+
# Normalize the platform CPU
|
34
|
+
ARCH = case cpu = RbConfig::CONFIG['host_cpu'].downcase
|
35
|
+
when /amd64|x86_64/
|
36
|
+
"x86_64"
|
37
|
+
when /i?86|x86|i86pc/
|
38
|
+
"x86"
|
39
|
+
when /ppc|powerpc/
|
40
|
+
"powerpc"
|
41
|
+
when /^arm/
|
42
|
+
"arm"
|
43
|
+
else
|
44
|
+
cpu
|
45
|
+
end
|
46
|
+
|
47
|
+
LIBEXT = case OS
|
48
|
+
when /darwin/
|
49
|
+
'dylib'
|
50
|
+
when /linux|bsd|solaris/
|
51
|
+
'so'
|
52
|
+
when /windows|cygwin/
|
53
|
+
'dll'
|
54
|
+
else
|
55
|
+
'so'
|
56
|
+
end
|
57
|
+
|
58
|
+
TUPLE = "#{ARCH}-#{OS}"
|
59
|
+
|
60
|
+
def self.tuple
|
61
|
+
TUPLE
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.libext
|
65
|
+
LIBEXT
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.dlext
|
69
|
+
RbConfig::CONFIG['DLEXT']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: helix_runtime
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yehuda Katz
|
8
|
+
- Godfrey Chan
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-04-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '10.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '10.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.10'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.10'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.4'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.4'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake-compiler
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.9.7
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.9.7
|
70
|
+
description:
|
71
|
+
email:
|
72
|
+
- wycats@gmail.com
|
73
|
+
- godfreykfc@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions:
|
76
|
+
- ext/helix_runtime/native/extconf.rb
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- Gemfile
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- ext/helix_runtime/extconf.rb
|
85
|
+
- ext/helix_runtime/native/extconf.rb
|
86
|
+
- ext/helix_runtime/native/helix_runtime.c
|
87
|
+
- ext/helix_runtime/native/helix_runtime.h
|
88
|
+
- helix_runtime.gemspec
|
89
|
+
- lib/helix_runtime.rb
|
90
|
+
- lib/helix_runtime/build_task.rb
|
91
|
+
- lib/helix_runtime/platform.rb
|
92
|
+
- lib/helix_runtime/version.rb
|
93
|
+
homepage: https://github.com/tildeio/helix
|
94
|
+
licenses: []
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.3.1
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.6.8
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: The Helix Runtime
|
116
|
+
test_files: []
|