chore(build): from source (#241)

* chore(build): from source

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* chore: update readme

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham 2024-08-26 08:36:05 -04:00 committed by GitHub
parent 1cb68e9aa2
commit db1f1efb27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 22 deletions

View File

@ -21,34 +21,16 @@ luajit: $(BUILD_DIR)/tiktoken_core.$(EXT)
lua51: $(BUILD_DIR)/tiktoken_core-lua51.$(EXT)
define build_from_source
git clone https://github.com/gptlang/lua-tiktoken.git $(BUILD_DIR)/lua-tiktoken-temp
git clone --branch v0.2.2 --depth 1 https://github.com/gptlang/lua-tiktoken.git $(BUILD_DIR)/lua-tiktoken-temp
cd $(BUILD_DIR)/lua-tiktoken-temp && cargo build --features=$1
cp $(BUILD_DIR)/lua-tiktoken-temp/target/debug/libtiktoken_core.$(EXT) $(BUILD_DIR)/tiktoken_core.$(EXT)
rm -rf $(BUILD_DIR)/lua-tiktoken-temp
endef
define download_release
curl -L https://github.com/gptlang/lua-tiktoken/releases/latest/download/tiktoken_core-$1-$(ARCH)-$2.$(EXT) -o $(BUILD_DIR)/tiktoken_core.$(EXT)
endef
ifeq ($(BUILD_FROM_SOURCE), true)
$(BUILD_DIR)/tiktoken_core.$(EXT): $(BUILD_DIR)
$(BUILD_DIR)/tiktoken_core.$(EXT): $(BUILD_DIR)
$(call build_from_source,luajit)
$(BUILD_DIR)/tiktoken_core-lua51.$(EXT): $(BUILD_DIR)
$(BUILD_DIR)/tiktoken_core-lua51.$(EXT): $(BUILD_DIR)
$(call build_from_source,lua51)
else
ifneq ($(filter arm64 aarch64,$(ARCH)),)
$(BUILD_DIR)/tiktoken_core.$(EXT): $(BUILD_DIR)
$(call build_from_source,luajit)
$(BUILD_DIR)/tiktoken_core-lua51.$(EXT): $(BUILD_DIR)
$(call build_from_source,lua51)
else
$(BUILD_DIR)/tiktoken_core.$(EXT): $(BUILD_DIR)
$(call download_release,$(OS),luajit)
$(BUILD_DIR)/tiktoken_core-lua51.$(EXT): $(BUILD_DIR)
$(call download_release,$(OS),lua51)
endif
endif
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)

View File

@ -62,7 +62,7 @@ For Windows users, change the build command to the following:
> [!IMPORTANT]
>
> If your neovim doesn't use LuaJIT, then change `build` to `make lua51`. By default running make will install luajit.
> For ARM-based setup, make sure to also install cargo as we will have to build the tiktoken_core from source.
> Avante.nvim will now requires cargo to build tiktoken_core from source.
> [!NOTE]
>