错误代码:
smtx@123:~/OpenHarmony$ ./build.sh --product-name e2000 --ccache --target-cpu arm64
++++++++++++++++++++++++++++++++++++++++
The system shell is bash 5.0.17(1)-release
++++++++++++++++++++++++++++++++++++++++
2023-09-22 11:33:02
--product-name e2000 --ccache --target-cpu arm64
Traceback (most recent call last):
File "/home/smtx/OpenHarmony/build.py", line 74, in <module>
sys.exit(__main__._main())
NameError: name '__main__' is not defined
操作步骤:
Phytium-OH_3.2_release-E2000 Demo开发板编译集成方法
搭建开发环境
1.1 硬件环境
工欲善其事必先利其器,所以首先准备一台装有ubuntu20.04系统X86主机,内存最低配置要求16G。
硬件配置肯定是多多益善了,配置越高,编译过程就更加的纵享丝滑了!
1.2 下载repo脚本文件
git config --global user.name "yourname" git config --global user.email "your-email-address" git config --global credential.helper store
- 安装码云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
1.3 获取OpenHarmony标准系统源码
通过repo + ssh 下载(需注册公钥,请参考码云帮助中心)。
export WORK_SPACE=/home/xxx/OpenHarmony #替换成自己定义的workspace路径 export PROJ_ROOT=$WORK_SPACE/3.2-release mkdir $WORK_SPACE mkdir $PROJ_ROOT cd $PROJ_ROOT repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.2-Release --no-repo-verify repo sync -c repo forall -c 'git lfs pull'
1.4 获取编译工具链
使用安装包方式获取编译工具链。
sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby
1.5 执行prebuilts
在源码根目录下执行脚本,安装编译器及二进制工具。
cd $PROJ_ROOT bash build/prebuilts_download.sh
代码下载与整合
2.1 下载phytium OH_3.2_release E2000适配源码
创建存放phytiym phytium OH_3.2_release源码的目录,进到该目录,下载phytium OH_3.2_release E2000适配源码:
export PHY_DEV=$WORK_SPACE/phytium_device mkdir $PHY_DEV cd $PHY_DEV git clone https://gitee.com/phytium_embedded/phytium-openharmony-e2000-device.git
2.2 整合phytiym device vendor相关源码
- 通过前面的步骤,我们下载好了相关飞腾部分的修改。是时候将其和入到鸿蒙主干了。这里我们贴心的为开发者准备了一键构建脚本,我们这里执行脚本!
./phytium_env.sh $PROJ_ROOT THE OHOS_PATH_ROOT /home/xxx/OpenHarmony/3.2-release #### sync phytium env start! #### #### sync device_soc_phytium #### #### sync device_soc_phytium end #### #### sync device_board_phytium #### #### sync device_board_phytium end #### #### sync vendor_phytium #### #### sync vendor_phytium end #### #### sync kernel #### #### sync kernel end #### #### applay 0001_drivers_peripheral.patch #### #### applay 0001_foundation_arkui_ace_engine.patch #### #### applay 0001_foundation_graphic_graphic_2d.patch #### #### sync phytium end! ####
这里我们需要传入的参数是鸿蒙的根目录!
代码编译
3.1 OpenHarmony编译
cd $PROJ_ROOT ./build.sh --product-name e2000 --ccache --target-cpu arm64
编译成功提示:
post_process =====build e2000 successful.
编译完成,我们进入到out目录查看生成的文件: