Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,23 @@ API 定义以及使用方式详见 [`InfiniCore文档`](https://github.com/Infin

### 一键安装

在 `script/` 目录中提供了 `install.py` 安装脚本。使用方式如下:
在 `script/` 目录中提供了 `install` 安装脚本。使用方式如下:

linux 系统:在`terminal`中执行
```shell
cd InfiniCore
source scripts/install.sh [XMAKE_CONFIG_FLAGS]
# 例如
# source scripts/install.sh 配置 CPU(默认配置)
# source scripts/install.sh --nv-gpu=true --cuda=$CUDA_HOME 配置 英伟达 加速卡
```
windows 系统:在`CMD`中执行
```shell
cd InfiniCore

python scripts/install.py [XMAKE_CONFIG_FLAGS]
# 例如
# python scripts/install.py 配置 CPU(默认配置)
# python scripts/install.py --nv-gpu=true --cuda=\""%CUDA_HOME%"\" 配置 英伟达 加速卡
```

参数 `XMAKE_CONFIG_FLAGS` 是 xmake 构建配置,可配置下列可选项:
Expand Down
8 changes: 8 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /bin/bash

python scripts/install.py ${@:1}

if [ -z "${INFINI_ROOT}" ]; then
sleep 1
. ~/.bashrc
fi
32 changes: 32 additions & 0 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,38 @@ if is_plat("windows") then
add_cxflags("/utf-8", {force = true})
end

-- 添加INFINI_ROOT环境变量
on_config(function()
function Check_INFINI_ROOT()
if is_plat("windows") then
return
end

-- .bashrc文件中是否有INFINI_ROOT
local marker = "# INFINI_ROOT configuration (auto-added by xmake.lua).\n"
local bashrc_path = path.join(os.getenv("HOME"), ".bashrc")
if io.readfile(bashrc_path):find(marker, 1, true) then
return
end

-- 向.bashrc文件中添加 INFINI_ROOT
local INFINI_ROOT = path.join(os.getenv("HOME"), ".infini")
print(string.format("INFINI_ROOT not set!!! New INFINI_ROOT: %s\n", INFINI_ROOT))
local file = io.open(bashrc_path, "a")
if file then
file:write("\n")
file:write(marker)
file:write(string.format("export INFINI_ROOT=%s\n",INFINI_ROOT))
file:write(string.format("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INFINI_ROOT/lib\n"))
file:flush()
file:close()
else
print(string.format("could not open file: %s\n",bashrc_path))
end
end
Check_INFINI_ROOT()
end)

-- CPU
option("cpu")
set_default(true)
Expand Down