|
1 | | -test-all: test-debug test-release |
2 | | - |
3 | | -test-debug: build-debug |
4 | | - ./test.js ./build/Debug/ruby_parser.node |
5 | | - |
6 | | -test-release: build-release |
7 | | - ./test.js ./build/Release/ruby_parser.node |
8 | | - |
9 | | -build-debug: build-deps configure |
10 | | - node-gyp build -d |
11 | | - |
12 | | -build-release: build-deps configure |
13 | | - node-gyp build |
| 1 | +UNAME_S := $(shell uname -s) |
| 2 | +ifeq ($(UNAME_S),Linux) |
| 3 | + PLATFORM = linux-x86_64 |
| 4 | +endif |
| 5 | +ifeq ($(UNAME_S),Darwin) |
| 6 | + PLATFORM = darwin-x86_64 |
| 7 | +endif |
| 8 | + |
| 9 | +VERSION = 3.0.0-3 |
| 10 | + |
| 11 | +ifndef BUILD_ENV |
| 12 | + BUILD_ENV = debug |
| 13 | +endif |
| 14 | + |
| 15 | +ifeq ($(BUILD_ENV), debug) |
| 16 | + NODE_GYP_FLAGS = -d |
| 17 | + GYP_ENV = Debug |
| 18 | +else |
| 19 | + NODE_GYP_FLAGS = |
| 20 | + GYP_ENV = Release |
| 21 | +endif |
| 22 | + |
| 23 | +ASSET_PREFIX = https://github.com/lib-ruby-parser/cpp-bindings/releases/download/v$(VERSION) |
| 24 | +LIB_RUBY_PARSER_H_URL = $(ASSET_PREFIX)/lib-ruby-parser.h |
| 25 | +LIB_RUBY_PARSER_A_URL = $(ASSET_PREFIX)/$(PLATFORM).a |
14 | 26 |
|
15 | 27 | configure: |
16 | 28 | node-gyp configure |
17 | 29 |
|
18 | | -build-deps: run-build-convert build-cpp-bindings-shared |
19 | | - |
20 | | -run-build-convert: |
| 30 | +generate-bindings: |
21 | 31 | cd build-convert && cargo build |
22 | 32 |
|
23 | | -build-cpp-bindings-shared: |
24 | | - cd lib-ruby-parser-cpp-bindings && make cargo-build-release |
| 33 | +.PHONY: build |
| 34 | +build: |
| 35 | + node-gyp build $(NODE_GYP_FLAGS) |
| 36 | + |
| 37 | +GYP_OUTPUT = ./build/$(GYP_ENV)/ruby_parser.node |
| 38 | +test: |
| 39 | + ./test.js $(GYP_OUTPUT) |
25 | 40 |
|
26 | 41 | clean: |
27 | | - rm -rf build |
28 | | - rm -rf node_modules |
| 42 | + rm -f $(GYP_OUTPUT) |
29 | 43 | rm -f convert_gen.h |
30 | | - rm -rf lib-ruby-parser-cpp-bindings/target |
31 | | - cd build-convert && cargo clean |
| 44 | + |
| 45 | +# // cpp bindings files |
| 46 | + |
| 47 | +update-cpp-bindings: |
| 48 | + wget $(LIB_RUBY_PARSER_H_URL) -O lib-ruby-parser.h |
| 49 | + wget $(LIB_RUBY_PARSER_A_URL) -O lib-ruby-parser.a |
0 commit comments