Ubuntu22.04编译FuchsiaOS

编译环境:

系统:Ubuntu 22.04.2 LTS 64 位
CPU:Intel® Core™ i5-4200M CPU @ 2.50GHz × 4
Memory:8GB
Graphics:GeForce GT 755M

下载代码:

下载 Fuchsia 源代码需要大约 2 GB 的机器空间。 根据您的构建配置,您稍后在构建 Fuchsia 时还需要 80 到 90 GB 的空间。 此外,下载过程会占用大量内存。 建议在此期间关闭非关键进程。

1.下载前需要检查当前机器是否符合编译环境,运行以下命令:

curl -sO https://storage.googleapis.com/fuchsia-ffx/ffx-linux-x64 && chmod +x ffx-linux-x64 && ./ffx-linux-x64 platform preflight

9

2.安装编译所需的包:

sudo apt install curl file git unzip

3.开始下载

进入下载目录

cd $HOME

运行脚本:

curl -s "https://fuchsia.googlesource.com/fuchsia/+/HEAD/scripts/bootstrap?format=TEXT" | base64 --decode | bash

10

在下载过程中会出现 Authentication error,可以通过提示完成授权,或手动登录授权。
14

编译代码:

硬件要求

您只能在具有以下主机架构之一的机器上构建 Fuchsia:

x86-64 Linux(仅限基于 Debian 的发行版)
x86-64 macOS

不支持 Windows 和 ARM64。

1.编译前先设置配置信息,Fuchsia 的构建配置通知构建系统构建哪个产品以及构建哪个架构。
这里我使用 QEMU模拟器 启动,所以使用这个命令:

fx set core.qemu-x64

7

core 是具有 Fuchsia 最小功能集的产品,包括常见的网络功能。
qemu-x64 是指基于开源模拟器 QEMU 的 Fuchsia 模拟器(FEMU)的 x64 架构的板卡。
想了解更加详细的配置信息可以访问这个链接:fx workflows

2.开始编译,执行这个命令:

fx build

11

当您修改源代码时,再次运行 fx build 命令执行增量构建,或运行 fx -i build 命令启动 watcher,它会在您更新源代码时自动构建

在编译过程中,我这个老旧笔记本很慢。
12

启动Fuchsia:

1.启动 package server
在启动模拟器之前,启动包服务器。

fx serve

2.启动模拟器

带网络启动

ffx emu start --net tap

不带网络启动

ffx emu start --net none

13

1 Like

由于在开发编译组件时遇到错误,我又进行了一次构建,使用下面命令:

fx set workstation_eng.x64

fx build

启动时又添加了新参数,

ffx emu start --gpu swiftshader_indirect  --net tap

15

指定 FEMU 使用的 GPU

GPU Emulation method Explanation Flag
Hardware (host GPU) Uses the host machine’s GPU directly to perform GPU processing. ffx emu start --gpu host
SwiftShader Uses SwiftShader libraries to simulate GPU processing. ffx emu start --gpu swiftshader_indirect
Auto Resolves to host if there is a hardware GPU available or swiftshader_indirect if there isn’t a hardware GPU available. auto is the current default. ffx emu start --gpu auto
1 Like

感谢分享!我使用 i7-7600U 核显笔记本,启动之后很卡顿,你的独显运行流畅吗?

我的这个显卡不在支持范围内,启动模拟器后只有设置密码的界面,其他点击就黑屏。本机cpu占用率50%吧,编译了一下helloworld组件,速度一般不是很快。