docker
是很香的,从第一次接触docker
就对它爱不释手, 脏活累活它干了,少了太多的麻烦. docker
编译鸿蒙看编译环境篇就行了, L1
和 L2
都编译通过了.个人喜欢做一劳永逸的事,如果有试过手动去安装鸿蒙开发环境,下载源码,确保编译成功其实是件非常麻烦的事情, 在虚拟机和WSL2上都跑通之后,发现其中的坑不少,这些坑本身没有技术含量,知道了也就知道了,但它们却跟牛皮癣一样,遇到了就不容易好老复发真烦人. 如何防止得牛皮癣的最好办法不是去治疗牛皮癣,而是不得牛皮癣,打上牛皮癣的疫苗. 这是本篇存在的意义,让整个过程简单,舒适,一气呵成.
脚本获取方式: 1.直接下载 2.本篇内容 ctrl+c/v
turing@ubuntu: wget http://maniu.com/weharmony/L1/maniu.sh
turing@ubuntu: wget http://maniu.com/weharmony/L1/path.sh
两个脚本文件在 Ubuntu 20.04 LTS
下运行没有问题, 推荐大家统一使用这个版本,尽量不要去折腾其他环境,真的,很容易遇到牛皮癣.
脚本1: sudo ./maniu.sh
#!/bin/bash
#使用版本: ubuntu:20.04
#1\. 安装脚本编译鸿蒙轻量级内核(L1/liteos)所需各种环境
#2\. 下载L1最新全量源码包 code-v1.1.1-LTS.tar.gz 至 /home/openharmony
#在脚本所在目录,执行以下命令即可
#turing@ubuntu:~$sudo ./maniu.sh
apt-get update -y
apt-get install curl wget -y
apt-get install vim -y
apt-get install ssh -y
apt-get install git -y
apt-get install python3.8 -y
apt-get install python3-pip -y
apt-get install dosfstools -y
apt-get install mtools -y
apt-get install scons -y
apt-get install make -y
apt-get install libffi-dev -y
apt-get install zip -y
apt-get install python3-distutils -y
apt-get install binutils -y
apt-get install mtd-utils -y
apt-get install libc6-dev-x32 -y
DEBIAN_FRONTEND="noninteractive" TZ="America/New_York" apt-get -y install tzdata
apt-get install default-jre -y
apt-get install default-jdk -y
apt-get install bison -y
apt-get install flex -y
apt-get install bc -y
apt-get install u-boot-tools -y
apt-get install gcc-arm-linux-gnueabi -y
apt-get install build-essential
apt-get install locales
locale-gen "en_US.UTF-8"
rm -rf /bin/sh /usr/bin/python /usr/bin/python3
ln -s /bin/bash /bin/sh
ln -s /usr/bin/python3.8 /usr/bin/python3
ln -s /usr/bin/python3.8 /usr/bin/python
pip3 install --trusted-host mirrors.aliyun.com -i https://mirrors.aliyun.com/pypi/simple setuptools
pip3 install --trusted-host mirrors.aliyun.com -i https://mirrors.aliyun.com/pypi/simple kconfiglib
pip3 install --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple pycryptodome
pip3 install --trusted-host mirrors.aliyun.com -i https://mirrors.aliyun.com/pypi/simple ecdsa
python3 -m pip install --user ohos-build
# 安装编译环境
mkdir -p /home/tools
wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar
wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar
wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz
wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar
wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/gn/1717/linux/gn-linux-x86-1717.tar.gz
wget -P /home/tools https://mirrors.huaweicloud.com/nodejs/v12.20.0/node-v12.20.0-linux-x64.tar.gz
wget -P /home/tools https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar
wget -P /home/tools https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar
tar xvf /home/tools/llvm-linux-9.0.0-36191.tar -C /home/tools
tar xvf /home/tools/hc-gen-0.65-linux.tar -C /home/tools
tar xvf /home/tools/gcc_riscv32-linux-7.3.0.tar.gz -C /home/tools
tar xvf /home/tools/ninja.1.9.0.tar -C /home/tools
tar xvf /home/tools/gn-linux-x86-1717.tar.gz -C /home/tools
tar xvf /home/tools/node-v12.20.0-linux-x64.tar.gz -C /home/tools
#删除下载的压缩包
rm -rf /home/tools/*.tar
rm -rf /home/tools/*.gz
#安装ohos/hpm-cli
npm install -g @ohos/hpm-cli --registry https://mirrors.huaweicloud.com/repository/npm/
说明:
脚本2: ./path.sh
注意执行这个脚本不要用 sudo
turing@ubuntu:~$./path.sh
如果出现 bash: ./path.sh: Permission denied 加上用户执行脚本的权限后再执行
turing@ubuntu:~$sudo chmod a+x ./path.sh
脚本内容:
#!/bin/bash
#使用版本: ubuntu:20.04
#本脚本用于设置用户的环境变量,在 ./maniu.sh 执行成功后执行
#在脚本所在目录,执行以下命令即可,注意不要用 sudo
#turing@ubuntu:~$./path.sh
# 下载源码包,目前鸿蒙轻量级内核最新源码包为code-v1.1.1-LTS.tar.gz,后续有更新请自行替换
mkdir -p /home/openharmony
wget -P /home/openharmony https://repo.huaweicloud.com/harmonyos/os/1.1.1/code-v1.1.1-LTS.tar.gz
tar xvf /home/openharmony/code-v1.1.1-LTS.tar.gz -C /home/openharmony
sed -i '$aexport PATH=/home/tools/llvm/bin:$PATH' ~/.bashrc
sed -i '$aexport PATH=/home/tools/hc-gen:$PATH' ~/.bashrc
sed -i '$aexport PATH=/home/tools/gcc_riscv32/bin:$PATH' ~/.bashrc
sed -i '$aexport PATH=/home/tools/ninja:$PATH' ~/.bashrc
sed -i '$aexport PATH=/home/tools/node-v12.20.0-linux-x64/bin:$PATH' ~/.bashrc
sed -i '$aexport PATH=/home/tools:$PATH' ~/.bashrc
sed -i '$aexport PATH=~/.local/bin:$PATH' ~/.bashrc
export PATH=/home/tools/llvm/bin:$PATH
export PATH=/home/tools/hc-gen:$PATH
export PATH=/home/tools/gcc_riscv32/bin:$PATH
export PATH=/home/tools/ninja:$PATH
export PATH=/home/tools/node-v12.20.0-linux-x64/bin:$PATH
export PATH=/home/tools:$PATH
export PATH=~/.local/bin:$PATH
source ~/.bashrc
#输入 hb 或 gn 验证是否成功
#turing@ubuntu:~$ hb
#usage: hb [-h] [-v] {build,set,env,clean,deps} ...
#OHOS Build System version 0.4.2
说明:
~/.bashrc
看下是否环境变量写入成功hb set
turing@ubuntu:/home/openharmony/code-v1.1.1-LTS$# hb set
[OHOS INFO] Input code path: .
OHOS Which product do you need? (Use arrow keys)
hisilicon
❯ ipcamera_hispark_aries
wifiiot_hispark_pegasus
ipcamera_hispark_taurus
ohos_config.json
文件 {
"root_path": "/home/openharmony/code-v1.1.1-LTS",
"board": "hispark_aries",
"kernel": "liteos_a",
"product": "ipcamera_hispark_aries",
"product_path": "/home/openharmony/code-v1.1.1-LTS/vendor/hisilicon/hispark_aries",
"device_path": "/home/openharmony/code-v1.1.1-LTS/device/hisilicon/hispark_aries/sdk_liteos",
"patch_cache": null
}
hb build 一气呵成
turing@ubuntu:/home/openharmony/code-v1.1.1-LTS$# hb build
如果你觉得这篇内容对你还蛮有帮助,我想邀请你帮我三个小忙:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。