Skip to content

Commit f7682d9

Browse files
committed
Improve local building
- Add make targets for local building and testing This is especially useful for building and testing on Darwin - Split makefile in two: one direct and one for docker This is necessary because direct targets and dockerized targets overlap on Linux. - Fix a few Dockerfile oversights due to updates in libexec
1 parent b6f6a16 commit f7682d9

File tree

4 files changed

+101
-31
lines changed

4 files changed

+101
-31
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Makefile
77
/ext/libv8-node/.location.yml
88
/test/mini_racer
9+
/test/bundle
910
*.nix
1011
*.vim
1112
.envrc

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ WORKDIR /code
88

99
ARG NODE_VERSION=17.3.1
1010

11+
COPY sums/v${NODE_VERSION}.sum /code/sums/
1112
COPY libexec/download-node /code/libexec/
1213
RUN ./libexec/download-node ${NODE_VERSION}
1314
COPY libexec/extract-node /code/libexec/
1415
COPY patch/* /code/patch/
1516
RUN ./libexec/extract-node ${NODE_VERSION}
17+
COPY libexec/platform /code/libexec/
1618
COPY libexec/build-libv8 /code/libexec/
1719
RUN ./libexec/build-libv8 ${NODE_VERSION}
1820
COPY libexec/build-monolith /code/libexec/

Makefile

+33-31
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
11
PWD := $(shell pwd)
2+
OS := $(shell uname -s | tr '[A-Z]' '[a-z]')
3+
CPU := $(shell uname -m)
24
VERSION := $(shell ./libexec/metadata version)
35
NODE_VERSION := $(shell ./libexec/metadata node_version)
6+
RUBY_VERSION = $(shell ruby -e 'puts RUBY_VERSION.gsub(/\d+$$/, "0")')
47

5-
all:
8+
vars:
9+
@echo $(PWD)
10+
@echo $(OS) $(CPU)
11+
@echo $(VERSION) $(NODE_VERSION)
12+
@echo $(RUBY_VERSION)
613

7-
pkg/libv8-node-$(VERSION)-x86_64-linux.gem:
8-
docker build --platform linux/amd64 --build-arg RUBY_VERSION=2.4 --progress plain -t libv8-node:gnu .
9-
docker run --platform linux/amd64 --rm -it -v "$(PWD)/pkg":/pkg libv8-node:gnu cp $@ /pkg/
14+
all: gem test
1015

11-
pkg/libv8-node-$(VERSION)-x86_64-linux-musl.gem:
12-
docker build --platform linux/amd64 --build-arg RUBY_VERSION=2.4-alpine --progress plain -t libv8-node:musl .
13-
docker run --platform linux/amd64 --rm -it -v "$(PWD)/pkg":/pkg libv8-node:musl cp $@ /pkg/
16+
build: src/node-v$(NODE_VERSION)/out/Release/node
1417

15-
pkg/libv8-node-$(VERSION)-aarch64-linux.gem:
16-
docker build --platform linux/arm64 --build-arg RUBY_VERSION=2.4 --progress plain -t libv8-node:gnu .
17-
docker run --platform linux/arm64 --rm -it -v "$(PWD)/pkg":/pkg libv8-node:gnu cp $@ /pkg/
18+
lib: src/node-v$(NODE_VERSION)/out/Release/libv8_monolith.a
1819

19-
pkg/libv8-node-$(VERSION)-aarch64-linux-musl.gem:
20-
docker build --platform linux/arm64 --build-arg RUBY_VERSION=2.4-alpine --progress plain -t libv8-node:musl .
21-
docker run --platform linux/arm64 --rm -it -v "$(PWD)/pkg":/pkg libv8-node:musl cp $@ /pkg/
20+
gem: pkg/libv8-node-$(VERSION)-$(CPU)-$(OS).gem
2221

23-
test/x86_64-linux: pkg/libv8-node-$(VERSION)-x86_64-linux.gem
24-
test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
25-
cd test/mini_racer && git fetch origin refs/pull/186/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
26-
ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb
27-
docker run --platform linux/amd64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:gnu sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test'
22+
test: test/$(CPU)-$(OS)
2823

29-
test/x86_64-linux-musl: pkg/libv8-node-$(VERSION)-x86_64-linux-musl.gem
30-
test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
31-
cd test/mini_racer && git fetch origin refs/pull/186/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
32-
ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb
33-
docker run --platform linux/amd64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:musl sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test'
24+
src/node-v$(NODE_VERSION).tar.gz:
25+
./libexec/download-node $(NODE_VERSION)
3426

35-
test/aarch64-linux: pkg/libv8-node-$(VERSION)-aarch64-linux.gem
36-
test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
37-
cd test/mini_racer && git fetch origin refs/pull/186/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
38-
ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb
39-
docker run --platform linux/arm64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:gnu sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test'
27+
src/node-v$(NODE_VERSION): src/node-v$(NODE_VERSION).tar.gz
28+
./libexec/extract-node $(NODE_VERSION)
29+
30+
src/node-v$(NODE_VERSION)/out/Release/node: src/node-v$(NODE_VERSION)
31+
./libexec/build-libv8 $(NODE_VERSION)
32+
33+
src/node-v$(NODE_VERSION)/out/Release/libv8_monolith.a: src/node-v$(NODE_VERSION)/out/Release/node
34+
./libexec/build-monolith $(NODE_VERSION)
35+
36+
vendor/v8: src/node-v$(NODE_VERSION)/out/Release/libv8_monolith.a
37+
./libexec/inject-libv8 $(NODE_VERSION)
38+
39+
pkg/libv8-node-$(VERSION)-$(CPU)-$(OS).gem: vendor/v8
40+
bundle exec rake binary
4041

41-
test/aarch64-linux-musl: pkg/libv8-node-$(VERSION)-aarch64-linux-musl.gem
42+
test/$(CPU)-$(OS): pkg/libv8-node-$(VERSION)-$(CPU)-$(OS).gem
4243
test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
43-
cd test/mini_racer && git fetch origin refs/pull/186/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
44+
cd test/mini_racer && git fetch origin refs/pull/232/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
4445
ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb
45-
docker run --platform linux/arm64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:musl sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test'
46+
ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec
47+
cd test/mini_racer && env TOP="$(PWD)" GEM_HOME="$(PWD)/test/bundle/ruby/$(RUBY_VERSION)" BUNDLE_PATH="$(PWD)/test/bundle" sh -c 'rm -rf "$${GEM_HOME}" && gem install $${TOP}/$< && bundle install && bundle exec rake compile && bundle exec rake test'

Makefile.docker

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
PWD := $(shell pwd)
2+
OS := $(shell uname -s | tr '[A-Z]' '[a-z]')
3+
CPU := $(shell uname -m)
4+
VERSION := $(shell ./libexec/metadata version)
5+
NODE_VERSION := $(shell ./libexec/metadata node_version)
6+
RUBY_VERSION = $(shell ruby -e 'puts RUBY_VERSION.gsub(/\d+$$/, "0")')
7+
8+
vars:
9+
@echo $(PWD)
10+
@echo $(OS) $(CPU)
11+
@echo $(VERSION) $(NODE_VERSION)
12+
@echo $(RUBY_VERSION)
13+
14+
all: gem test
15+
16+
gem: pkg/libv8-node-$(VERSION)-$(CPU)-$(OS).gem
17+
18+
test: test/$(CPU)-$(OS)
19+
20+
test/linux: test/$(CPU)-linux
21+
test/linux-musl: test/$(CPU)-linux-musl
22+
23+
pkg/libv8-node-$(VERSION)-x86_64-linux.gem:
24+
docker build --platform linux/amd64 --build-arg RUBY_VERSION=2.4 --build-arg NODE_VERSION=$(NODE_VERSION) --progress plain -t libv8-node:$(VERSION)-gnu .
25+
docker run --platform linux/amd64 --rm -it -v "$(PWD)/pkg":/pkg libv8-node:$(VERSION)-gnu cp $@ /pkg/
26+
27+
pkg/libv8-node-$(VERSION)-x86_64-linux-musl.gem:
28+
docker build --platform linux/amd64 --build-arg RUBY_VERSION=2.4-alpine --build-arg NODE_VERSION=$(NODE_VERSION) --progress plain -t libv8-node:$(VERSION)-musl .
29+
docker run --platform linux/amd64 --rm -it -v "$(PWD)/pkg":/pkg libv8-node:$(VERSION)-musl cp $@ /pkg/
30+
31+
pkg/libv8-node-$(VERSION)-aarch64-linux.gem:
32+
docker build --platform linux/arm64 --build-arg RUBY_VERSION=2.4 --build-arg NODE_VERSION=$(NODE_VERSION) --progress plain -t libv8-node:$(VERSION)-gnu .
33+
docker run --platform linux/arm64 --rm -it -v "$(PWD)/pkg":/pkg libv8-node:$(VERSION)-gnu cp $@ /pkg/
34+
35+
pkg/libv8-node-$(VERSION)-aarch64-linux-musl.gem:
36+
docker build --platform linux/arm64 --build-arg RUBY_VERSION=2.4-alpine --build-arg NODE_VERSION=$(NODE_VERSION) --progress plain -t libv8-node:$(VERSION)-musl .
37+
docker run --platform linux/arm64 --rm -it -v "$(PWD)/pkg":/pkg libv8-node:$(VERSION)-musl cp $@ /pkg/
38+
39+
test/x86_64-linux: pkg/libv8-node-$(VERSION)-x86_64-linux.gem
40+
test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
41+
cd test/mini_racer && git fetch origin refs/pull/232/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
42+
ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb
43+
ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec
44+
docker run --platform linux/amd64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:$(VERSION)-gnu sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test'
45+
46+
test/x86_64-linux-musl: pkg/libv8-node-$(VERSION)-x86_64-linux-musl.gem
47+
test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
48+
cd test/mini_racer && git fetch origin refs/pull/232/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
49+
ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb
50+
ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec
51+
docker run --platform linux/amd64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:$(VERSION)-musl sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test'
52+
53+
test/aarch64-linux: pkg/libv8-node-$(VERSION)-aarch64-linux.gem
54+
test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
55+
cd test/mini_racer && git fetch origin refs/pull/232/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
56+
ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb
57+
ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec
58+
docker run --platform linux/arm64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:$(VERSION)-gnu sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test'
59+
60+
test/aarch64-linux-musl: pkg/libv8-node-$(VERSION)-aarch64-linux-musl.gem
61+
test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1
62+
cd test/mini_racer && git fetch origin refs/pull/232/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x
63+
ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb
64+
ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec
65+
docker run --platform linux/arm64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:$(VERSION)-musl sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test'

0 commit comments

Comments
 (0)