This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
84 lines (71 loc) · 1.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
ifeq ($(OS), Windows_NT)
DETECTED_OS = Windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
DETECTED_OS = Linux
else
ifeq ($(UNAME_S), Darwin)
DETECTED_OS = Darwin
else
DETECTED_OS = Unknown
endif
endif
endif
ifeq ($(DETECTED_OS), Windows)
LIB_ASSET_NAME = libruby_parser_cpp-x86_64-pc-windows-msvc.lib
LOCAL_LIB_NAME = lib-ruby-parser.lib
NODE_FILE_NAME = win32.node
CODEGEN_FILE_NAME = codegen-x86_64-pc-windows-msvc
EXE = .exe
endif
ifeq ($(DETECTED_OS), Linux)
LIB_ASSET_NAME = libruby_parser_cpp-x86_64-unknown-linux-gnu.a
LOCAL_LIB_NAME = lib-ruby-parser.a
NODE_FILE_NAME = linux.node
CODEGEN_FILE_NAME = codegen-x86_64-unknown-linux-gnu
EXE =
endif
ifeq ($(UNAME_S), Darwin)
LIB_ASSET_NAME = libruby_parser_cpp-x86_64-apple-darwin.a
LOCAL_LIB_NAME = lib-ruby-parser.a
NODE_FILE_NAME = darwin.node
CODEGEN_FILE_NAME = codegen-x86_64-apple-darwin
EXE =
endif
VERSION = 4.0.3+ruby-3.1.1
ifndef BUILD_ENV
BUILD_ENV = debug
endif
ifeq ($(BUILD_ENV), debug)
NODE_GYP_FLAGS = -d
GYP_ENV = Debug
else
NODE_GYP_FLAGS =
GYP_ENV = Release
endif
ASSET_PREFIX = https://github.com/lib-ruby-parser/cpp-bindings/releases/download/v$(VERSION)
HEADER_URL = $(ASSET_PREFIX)/lib-ruby-parser.hpp
LIB_URL = $(ASSET_PREFIX)/$(LIB_ASSET_NAME)
include codegen/build.mk
setup:
npm install --ignore-scripts
npm install node-gyp --no-save
cp LICENSE pkg/
cp README.md pkg/
configure:
node ./node_modules/node-gyp/bin/node-gyp.js configure
GYP_OUTPUT = ./build/$(GYP_ENV)/ruby_parser.node
.PHONY: build
build: do-codegen
node ./node_modules/node-gyp/bin/node-gyp.js build $(NODE_GYP_FLAGS)
cp $(GYP_OUTPUT) pkg/$(NODE_FILE_NAME)
cp types.d.ts pkg/index.d.ts
test:
npm run test
clean:
rm -f $(GYP_OUTPUT)
rm -f $(CLEAN)
download-cpp-bindings:
$(call download_file, $(HEADER_URL), src/lib-ruby-parser.hpp)
$(call download_file, $(LIB_URL), $(LOCAL_LIB_NAME))