-
-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (40 loc) · 1.23 KB
/
Makefile
File metadata and controls
54 lines (40 loc) · 1.23 KB
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
UNAME := $(shell uname)
ARCH := $(patsubst aarch64,arm64,$(shell uname -m))
ifeq ($(UNAME), Linux)
OS := linux
EXT := so
else ifeq ($(UNAME), Darwin)
OS := macOS
EXT := dylib
else ifeq ($(UNAME), Windows_NT)
OS := windows
EXT := dll
else ifneq ($(findstring MSYS_NT,$(UNAME)),)
OS := windows
EXT := dll
else
$(error Unsupported operating system: $(UNAME))
endif
LUA_VERSIONS := luajit lua51
BUILD_DIR := build
.PHONY: help install-cli install-pre-commit install test tiktoken clean
install-pre-commit:
pip install pre-commit
pre-commit install
test:
nvim --headless --clean -u ./scripts/test.lua
all: luajit
luajit: $(BUILD_DIR)/tiktoken_core.$(EXT)
lua51: $(BUILD_DIR)/tiktoken_core-lua51.$(EXT)
define download_release
curl -LSsf https://github.com/gptlang/lua-tiktoken/releases/latest/download/tiktoken_core-$(1)-$(2)-$(3).$(EXT) -o $(4)
endef
$(BUILD_DIR)/tiktoken_core.$(EXT): | $(BUILD_DIR)
$(call download_release,$(OS),$(ARCH),luajit,$@)
$(BUILD_DIR)/tiktoken_core-lua51.$(EXT): | $(BUILD_DIR)
$(call download_release,$(OS),$(ARCH),lua51,$@)
tiktoken: $(BUILD_DIR)/tiktoken_core.$(EXT) $(BUILD_DIR)/tiktoken_core-lua51.$(EXT)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
clean:
rm -rf $(BUILD_DIR)