mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-09-10 21:59:54 -05:00
optimize maixcdk deploy and pkgs_info.json
This commit is contained in:
@@ -6,6 +6,7 @@ import shutil
|
||||
import sys
|
||||
import re
|
||||
import traceback
|
||||
import json
|
||||
|
||||
try:
|
||||
curr_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
@@ -128,7 +129,22 @@ def get_all_components_dl_info(find_dirs, kconfigs):
|
||||
files_info = get_components_files(components, valid_components, kconfigs)
|
||||
return files_info
|
||||
|
||||
def rebuild(build_path, configs, verbose):
|
||||
def save_pkgs_info(sdk_path, files_info):
|
||||
info_path = os.path.join(sdk_path, "dl", "pkgs_info.json")
|
||||
count = 0
|
||||
for name, files in files_info.items():
|
||||
if len(files) > 0:
|
||||
count += len(files)
|
||||
for i, item in enumerate(files):
|
||||
item["pkg_path"] = os.path.join(sdk_path, "dl", "pkgs", item["path"], item["filename"])
|
||||
print("\n-------------------------------------------------------------------")
|
||||
print("-- All {} files info need to be downloaded saved to\n {}".format(count, info_path))
|
||||
print("-------------------------------------------------------------------\n")
|
||||
os.makedirs(os.path.dirname(info_path), exist_ok=True)
|
||||
with open(info_path, "w") as f:
|
||||
json.dump(files_info, f, indent=4)
|
||||
|
||||
def rebuild(build_path, configs, toolchain_info, verbose):
|
||||
os.makedirs(build_path, exist_ok=True)
|
||||
os.chdir(build_path)
|
||||
config_path = os.path.join(build_path, "config", "global_config.mk")
|
||||
@@ -142,6 +158,21 @@ def rebuild(build_path, configs, verbose):
|
||||
all_configs.update(kconfigs)
|
||||
find_dirs = get_components_find_dirs(configs)
|
||||
files_info = get_all_components_dl_info(find_dirs, all_configs)
|
||||
# add toolchain dl info
|
||||
dl_info = []
|
||||
if toolchain_info["url"]:
|
||||
dl_info = [
|
||||
{
|
||||
"url": toolchain_info['url'],
|
||||
"sha256sum": toolchain_info['sha256sum'],
|
||||
"filename": toolchain_info['filename'],
|
||||
"path": toolchain_info['path'],
|
||||
}
|
||||
]
|
||||
download_extract_files(dl_info)
|
||||
files_info["toolchain"] = dl_info
|
||||
|
||||
save_pkgs_info(configs["SDK_PATH"], files_info)
|
||||
for name, files in files_info.items():
|
||||
if len(files) > 0:
|
||||
print(f"\n-- Download files for component {name}")
|
||||
@@ -175,11 +206,11 @@ def rebuild(build_path, configs, verbose):
|
||||
f.write(code)
|
||||
|
||||
# build
|
||||
build(build_path, configs, verbose)
|
||||
build(build_path, configs, toolchain_info, verbose)
|
||||
|
||||
def build(build_path, configs, verbose):
|
||||
def build(build_path, configs, toolchain_info, verbose):
|
||||
if not os.path.exists(build_path):
|
||||
rebuild(build_path, configs, verbose)
|
||||
rebuild(build_path, configs, toolchain_info, verbose)
|
||||
return
|
||||
os.chdir(build_path)
|
||||
if verbose:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys, re, os
|
||||
import yaml
|
||||
import json
|
||||
|
||||
|
||||
# current dir path
|
||||
@@ -51,6 +52,21 @@ def select_multi_toolchain(board_name, toolchain_info, select_id):
|
||||
break
|
||||
return toolchain_info[select_idx-1]
|
||||
|
||||
def save_pkgs_info(sdk_path, files_info):
|
||||
info_path = os.path.join(sdk_path, "dl", "pkgs_info.json")
|
||||
count = 0
|
||||
for name, files in files_info.items():
|
||||
if len(files) > 0:
|
||||
count += len(files)
|
||||
for i, item in enumerate(files):
|
||||
item["pkg_path"] = os.path.join(sdk_path, "dl", "pkgs", item["path"], item["filename"])
|
||||
print("\n-------------------------------------------------------------------")
|
||||
print("-- All {} files info need to be downloaded saved to\n {}".format(count, info_path))
|
||||
print("-------------------------------------------------------------------\n")
|
||||
os.makedirs(os.path.dirname(info_path), exist_ok=True)
|
||||
with open(info_path, "w") as f:
|
||||
json.dump(files_info, f, indent=4)
|
||||
|
||||
def main(board_name, boards_dir, out_cmake, toolchain_id = None):
|
||||
|
||||
# parse mk file, find PLATFORM_.*?=y to get board name
|
||||
@@ -72,17 +88,6 @@ def main(board_name, boards_dir, out_cmake, toolchain_id = None):
|
||||
|
||||
check_toolchain_info(toolchain_info, board_name)
|
||||
|
||||
if toolchain_info["url"]:
|
||||
items = [
|
||||
{
|
||||
"url": toolchain_info['url'],
|
||||
"sha256sum": toolchain_info['sha256sum'],
|
||||
"filename": toolchain_info['filename'],
|
||||
"path": toolchain_info['path'],
|
||||
}
|
||||
]
|
||||
download_extract_files(items)
|
||||
|
||||
toolchain_bin_path = os.path.join(dl_dir, "extracted", toolchain_info['bin_path']) if toolchain_info['bin_path'] else None
|
||||
|
||||
# generate cmake file, set CONFIG_TOOLCHAIN_PATH and CONFIG_TOOLCHAIN_PREFIX
|
||||
|
||||
@@ -245,16 +245,8 @@ def download_extract_files(items):
|
||||
}
|
||||
'''
|
||||
check_download_items(items)
|
||||
# show items
|
||||
info_path = os.path.join(sdk_path, "dl", "pkgs_info.json")
|
||||
print("\n-------------------------------------------------------------------")
|
||||
print("-- All {} files info need to be downloaded saved to\n {}".format(len(items), info_path))
|
||||
for i, item in enumerate(items):
|
||||
item["pkg_path"] = os.path.join(sdk_path, "dl", "pkgs", item["path"], item["filename"])
|
||||
print("-------------------------------------------------------------------\n")
|
||||
os.makedirs(os.path.dirname(info_path), exist_ok=True)
|
||||
with open(info_path, "w") as f:
|
||||
json.dump(items, f, indent=4)
|
||||
|
||||
for item in items:
|
||||
pkg_path = item["pkg_path"]
|
||||
|
||||
@@ -365,9 +365,9 @@ def main(sdk_path, project_path):
|
||||
print("-- Build now")
|
||||
t = time.time()
|
||||
if args.no_gen:
|
||||
build(build_path, configs, args.verbose)
|
||||
build(build_path, configs, info, args.verbose)
|
||||
else:
|
||||
rebuild(build_path, configs, args.verbose)
|
||||
rebuild(build_path, configs, info, args.verbose)
|
||||
t = time.time() - t
|
||||
print("\n==================================")
|
||||
print("build time: {:.2f}s ({})".format(t, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))
|
||||
|
||||
@@ -43,7 +43,10 @@ def serve(pkg_path, port = 8888):
|
||||
ips = []
|
||||
for name in ifs:
|
||||
print(name)
|
||||
if name.startswith("lo") or name.startswith("docker") or name.startswith("veth"):
|
||||
name_lower = name.lower()
|
||||
if name_lower.startswith("lo") or name_lower.startswith("docker") or name_lower.startswith("veth") or name_lower.startswith("vmware"):
|
||||
continue
|
||||
if ni.AF_INET not in ni.ifaddresses(name): # interface not get ip
|
||||
continue
|
||||
ip = ni.ifaddresses(name)[ni.AF_INET][0]['addr']
|
||||
print("-- fimd ip: {}".format(ip))
|
||||
@@ -81,7 +84,14 @@ def serve(pkg_path, port = 8888):
|
||||
if local_ip.startswith("192.168."):
|
||||
final_ip = local_ip
|
||||
final_img = img_big
|
||||
final_img.show(title="Scan the QR code to install")
|
||||
final_img.save(os.path.join("dist", "tmp_qr_all.png"))
|
||||
try:
|
||||
final_img.show(title="Scan the QR code to install")
|
||||
except Exception:
|
||||
print("")
|
||||
print("------------------------")
|
||||
print("[Error] show image failed, you can remain see QR code at dist directory")
|
||||
print("------------------------")
|
||||
# url = "http://{}:{}".format(, vars["project_args"].port)
|
||||
app.run(host="0.0.0.0", port = local_port)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
__version__ = "1.2.2"
|
||||
__version__ = "1.2.4"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user