OS:Ubuntu 22.04 x86_64
下载好Openharmony 4.0Beta2 的源码
$ pip3 install ohos-build
$ cd openharmony-4.0b2
$ hb set
Traceback (most recent call last):
File "/home/loongson/.local/bin/hb", line 8, in <module>
sys.exit(main())
File "/home/loongson/.local/lib/python3.10/site-packages/hb/__main__.py", line 49, in main
topdir = find_top()
File "/home/loongson/.local/lib/python3.10/site-packages/hb/__main__.py", line 37, in find_top
raise Exception("Please call hb utilities inside source root directory")
Exception: Please call hb utilities inside source root directory
从错信息看是找到某个目录,hb 是python写的,所以打算看看源码是找个目录出错了,根据出错信息直接看源码文件。
$ vim /home/loongson/.local/lib/python3.10/site-packages/hb/__main__.py
VERSION = "0.4.6"
def find_top():
cur_dir = os.getcwd()
while cur_dir != "/":
hb_internal = os.path.join(cur_dir, 'build/lite/hb_internal')
if os.path.exists(hb_internal):
return cur_dir
cur_dir = os.path.dirname(cur_dir)
raise Exception("Please call hb utilities inside source root directory")
查看python 代码可知报错原因是没找到 build/lite/hb_internal
,在OpenHamony 源码下确实没有发现有build/lite/hb_internal
, 去OpenHarmony 源码仓发现build_lite
这个仓库里面有,所以从这里下载一份到源码放到OpenHarmony 中去。
下载build_lite 源码, 从中复制hb_internal 到openharmony 的源码目录即可。
$ cd ../
$ git clone https://gitee.com/openharmony/build_lite
$ cd build_lite
$ cp -rf hb_internal ../openharmony-4.0b2/build/lite
$ cd ../openharmony-4.0b2