16 Star 0 Fork 76

OH RISC-V SIG/third_party_mindspore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build_helper.py 2.11 KB
一键复制 编辑 原始数据 按行查看 历史
#!/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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/riscv-sig/third_party_mindspore.git
[email protected]:riscv-sig/third_party_mindspore.git
riscv-sig
third_party_mindspore
third_party_mindspore
master

搜索帮助