Skip to content

Commit b8e635e

Browse files
committed
feat: add new ubuntu guide
1 parent 8883acc commit b8e635e

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
此项目目前处于早期开发阶段,不建议用于生产环境。
1212
[项目地址](https://github.com/Pivot-Studio/pivot-lang)
1313

14+
## 安装
15+
https://lang.pivotstudio.cn/tutorial/installation.html
16+
1417
## 文档地址
1518
https://lang.pivotstudio.cn
1619

book/src/tutorial/basicproject.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ entry指定了该项目的入口文件,即编译器将从该文件开始编译
2424
{{#include example/main.pi}}
2525
```
2626
源文件的后缀名必须为`.pi`
27-
在示例中,我们声明了一个外部函数`printi64ln`,该函数用于打印一个i64类型的值并换行。此源代码编译后执行会输出`666`
28-
> 重要:`printi64ln`函数是目前pl runtime中的一个测试用内置函数,内置函数在未来将有别的引入方法,并且此方法可能会在未来移除
27+
在示例中,我们调用了一个系统库重的函数`printi64ln`,该函数用于打印一个i64类型的值并换行。此源代码编译后执行会输出`666`
28+
> 重要:`printi64ln`函数是目前pl runtime中的一个测试用内置函数,此函数可能会在未来移除
2929
3030
## 编译
3131
如果你已经安装了`plc`,那么你可以在项目根目录下执行`plc main.pi`命令来编译该项目。此指令会生成一个名叫`out.plb`的文件,还有一些中间文件
3232

33-
> 如果你配置了镜头编译环境,还会生成一个叫做`out.plb.out`的文件,该文件是一个可执行文件,可以直接运行
33+
> 如果你配置了静态编译环境,还会生成一个叫做`out`的文件,该文件是一个可执行文件,可以直接运行
3434
> 而如果你只有jit环境,该文件不会生成,并且编译命令会输出一个clang报错和两行warning,这是正常现象
3535
3636
## jit运行
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
entry = "main.pi"
2+
project = "main"

book/src/tutorial/example/main.pi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use std::io;
12
fn main() i64 {
2-
printi64ln(666);
3+
io::printi64ln(666);
34
return 0;
45
}
56

6-
fn printi64ln(i: i64) void;

book/src/tutorial/installation.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,23 @@ Pivot Lang存在两种不同的编译方案:
2929
TODO
3030

3131
## Linux
32-
目前我们对Ubuntu 20.04 LTS 和 Ubuntu 22.04 LTS提供了预编译的pivot lang编译器,你可以在我们的[release页面](https://github.com/Pivot-Studio/pivot-lang/releases)进行下载。编译器也许也能在别的发行版上运行,但是我们并没有测试过。
33-
34-
在release中,`plc`程序是编译器可执行文件,下载后请将它添加到`PATH`环境变量中,之后即可运行`plc -h`进行验证。
32+
目前我们对Ubuntu 20.04 LTS 和 Ubuntu 22.04 LTS提供了apt包。
33+
首先你需要添加我们的apt源的gpg key:
34+
```bash
35+
wget -O - https://apt.lang.pivotstudio.cn/public.key | sudo apt-key add -
36+
```
37+
然后添加我们的apt源:
38+
```bash
39+
sudo add-apt-repository "deb [arch=amd64] https://apt.lang.pivotstudio.cn/repo focal main"
40+
sudo add-apt-repository "deb [arch=amd64] https://apt.lang.pivotstudio.cn/repo jammy main"
41+
```
42+
最后安装pivot lang编译器:
43+
```bash
44+
sudo apt install pivot-lang
45+
```
46+
你可以运行`plc`来检查是否安装成功。
47+
48+
请重启当前bash或者运行`source ~/.bashrc`来使环境变量生效。如果想安装`AOT`功能,请手动下载clang-14,下载方式见https://apt.llvm.org/
3549

3650

3751

@@ -40,6 +54,6 @@ TODO
4054

4155
在release中,`plc`程序是编译器可执行文件,下载后请将它添加到`PATH`环境变量中,之后即可运行`plc -h`进行验证。
4256

43-
57+
TODO mac文档已过期
4458
## Docker
4559
TODO

deb/DEBIAN/postinst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
GREEN='\033[0;32m'
2+
NC='\033[0m'
3+
14
if [ "$1" = configure ]; then
25
echo "export KAGARI_LIB_ROOT=/pl/planglib" >> ~/.bashrc
36
echo "export PL_ROOT=/pl" >> ~/.bashrc
7+
echo -e "${GREEN}"
8+
echo "-------------------------------------------------------------------"
49
echo "Successfully installed pivot-lang compiler with JIT feature!"
510
echo "the pivot-lang compiler is now available as 'plc' command"
611
echo "**jit feature does not support debug**"
712
echo "you may need to restart your shell to load environment variables"
813
echo "to install aot feature, please install clang-14 manually"
914
echo "see https://apt.llvm.org/ for more details"
15+
echo "-------------------------------------------------------------------"
16+
echo -e "${NC}"
1017
fi

0 commit comments

Comments
 (0)