背景
因为需要更进一步了解官方源码,所以特别下载了一波源码
操作环境
- Mac
- Docker
下载源码
# 安装 git-lfs
$ brew install git-lfs
# 安装码云官方工具 repo
$ curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中
$ chmod a+x /usr/local/bin/repo
$ pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
$ repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
$ repo sync -c
$ repo forall -c 'git lfs pull'
准备Docker编译环境
# 下载官方镜像
$ docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker
# 进入源码目录,并在源码目录启动容器
$ docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
# 安装预处理软件
$ sh build/prebuilts_download.sh
# 开始构建内置系统
$ ./build.sh --product-name bearpi_hm_nano --ccache
常见问题
Could not find compiler “riscv32-unknown-elf-gcc” in PATH
# 下载gcc_riscv32-linux
$ wget https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz
# 解压
$ tar -zxvf gcc_riscv32-linux-7.3.0.tar.gz
# 临时导出环境变量
$ export PATH=/home/openharmony/gcc_riscv32/bin:$PATH
# 查看环境是否存在
$ riscv32-unknown-elf-gcc -v
./build.sh: line 111: scons: command not found
apt install scons
ImportError: cannot import name ‘_counter’ from ‘Crypto.Util’
# 参考 https://stackoverflow.com/questions/54938481/importerror-cannot-import-name-counter-from-crypto-util
$ pip3 install pycryptodome