sq_mini_racer 0.2.3.sqreen4 → 0.2.4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +12 -0
- data/CHANGELOG +7 -0
- data/Dockerfile +22 -0
- data/LICENSE.txt +8 -1
- data/azure-pipelines.yml +69 -0
- data/azure-template.yml +92 -0
- data/ext/mini_racer_extension/extconf.rb +205 -87
- data/ext/mini_racer_extension/mini_racer_extension.cc +466 -315
- data/ext/mini_racer_extension/simdutf8check.h +463 -0
- data/lib/sqreen/mini_racer.rb +2 -2
- data/lib/sqreen/mini_racer/version.rb +1 -1
- data/mini_racer.gemspec +0 -1
- metadata +13 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb7be23e127c27a87be5d25075c26ec77ba06f19878e69088827077b6fc5844b
|
4
|
+
data.tar.gz: cc1a09e6683d40813f8702cd683b0237aa9717e79f3a93c95870367934a06a5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f854ba80b5702b0620feb0c16126e1b9f4b864a332a1e7b50df15fd4f8af16d49b330cdd296e3fa2b795d7c17857ae66d1705fdf4fd68784288317571120a651
|
7
|
+
data.tar.gz: 457b7ac2ef3b81a9f5f8d6353cf73c588c12af06af085fcfe456afa29b48ba96f324dc7cae173362a410c3009ae2394d30ea130e5785bcb24741378b79a0f851
|
data/.dockerignore
ADDED
data/CHANGELOG
CHANGED
data/Dockerfile
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
+
|
12
|
+
COPY Gemfile mini_racer.gemspec /code/
|
13
|
+
COPY lib/sqreen/mini_racer/version.rb /code/lib/sqreen/mini_racer/version.rb
|
14
|
+
WORKDIR /code
|
15
|
+
RUN bundle install
|
16
|
+
|
17
|
+
COPY Rakefile /code/
|
18
|
+
COPY ext /code/ext/
|
19
|
+
RUN bundle exec rake compile
|
20
|
+
|
21
|
+
COPY . /code/
|
22
|
+
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
|
3
|
+
Copyright (c) 2016-2019 The contributors
|
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
|
@@ -19,3 +19,10 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
THE SOFTWARE.
|
22
|
+
|
23
|
+
|
24
|
+
The file ext/mini_racer_extension/simdutf8check.h is a slighly modified file
|
25
|
+
from https://github.com/lemire/fastvalidate-utf-8, which is licensed under the
|
26
|
+
Apache 2.0 license. For more details, see:
|
27
|
+
|
28
|
+
https://github.com/lemire/fastvalidate-utf-8/blob/0f04b4068288711b72f1c3c730a8fb2d1b4cdd00/LICENSE
|
data/azure-pipelines.yml
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
jobs:
|
2
|
+
- template: azure-template.yml
|
3
|
+
parameters:
|
4
|
+
name: linux_2_0
|
5
|
+
displayName: Linux Ruby 2.0
|
6
|
+
rubyVersion: '2.0'
|
7
|
+
publishCoverage: true
|
8
|
+
|
9
|
+
- template: azure-template.yml
|
10
|
+
parameters:
|
11
|
+
name: linux_2_1
|
12
|
+
displayName: Linux Ruby 2.1
|
13
|
+
rubyVersion: '2.1'
|
14
|
+
|
15
|
+
- template: azure-template.yml
|
16
|
+
parameters:
|
17
|
+
name: linux_2_2
|
18
|
+
displayName: Linux Ruby 2.2
|
19
|
+
rubyVersion: '2.2'
|
20
|
+
|
21
|
+
- template: azure-template.yml
|
22
|
+
parameters:
|
23
|
+
name: linux_2_3
|
24
|
+
displayName: Linux Ruby 2.3
|
25
|
+
rubyVersion: '2.3'
|
26
|
+
|
27
|
+
- template: azure-template.yml
|
28
|
+
parameters:
|
29
|
+
name: linux_2_4
|
30
|
+
displayName: Linux Ruby 2.4
|
31
|
+
rubyVersion: '2.4'
|
32
|
+
|
33
|
+
- template: azure-template.yml
|
34
|
+
parameters:
|
35
|
+
name: linux_2_5
|
36
|
+
displayName: Linux Ruby 2.5
|
37
|
+
rubyVersion: '2.5'
|
38
|
+
|
39
|
+
- template: azure-template.yml
|
40
|
+
parameters:
|
41
|
+
name: linux_2_6
|
42
|
+
displayName: Linux Ruby 2.6
|
43
|
+
rubyVersion: '2.6'
|
44
|
+
|
45
|
+
- template: azure-template.yml
|
46
|
+
parameters:
|
47
|
+
name: linux_2_7
|
48
|
+
displayName: Linux Ruby 2.7
|
49
|
+
rubyVersion: '2.7'
|
50
|
+
|
51
|
+
- template: azure-template.yml
|
52
|
+
parameters:
|
53
|
+
name: linux_2_7_mini_racer
|
54
|
+
displayName: Linux Ruby 2.7 (with mini_racer)
|
55
|
+
rubyVersion: '2.7'
|
56
|
+
with_mini_racer: true
|
57
|
+
|
58
|
+
- template: azure-template.yml
|
59
|
+
parameters:
|
60
|
+
name: linux_2_7_therubyracer
|
61
|
+
displayName: Linux Ruby 2.7 (with therubyracer)
|
62
|
+
rubyVersion: '2.7'
|
63
|
+
with_therubyracer: true
|
64
|
+
|
65
|
+
- template: azure-template.yml
|
66
|
+
parameters:
|
67
|
+
name: macos_10_15
|
68
|
+
displayName: MacOS 10.15
|
69
|
+
imageName: 'macos-10.15'
|
data/azure-template.yml
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
parameters:
|
2
|
+
name: ~
|
3
|
+
displayName: ~
|
4
|
+
rubyVersion: bundled
|
5
|
+
imageName: ubuntu-18.04
|
6
|
+
publishCoverage: false
|
7
|
+
with_mini_racer: false
|
8
|
+
with_therubyracer: false
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
- job: ${{ parameters.name }}
|
12
|
+
displayName: ${{ parameters.displayName }}
|
13
|
+
pool:
|
14
|
+
vmImage: ${{ parameters.imageName }}
|
15
|
+
|
16
|
+
variables:
|
17
|
+
TESTOPTS: -v
|
18
|
+
${{ if eq(parameters.publishCoverage, true) }}:
|
19
|
+
CPPFLAGS: --coverage
|
20
|
+
LDFLAGS: --coverage
|
21
|
+
${{ if eq(parameters.rubyVersion, 'bundled') }}:
|
22
|
+
gem: gem
|
23
|
+
bundle: bundle
|
24
|
+
${{ if ne(parameters.rubyVersion, 'bundled') }}:
|
25
|
+
gem: /opt/ruby/${{ parameters.rubyVersion }}/bin/gem
|
26
|
+
bundle: /opt/ruby/${{ parameters.rubyVersion }}/bin/bundle
|
27
|
+
GEM_HOME: /opt/ruby/${{ parameters.rubyVersion }}/lib/ruby/gems/${{ parameters.rubyVersion }}.0
|
28
|
+
|
29
|
+
steps:
|
30
|
+
- checkout: self
|
31
|
+
displayName: Checkout
|
32
|
+
clean: true
|
33
|
+
submodules: recursive
|
34
|
+
|
35
|
+
- ${{ if ne(parameters.rubyVersion, 'bundled') }}:
|
36
|
+
- script: |
|
37
|
+
sudo apt-get install -y gnupg
|
38
|
+
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 5D98E7264E3F3D89463B314B12229434A9F003C9
|
39
|
+
echo deb [arch=amd64] http://sqreen-download-private.s3.amazonaws.com/deb bionic main | sudo tee -a /etc/apt/sources.list
|
40
|
+
sudo apt-get update
|
41
|
+
sudo apt-get install -y sq-ruby${{ parameters.rubyVersion }} ruby-
|
42
|
+
displayName: Install Ruby
|
43
|
+
|
44
|
+
- ${{ if eq(parameters.rubyVersion, 'bundled') }}:
|
45
|
+
- script: sudo $(gem) install bundler --version '< 2.0' --no-document
|
46
|
+
displayName: Install bundler
|
47
|
+
|
48
|
+
- ${{ if eq(parameters.imageName, 'ubuntu-18.04') }}:
|
49
|
+
- script: |
|
50
|
+
sudo apt-get install -y build-essential git curl valgrind g++ make
|
51
|
+
displayName: Install Linux packages
|
52
|
+
|
53
|
+
- script: $(bundle) install --path vendor/bundle
|
54
|
+
displayName: Install gem dependencies
|
55
|
+
env:
|
56
|
+
${{ if eq(parameters.with_mini_racer, true) }}:
|
57
|
+
LOAD_MINI_RACER: 1
|
58
|
+
${{ if eq(parameters.with_therubyracer, true) }}:
|
59
|
+
LOAD_THERUBYRACER: 1
|
60
|
+
|
61
|
+
- script: PATH=`dirname $(bundle)`:$PATH CPPFLAGS=$(CPPFLAGS) LDFLAGS=$(LDFLAGS) $(bundle) exec rake compile
|
62
|
+
displayName: Compile extension
|
63
|
+
|
64
|
+
- script: |
|
65
|
+
find . -name '*.log' -exec cat '{}' \;
|
66
|
+
displayName: Print logs
|
67
|
+
condition: failed()
|
68
|
+
|
69
|
+
- script: $(bundle) exec rake test
|
70
|
+
displayName: Run tests
|
71
|
+
env:
|
72
|
+
${{ if eq(parameters.with_mini_racer, true) }}:
|
73
|
+
LOAD_MINI_RACER: 1
|
74
|
+
${{ if eq(parameters.with_therubyracer, true) }}:
|
75
|
+
LOAD_THERUBYRACER: 1
|
76
|
+
|
77
|
+
- ${{ if and(eq(parameters.imageName, 'ubuntu-18.04'), eq(parameters.with_mini_racer, false), eq(parameters.with_therubyracer, false)) }}:
|
78
|
+
- script: $(bundle) exec rake test:valgrind
|
79
|
+
displayName: Run tests w/ valgrind
|
80
|
+
|
81
|
+
- script: |
|
82
|
+
PATH=$PATH:$(dirname $(which $(gem)))
|
83
|
+
$(bundle) exec rake build
|
84
|
+
sudo PATH=$PATH $(gem) install pkg/*.gem
|
85
|
+
displayName: Check that the gem is installable
|
86
|
+
|
87
|
+
- ${{ if eq(parameters.publishCoverage, true) }}:
|
88
|
+
- bash: >
|
89
|
+
test -z "$CODECOV_TOKEN" || bash <(curl -s https://codecov.io/bash)
|
90
|
+
displayName: "Publish coverage (Codecov)"
|
91
|
+
env:
|
92
|
+
CODECOV_TOKEN: $(CODECOV_TOKEN)
|
@@ -1,23 +1,220 @@
|
|
1
1
|
require 'mkmf'
|
2
|
+
|
2
3
|
require 'fileutils'
|
4
|
+
require 'net/http'
|
5
|
+
require 'json'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rubygems/package'
|
3
8
|
|
4
|
-
IS_DARWIN = RUBY_PLATFORM =~ /darwin/
|
5
9
|
IS_SOLARIS = RUBY_PLATFORM =~ /solaris/
|
10
|
+
IS_LINUX_MUSL = RUBY_PLATFORM =~ /linux-musl/
|
11
|
+
|
12
|
+
def cppflags_clear_std!
|
13
|
+
$CPPFLAGS.gsub! /-std=[^\s]+/, ''
|
14
|
+
end
|
15
|
+
|
16
|
+
def cppflags_add_frame_pointer!
|
17
|
+
$CPPFLAGS += " -fno-omit-frame-pointer"
|
18
|
+
end
|
19
|
+
|
20
|
+
def cppflags_add_cpu_extension!
|
21
|
+
if enable_config('avx2')
|
22
|
+
$CPPFLAGS += " -mavx2"
|
23
|
+
else
|
24
|
+
$CPPFLAGS += " -mssse3"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def libv8_gem_name
|
29
|
+
#return "libv8-solaris" if IS_SOLARIS
|
30
|
+
#return "libv8-alpine" if IS_LINUX_MUSL
|
31
|
+
|
32
|
+
'libv8-node'
|
33
|
+
end
|
34
|
+
|
35
|
+
def libv8_requirement
|
36
|
+
'~> 10.22.1.0.beta1'
|
37
|
+
end
|
38
|
+
|
39
|
+
def libv8_basename(version)
|
40
|
+
"#{libv8_gem_name}-#{version}-#{ruby_platform}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def libv8_gemspec(version)
|
44
|
+
"#{libv8_basename(version)}.gemspec"
|
45
|
+
end
|
46
|
+
|
47
|
+
def libv8_local_path(path=Gem.path)
|
48
|
+
name_glob = "#{libv8_gem_name}-*-#{ruby_platform}"
|
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
|
62
|
+
|
63
|
+
unless found_path && found_spec
|
64
|
+
puts "not found in specs: no '#{libv8_requirement}' in #{paths.inspect}"
|
65
|
+
return
|
66
|
+
end
|
67
|
+
|
68
|
+
puts "found in specs: #{found_path}"
|
69
|
+
|
70
|
+
gemdir = File.basename(found_path, '.gemspec')
|
71
|
+
dir = File.expand_path(File.join(found_path, '..', '..', 'gems', gemdir))
|
72
|
+
|
73
|
+
unless Dir.exist?(dir)
|
74
|
+
puts "not found in gems: #{dir}"
|
75
|
+
return
|
76
|
+
end
|
77
|
+
|
78
|
+
puts "found in gems: #{dir}"
|
79
|
+
|
80
|
+
[dir, found_spec]
|
81
|
+
end
|
82
|
+
|
83
|
+
def vendor_path
|
84
|
+
File.join(Dir.pwd, 'vendor')
|
85
|
+
end
|
86
|
+
|
87
|
+
def libv8_vendor_path
|
88
|
+
libv8_local_path([vendor_path])
|
89
|
+
end
|
90
|
+
|
91
|
+
def parse_platform(str)
|
92
|
+
Gem::Platform.new(str).tap do |p|
|
93
|
+
p.instance_eval { @version = 'musl' } if str =~ /-musl/ && p.version.nil?
|
94
|
+
p.instance_eval { @cpu = 'x86_64' } if str =~ /universal.*darwin/
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def ruby_platform
|
99
|
+
parse_platform(RUBY_PLATFORM)
|
100
|
+
end
|
101
|
+
|
102
|
+
def http_get(uri)
|
103
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
104
|
+
res = http.get(uri.path)
|
105
|
+
|
106
|
+
abort("HTTP error #{res.code}: #{uri}") unless res.code == '200'
|
107
|
+
|
108
|
+
return res.body
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def libv8_remote_search
|
113
|
+
body = http_get(URI("https://rubygems.org/api/v1/versions/#{libv8_gem_name}.json"))
|
114
|
+
json = JSON.parse(body)
|
115
|
+
|
116
|
+
versions = json.select do |v|
|
117
|
+
Gem::Requirement.new(libv8_requirement).satisfied_by?(Gem::Version.new(v['number']))
|
118
|
+
end
|
119
|
+
abort(<<-ERROR) if versions.empty?
|
120
|
+
ERROR: could not find #{libv8_gem_name} (requirement #{libv8_requirement}) in rubygems.org
|
121
|
+
ERROR
|
122
|
+
|
123
|
+
platform_versions = versions.select do |v|
|
124
|
+
parse_platform(v['platform']) == ruby_platform unless v['platform'] =~ /universal.*darwin/
|
125
|
+
end
|
126
|
+
abort(<<-ERROR) if platform_versions.empty?
|
127
|
+
ERROR: found gems matching #{libv8_gem_name}:'#{libv8_requirement}', but no binary for #{ruby_platform}
|
128
|
+
try "gem install #{libv8_gem_name}:'#{libv8_requirement}'" to attempt to build #{libv8_gem_name} from source
|
129
|
+
ERROR
|
130
|
+
|
131
|
+
puts "found #{libv8_gem_name} for #{ruby_platform} on rubygems: #{platform_versions.map { |v| v['number'] }.join(', ')}"
|
132
|
+
|
133
|
+
platform_versions.sort_by { |v| Gem::Version.new(v['number']) }.last
|
134
|
+
end
|
135
|
+
|
136
|
+
def libv8_download_uri(name, version, platform)
|
137
|
+
URI("https://rubygems.org/downloads/#{name}-#{version}-#{platform}.gem")
|
138
|
+
end
|
139
|
+
|
140
|
+
def libv8_downloaded_gem(name, version, platform)
|
141
|
+
"#{name}-#{version}-#{platform}.gem"
|
142
|
+
end
|
143
|
+
|
144
|
+
def libv8_download(name, version, platform)
|
145
|
+
FileUtils.mkdir_p(File.join(vendor_path, 'cache'))
|
146
|
+
body = http_get(libv8_download_uri(name, version, platform))
|
147
|
+
File.open(File.join(vendor_path, 'cache', libv8_downloaded_gem(name, version, platform)), 'wb') { |f| f.write(body) }
|
148
|
+
end
|
149
|
+
|
150
|
+
def libv8_install!
|
151
|
+
cmd = "gem install #{libv8_gem_name} --version '#{libv8_requirement}' --install-dir '#{vendor_path}'"
|
152
|
+
puts "installing #{libv8_gem_name} using `#{cmd}`"
|
153
|
+
rc = system(cmd)
|
154
|
+
|
155
|
+
abort(<<-ERROR) unless rc
|
156
|
+
ERROR: could not install #{libv8_gem_name}:#{libv8_requirement}
|
157
|
+
try "gem install #{libv8_gem_name} -v '#{libv8_requirement}'" to attempt to build libv8 from source
|
158
|
+
ERROR
|
159
|
+
|
160
|
+
libv8_local_path([vendor_path])
|
161
|
+
end
|
162
|
+
|
163
|
+
def libv8_vendor!
|
164
|
+
return libv8_install! if Gem::VERSION < '2.0'
|
165
|
+
|
166
|
+
version = libv8_remote_search
|
167
|
+
|
168
|
+
puts "downloading #{libv8_downloaded_gem(libv8_gem_name, version['number'], version['platform'])} to #{vendor_path}"
|
169
|
+
libv8_download(libv8_gem_name, version['number'], version['platform'])
|
170
|
+
|
171
|
+
package = Gem::Package.new(File.join(vendor_path, 'cache', libv8_downloaded_gem(libv8_gem_name, version['number'], version['platform'])))
|
172
|
+
package.extract_files(File.join(vendor_path, 'gems', File.basename(libv8_downloaded_gem(libv8_gem_name, version['number'], version['platform']), '.gem')))
|
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) }
|
175
|
+
|
176
|
+
libv8_vendor_path
|
177
|
+
end
|
178
|
+
|
179
|
+
def ensure_libv8_load_path
|
180
|
+
puts "platform ruby:#{RUBY_PLATFORM} rubygems:#{Gem::Platform.new(RUBY_PLATFORM)} detected:#{ruby_platform}"
|
181
|
+
|
182
|
+
libv8_path, spec = libv8_local_path
|
183
|
+
if !ENV['ONLY_INSTALLED_LIBV8_GEM'] && !libv8_path
|
184
|
+
libv8_path, spec = libv8_vendor_path || libv8_vendor!
|
185
|
+
end
|
186
|
+
|
187
|
+
abort(<<-ERROR) unless libv8_path
|
188
|
+
ERROR: could not find #{libv8_gem_name}
|
189
|
+
ERROR
|
190
|
+
|
191
|
+
$LOAD_PATH.unshift(File.join(libv8_path, 'ext'))
|
192
|
+
$LOAD_PATH.unshift(File.join(libv8_path, 'lib'))
|
193
|
+
end
|
194
|
+
|
195
|
+
ensure_libv8_load_path
|
196
|
+
|
197
|
+
require 'libv8-node'
|
198
|
+
|
199
|
+
IS_DARWIN = RUBY_PLATFORM =~ /darwin/
|
6
200
|
|
7
201
|
have_library('pthread')
|
8
202
|
have_library('objc') if IS_DARWIN
|
9
|
-
|
203
|
+
cppflags_clear_std!
|
10
204
|
$CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
|
11
205
|
$CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
|
12
206
|
$CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
|
13
207
|
$CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN
|
14
208
|
$CPPFLAGS += " -std=c++0x"
|
15
209
|
$CPPFLAGS += " -fpermissive"
|
16
|
-
|
210
|
+
cppflags_add_frame_pointer!
|
211
|
+
cppflags_add_cpu_extension!
|
17
212
|
|
18
213
|
$CPPFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
|
19
214
|
|
20
215
|
$LDFLAGS.insert(0, " -stdlib=libc++ ") if IS_DARWIN
|
216
|
+
$LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
|
217
|
+
$LDFLAGS += " -Wl,-undefined,error " if IS_DARWIN
|
21
218
|
|
22
219
|
if ENV['CXX']
|
23
220
|
puts "SETTING CXX"
|
@@ -52,94 +249,15 @@ if CONFIG['warnflags']
|
|
52
249
|
CONFIG['warnflags'].gsub!('-Wimplicit-function-declaration', '')
|
53
250
|
end
|
54
251
|
|
55
|
-
if enable_config('debug')
|
252
|
+
if enable_config('debug') || enable_config('asan')
|
56
253
|
CONFIG['debugflags'] << ' -ggdb3 -O0'
|
57
254
|
end
|
58
255
|
|
59
|
-
|
60
|
-
dirs = %w[/lib64 /usr/lib64 /lib /usr/lib]
|
61
|
-
found_v5 = dirs.map { |d| "#{d}/libtinfo.so.5" }.find &File.method(:file?)
|
62
|
-
return '' if found_v5
|
63
|
-
found_v6 = dirs.map { |d| "#{d}/libtinfo.so.6" }.find &File.method(:file?)
|
64
|
-
return '' unless found_v6
|
65
|
-
FileUtils.ln_s found_v6, 'gemdir/libtinfo.so.5', :force => true
|
66
|
-
"LD_LIBRARY_PATH='#{File.expand_path('gemdir')}:#{ENV['LD_LIBRARY_PATH']}'"
|
67
|
-
end
|
68
|
-
|
69
|
-
def libv8_gem_name
|
70
|
-
return "libv8-solaris" if IS_SOLARIS
|
71
|
-
|
72
|
-
is_musl = false
|
73
|
-
begin
|
74
|
-
is_musl = !!(File.read('/proc/self/maps') =~ /ld-musl-x86_64/)
|
75
|
-
rescue; end
|
76
|
-
|
77
|
-
is_musl ? 'libv8-alpine' : 'libv8'
|
78
|
-
end
|
79
|
-
|
80
|
-
# old rubygem versions prefer source gems to binary ones
|
81
|
-
# ... and their --platform switch is broken too, as it leaves the 'ruby'
|
82
|
-
# platform in Gem.platforms.
|
83
|
-
def force_platform_gem
|
84
|
-
gem_version = `gem --version`
|
85
|
-
return 'gem' unless $?.success?
|
86
|
-
|
87
|
-
return 'gem' if gem_version.to_f.zero? || gem_version.to_f >= 2.3
|
88
|
-
return 'gem' if RUBY_PLATFORM != 'x86_64-linux'
|
89
|
-
|
90
|
-
gem_binary = `which gem`
|
91
|
-
return 'gem' unless $?.success?
|
92
|
-
|
93
|
-
ruby = File.foreach(gem_binary.strip).first.sub(/^#!/, '').strip
|
94
|
-
unless File.file? ruby
|
95
|
-
warn "No valid ruby: #{ruby}"
|
96
|
-
return 'gem'
|
97
|
-
end
|
98
|
-
|
99
|
-
require 'tempfile'
|
100
|
-
file = Tempfile.new('sq_mini_racer')
|
101
|
-
file << <<EOS
|
102
|
-
require 'rubygems'
|
103
|
-
Gem.platforms.reject! { |it| it == 'ruby' }
|
104
|
-
#{IO.read(gem_binary.strip)}
|
105
|
-
EOS
|
106
|
-
file.close
|
107
|
-
"#{ruby} '#{file.path}'"
|
108
|
-
end
|
109
|
-
|
110
|
-
LIBV8_VERSION = '6.7.288.46.1'
|
111
|
-
libv8_rb = Dir.glob('**/libv8.rb').first
|
112
|
-
FileUtils.mkdir_p('gemdir')
|
113
|
-
unless libv8_rb
|
114
|
-
gem_name = libv8_gem_name
|
115
|
-
cmd = "#{fixup_libtinfo} #{force_platform_gem} install --version '= #{LIBV8_VERSION}' --install-dir gemdir #{gem_name}"
|
116
|
-
puts "Will try downloading #{gem_name} gem: #{cmd}"
|
117
|
-
`#{cmd}`
|
118
|
-
unless $?.success?
|
119
|
-
warn <<EOS
|
120
|
-
|
121
|
-
WARNING: Could not download a private copy of the libv8 gem. Please make
|
122
|
-
sure that you have internet access and that the `gem` binary is available.
|
123
|
-
|
124
|
-
EOS
|
125
|
-
end
|
126
|
-
|
127
|
-
libv8_rb = Dir.glob('**/libv8.rb').first
|
128
|
-
unless libv8_rb
|
129
|
-
warn <<EOS
|
130
|
-
|
131
|
-
WARNING: Could not find libv8 after the local copy of libv8 having supposedly
|
132
|
-
been installed.
|
133
|
-
|
134
|
-
EOS
|
135
|
-
end
|
136
|
-
end
|
256
|
+
Libv8::Node.configure_makefile
|
137
257
|
|
138
|
-
if
|
139
|
-
|
140
|
-
|
258
|
+
if enable_config('asan')
|
259
|
+
$CPPFLAGS.insert(0, " -fsanitize=address ")
|
260
|
+
$LDFLAGS.insert(0, " -fsanitize=address ")
|
141
261
|
end
|
142
262
|
|
143
|
-
require 'libv8'
|
144
|
-
Libv8.configure_makefile
|
145
263
|
create_makefile 'sq_mini_racer_extension'
|