-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tiktoken): automatic build (#9)
Signed-off-by: Aaron Pham <[email protected]>
- Loading branch information
Showing
4 changed files
with
90 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
local H = {} | ||
local M = {} | ||
|
||
H.get_os_name = function() | ||
local os_name = vim.loop.os_uname().sysname | ||
if os_name == "Linux" then | ||
return "linux" | ||
elseif os_name == "Darwin" then | ||
return "macOS" | ||
else | ||
error("Unsupported operating system: " .. os_name) | ||
end | ||
end | ||
|
||
H.library_path = function() | ||
local os_name = H.get_os_name() | ||
local ext = os_name == "linux" and "so" or "dylib" | ||
local dirname = string.sub(debug.getinfo(1).source, 2, #"/tiktoken_lib.lua" * -1) | ||
return dirname .. ("../build/?.%s"):format(ext) | ||
end | ||
|
||
M.load = function() | ||
local library_path = H.library_path() | ||
if not string.find(package.cpath, library_path, 1, true) then | ||
package.cpath = package.cpath .. ";" .. library_path | ||
end | ||
end | ||
|
||
return M |