当前位置: 首页 > 工具软件 > Firefox Home > 使用案例 >

在银河麒麟上编译运行firefox

东方文林
2023-12-01

1.关闭系统安全认证(可选)

不关闭会一直弹各种确认框,让你授权

sudo setstatus disable

2.安装git

sudo apt-get update
sudo apt-get install git

3.下载源码

git clone https://github.com/mozilla/gecko-dev.git

或者使用国内镜像

git clone https://gitee.com/mirrors/gecko-dev.git

这里推荐国内镜像,速度比较快
(注:源码必须选择git或者hg方式下载的代码,否则构建系统可能不支持)

如果使用hg,则需要安装hg,这里不做介绍
hg clone https://hg.mozilla.org/mozilla-central
gecko-dev是mozilla-central的github仓库

4.bootstrap

4.1.一些问题的预处理

cd gecko-dev

问题1:NotImplementedError: Bootstrap support for this Linux distro not yet available: kylin

vi python/mozboot/mozboot/bootstrap.py

找到DEBIAN_DISTROS =
在里面添加kylin字段

问题2:ERROR: Could not find pip3.

sudo apt-get install python3-pip


问题3:安装rustc编译器失败

sudo apt-get install curl
curl https://sh.rustup.rs/ > rustup-init.sh
chmod +x rustup-init.sh && ./rustup-init.sh

提示:

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation

输入1,敲enter键

vim ~/.cargo/config

输入

[source.crates-io]
replace-with = 'tuna'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

保存退出

source $HOME/.cargo/env
cargo install cbindgen

4.2.运行bootstrap

./mach bootstrap

提示:
Press ENTER/RETURN to continue or CTRL+c to abort.
敲enter键

提示:Please choose the version of Firefox you want to build:
1. Firefox for Desktop Artifact Mode [default]
2. Firefox for Desktop
3. GeckoView/Firefox for Android Artifact Mode
4. GeckoView/Firefox for Android
5. SpiderMonkey JavaScript engine
输入2,敲enter键

提示:一些软件的安装
您希望继续执行吗? [Y/n]
输入Y,敲enter键

提示:How would you like to continue?
1. Install a modern Mercurial via pip [default]
2. Install a legacy Mercurial via apt
3. Do not install Mercurial
输入1,敲enter键

提示:Could not find a Rust compiler.
Will try to install Rust.
在这边会卡住,直接ctrl + c退出

提示:Would you like to run a few configuration steps to ensure Git is optimally configured? (Yn):
输入n,敲enter键

提示:Will you be submitting commits to Mozilla? (Yn):
输入n,敲enter键

提示:Would you like to enable build system telemetry? (Yn):
输入n,敲enter键

5.configure

5.1.安装clang

sudo apt-get install clang

5.2.安装node.js(>=10.23.1)

mkdir ~/tmp
cd ~/tmp
wget https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-arm64.tar.gz
tar -zxvf node-v16.14.2-linux-arm64.tar.gz
sudo cp node-v16.14.2-linux-arm64/* /usr/ -r
cd -

5.3.执行configure

./mach configure

如果出现ERROR: Cannot find unzip
可以

unset UNZIP
./mach configure

6.build

6.1.安装lld

sudo apt-get install lld
sudo ln -s /usr/bin/wasm-ld-10 /usr/bin/wasm-ld

6.2.安装libclang_rt.builtins-wasm32.a

这个要和lld的版本对应,因为我本地是10.0的版本所以就下载了10.0的对应版本

cd ~/tmp
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-10/libclang_rt.builtins-wasm32-wasi-10.0.tar.gz
tar -zxvf libclang_rt.builtins-wasm32-wasi-10.0.tar.gz
sudo cp -r lib/wasi /usr/lib/llvm-10/lib/clang/10.0.0/lib/
cd -

6.3.执行build

./mach build

7.run

./mach run

即可运行firefox

 类似资料: