sq_mini_racer 0.2.5.0.2 → 0.3.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/CHANGELOG +73 -0
- data/Dockerfile +0 -1
- data/README.md +17 -2
- data/Rakefile +44 -62
- data/azure-pipelines.yml +3 -3
- data/azure-template.yml +10 -1
- data/ext/mini_racer_extension/extconf.rb +62 -55
- data/ext/mini_racer_extension/mini_racer_extension.cc +239 -97
- data/ext/mini_racer_loader/extconf.rb +8 -0
- data/ext/{prv_ext_loader/prv_ext_loader.c → mini_racer_loader/mini_racer_loader.c} +24 -5
- data/lib/sqreen/mini_racer.rb +90 -24
- data/lib/sqreen/mini_racer/version.rb +3 -3
- data/mini_racer.gemspec +14 -5
- data/valgrind.supp +74 -0
- metadata +68 -16
- data/.travis.yml +0 -73
- data/ext/prv_ext_loader/extconf.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5a4f1dcba4f3dd9929c02a63a4ca5e123626c670aec78dd1bd99e045b4406ef
|
4
|
+
data.tar.gz: 162ccdbc01829df6b722e885d6242c17764373b66d5610287a7604d6dcf9dbc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3182e0f36469dbc4a2d5a254c879f7bfb51d1dd2abe903284cb9aefaecc8743fdd16408dec1ae58ab61e90b1e19c61152dbc80ed4d9c92f550684469c80e2b9
|
7
|
+
data.tar.gz: ab44723c482430200ffc20a127cc27672020de03a22e1edd84a42212166742dbe006173951bd345a0f76437ab6186cb5078faa7de2b5d6d41d27df8a0c2f3109
|
data/.gitignore
CHANGED
@@ -11,3 +11,12 @@ lib/*.so
|
|
11
11
|
/lib/sq_mini_racer/
|
12
12
|
/ext/mini_racer_extension/mini_racer.creator.*
|
13
13
|
*.bundle
|
14
|
+
/mini_racer.config
|
15
|
+
/mini_racer.creator
|
16
|
+
/mini_racer.creator.user
|
17
|
+
/mini_racer.files
|
18
|
+
/mini_racer.includes
|
19
|
+
/compile_commands.json
|
20
|
+
/.vscode/
|
21
|
+
/.clangd/
|
22
|
+
/.idea/
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,76 @@
|
|
1
|
+
- Unreleased
|
2
|
+
|
3
|
+
- FIX: on downgrade mkmf was picking the wrong version of libv8, this fix will correct future issues
|
4
|
+
|
5
|
+
- 23-07-2020
|
6
|
+
|
7
|
+
- 0.3.1
|
8
|
+
|
9
|
+
- FIX: specify that libv8 must be larger than 8.4.255 but smaller than 8.5, this avoids issues going forward
|
10
|
+
|
11
|
+
- 22-07-2020
|
12
|
+
|
13
|
+
- 0.3.0
|
14
|
+
|
15
|
+
- FEATURE: upgraded to libv8 version 8.4.255.0
|
16
|
+
|
17
|
+
- 29-06-2020
|
18
|
+
|
19
|
+
- 0.2.15
|
20
|
+
|
21
|
+
- FEATURE: basic wasm support via pump_message_loop
|
22
|
+
|
23
|
+
- 15-05-2020
|
24
|
+
|
25
|
+
- 0.2.14
|
26
|
+
|
27
|
+
- FIX: ensure_gc_after_idle should take in milliseconds like the rest of the APIs not seconds
|
28
|
+
- FEATURE: strict params on MiniRacer::Context.new
|
29
|
+
|
30
|
+
- 15-05-2020
|
31
|
+
|
32
|
+
- 0.2.13
|
33
|
+
|
34
|
+
- FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
|
35
|
+
|
36
|
+
- 15-05-2020
|
37
|
+
|
38
|
+
- 0.2.12
|
39
|
+
|
40
|
+
- FEATURE: isolate.low_memory_notification which can force a full GC
|
41
|
+
- FEATURE: MiniRacer::Context.new(ensure_gc_after_idle: 2) - to force full GC 2 seconds after context is idle, this allows you to conserve memory on isolates
|
42
|
+
|
43
|
+
- 14-05-2020
|
44
|
+
|
45
|
+
- 0.2.11
|
46
|
+
|
47
|
+
- FIX: dumping heap snapshots was not flushing the file leading to corrupt snapshots
|
48
|
+
- FIX: a use-after-free shutdown crash
|
49
|
+
|
50
|
+
- 0.2.10
|
51
|
+
|
52
|
+
- 22-04-2020
|
53
|
+
|
54
|
+
- FEATURE: memory softlimit support for nogvl_context_call
|
55
|
+
|
56
|
+
- 0.2.9
|
57
|
+
|
58
|
+
- 09-01-2020
|
59
|
+
|
60
|
+
- FIX: correct segfault when JS returns a Symbol and properly cast to ruby symbol
|
61
|
+
|
62
|
+
- 0.2.8
|
63
|
+
|
64
|
+
- 11-11-2019
|
65
|
+
|
66
|
+
- FIX: ensure thread live cycle is properly accounter for following file descriptor fix
|
67
|
+
|
68
|
+
- 0.2.7
|
69
|
+
|
70
|
+
- 11-11-2019
|
71
|
+
|
72
|
+
- FIX: release the file descriptor for timeout pipe earlier (this avoids holding too many files open in Ruby 2.7)
|
73
|
+
|
1
74
|
- 14-05-2019
|
2
75
|
|
3
76
|
- 0.2.6
|
data/Dockerfile
CHANGED
data/README.md
CHANGED
@@ -234,12 +234,17 @@ context = MiniRacer::Context.new(isolate: isolate)
|
|
234
234
|
# give up to 100ms for V8 garbage collection
|
235
235
|
isolate.idle_notification(100)
|
236
236
|
|
237
|
+
# force V8 to perform a full GC
|
238
|
+
isolate.low_memory_notification
|
239
|
+
|
237
240
|
```
|
238
241
|
|
239
242
|
This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
|
240
243
|
|
241
244
|
Note that this method maps directly to [`v8::Isolate::IdleNotification`](http://bespin.cz/~ondras/html/classv8_1_1Isolate.html#aea16cbb2e351de9a3ae7be2b7cb48297), and that in particular its return value is the same (true if there is no further garbage to collect, false otherwise) and the same caveats apply, in particular that `there is no guarantee that the [call will return] within the time limit.`
|
242
245
|
|
246
|
+
Additionally you may automate this process on a context by defining it with `MiniRacer::Content.new(ensure_gc_after_idle: 1000)`. Using this will ensure V8 will run a full GC using `context.isolate.low_memory_notification` 1 second after the last eval on the context. Low memory notification is both slower and more aggressive than an idle_notification and will ensure long living isolates use minimal amounts of memory.
|
247
|
+
|
243
248
|
### V8 Runtime flags
|
244
249
|
|
245
250
|
It is possible to set V8 Runtime flags:
|
@@ -277,7 +282,7 @@ context.eval js
|
|
277
282
|
The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
|
278
283
|
Please refer to http://node.green/ as a reference on other harmony features.
|
279
284
|
|
280
|
-
A list of all V8 runtime flags can be found using `node --v8-options`, or else by perusing [the V8 source code for flags (make sure to use the right version of V8)](https://github.com/v8/v8/blob/master/src/flag-definitions.h).
|
285
|
+
A list of all V8 runtime flags can be found using `node --v8-options`, or else by perusing [the V8 source code for flags (make sure to use the right version of V8)](https://github.com/v8/v8/blob/master/src/flags/flag-definitions.h).
|
281
286
|
|
282
287
|
Note that runtime flags must be set before any other operation (e.g. creating a context, a snapshot or an isolate), otherwise an exception will be thrown.
|
283
288
|
|
@@ -314,6 +319,16 @@ context.eval("a = 2")
|
|
314
319
|
# nothing works on the context from now on, its a shell waiting to be disposed
|
315
320
|
```
|
316
321
|
|
322
|
+
A MiniRacer context can also be dumped in a heapsnapshot file using `#write_heap_snapshot(file_or_io)`
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
context = MiniRacer::Context.new(timeout: 5)
|
326
|
+
context.eval("let a='testing';")
|
327
|
+
context.write_heap_snapshot("test.heapsnapshot")
|
328
|
+
```
|
329
|
+
|
330
|
+
This file can then be loaded in the memory tab of the chrome dev console.
|
331
|
+
|
317
332
|
### Function call
|
318
333
|
|
319
334
|
This calls the function passed as first argument:
|
@@ -451,7 +466,7 @@ Add this to your .travis.yml file:
|
|
451
466
|
|
452
467
|
## Contributing
|
453
468
|
|
454
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
469
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rubyjs/mini_racer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
455
470
|
|
456
471
|
|
457
472
|
## License
|
data/Rakefile
CHANGED
@@ -1,75 +1,57 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
3
|
require "rake/extensiontask"
|
4
|
+
require "shellwords"
|
5
|
+
|
6
|
+
class ValgrindTestTask < Rake::TestTask
|
7
|
+
VALGRIND_EXEC = 'valgrind'
|
8
|
+
DEFAULT_VALGRIND_OPTS = %w{
|
9
|
+
--trace-children=yes
|
10
|
+
--partial-loads-ok=yes
|
11
|
+
--error-limit=no
|
12
|
+
--error-exitcode=33
|
13
|
+
--num-callers=100
|
14
|
+
--suppressions=valgrind.supp
|
15
|
+
--gen-suppressions=all
|
16
|
+
}
|
17
|
+
|
18
|
+
attr_accessor :valgrind_args
|
19
|
+
|
20
|
+
def initialize(name=:valgrind_test)
|
21
|
+
@valgrind_args = DEFAULT_VALGRIND_OPTS
|
22
|
+
super
|
23
|
+
end
|
4
24
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Rake::ExtensionTask.new( 'mini_racer_extension', gem ) do |ext|
|
15
|
-
ext.name = 'sq_mini_racer_extension'
|
16
|
-
end
|
17
|
-
Rake::ExtensionTask.new('prv_ext_loader', gem)
|
18
|
-
|
19
|
-
|
20
|
-
# via http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
|
21
|
-
namespace :test do
|
22
|
-
desc "run test suite with Address Sanitizer"
|
23
|
-
task :asan do
|
24
|
-
ENV["CONFIGURE_ARGS"] = [ENV["CONFIGURE_ARGS"], '--enable-asan'].compact.join(' ')
|
25
|
-
Rake::Task['compile'].invoke
|
26
|
-
|
27
|
-
asan_path = `ldconfig -N -p |grep libasan | grep -v 32 | sed 's/.* => \\(.*\\)$/\\1/'`.chomp.split("\n")[-1]
|
28
|
-
|
29
|
-
|
30
|
-
cmdline = "env LD_PRELOAD=\"#{asan_path}\" ruby test/test_leak.rb"
|
31
|
-
puts cmdline
|
32
|
-
system cmdline
|
33
|
-
|
34
|
-
cmdline = "env LD_PRELOAD=\"#{asan_path}\" rake test"
|
35
|
-
puts cmdline
|
36
|
-
system cmdline
|
25
|
+
# see original def in fileutils.rb
|
26
|
+
def ruby(*args, &block)
|
27
|
+
options = (Hash === args.last) ? args.pop : {}
|
28
|
+
if args.length > 1
|
29
|
+
sh(*([VALGRIND_EXEC] + valgrind_args + [RUBY] + args + [options]), &block)
|
30
|
+
else
|
31
|
+
# if the size is 1 it's assumed the arguments are already escaped
|
32
|
+
non_escaped_args = [VALGRIND_EXEC] + valgrind_args + [RUBY]
|
33
|
+
sh("#{non_escaped_args.map { |s| Shellwords.escape(s) }.join(' ')} #{args.first}", options, &block)
|
37
34
|
end
|
38
|
-
|
39
|
-
|
40
|
-
# interpreter
|
41
|
-
VALGRIND_BASIC_OPTS = "--num-callers=50 --error-limit=no \
|
42
|
-
--partial-loads-ok=yes --undef-value-errors=no"
|
35
|
+
end
|
36
|
+
end
|
43
37
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
system cmdline
|
38
|
+
test_task_cfg = Proc.new do |t|
|
39
|
+
t.libs << 'test'
|
40
|
+
t.libs << 'lib'
|
41
|
+
t.test_files = FileList['test/**/*_test.rb']
|
49
42
|
end
|
50
43
|
|
51
|
-
|
52
|
-
|
53
|
-
cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --leak-check=full ruby test/test_leak.rb"
|
54
|
-
puts cmdline
|
55
|
-
require 'open3'
|
56
|
-
_, stderr = Open3.capture3(cmdline)
|
44
|
+
Rake::TestTask.new(:test, &test_task_cfg)
|
45
|
+
ValgrindTestTask.new(:'test:valgrind', &test_task_cfg)
|
57
46
|
|
58
|
-
|
59
|
-
stderr.split("\n").each do |line|
|
47
|
+
task :default => [:compile, :test]
|
60
48
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
section = ""
|
68
|
-
else
|
69
|
-
section << line << "\n"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
49
|
+
gem = Gem::Specification.load( File.dirname(__FILE__) + '/mini_racer.gemspec' )
|
50
|
+
Rake::ExtensionTask.new( 'mini_racer_loader', gem ) do |ext|
|
51
|
+
ext.name = 'sq_mini_racer_loader'
|
52
|
+
end
|
53
|
+
Rake::ExtensionTask.new( 'mini_racer_extension', gem ) do |ext|
|
54
|
+
ext.name = 'sq_mini_racer_extension'
|
73
55
|
end
|
74
56
|
|
75
57
|
desc 'run clang-tidy linter on mini_racer_extension.cc'
|
data/azure-pipelines.yml
CHANGED
data/azure-template.yml
CHANGED
@@ -66,7 +66,7 @@ jobs:
|
|
66
66
|
displayName: Print logs
|
67
67
|
condition: failed()
|
68
68
|
|
69
|
-
- script: $(bundle) exec rake test
|
69
|
+
- script: TESTOPTS=--junit $(bundle) exec rake test
|
70
70
|
displayName: Run tests
|
71
71
|
env:
|
72
72
|
${{ if eq(parameters.with_mini_racer, true) }}:
|
@@ -74,6 +74,15 @@ jobs:
|
|
74
74
|
${{ if eq(parameters.with_therubyracer, true) }}:
|
75
75
|
LOAD_THERUBYRACER: 1
|
76
76
|
|
77
|
+
- task: PublishTestResults@2
|
78
|
+
displayName: Publish test results
|
79
|
+
condition: succeededOrFailed()
|
80
|
+
inputs:
|
81
|
+
testResultsFormat: 'JUnit'
|
82
|
+
testResultsFiles: '**/report.xml'
|
83
|
+
searchFolder: '$(System.DefaultWorkingDirectory)'
|
84
|
+
mergeTestResults: true
|
85
|
+
|
77
86
|
- ${{ if and(eq(parameters.imageName, 'ubuntu-18.04'), eq(parameters.with_mini_racer, false), eq(parameters.with_therubyracer, false)) }}:
|
78
87
|
- script: $(bundle) exec rake test:valgrind
|
79
88
|
displayName: Run tests w/ valgrind
|
@@ -26,58 +26,52 @@ def cppflags_add_cpu_extension!
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def libv8_gem_name
|
29
|
-
#return "libv8-solaris" if IS_SOLARIS
|
30
|
-
#return "libv8-alpine" if IS_LINUX_MUSL
|
31
|
-
|
32
29
|
'libv8-node'
|
33
30
|
end
|
34
31
|
|
35
|
-
def
|
36
|
-
'
|
32
|
+
def libv8_version
|
33
|
+
'14.14.0.0.beta2'
|
37
34
|
end
|
38
35
|
|
39
|
-
def libv8_basename
|
40
|
-
"#{libv8_gem_name}-#{
|
36
|
+
def libv8_basename
|
37
|
+
"#{libv8_gem_name}-#{libv8_version}-#{ruby_platform}"
|
41
38
|
end
|
42
39
|
|
43
|
-
def
|
44
|
-
|
40
|
+
def libv8_gemspec_no_libc
|
41
|
+
platform_no_libc = ruby_platform.to_s.split('-')[0..1].join('-')
|
42
|
+
"#{libv8_gem_name}-#{libv8_version}-#{platform_no_libc}.gemspec"
|
45
43
|
end
|
46
44
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
puts "looking for #{name_glob} in #{path.inspect}"
|
51
|
-
|
52
|
-
paths = path.map { |p| Dir.glob(File.join(p, 'specifications', name_glob + '.gemspec')) }.flatten
|
53
|
-
|
54
|
-
if paths.empty?
|
55
|
-
puts "#{name_glob} not found in #{path.inspect}"
|
56
|
-
return
|
57
|
-
end
|
58
|
-
|
59
|
-
specs = paths.map { |p| [p, eval(File.read(p))] }
|
60
|
-
.select { |_, spec| Gem::Requirement.new(libv8_requirement).satisfied_by?(spec.version) }
|
61
|
-
found_path, found_spec = specs.sort_by { |_, spec| spec.version }.last
|
45
|
+
def libv8_gemspec
|
46
|
+
"#{libv8_basename}.gemspec"
|
47
|
+
end
|
62
48
|
|
63
|
-
|
64
|
-
|
49
|
+
def libv8_local_path(path=Gem.path)
|
50
|
+
gemspecs = [libv8_gemspec, libv8_gemspec_no_libc].uniq
|
51
|
+
puts "looking for #{gemspecs.join(', ')} in installed gems"
|
52
|
+
candidates = path.product(gemspecs)
|
53
|
+
.map { |(p, gemspec)| File.join(p, 'specifications', gemspec) }
|
54
|
+
p candidates
|
55
|
+
found = candidates.select { |f| File.exist?(f) }.first
|
56
|
+
|
57
|
+
unless found
|
58
|
+
puts "#{gemspecs.join(', ')} not found in installed gems"
|
65
59
|
return
|
66
60
|
end
|
67
61
|
|
68
|
-
puts "found in specs: #{
|
62
|
+
puts "found in installed specs: #{found}"
|
69
63
|
|
70
|
-
gemdir = File.basename(
|
71
|
-
dir = File.expand_path(File.join(
|
64
|
+
gemdir = File.basename(found, '.gemspec')
|
65
|
+
dir = File.expand_path(File.join(found, '..', '..', 'gems', gemdir))
|
72
66
|
|
73
67
|
unless Dir.exist?(dir)
|
74
|
-
puts "not found in gems: #{dir}"
|
68
|
+
puts "not found in installed gems: #{dir}"
|
75
69
|
return
|
76
70
|
end
|
77
71
|
|
78
|
-
puts "found in gems: #{dir}"
|
72
|
+
puts "found in installed gems: #{dir}"
|
79
73
|
|
80
|
-
|
74
|
+
dir
|
81
75
|
end
|
82
76
|
|
83
77
|
def vendor_path
|
@@ -85,12 +79,25 @@ def vendor_path
|
|
85
79
|
end
|
86
80
|
|
87
81
|
def libv8_vendor_path
|
88
|
-
|
82
|
+
puts "looking for #{libv8_basename} in #{vendor_path}"
|
83
|
+
path = Dir.glob("#{vendor_path}/#{libv8_basename}").first
|
84
|
+
|
85
|
+
unless path
|
86
|
+
puts "#{libv8_basename} not found in #{vendor_path}"
|
87
|
+
return
|
88
|
+
end
|
89
|
+
|
90
|
+
puts "looking for #{libv8_basename}/lib/libv8-node.rb in #{vendor_path}"
|
91
|
+
unless Dir.glob(File.join(vendor_path, libv8_basename, 'lib', 'libv8-node.rb')).first
|
92
|
+
puts "#{libv8_basename}/lib/libv8.rb not found in #{vendor_path}"
|
93
|
+
return
|
94
|
+
end
|
95
|
+
|
96
|
+
path
|
89
97
|
end
|
90
98
|
|
91
99
|
def parse_platform(str)
|
92
100
|
Gem::Platform.new(str).tap do |p|
|
93
|
-
p.instance_eval { @version = 'musl' } if str =~ /-musl/ && p.version.nil?
|
94
101
|
p.instance_eval { @cpu = 'x86_64' } if str =~ /universal.*darwin/
|
95
102
|
end
|
96
103
|
end
|
@@ -114,23 +121,21 @@ def libv8_remote_search
|
|
114
121
|
json = JSON.parse(body)
|
115
122
|
|
116
123
|
versions = json.select do |v|
|
117
|
-
Gem::
|
124
|
+
Gem::Version.new(v['number']) == Gem::Version.new(libv8_version)
|
118
125
|
end
|
119
126
|
abort(<<-ERROR) if versions.empty?
|
120
|
-
ERROR: could not find #{libv8_gem_name} (
|
127
|
+
ERROR: could not find #{libv8_gem_name} (version #{libv8_version}) in rubygems.org
|
121
128
|
ERROR
|
122
129
|
|
123
130
|
platform_versions = versions.select do |v|
|
124
131
|
parse_platform(v['platform']) == ruby_platform unless v['platform'] =~ /universal.*darwin/
|
125
132
|
end
|
126
133
|
abort(<<-ERROR) if platform_versions.empty?
|
127
|
-
ERROR: found
|
128
|
-
try "gem install #{libv8_gem_name}
|
134
|
+
ERROR: found #{libv8_gem_name}-#{libv8_version}, but no binary for #{ruby_platform}
|
135
|
+
try "gem install #{libv8_gem_name} -v '#{libv8_version}'" to attempt to build libv8 from source
|
129
136
|
ERROR
|
130
137
|
|
131
|
-
|
132
|
-
|
133
|
-
platform_versions.sort_by { |v| Gem::Version.new(v['number']) }.last
|
138
|
+
platform_versions.first
|
134
139
|
end
|
135
140
|
|
136
141
|
def libv8_download_uri(name, version, platform)
|
@@ -142,19 +147,19 @@ def libv8_downloaded_gem(name, version, platform)
|
|
142
147
|
end
|
143
148
|
|
144
149
|
def libv8_download(name, version, platform)
|
145
|
-
FileUtils.mkdir_p(
|
150
|
+
FileUtils.mkdir_p(vendor_path)
|
146
151
|
body = http_get(libv8_download_uri(name, version, platform))
|
147
|
-
File.open(File.join(vendor_path,
|
152
|
+
File.open(File.join(vendor_path, libv8_downloaded_gem(name, version, platform)), 'wb') { |f| f.write(body) }
|
148
153
|
end
|
149
154
|
|
150
155
|
def libv8_install!
|
151
|
-
cmd = "gem install #{libv8_gem_name} --version '#{
|
156
|
+
cmd = "gem install #{libv8_gem_name} --version '#{libv8_version}' --install-dir '#{vendor_path}'"
|
152
157
|
puts "installing #{libv8_gem_name} using `#{cmd}`"
|
153
158
|
rc = system(cmd)
|
154
159
|
|
155
160
|
abort(<<-ERROR) unless rc
|
156
|
-
ERROR: could not install #{libv8_gem_name}
|
157
|
-
try "gem install #{libv8_gem_name} -v '#{
|
161
|
+
ERROR: could not install #{libv8_gem_name} #{libv8_version}
|
162
|
+
try "gem install #{libv8_gem_name} -v '#{libv8_version}'" to attempt to build libv8 from source
|
158
163
|
ERROR
|
159
164
|
|
160
165
|
libv8_local_path([vendor_path])
|
@@ -168,20 +173,18 @@ def libv8_vendor!
|
|
168
173
|
puts "downloading #{libv8_downloaded_gem(libv8_gem_name, version['number'], version['platform'])} to #{vendor_path}"
|
169
174
|
libv8_download(libv8_gem_name, version['number'], version['platform'])
|
170
175
|
|
171
|
-
package = Gem::Package.new(File.join(vendor_path,
|
172
|
-
package.extract_files(File.join(vendor_path,
|
173
|
-
FileUtils.mkdir_p(File.join(vendor_path, 'specifications'))
|
174
|
-
File.open(File.join(vendor_path, 'specifications', File.basename(libv8_downloaded_gem(libv8_gem_name, version['number'], version['platform']), '.gem') + '.gemspec'), 'wb') { |f| f.write(package.spec.to_ruby) }
|
176
|
+
package = Gem::Package.new(File.join(vendor_path, libv8_downloaded_gem(libv8_gem_name, version['number'], version['platform'])))
|
177
|
+
package.extract_files(File.join(vendor_path, File.basename(libv8_downloaded_gem(libv8_gem_name, version['number'], version['platform']), '.gem')))
|
175
178
|
|
176
179
|
libv8_vendor_path
|
177
180
|
end
|
178
181
|
|
179
182
|
def ensure_libv8_load_path
|
180
|
-
puts "platform
|
183
|
+
puts "detected platform #{RUBY_PLATFORM} => #{ruby_platform}"
|
181
184
|
|
182
|
-
libv8_path
|
183
|
-
|
184
|
-
libv8_path
|
185
|
+
libv8_path = libv8_local_path
|
186
|
+
unless ENV['ONLY_INSTALLED_LIBV8_GEM']
|
187
|
+
libv8_path ||= libv8_vendor_path || libv8_vendor!
|
185
188
|
end
|
186
189
|
|
187
190
|
abort(<<-ERROR) unless libv8_path
|
@@ -207,6 +210,8 @@ $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
|
|
207
210
|
$CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN
|
208
211
|
$CPPFLAGS += " -std=c++0x"
|
209
212
|
$CPPFLAGS += " -fpermissive"
|
213
|
+
$CPPFLAGS += " -DV8_COMPRESS_POINTERS"
|
214
|
+
$CPPFLAGS += " -fvisibility=hidden "
|
210
215
|
cppflags_add_frame_pointer!
|
211
216
|
cppflags_add_cpu_extension!
|
212
217
|
|
@@ -214,12 +219,14 @@ $CPPFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
|
|
214
219
|
|
215
220
|
$LDFLAGS.insert(0, " -stdlib=libc++ ") if IS_DARWIN
|
216
221
|
$LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
|
217
|
-
$LDFLAGS += " -Wl,-undefined,error " if IS_DARWIN
|
218
222
|
|
219
223
|
if ENV['CXX']
|
220
224
|
puts "SETTING CXX"
|
221
225
|
CONFIG['CXX'] = ENV['CXX']
|
222
226
|
end
|
227
|
+
# 1.9 has no $CXXFLAGS
|
228
|
+
$CPPFLAGS += " #{ENV['CPPFLAGS']}" if ENV['CPPFLAGS']
|
229
|
+
$LDFLAGS += " #{ENV['LDFLAGS']}" if ENV['LDFLAGS']
|
223
230
|
|
224
231
|
CXX11_TEST = <<EOS
|
225
232
|
#if __cplusplus <= 199711L
|