File tree Expand file tree Collapse file tree 6 files changed +34
-9
lines changed Expand file tree Collapse file tree 6 files changed +34
-9
lines changed Original file line number Diff line number Diff line change 1111此项目目前处于早期开发阶段,不建议用于生产环境。
1212[ 项目地址] ( https://github.com/Pivot-Studio/pivot-lang )
1313
14+ ## 安装
15+ 见https://lang.pivotstudio.cn/tutorial/installation.html
16+
1417## 文档地址
1518https://lang.pivotstudio.cn
1619
Original file line number Diff line number Diff 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运行
Original file line number Diff line number Diff line change 11entry = " main.pi"
2+ project = " main"
Original file line number Diff line number Diff line change 1+ use std::io;
12fn main() i64 {
2- printi64ln(666);
3+ io:: printi64ln(666);
34 return 0;
45}
56
6- fn printi64ln(i: i64) void;
Original file line number Diff line number Diff line change @@ -29,9 +29,23 @@ Pivot Lang存在两种不同的编译方案:
2929TODO
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
4054
4155在release中,` plc ` 程序是编译器可执行文件,下载后请将它添加到` PATH ` 环境变量中,之后即可运行` plc -h ` 进行验证。
4256
43-
57+ TODO mac文档已过期
4458## Docker
4559TODO
Original file line number Diff line number Diff line change 1+ GREEN='\033[0;32m'
2+ NC='\033[0m'
3+
14if [ "$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}"
1017fi
You can’t perform that action at this time.
0 commit comments