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:
parent
1cb68e9aa2
commit
db1f1efb27
24
Makefile
24
Makefile
@ -21,34 +21,16 @@ luajit: $(BUILD_DIR)/tiktoken_core.$(EXT)
|
|||||||
lua51: $(BUILD_DIR)/tiktoken_core-lua51.$(EXT)
|
lua51: $(BUILD_DIR)/tiktoken_core-lua51.$(EXT)
|
||||||
|
|
||||||
define build_from_source
|
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
|
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)
|
cp $(BUILD_DIR)/lua-tiktoken-temp/target/debug/libtiktoken_core.$(EXT) $(BUILD_DIR)/tiktoken_core.$(EXT)
|
||||||
rm -rf $(BUILD_DIR)/lua-tiktoken-temp
|
rm -rf $(BUILD_DIR)/lua-tiktoken-temp
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define download_release
|
$(BUILD_DIR)/tiktoken_core.$(EXT): $(BUILD_DIR)
|
||||||
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)
|
|
||||||
$(call build_from_source,luajit)
|
$(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)
|
$(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):
|
$(BUILD_DIR):
|
||||||
mkdir -p $(BUILD_DIR)
|
mkdir -p $(BUILD_DIR)
|
||||||
|
@ -62,7 +62,7 @@ For Windows users, change the build command to the following:
|
|||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
>
|
>
|
||||||
> If your neovim doesn't use LuaJIT, then change `build` to `make lua51`. By default running make will install luajit.
|
> 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]
|
> [!NOTE]
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user