代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony/third_party_mindspore 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python3
import os
import shutil
import zipfile
import argparse
def extract_source(in_zip_path, out_src_path):
"depress source code form release package"
print('Extracting zipped release package...')
f = zipfile.ZipFile(in_zip_path, "r")
f.extractall(path=out_src_path)
old_src_dir = out_src_path + "/mindspore-v2.1.0/"
new_src_dir = out_src_path + "/source/"
os.rename(old_src_dir, new_src_dir)
print("Done extraction.")
def do_patch(patch_dir, target_dir):
patches = [
'0001-build-gn-c-api-for-OHOS.patch',
'0002-train-and-build.patch',
'0003-add-js-api.patch',
'0004-cross-compile-ndkso-fp16-nnrt-train_capi.patch',
'0005-micro-for-ohos.patch',
'0006-remove-lite-expression-fix-double-loadso.patch',
]
cwd = os.getcwd()
os.chdir(target_dir)
print('Change dir to', os.getcwd())
os.system('git init .')
os.system('git add .; git commit -m "init"')
for patch in patches:
print('Applying ', patch, '...')
ret = os.system('git apply ' + patch_dir + '/' + patch)
if ret != 0:
raise Exception("Apply patch {} failed.".format(patch))
os.system('git add .; git commit -m "auto-apply ' + patch + '"')
print('Done')
os.chdir(cwd)
def create_status_file(out_src_path):
f = open(out_src_path + '/.status', 'w')
f.write('ok')
f.close
def main_work():
parser = argparse.ArgumentParser(description="mindspore build helper")
parser.add_argument('--in_zip_path')
parser.add_argument('--out_src_path')
parser.add_argument('--patch_dir')
args = vars(parser.parse_args())
in_zip_path = os.path.realpath(args['in_zip_path'])
out_src_path = args['out_src_path']
patch_dir = os.path.realpath(args['patch_dir'])
if os.path.exists(out_src_path):
shutil.rmtree(out_src_path)
os.mkdir(out_src_path)
out_src_path = os.path.realpath(out_src_path)
extract_source(in_zip_path, out_src_path)
do_patch(patch_dir, out_src_path + '/source/')
create_status_file(out_src_path)
if __name__ == "__main__":
main_work()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。