8 Star 3 Fork 226

OpenHarmony/xts_hats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
check_hvigor.py 3.00 KB
一键复制 编辑 原始数据 按行查看 历史
冯强 提交于 2024-04-29 09:33 . add check for hvigor
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright (c) 2020-2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import sys
import subprocess
import hashlib
import json5
def get_file_md5(file_path):
hash_md5 = hashlib.md5()
with open(file_path, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
def get_hvigor_version(json_file):
with open(json_file, 'r') as f:
data = json5.load(f)
return data.get('hvigorVersion')
return "0.0.0"
def output_unmatched_project(prject_list, filename):
print("")
print(
"Error: The {} in the following directory does not meet the requirements:"
.format(filename))
for prj in prject_list:
print(prj[0], prj[1])
print("")
def check_hvigor_wrapper_js(hvigor_prj_list):
unmatch_info = []
baseline_md5 = "558a3eec8ee9e753b63f99abe79c0ec3"
for dir in hvigor_prj_list:
filename = os.path.join(dir, 'hvigor', 'hvigor-wrapper.js')
md5 = get_file_md5(filename)
if md5 != baseline_md5:
unmatch_info.append((md5, filename))
if len(unmatch_info):
output_unmatched_project(unmatch_info, 'hvigor-wrapper.js')
print('Please copy from {}'.format('test/xts/acts/arkcompiler/ecmanewfeatures/hvigor/hvigor-wrapper.js'))
return False
return True
def check_hvigor_version(hvigor_prj_list):
unmatch_prj_list = []
baseline_version = '4.0.2'
for dir in hvigor_prj_list:
filename = os.path.join(dir, 'hvigor', 'hvigor-config.json5')
version = get_hvigor_version(filename)
if version != baseline_version:
unmatch_prj_list.append((version, filename))
if len(unmatch_prj_list):
output_unmatched_project(unmatch_prj_list, 'hvigor-config.json5')
print("Plesse use {}".format(baseline_version))
return False
return True
def get_hvigor_prject_list(directory):
hvigor_prj_list = []
for root, dirs, files in os.walk(directory):
for dir in dirs:
if dir == 'hvigor':
hvigor_prj_list.append(root)
return hvigor_prj_list
if __name__ == "__main__":
this_file = os.path.realpath(__file__)
curr_dir = os.path.dirname(this_file)
hvigor_prj_list = get_hvigor_prject_list(curr_dir)
js_valid = check_hvigor_wrapper_js(hvigor_prj_list)
json_valid = check_hvigor_version(hvigor_prj_list)
if not js_valid or not json_valid:
sys.exit(1)
sys.exit(0)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/xts_hats.git
git@gitee.com:openharmony/xts_hats.git
openharmony
xts_hats
xts_hats
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891