mini_racer 0.1.15 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d6c94af48c76bdd1d4ce6744e81cf812192498d8
4
- data.tar.gz: dd14708bbca74f0845ce37310fb4a7679326e7cb
2
+ SHA256:
3
+ metadata.gz: f868c575c8ed41f4080580b2d09d0d42522d337390f425b3110e38298952a6f4
4
+ data.tar.gz: 9c2df1f0171dd3ed4bba7a59faa3ea7d87a1976087395da3ec56966aeedd23d8
5
5
  SHA512:
6
- metadata.gz: 8982f3a4a7aa6c9f89a581099c48a2e694930f9e4f48beaf88cfaf38f9a21004b32fd5093937ffa0096ac4ebb725c7f99402928a0ab4b54153114fa81267d21b
7
- data.tar.gz: f9219565baccdea2ce89be3e50012b204e4482296f83084517db0e996a4a6147050230f6afcebc4ba79e1b127aa3dcbe845962c3087c5dd3ec3b2e16970537f0
6
+ metadata.gz: 7c51ea3a8f4abc4ae458090ce2f37760110ac240f7600e3fd249f07df97725e0b7903884fb90063b3d3140c0337eeae132a6e395b1f74777c85dfddc03b6ad96
7
+ data.tar.gz: '0948c498cdb9a0767dbe0de9d4b233d2561eb6b72f6603170c3f4d9304083487a03fc395f8803f1d1690ef6f9d06e0faddc86ef694b950c0e95ea4047943c96e'
data/.dockerignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ lib/mini_racer_extension.so
11
+ lib/mini_racer_loader.so
12
+ *.bundle
@@ -0,0 +1,78 @@
1
+ name: Test
2
+ on:
3
+ - push
4
+
5
+ jobs:
6
+ test-darwin:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ os:
11
+ - '10.15'
12
+ - '11.0'
13
+ platform:
14
+ - x86_64
15
+ # arm64
16
+ name: Test (darwin)
17
+ runs-on: macos-${{ matrix.os }}
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v2
21
+ - name: Bundle
22
+ run: bundle install
23
+ - name: Compile
24
+ run: bundle exec rake compile
25
+ - name: Test
26
+ run: bundle exec rake test
27
+ test-linux:
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ ruby:
32
+ - '2.6'
33
+ - '2.7'
34
+ - '3.0'
35
+ platform:
36
+ - amd64
37
+ - arm64
38
+ # arm
39
+ # ppc64le
40
+ # s390x
41
+ libc:
42
+ - gnu
43
+ - musl
44
+ name: Test (linux)
45
+ runs-on: ubuntu-20.04
46
+ steps:
47
+ - name: Enable ${{ matrix.platform }} platform
48
+ id: qemu
49
+ if: ${{ matrix.platform != 'amd64' }}
50
+ run: |
51
+ docker run --privileged --rm tonistiigi/binfmt:latest --install ${{ matrix.platform }} | tee platforms.json
52
+ echo "::set-output name=platforms::$(cat platforms.json)"
53
+ - name: Start container
54
+ id: container
55
+ run: |
56
+ case ${{ matrix.libc }} in
57
+ gnu)
58
+ echo 'ruby:${{ matrix.ruby }}'
59
+ ;;
60
+ musl)
61
+ echo 'ruby:${{ matrix.ruby }}-alpine'
62
+ ;;
63
+ esac > container_image
64
+ echo "::set-output name=image::$(cat container_image)"
65
+ docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" --platform linux/${{ matrix.platform }} $(cat container_image) /bin/sleep 64d | tee container_id
66
+ docker exec -w "${PWD}" $(cat container_id) uname -a
67
+ echo "::set-output name=id::$(cat container_id)"
68
+ - name: Install Alpine system dependencies
69
+ if: ${{ matrix.libc == 'musl' }}
70
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base linux-headers bash python2 python3 git curl tar clang binutils-gold
71
+ - name: Checkout
72
+ uses: actions/checkout@v2
73
+ - name: Bundle
74
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle install
75
+ - name: Compile
76
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake compile
77
+ - name: Test
78
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake test
data/.gitignore CHANGED
@@ -8,4 +8,6 @@ Gemfile.lock
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  lib/mini_racer_extension.so
11
+ lib/mini_racer_loader.so
11
12
  *.bundle
13
+ .vscode/
data/.travis.yml CHANGED
@@ -1,19 +1,23 @@
1
1
  language: ruby
2
+ os: linux
2
3
  rvm:
3
- - 2.1
4
- - 2.2
5
- - 2.3.3
6
- - 2.4.0
7
- matrix:
4
+ - 2.6
5
+ - 2.7
6
+ - 3.0
7
+ - ruby-head
8
+ arch:
9
+ - amd64
10
+ - arm64
11
+ jobs:
8
12
  include:
9
- - rvm: 2.4.0
13
+ - rvm: 2.6
10
14
  os: osx
11
- osx_image: xcode8.2
12
- - rvm: 2.4.0
15
+ osx_image: xcode11.3
16
+ - rvm: 2.6
13
17
  os: osx
14
- osx_image: xcode7.3
15
- dist: trusty
16
- sudo: true
17
- before_install:
18
- - gem install bundler -v 1.12.0
18
+ osx_image: xcode12.2
19
+ - rvm: 2.7
20
+ os: osx
21
+ osx_image: xcode12.2
22
+ dist: xenial
19
23
  cache: bundler
data/CHANGELOG CHANGED
@@ -1,3 +1,138 @@
1
+ - 11-04-2021
2
+
3
+ - 0.4.0
4
+
5
+ - FEATURE: upgrade to libv8 node 15.14.0 (v8 8.6.395.17)
6
+ - Promote 0.4.0.beta1 to release, using libv8-node release path
7
+
8
+ - 08-04-2021
9
+
10
+ - 0.4.0.beta1
11
+
12
+ - FIX: on downgrade mkmf was picking the wrong version of libv8, this fix will correct future issues
13
+ - FEATURE: upgraded libv8 to use node libv8 build which supports M1 and various ARM builds v8 moved to (8.6.395.17)
14
+
15
+ - 23-07-2020
16
+
17
+ - 0.3.1
18
+
19
+ - FIX: specify that libv8 must be larger than 8.4.255 but smaller than 8.5, this avoids issues going forward
20
+
21
+ - 22-07-2020
22
+
23
+ - 0.3.0
24
+
25
+ - FEATURE: upgraded to libv8 version 8.4.255.0
26
+
27
+ - 29-06-2020
28
+
29
+ - 0.2.15
30
+
31
+ - FEATURE: basic wasm support via pump_message_loop
32
+
33
+ - 15-05-2020
34
+
35
+ - 0.2.14
36
+
37
+ - FIX: ensure_gc_after_idle should take in milliseconds like the rest of the APIs not seconds
38
+ - FEATURE: strict params on MiniRacer::Context.new
39
+
40
+ - 15-05-2020
41
+
42
+ - 0.2.13
43
+
44
+ - FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
45
+
46
+ - 15-05-2020
47
+
48
+ - 0.2.12
49
+
50
+ - FEATURE: isolate.low_memory_notification which can force a full GC
51
+ - 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
52
+
53
+ - 14-05-2020
54
+
55
+ - 0.2.11
56
+
57
+ - FIX: dumping heap snapshots was not flushing the file leading to corrupt snapshots
58
+ - FIX: a use-after-free shutdown crash
59
+
60
+ - 0.2.10
61
+
62
+ - 22-04-2020
63
+
64
+ - FEATURE: memory softlimit support for nogvl_context_call
65
+
66
+ - 0.2.9
67
+
68
+ - 09-01-2020
69
+
70
+ - FIX: correct segfault when JS returns a Symbol and properly cast to ruby symbol
71
+
72
+ - 0.2.8
73
+
74
+ - 11-11-2019
75
+
76
+ - FIX: ensure thread live cycle is properly accounter for following file descriptor fix
77
+
78
+ - 0.2.7
79
+
80
+ - 11-11-2019
81
+
82
+ - FIX: release the file descriptor for timeout pipe earlier (this avoids holding too many files open in Ruby 2.7)
83
+
84
+ - 14-05-2019
85
+
86
+ - 0.2.6
87
+
88
+ - FEATURE: add support for write_heap_snapshot which helps you analyze memory
89
+
90
+ - 25-04-2019
91
+
92
+ - 0.2.5
93
+
94
+ - FIX: Compatiblity fixes for V8 7 and above @ignisf
95
+ - FIX: Memory leak in gc_callback @messense
96
+ - IMPROVEMENT: Added example of sourcemap support @ianks
97
+ - URGENT: you will need this release for latest version of libv8 to work
98
+
99
+ - 02-11-2018
100
+
101
+ - 0.2.4
102
+
103
+ - FIX: deadlock releasing context when shared isolates are used
104
+ - FEATURE: include js backtrace when snapshots do not compile
105
+
106
+ - 28-09-2018
107
+
108
+ - 0.2.3
109
+
110
+ - Drop all conditional logic from Mini Racer compilation for clang, always
111
+ rely on MacOS being High Sierra or up
112
+
113
+ - 26-09-2018
114
+
115
+ - 0.2.2
116
+
117
+ - WORKAROUND: RUBY_PLATFORM is hardcoded on Ruby compile and can not be
118
+ trusted for feature detection, use a different technique when checking for
119
+ macOS Mojave
120
+
121
+ - 25-09-2018
122
+
123
+ - 0.2.1
124
+
125
+ - FEATURE: Mojave macOS support
126
+
127
+ - 06-07-2018
128
+
129
+ - 0.2.0
130
+ - FEATURE: context#call to allow for cheaper invocation of functions
131
+ - FIX: rare memory leak when terminating a long running attached function
132
+ - FIX: rare segfault when terminating a long running attached function
133
+ - FIX: Reimplement Isolate#idle_notification using idle_notification_deadline, API remains the same @ignisf
134
+ - Account for changes in the upstream V8 API @ignisf
135
+ - Support for libv8 6.7
1
136
 
2
137
  23-08-2017
3
138
 
data/Dockerfile ADDED
@@ -0,0 +1,21 @@
1
+ ARG RUBY_VERSION=2.7
2
+ FROM ruby:${RUBY_VERSION}
3
+
4
+ RUN test ! -f /etc/alpine-release || apk add --no-cache build-base git
5
+
6
+ # without this `COPY .git`, we get the following error:
7
+ # fatal: not a git repository (or any of the parent directories): .git
8
+ # but with it we need the full gem just to compile the extension because
9
+ # of gemspec's `git --ls-files`
10
+ # COPY .git /code/.git
11
+ COPY Gemfile mini_racer.gemspec /code/
12
+ COPY lib/mini_racer/version.rb /code/lib/mini_racer/version.rb
13
+ WORKDIR /code
14
+ RUN bundle install
15
+
16
+ COPY Rakefile /code/
17
+ COPY ext /code/ext/
18
+ RUN bundle exec rake compile
19
+
20
+ COPY . /code/
21
+ CMD bundle exec irb -rmini_racer
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 TODO: Write your name
3
+ Copyright (c) 2016-2019, the mini_racer project authors.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MiniRacer
2
2
 
3
- [![Build Status](https://travis-ci.org/discourse/mini_racer.svg?branch=master)](https://travis-ci.org/discourse/mini_racer)
3
+ [![Build Status](https://travis-ci.org/rubyjs/mini_racer.svg?branch=master)](https://travis-ci.org/rubyjs/mini_racer)
4
4
 
5
5
  Minimal, modern embedded V8 for Ruby.
6
6
 
@@ -10,6 +10,12 @@ It was created as an alternative to the excellent [therubyracer](https://github.
10
10
 
11
11
  MiniRacer has an adapter for [execjs](https://github.com/rails/execjs) so it can be used directly with Rails projects to minify assets, run babel or compile CoffeeScript.
12
12
 
13
+ ### A note about Ruby version Support
14
+
15
+ MiniRacer only supports non-EOL versions of Ruby. See [Ruby](https://www.ruby-lang.org/en/downloads) to see the list of non-EOL Rubies.
16
+
17
+ If you require support for older versions of Ruby install an older version of the gem.
18
+
13
19
  ## Features
14
20
 
15
21
  ### Simple eval for JavaScript
@@ -79,6 +85,19 @@ context.eval 'var a = new Array(10000); while(true) {a = a.concat(new Array(1000
79
85
  # => V8OutOfMemoryError is raised
80
86
  ```
81
87
 
88
+ ### Object marshal max stackdepth support
89
+
90
+ Contexts can specify a stack depth limit for object marshalling. Max depth is unbounded by default.
91
+
92
+ ```ruby
93
+ # terminates script if stack depth exceeds max during marshal
94
+ context = MiniRacer::Context.new(marshal_stack_depth: 500)
95
+ context.attach("a", proc{|a| a})
96
+
97
+ context.eval("let arr = []; arr.push(arr); a(arr)")
98
+ # => RuntimeError is raised
99
+ ```
100
+
82
101
  ### Rich debugging with "filename" support
83
102
 
84
103
  ```ruby
@@ -91,6 +110,27 @@ context.eval('bar()', filename: 'a/bar.js')
91
110
 
92
111
  ```
93
112
 
113
+ ### Fork safety
114
+
115
+ Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe.
116
+ Sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
117
+
118
+ If you want to ensure your application does not leak memory after fork either:
119
+
120
+ 1. Ensure no MiniRacer::Context objects are created in the master process
121
+
122
+ Or
123
+
124
+ 2. Dispose manually of all MiniRacer::Context objects prior to forking
125
+
126
+ ```ruby
127
+ # before fork
128
+
129
+ require 'objspace'
130
+ ObjectSpace.each_object(MiniRacer::Context){|c| c.dispose}
131
+
132
+ # fork here
133
+ ```
94
134
 
95
135
  ### Threadsafe
96
136
 
@@ -203,12 +243,17 @@ context = MiniRacer::Context.new(isolate: isolate)
203
243
  # give up to 100ms for V8 garbage collection
204
244
  isolate.idle_notification(100)
205
245
 
246
+ # force V8 to perform a full GC
247
+ isolate.low_memory_notification
248
+
206
249
  ```
207
250
 
208
251
  This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
209
252
 
210
253
  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.`
211
254
 
255
+ 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.
256
+
212
257
  ### V8 Runtime flags
213
258
 
214
259
  It is possible to set V8 Runtime flags:
@@ -217,7 +262,7 @@ It is possible to set V8 Runtime flags:
217
262
  MiniRacer::Platform.set_flags! :noconcurrent_recompilation, max_inlining_levels: 10
218
263
  ```
219
264
 
220
- This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to alwatys appreciate V8's liberal use of threading:
265
+ This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to always appreciate V8's liberal use of threading:
221
266
  ```ruby
222
267
  MiniRacer::Platform.set_flags! :noconcurrent_recompilation, :noconcurrent_sweeping
223
268
  ```
@@ -246,7 +291,7 @@ context.eval js
246
291
  The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
247
292
  Please refer to http://node.green/ as a reference on other harmony features.
248
293
 
249
- 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).
294
+ 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).
250
295
 
251
296
  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.
252
297
 
@@ -283,6 +328,32 @@ context.eval("a = 2")
283
328
  # nothing works on the context from now on, its a shell waiting to be disposed
284
329
  ```
285
330
 
331
+ A MiniRacer context can also be dumped in a heapsnapshot file using `#write_heap_snapshot(file_or_io)`
332
+
333
+ ```ruby
334
+ context = MiniRacer::Context.new(timeout: 5)
335
+ context.eval("let a='testing';")
336
+ context.write_heap_snapshot("test.heapsnapshot")
337
+ ```
338
+
339
+ This file can then be loaded in the memory tab of the chrome dev console.
340
+
341
+ ### Function call
342
+
343
+ This calls the function passed as first argument:
344
+
345
+ ```ruby
346
+ context = MiniRacer::Context.new
347
+ context.eval('function hello(name) { return "Hello, " + name + "!" }')
348
+ context.call('hello', 'George')
349
+ # "Hello, George!"
350
+ ```
351
+
352
+ Performance is slightly better than running `eval('hello("George")')` since:
353
+
354
+ - compilation of eval'd string is avoided
355
+ - function arguments don't need to be converted to JSON
356
+
286
357
  ## Performance
287
358
 
288
359
  The `bench` folder contains benchmark.
@@ -324,6 +395,10 @@ Note how the global interpreter lock release leads to 2 threads doing the same w
324
395
 
325
396
  As a rule MiniRacer strives to always support and depend on the latest stable version of libv8.
326
397
 
398
+ ## Source Maps
399
+
400
+ MiniRacer can fully support source maps but must be configured correctly to do so. [Check out this example](./examples/source-map-support/) for a working implementation.
401
+
327
402
  ## Installation
328
403
 
329
404
  Add this line to your application's Gemfile:
@@ -341,14 +416,14 @@ Or install it yourself as:
341
416
  $ gem install mini_racer
342
417
 
343
418
 
344
- **Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or gcc 4.8 (or later).
419
+ **Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or GCC 6.3 (or later).
345
420
 
346
421
 
347
422
  ## Travis-ci
348
423
 
349
- To install `mini-racer` you will need a version of gcc that supports C++11 (gcc 4.8) this is included by default in ubuntu trusty based images.
424
+ To install `mini-racer` you will need a version of GCC that supports C++11 (GCC 6.3) this is included by default in ubuntu trusty based images.
350
425
 
351
- Travis today ships by default with a precise based image. Precise Pangolin (12.04 LTS) was first released in August 2012. Even though you can install GCC 4.8 on precise the simpler approach is to opt for the trusty based image.
426
+ Travis today ships by default with a precise based image. Precise Pangolin (12.04 LTS) was first released in August 2012. Even though you can install GCC 6.3 on precise the simpler approach is to opt for the trusty based image.
352
427
 
353
428
  Add this to your .travis.yml file:
354
429
 
@@ -400,7 +475,7 @@ Add this to your .travis.yml file:
400
475
 
401
476
  ## Contributing
402
477
 
403
- Bug reports and pull requests are welcome on GitHub at https://github.com/discourse/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.
478
+ 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.
404
479
 
405
480
 
406
481
  ## License
data/Rakefile CHANGED
@@ -11,11 +11,28 @@ end
11
11
  task :default => [:compile, :test]
12
12
 
13
13
  gem = Gem::Specification.load( File.dirname(__FILE__) + '/mini_racer.gemspec' )
14
+ Rake::ExtensionTask.new( 'mini_racer_loader', gem )
14
15
  Rake::ExtensionTask.new( 'mini_racer_extension', gem )
15
16
 
16
17
 
17
18
  # via http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
18
19
  namespace :test do
20
+ desc "run test suite with Address Sanitizer"
21
+ task :asan do
22
+ ENV["CONFIGURE_ARGS"] = [ENV["CONFIGURE_ARGS"], '--enable-asan'].compact.join(' ')
23
+ Rake::Task['compile'].invoke
24
+
25
+ asan_path = `ldconfig -N -p |grep libasan | grep -v 32 | sed 's/.* => \\(.*\\)$/\\1/'`.chomp.split("\n")[-1]
26
+
27
+
28
+ cmdline = "env LD_PRELOAD=\"#{asan_path}\" ruby test/test_leak.rb"
29
+ puts cmdline
30
+ system cmdline
31
+
32
+ cmdline = "env LD_PRELOAD=\"#{asan_path}\" rake test"
33
+ puts cmdline
34
+ system cmdline
35
+ end
19
36
  # partial-loads-ok and undef-value-errors necessary to ignore
20
37
  # spurious (and eminently ignorable) warnings from the ruby
21
38
  # interpreter
@@ -52,3 +69,28 @@ namespace :test do
52
69
  end
53
70
  end
54
71
  end
72
+
73
+ desc 'run clang-tidy linter on mini_racer_extension.cc'
74
+ task :lint do
75
+ require 'mkmf'
76
+ require 'libv8'
77
+
78
+ Libv8.configure_makefile
79
+
80
+ conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
81
+ 'arch_hdrdir' => $arch_hdrdir.quote,
82
+ 'top_srcdir' => $top_srcdir.quote)
83
+ if $universal and (arch_flag = conf['ARCH_FLAG']) and !arch_flag.empty?
84
+ conf['ARCH_FLAG'] = arch_flag.gsub(/(?:\G|\s)-arch\s+\S+/, '')
85
+ end
86
+
87
+ checks = %W(bugprone-*
88
+ cert-*
89
+ cppcoreguidelines-*
90
+ clang-analyzer-*
91
+ performance-*
92
+ portability-*
93
+ readability-*).join(',')
94
+
95
+ sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$CPPFLAGS", conf)
96
+ end
@@ -1,16 +1,28 @@
1
1
  require 'mkmf'
2
- require 'libv8'
2
+ require_relative '../../lib/mini_racer/version'
3
+ gem 'libv8-node', MiniRacer::LIBV8_NODE_VERSION
4
+ require 'libv8-node'
5
+
6
+ IS_DARWIN = RUBY_PLATFORM =~ /darwin/
3
7
 
4
8
  have_library('pthread')
5
- have_library('objc') if RUBY_PLATFORM =~ /darwin/
9
+ have_library('objc') if IS_DARWIN
6
10
  $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
7
11
  $CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
8
12
  $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
9
- $CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or RUBY_PLATFORM =~ /darwin/
10
- $CPPFLAGS += " -std=c++0x"
13
+ $CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN
14
+ $CPPFLAGS += " -std=c++14"
11
15
  $CPPFLAGS += " -fpermissive"
16
+ #$CPPFLAGS += " -DV8_COMPRESS_POINTERS"
17
+ $CPPFLAGS += " -fvisibility=hidden "
18
+
19
+ $CPPFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
20
+
21
+ $LDFLAGS.insert(0, " -stdlib=libc++ ") if IS_DARWIN
12
22
 
13
- $LDFLAGS.insert 0, " -stdlib=libstdc++ " if RUBY_PLATFORM =~ /darwin/
23
+ # check for missing symbols at link time
24
+ # $LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
25
+ # $LDFLAGS += " -Wl,-undefined,error " if IS_DARWIN
14
26
 
15
27
  if ENV['CXX']
16
28
  puts "SETTING CXX"
@@ -39,16 +51,21 @@ installing GCC 4.8. See mini_racer's README.md for more information.
39
51
  EOS
40
52
  end
41
53
 
42
- CONFIG['LDSHARED'] = '$(CXX) -shared' unless RUBY_PLATFORM =~ /darwin/
54
+ CONFIG['LDSHARED'] = '$(CXX) -shared' unless IS_DARWIN
43
55
  if CONFIG['warnflags']
44
56
  CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
45
57
  CONFIG['warnflags'].gsub!('-Wimplicit-function-declaration', '')
46
58
  end
47
59
 
48
- if enable_config('debug')
60
+ if enable_config('debug') || enable_config('asan')
49
61
  CONFIG['debugflags'] << ' -ggdb3 -O0'
50
62
  end
51
63
 
52
- Libv8.configure_makefile
64
+ Libv8::Node.configure_makefile
65
+
66
+ if enable_config('asan')
67
+ $CPPFLAGS.insert(0, " -fsanitize=address ")
68
+ $LDFLAGS.insert(0, " -fsanitize=address ")
69
+ end
53
70
 
54
71
  create_makefile 'mini_racer_extension'