华为鸿蒙操作系统学习(3):经过上次的编译发现,鸿蒙的整个项目的源代码现在使用的是v1.0版本。原来可以编译3个设备固件,但是只编译成功两个。使用Dockerfile进行源代码的构建,构建成功。

前言


本文的原文连接是:
https://blog.csdn.net/freewebsys/article/details/108652134

【鸿蒙系统分类】:
http://blog.csdn.net/freewebsys/article/category/10390587

【gitee项目地址】:
https://gitee.com/studyharmony/linux-build

未经博主允许不得转载。
博主地址是:http://blog.csdn.net/freewebsys

1,关于鸿蒙系统


OpenHarmony是开放原子开源基金会(OpenAtom Foundation)旗下开源项目,定位是一款面向全场景的开源分布式操作系统。
OpenHarmony在传统的单设备系统能力的基础上,创造性地提出了基于同一套系统能力、适配多种终端形态的理念,支持多种终端设备上运行,第一个版本支持128K-128M设备上运行,欢迎参加开源社区一起持续演进。
针对设备开发者,OpenHarmony采用了组件化的设计方案,可以根据设备的资源能力和业务特征进行灵活裁剪,满足不同形态的终端设备对于操作系统的要求。可运行在百K级别的资源受限设备和穿戴类设备,也可运行在百M级别的智能家用摄像头/行车记录仪等相对资源丰富的设备。

2,使用


根据上次的Dockerfile 经验:
https://yanghuaiyuan.blog.csdn.net/article/details/108621002

发现:
获取Hi3516源码,获取Hi3861源码的下载地址是一个。

https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz

目前鸿蒙支持编译出的固件:

usage: 
  python build.py ipcamera_hi3516dv300
  python build.py ipcamera_hi3518ev300
  python build.py wifiiot

发现,ipcamera_hi3516dv300 ,ipcamera_hi3518ev300 可以编译成功。
但是 wifiiot 不可以,报错了。有些是编码的问题。

3,使用Dockerfile进行源代码的构建


环境搭建是第一步。
我觉得应该给个官方的Dockerfile,这样直接下载镜像得了。

https://gitee.com/studyharmony/linux-build/blob/master/Dockerfile

# 构建命令:
# docker build -t openharmony:dev . 

#使用 ubuntu:18.04 做基础镜像减少大小。
# 然后安装构建鸿蒙系统需要的软件
 
FROM docker.io/ubuntu:18.04

# https://developer.aliyun.com/mirror/
# https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b115c0SRA

# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse\n\
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse\n\
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse\n" > /etc/apt/sources.list && \
echo "[global]\n\
trusted-host=mirrors.aliyun.com\n\
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone

# 按照官方的方法继续软件安装:
# https://openharmony.gitee.com/openharmony/docs/blob/master/quick-start/%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83-0.md

# 将Linux shell改为bash 
RUN apt update &&  apt-get install -y curl && rm -rf /bin/sh && ln -s /bin/bash /bin/sh

# 这个是很少变的,放到前面
# 安装gn && 安装ninja && 安装LLVM编译工具链 && 安装hc-gen

RUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar && \
    tar -xf gn.1523.tar -C /opt/ && rm -f gn.1523.tar

RUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar && \
    tar -xf ninja.1.9.0.tar -C /opt/ && rm -f ninja.1.9.0.tar

# 724M 这个好大,每次都要下载好一会
RUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar && \
    tar -xf llvm-linux-9.0.0-34042.tar -C /opt/ && rm -f llvm-linux-9.0.0-34042.tar

RUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar && \
    tar -xf hc-gen-0.65-linux.tar -C /opt/ && rm -f hc-gen-0.65-linux.tar

#安装gcc_riscv32 109M。
RUN cd /opt && curl -O https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz && \
    tar -xf gcc_riscv32-linux-7.3.0.tar.gz -C /opt/ && rm -f gcc_riscv32-linux-7.3.0.tar.gz

#增加语言utf-8
ENV LANG=zh_CN.UTF-8
ENV LC_CTYPE=zh_CN.UTF-8

# llvm 和其他路径不一样。
RUN echo "export PATH=/opt/gn:/opt/ninja:/opt/llvm/bin:/opt/hc-gen:/opt/gcc_riscv32/bin:$PATH" >> /root/.bashrc 

# 安装Python环境
RUN apt-get install -y python3.8 python3-pip dosfstools scons mtools zip && \
    pip3 install setuptools kconfiglib pycryptodome six ecdsa && \
    rm -f /usr/bin/python && ln -s /usr/bin/python3.8 /usr/bin/python


# 使用: 
# mkdir -p data && docker run -it -v $PWD/data:/data openharmony:dev bash

3,总结


构建代码,从Dockerfile 的方式,进行快速的代码构建。标准化。
但是我没有硬件,只要构建成功之后,就可以直接刷到固件上了。
关键是代码的学习研究。

本文的原文连接是:
https://blog.csdn.net/freewebsys/article/details/108652134

博主地址是:https://blog.csdn.net/freewebsys

猜你喜欢

转载自blog.csdn.net/freewebsys/article/details/108652134