Skip to content

Commit 8b7154a

Browse files
committed
Implement proof of concept
0 parents  commit 8b7154a

File tree

19 files changed

+333
-0
lines changed

19 files changed

+333
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/pkg
2+
/src
3+
/vendor
4+
/Gemfile.lock
5+
*.gem
6+
/Makefile

CHANGELOG.md

Whitespace-only changes.

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source "https://rubygems.org"
2+
3+
# Specify your gem's dependencies in libv8.gemspec
4+
gemspec

LICENSE

Whitespace-only changes.

README.md

Whitespace-only changes.

Rakefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
require 'bundler/setup'
2+
3+
Bundler::GemHelper.install_tasks
4+
5+
module Helpers
6+
module_function
7+
8+
def binary_gemspec(platform = Gem::Platform.local)
9+
gemspec = eval(File.read('libv8-node.gemspec'))
10+
gemspec.platform = platform
11+
gemspec
12+
end
13+
14+
def binary_gem_name(platform = Gem::Platform.local)
15+
File.basename(binary_gemspec(platform).cache_file)
16+
end
17+
end
18+
19+
task :compile do
20+
#sh 'ruby ext/libv8-node/extconf.rb'
21+
end
22+
23+
task :binary => :compile do
24+
gemspec = Helpers.binary_gemspec
25+
gemspec.extensions.clear
26+
27+
# We don't need most things for the binary
28+
gemspec.files = []
29+
gemspec.files += ['lib/libv8-node.rb', 'lib/libv8_node.rb', 'lib/libv8_node/version.rb']
30+
gemspec.files += ['ext/libv8-node/location.rb', 'ext/libv8-node/paths.rb']
31+
gemspec.files += ['ext/libv8-node/.location.yml']
32+
33+
# V8
34+
gemspec.files += Dir['vendor/v8/include/**/*.h']
35+
gemspec.files += Dir['vendor/v8/out.gn/**/*.a']
36+
37+
FileUtils.chmod(0o0644, gemspec.files)
38+
FileUtils.mkdir_p('pkg')
39+
40+
package = if Gem::VERSION < '2.0.0'
41+
Gem::Builder.new(gemspec).build
42+
else
43+
require 'rubygems/package'
44+
Gem::Package.build(gemspec)
45+
end
46+
47+
FileUtils.mv(package, 'pkg')
48+
end

build-libv8

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
set -e
4+
set -u
5+
6+
version="${1}"
7+
8+
cd "src/node-${version}"
9+
10+
# taken from
11+
# ./configure
12+
# make
13+
# make -C out BUILDTYPE=Release V=1
14+
15+
python configure.py --openssl-no-asm --without-npm
16+
make BUILDTYPE=Release out/Makefile
17+
make -C out BUILDTYPE=Release V=1 v8
18+
make -C out BUILDTYPE=Release V=1 v8_libbase
19+
make -C out BUILDTYPE=Release V=1 v8_libplatform
20+
make -C out BUILDTYPE=Release V=1 v8_libsampler
21+

build-monolith

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
set -e
4+
set -u
5+
6+
version="${1}"
7+
8+
cd "src/node-${version}"
9+
10+
BASEDIR="${PWD}"
11+
BUILDTYPE="${BUILDTYPE:-Release}"
12+
LIBV8_MONOLITH="libv8_monolith.a"
13+
14+
cd "out/${BUILDTYPE}/obj.target"
15+
16+
platform=$(uname)
17+
18+
rm -vf "${LIBV8_MONOLITH}"
19+
case "${platform}" in
20+
"SunOS")
21+
/usr/xpg4/bin/find . -path "**/v8*/**/*.o" | xargs ar cqs "${LIBV8_MONOLITH}"
22+
/usr/xpg4/bin/find . -path "**/icu*/**/*.o" | xargs ar cqs "${LIBV8_MONOLITH}"
23+
;;
24+
"Darwin")
25+
#/usr/bin/find . -path "**/v8*/**/*.o" | xargs ar -q "${LIBV8_MONOLITH}"
26+
#/usr/bin/find . -path "**/icu*/**/*.o" | xargs ar -q "${LIBV8_MONOLITH}"
27+
/usr/bin/find . -path "**/v8*/**/*.o" -or -path "**/icu*/**/*.o" | sort | uniq | xargs ar -q "${LIBV8_MONOLITH}"
28+
;;
29+
"Linux")
30+
find . -path './deps/v8/gypfiles/*.a' | while read -r lib; do
31+
ar -t "${lib}" | xargs ar -q "${LIBV8_MONOLITH}"
32+
done
33+
find . -path './tools/icu/*.a' | while read -r lib; do
34+
ar -t "${lib}" | xargs ar -q "${LIBV8_MONOLITH}"
35+
done
36+
;;
37+
*)
38+
echo "Unsupported platform: ${platform}"
39+
exit 1
40+
;;
41+
esac
42+
43+
mv -vf "${LIBV8_MONOLITH}" "${BASEDIR}/out/${BUILDTYPE}/${LIBV8_MONOLITH}"

download-node

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
set -e
4+
set -u
5+
6+
version="${1}"
7+
8+
mkdir -p src
9+
10+
curl -L -o "src/node-${version}.tar.gz" "https://github.com/nodejs/node/archive/v${version}.tar.gz"

ext/libv8-node/.location.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--- !ruby/object:Libv8Node::Location::Vendor {}
2+

0 commit comments

Comments
 (0)