获取代码
获取 Fuchsia 源代码
该指南提供以下内容:
[下载Fuchsia的代码]()
[设置环境变量]()
启动前
在你使用前,需要使用Fuchsia的开发工具
Linux 版本
curl -sO https://storage.googleapis.com/fuchsia-ffx/ffx-linux-x64 && chmod +x ffx-linux-x64 && ./ffx-linux-x64 platform preflight
MacOS 版本
curl -sO https://storage.googleapis.com/fuchsia-ffx/ffx-macos-x64 && chmod +x ffx-macos-x64 && ./ffx-macos-x64 platform preflight
前提
Fuchsia需要使用curl、unzip和git 工具
Linux 版本
sudo apt-get install curl git unzip
MacOS 版本
xcode-select --install
下载Fuchsia代码
Fuchsia的[启动脚本]() 会创建fuchsia文件夹和并下载源码到该文件夹里。
注意:下载Fuchsia的源码需要至少 2GiB 的硬盘空间。因此,你就需要拥有80-90 GiB 的构建空间,在构建配置时依赖。
下载Fuchsia 源码步骤:
选择一个文件夹
注意:下面是使用home 的文件夹进行示范
cd ~
运行脚本
curl -s "https://fuchsia.googlesource.com/fuchsia/+/HEAD/scripts/bootstrap?format=TEXT" | base64 --decode | bash
下载时间可能需要1个小时。如果你看到Invalid authentication credentials 错误,请点击 [授权错误]()
设置环境变量
Fuchsia推荐 根据以下步骤更新脚本
添加 .jiri_root/bin` 到你的`PATH
.jiri_root/bin` 文件包含了jiri和fx 工具,它们是Fuchsia基本的。Fuchsia使用jiri 工具去管理项目仓库。 fx 工具帮助配置、构建、运行和debug Fuchsia,jiri 必须在 `PATH可用
加载 scripts/fx-env.sh 文件
尽管这个不是必须的。加载fx-env.sh` 脚本开启非常有用的功能在终端上。比如,它创建一个 `FUCHSIA_DIR` 环境变量提供 `fd 命令功能
更新自己的shell脚本
更新自己的shell 脚本 添加Fuchsia的环境变量在终端上
注意:如果你不希望更新你的环境变量请查看 [不需要更新PATH]()
步骤如下:
使用文本编辑器打开 ~/.bash_profile 文件,例如:
注意:该教程是使用 bash` 终端。如果你使用的是 `zsh` 的话,请使用`~/.zprofile
nano ~/.bash_profile
添加下面命令行,在 ~/.bash_profile 文件上
注意:如果你的Fuchsia 源码不存在 ~/fuchsia文件夹,那么需要用你的绝对路径替换
export PATH=~/fuchsia/.jiri_root/bin:$PATH
source ~/fuchsia/scripts/fx-env.sh
保存文件并退出
更新环境变量,运行一下命令
source ~/.bash_profile
验证命令是否已存在
jiri help
fx help