代码拉取完成,页面将自动刷新
同步操作将从 QuecPython/HeliosSDK 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- coding: utf-8 -*-
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
#
# 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, sys, json
if os.name == 'nt':
host_spec = ' HOST=win32'
else:
host_spec = ' HOST=linux'
argv = sys.argv
argc = len(argv)
error_occurred = False
build_log_dir = 'output/log'
build_log_file = 'build.log'
platform_json = 'system/platform/platform.json'
# error process
def error_proc(msg, prompt='CommandError', errtype='EARGV'):
global error_occurred
if not error_occurred:
print("! %s: [%s]: `%s'" % (prompt, errtype, msg))
error_occurred = True
# help cmd process
def help_proc():
print('Usage: helios <action> [<app>] [<at>] [<fw_name>]\n')
print('These are common commands used in various situations:')
print(' menuconfig - Do the project configuration')
print(' make <app> [[<at>] [<fw_name>]] - Do the compilation work')
print(' private_clean - Clean the app private target')
print(' clean - Clean the output directory')
print(' help - Show this help page')
# menuconfig cmd process
def menuconfig_proc():
cmd_str = 'make menuconfig PY=' + argv[1] + host_spec
os.system(cmd_str)
# clean cmd process
def clean_proc():
cmd_str = 'make clean PY=' + argv[1]
os.system(cmd_str)
# clean cmd process
def private_clean_proc():
cmd_str = 'make private_clean PY=' + argv[1]
os.system(cmd_str)
# get plat by board
def get_plat_by_board(board):
if not os.path.exists(platform_json):
error_proc(platform_json, 'NotFoundError', 'ECONF')
return ''
with open(platform_json, 'r', encoding='utf-8') as f:
platforms = json.load(f)
for k,v in platforms.items():
if board in v:
return k
return ''
# make cmd process
def make_proc():
global argv
global argc
got_plat = False
got_noos = False
got_verbose = False
got_seq_params = False
got_fw_name = False
app_entry = argv[3].replace('\\', '/')
app_entry_chr_list = list(app_entry)
for i in list(reversed(range(0, len(app_entry_chr_list)))):
if app_entry_chr_list[i-len(app_entry_chr_list)] == '/':
app_entry_chr_list[i-len(app_entry_chr_list)] = ''
else:
break
app_entry = ''.join(app_entry_chr_list)
if not len(app_entry) or not os.path.exists(os.path.abspath(app_entry)):
error_proc(argv[3], 'NotFoundError', 'EARGV')
return
cmd_str = argv[2] + ' APP_ENTRY=' + app_entry
if argc != 4:
for arg in argv[4:]:
if arg.find('@') >= 0: # sequential parameters process
if got_seq_params:
error_proc(arg)
return
else:
seq_params = arg.split('@')
for i in seq_params:
if i == '':
pass
elif get_plat_by_board(i):
if got_plat:
error_proc(i)
return
else:
cmd_str = cmd_str + ' PLAT=' + get_plat_by_board(i) + ' BOARD=' + i
got_plat = True
elif i == 'NOOS':
if got_noos:
error_proc(i)
return
else:
cmd_str = cmd_str + ' NOOS=y'
got_noos = True
elif i == 'verbose':
if got_verbose:
error_proc(i)
return
else:
cmd_str = cmd_str + ' V=1'
got_verbose = True
else:
error_proc(i)
return
got_seq_params = True
else:
if got_fw_name:
error_proc(arg)
return
else:
cmd_str = cmd_str + ' FW_NAME=' + arg
got_fw_name = True
cmd_str = cmd_str + host_spec
cmd_str = cmd_str + ' PY=' + argv[1]
cmd_str = cmd_str + ' 2>&1 | tee ' + build_log_dir + '/' + build_log_file
if not os.path.exists(build_log_dir):
os.makedirs(build_log_dir)
os.system(cmd_str)
# flash cmd process
def flash_proc():
global argv
global argc
if argc != 4:
error_proc('arguments count error')
return
else:
app_entry = argv[3].replace('\\', '/')
app_entry_chr_list = list(app_entry)
for i in list(reversed(range(0, len(app_entry_chr_list)))):
if app_entry_chr_list[i-len(app_entry_chr_list)] == '/':
app_entry_chr_list[i-len(app_entry_chr_list)] = ''
else:
break
app_entry = ''.join(app_entry_chr_list)
if not len(app_entry) or not os.path.exists(os.path.abspath(app_entry)):
error_proc(argv[3], 'NotFoundError', 'EARGV')
return
cmd_str = 'make flash APP_ENTRY=' + app_entry + ' PY=' + argv[1]
os.system(cmd_str)
# main entry:
if __name__ == '__main__':
if argc > 6:
error_proc(argv[6:], 'EARGC')
exit()
if argc == 2:
help_proc()
elif argc == 3:
if argv[2] == 'help':
help_proc()
elif argv[2] == 'menuconfig':
menuconfig_proc()
elif argv[2] == 'clean':
clean_proc()
elif argv[2] == 'private_clean':
private_clean_proc()
else:
error_proc(argv[2])
else:
if argv[2] == 'make':
make_proc()
elif argv[2] == 'flash':
flash_proc()
else:
error_proc(argv[2])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。