gitee官方文档:
https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-sourcecode-acquire.md
1.ubuntu上下载、编译工程
两种方式
1.1 Ubuntu镜像+虚拟机
资源链接:
/https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases
注意更改软件源镜像,提高下载速度,可在安装ubuntu的时候就更换
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
1.2 WSL2搭配ubuntu
指导链接:
https://docs.microsoft.com/zh-cn/windows/wsl/install-win10
1.3 安装完ubuntu需要安装两个工具
- sudo apt install net-tools:用于ipconfig查找工具
- sudo apt-get install openssh-server:用于远程终端连接
2. 远程终端推荐-MobaXterm
资源及安装指导链接:
https://zhuanlan.zhihu.com/p/56341917
3.安装相关软件
sudo apt-get install binutils git-core 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 lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4
4.码云密钥注册
4.1 注册码云
https://gitee.com/explore
4.2 注册码云SSH公钥,请参考码云帮助中心
ssh-keygen -t rsa -C “xxxxxx@xxxxxxxx.com”
cat ~/.ssh/id_rsa.pub
4.3 安装git客户端和git-lfs并配置用户信息。
- git config --global user.name “xxxxxx”
- git config --global user.email “xxxxxx@qq.com”
- git config --global credential.helper store
4.4 安装码云repo工具,可以执行如下命令
- curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > ./repo
- sudo mv ./repo /usr/local/bin/repo
- sudo chmod a+x /usr/local/bin/repo
- sudo apt install python3-pip
- sudo apt install ruby
- sudo apt-get install libtinfo5
- sudo apt-get install npm
- pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
5.代码拉取
5.1 拉取命令
建立work文件夹
sudo ln -s /usr/bin/python3 /usr/bin/python该命令用于为其创建符号连接,重要
- repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify --depth=1
- repo sync -c -j32
- repo forall -c ‘git lfs pull’
- repo forall -c ‘git lfs pull’ 每次编译前需重新执行,更新二进制
6. 准备编译
- build/prebuilts_download.sh
- repo start local_br --all
7.代码编译
进入源码根目录,执行如下命令进行版本编译。
- sudo apt-get install libtinfo5
- ./build.sh --product-name Hi3516DV300
- ./build.sh --product-name Hi3516DV300 --ccache --gn-args is_double_framework=false --gn-args use_musl=true --gn-args use_custom_libcxx=false --build-target appdatamgr_jskits
4.在15000多行的时候会报一个错误:
此时需要安装一下jdk,具体步骤如下:
参考链接:jdk安装指南
1.更新软件包列表 : sudo apt-get update
2.安装openjdk-8-jdk: sudo apt-get install openjdk-8-jdk
3.查看java版本,看看是否安装成功: java -version
8. 运行调试
官网指导文件
out/hi3516dv300/mingw_x86_64/common/
- 获取编译产物:将该目录下的所有文件拷贝到windows平台,以手机平台为例
- 将IDE生成的应用hap包进行解包(可使用zip解压),获取执行的bundle文件(hap包内的assets\js\xxx 目录),将整个目录拷贝到D:\Workspace\preview\js 这个固定目录下