背景

因为需要更进一步了解官方源码,所以特别下载了一波源码

操作环境

  1. Mac
  2. Docker

下载源码

  1. # 安装 git-lfs
  2. $ brew install git-lfs
  3. # 安装码云官方工具 repo
  4. $ curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中
  5. $ chmod a+x /usr/local/bin/repo
  6. $ pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
  1. $ repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
  2. $ repo sync -c
  3. $ repo forall -c 'git lfs pull'

准备Docker编译环境

  1. # 下载官方镜像
  2. $ docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker
  3. # 进入源码目录,并在源码目录启动容器
  4. $ docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
  5. # 安装预处理软件
  6. $ sh build/prebuilts_download.sh
  7. # 开始构建内置系统
  8. $ ./build.sh --product-name bearpi_hm_nano --ccache

再次成了

常见问题

Could not find compiler “riscv32-unknown-elf-gcc” in PATH

  1. # 下载gcc_riscv32-linux
  2. $ wget https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz
  3. # 解压
  4. $ tar -zxvf gcc_riscv32-linux-7.3.0.tar.gz
  5. # 临时导出环境变量
  6. $ export PATH=/home/openharmony/gcc_riscv32/bin:$PATH
  7. # 查看环境是否存在
  8. $ riscv32-unknown-elf-gcc -v

./build.sh: line 111: scons: command not found

  1. apt install scons

ImportError: cannot import name ‘_counter’ from ‘Crypto.Util’

  1. # 参考 https://stackoverflow.com/questions/54938481/importerror-cannot-import-name-counter-from-crypto-util
  2. $ pip3 install pycryptodome

参考链接

  1. 源码下载文档【码云】
  2. Docker编译环境【码云】