-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (85 loc) · 2.27 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
UNAME := $(shell uname)
LIB_FILE = addon.node
ifeq ($(UNAME), Darwin)
ARCH ?= $(shell uname -m)
LIBC ?= unknown
endif
ifeq ($(UNAME), Linux)
ARCH ?= $(shell uname -m)
LIBC ?= glibc
endif
ifeq ($(ARCH), x86_64)
ARCH = x64
endif
DOCKER_IMAGE_GLIBC = node:16-slim ##TODO: remove "-builder"
DOCKER_IMAGE_MUSL = node:16-alpine ## TODO: change according to n8n image
DOCKER_PLATFORM_ARM64 = arm64
DOCKER_PLATFORM_X64 = amd64
TGZ_NAME = $(shell uname | tr '[:upper:]' '[:lower:]')-$(ARCH)-$(LIBC).tar.gz
.ONESHELL:
init:
pnpm install
ifeq ($(UNAME), Darwin)
curl -sL https://github.com/nodejs/node-gyp/raw/main/macOS_Catalina_acid_test.sh | bash
xcode-select --install
brew install gperf openssl zlib #macos-only
endif
ifeq ($(UNAME), Linux)
#see https://tdlib.github.io/deps/td/build.html?language=JavaScript
sudo apt-get update
sudo apt-get install make git zlib1g-dev libssl-dev gperf php-cli cmake g++ -y
sudo apt-get install npm docker.io -y
endif
clean: clean-prebuilds clean-archives
build:
build-lib
run:
bash run.sh
publish:
npm publish
clean:
rm -rf build/
rm -rf dist/
rm -rf node_modules/
clean-prebuilds
clean-archives
clean-prebuilds:
rm -rf prebuilds/
clean-archives:
rm -rf *.tar.gz
rm -rf prebuilds/*.tar.gz
build-lib-native: build-lib-native-compile build-lib-archive
build-lib-docker-linux-arm64-glibc:
mkdir -p prebuilds/lib
docker run \
-v `pwd`:/rep \
--platform linux/$(DOCKER_PLATFORM_ARM64) \
$(DOCKER_IMAGE_GLIBC) \
sh /rep/prebuilt-addon-docker.sh
build-lib-docker-linux-arm64-musl:
mkdir -p prebuilds/lib
docker run \
-v `pwd`:/rep \
--platform linux/$(DOCKER_PLATFORM_ARM64) \
$(DOCKER_IMAGE_MUSL) \
sh /rep/prebuilt-addon-docker.sh
build-lib-docker-linux-x64-glibc:
mkdir -p prebuilds/lib
docker run \
-v `pwd`:/rep \
--platform linux/$(DOCKER_PLATFORM_X64) \
$(DOCKER_IMAGE_GLIBC) \
sh /rep/prebuilt-addon-docker.sh
build-lib-docker-linux-x64-musl:
mkdir -p prebuilds/lib
docker run \
-v `pwd`:/rep \
--platform linux/$(DOCKER_PLATFORM_X64) \
$(DOCKER_IMAGE_MUSL) \
sh /rep/prebuilt-addon-docker.sh
build-lib-native-compile:
npm run build:gyp
mkdir -p prebuilds/lib/
cp -L build/Release/$(LIB_FILE) ./prebuilds/lib/$(LIB_FILE)
build-lib-archive:
cd prebuilds && tar -czvf $(TGZ_NAME) lib/* && cp $(TGZ_NAME) ..