mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
improve update res scripts
This commit is contained in:
parent
352a52c468
commit
02f7310b92
@ -2,6 +2,7 @@
|
||||
|
||||
2023/07/05
|
||||
* 完善serial helper的文档(感谢俊杰提供补丁)。
|
||||
* 完善资源生成脚本(感谢智明提供补丁)。
|
||||
|
||||
2023/07/04
|
||||
* 完善conf\_node\_get\_child\_value。
|
||||
|
@ -4,6 +4,7 @@ import json
|
||||
import shutil
|
||||
import platform
|
||||
from SCons import Script
|
||||
import res_config
|
||||
|
||||
PLATFORM = platform.system()
|
||||
|
||||
@ -25,53 +26,29 @@ def mkdir_if_not_exist(fullpath):
|
||||
os.makedirs(fullpath)
|
||||
|
||||
|
||||
def load_project_json(filename):
|
||||
try:
|
||||
if sys.version_info >= (3, 0):
|
||||
with open(filename, 'r', encoding='utf8') as f:
|
||||
info = json.load(f)
|
||||
return info
|
||||
else:
|
||||
with open(filename, 'r') as f:
|
||||
info = json.load(f)
|
||||
return info
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def get_project_w(info, theme):
|
||||
return info['assets']['themes'][theme]['lcd']['width']
|
||||
return info.get_res_w(theme);
|
||||
|
||||
|
||||
def get_project_h(info, theme):
|
||||
return info['assets']['themes'][theme]['lcd']['height']
|
||||
return info.get_res_h(theme);
|
||||
|
||||
def get_project_lcd_orientation(info, theme):
|
||||
orientation = '0'
|
||||
if 'lcdOrientation' in info['assets'] :
|
||||
orientation = info['assets']['lcdOrientation']
|
||||
if 'orientation' in info['assets']['themes'][theme]['lcd'] :
|
||||
return info['assets']['themes'][theme]['lcd']['orientation']
|
||||
else :
|
||||
return orientation
|
||||
return info.get_res_lcd_orientation(theme);
|
||||
|
||||
def get_project_theme(info):
|
||||
return info['assets']['activedTheme']
|
||||
return info.get_res_actived_theme();
|
||||
|
||||
|
||||
def get_project_language(info):
|
||||
return info['assets']['defaultLanguage']
|
||||
return info.get_res_language()
|
||||
|
||||
|
||||
def get_project_country(info):
|
||||
return info['assets']['defaultCountry']
|
||||
return info.get_res_country()
|
||||
|
||||
def get_project_res_root(info):
|
||||
res_root = info['assets']['outputDir']
|
||||
if os.path.isabs(res_root):
|
||||
return res_root
|
||||
else:
|
||||
return '../' + res_root
|
||||
return os.path.abspath(info.get_res_res_root())
|
||||
|
||||
class AppHelperBase:
|
||||
def set_deps(self, DEPENDS_LIBS):
|
||||
@ -407,9 +384,20 @@ class AppHelperBase:
|
||||
APP_DEFAULT_FONT = 'default'
|
||||
APP_DEFAULT_LANGUAGE = 'zh'
|
||||
APP_DEFAULT_COUNTRY = 'CN'
|
||||
config = None;
|
||||
if 'res_config_script' in ARGUMENTS :
|
||||
config = res_config.set_res_config_by_script(ARGUMENTS['res_config_script'], ARGUMENTS.get('res_config_script_argv', ''))
|
||||
elif 'res_config_file' in ARGUMENTS :
|
||||
config_file = os.path.abspath(ARGUMENTS['res_config_file'])
|
||||
config = res_config.res_config()
|
||||
if not os.path.exists(config_file) or config_file == '':
|
||||
config_file = os.path.abspath('./project.json')
|
||||
config.load_file(config_file)
|
||||
else :
|
||||
config = res_config.res_config()
|
||||
config.load_file(os.path.abspath('./project.json'))
|
||||
|
||||
config = load_project_json('project.json')
|
||||
if config and 'assets' in config:
|
||||
if config != None :
|
||||
APP_THEME = get_project_theme(config)
|
||||
LCD_WIDTH = get_project_w(config, APP_THEME)
|
||||
LCD_HEIGHT = get_project_h(config, APP_THEME)
|
||||
@ -463,7 +451,7 @@ class AppHelperBase:
|
||||
tmp = LCD_WIDTH;
|
||||
LCD_WIDTH = LCD_HEIGHT;
|
||||
LCD_HEIGHT = tmp;
|
||||
|
||||
APP_RES_ROOT = APP_RES_ROOT.replace('\\','/')
|
||||
APP_CCFLAGS = ' -DLCD_WIDTH=' + LCD_WIDTH + ' -DLCD_HEIGHT=' + LCD_HEIGHT + ' '
|
||||
APP_CCFLAGS = APP_CCFLAGS + ' -DAPP_DEFAULT_FONT=\\\"' + APP_DEFAULT_FONT + '\\\" '
|
||||
APP_CCFLAGS = APP_CCFLAGS + ' -DAPP_THEME=\\\"' + APP_THEME + '\\\" '
|
||||
|
4
scripts/project_scripts/__init__.py
Normal file
4
scripts/project_scripts/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
APP_SCRIPTS_ROOT = os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, APP_SCRIPTS_ROOT)
|
140
scripts/project_scripts/app_helper.py
Normal file
140
scripts/project_scripts/app_helper.py
Normal file
@ -0,0 +1,140 @@
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import awtk_locator as locator
|
||||
from SCons import Script
|
||||
|
||||
def Helper(ARGUMENTS):
|
||||
locator.init(ARGUMENTS)
|
||||
|
||||
from app_helper_base import AppHelperBase
|
||||
return AppHelperBase(ARGUMENTS)
|
||||
|
||||
|
||||
def parse_needed_file(helper, root, file):
|
||||
dst = helper.APP_BIN_DIR
|
||||
if isinstance(file, list):
|
||||
src = os.path.abspath(os.path.join(root, file[0]))
|
||||
if len(file) > 1:
|
||||
dst = os.path.abspath(os.path.join(helper.APP_BIN_DIR, file[1]))
|
||||
else:
|
||||
src = os.path.abspath(os.path.join(root, file))
|
||||
return src, dst
|
||||
|
||||
|
||||
def clear_needed_files(helper, root, needed_files):
|
||||
for file in needed_files:
|
||||
src, dst = parse_needed_file(helper, root, file)
|
||||
|
||||
if os.path.isfile(src):
|
||||
if os.path.isdir(dst):
|
||||
dst = os.path.join(dst, os.path.basename(src))
|
||||
if os.path.exists(dst):
|
||||
os.remove(dst)
|
||||
print('Removed {}'.format(os.path.relpath(dst, helper.APP_ROOT)))
|
||||
elif os.path.isdir(src) and os.path.isdir(dst):
|
||||
dirs = []
|
||||
for _root, _dirs, _files in os.walk(src):
|
||||
for _file in _files:
|
||||
_dst = os.path.join(dst, os.path.relpath(os.path.join(_root, _file), src))
|
||||
if os.path.exists(_dst):
|
||||
os.remove(_dst)
|
||||
print('Removed {}'.format(os.path.relpath(_dst, helper.APP_ROOT)))
|
||||
for _dir in _dirs:
|
||||
dirs.append(os.path.join(dst, _dir))
|
||||
for _dir in dirs:
|
||||
try:
|
||||
os.rmdir(_dir)
|
||||
print('Removed {}'.format(os.path.relpath(_dir, helper.APP_ROOT)))
|
||||
except:
|
||||
none
|
||||
if not os.path.relpath(helper.APP_BIN_DIR, dst) == '.':
|
||||
try:
|
||||
os.rmdir(dst)
|
||||
print('Removed {}'.format(os.path.relpath(dst, helper.APP_ROOT)))
|
||||
except:
|
||||
none
|
||||
|
||||
|
||||
def copy_needed_files(helper, root, needed_files):
|
||||
for file in needed_files:
|
||||
src, dst = parse_needed_file(helper, root, file)
|
||||
|
||||
if os.path.isfile(src):
|
||||
if os.path.exists(src):
|
||||
if not os.path.exists(os.path.dirname(dst)):
|
||||
os.makedirs(os.path.dirname(dst))
|
||||
shutil.copy(src, dst)
|
||||
print(src + '==>' + dst)
|
||||
else:
|
||||
print('[NeededFiles]: Not found {src}', src)
|
||||
elif os.path.isdir(src):
|
||||
if os.path.exists(src):
|
||||
for _root, _dirs, _files in os.walk(src):
|
||||
for _file in _files:
|
||||
_src = os.path.join(_root, _file)
|
||||
_dst = os.path.join(dst, os.path.relpath(_src, src))
|
||||
if not os.path.exists(os.path.dirname(_dst)):
|
||||
os.makedirs(os.path.dirname(_dst))
|
||||
shutil.copy(_src, _dst)
|
||||
print(src + '==>' + dst)
|
||||
else:
|
||||
print('[NeededFiles]: Not found {src}', src)
|
||||
|
||||
|
||||
def prepare_depends_libs(ARGUMENTS, helper, libs):
|
||||
if ARGUMENTS.get('PREPARE_DEPENDS', '').lower().startswith('f'):
|
||||
return
|
||||
|
||||
args = ' AWTK_ROOT=\"{}\"'.format(helper.AWTK_ROOT)
|
||||
if helper.MVVM_ROOT:
|
||||
args += ' MVVM_ROOT=\"{}\"'.format(helper.MVVM_ROOT)
|
||||
|
||||
if 'APP_BIN_DIR' in ARGUMENTS:
|
||||
helper.APP_BIN_DIR = os.path.abspath(ARGUMENTS['APP_BIN_DIR'])
|
||||
args += ' APP_BIN_DIR=\"{}\"'.format(helper.APP_BIN_DIR.replace('\\', '/'))
|
||||
if not os.path.exists(helper.APP_BIN_DIR):
|
||||
os.makedirs(helper.APP_BIN_DIR)
|
||||
else:
|
||||
args += ' APP_BIN_DIR=\"{}\"'.format(os.path.abspath(helper.APP_BIN_DIR).replace('\\', '/'))
|
||||
|
||||
for key in ARGUMENTS:
|
||||
if not key == 'AWTK_ROOT' and not key == 'MVVM_ROOT' and not key == 'APP_BIN_DIR' :
|
||||
if ' ' in ARGUMENTS[key]:
|
||||
args += ' {}=\"{}\"'.format(key, ARGUMENTS[key])
|
||||
else:
|
||||
args += ' {}={}'.format(key, ARGUMENTS[key])
|
||||
|
||||
num_jobs_str = ''
|
||||
num_jobs = Script.GetOption('num_jobs')
|
||||
if num_jobs > 1:
|
||||
num_jobs_str = ' -j' + str(num_jobs)
|
||||
|
||||
clean_str = ''
|
||||
if Script.GetOption('clean'):
|
||||
clean_str = ' -c '
|
||||
|
||||
for lib in libs:
|
||||
if 'root' in lib and os.path.exists(lib['root'] + '/SConstruct'):
|
||||
cmd = 'cd ' + lib['root'] + ' && scons' + clean_str + num_jobs_str + args
|
||||
print('\n*******************************************************************************')
|
||||
print('[Dependencies]: {}'.format(lib['root']))
|
||||
print('*******************************************************************************\n')
|
||||
result = os.system(cmd)
|
||||
if not result == 0:
|
||||
sys.exit(result)
|
||||
|
||||
if 'needed_files' in lib:
|
||||
if Script.GetOption('clean'):
|
||||
clear_needed_files(helper, lib['root'], lib['needed_files'])
|
||||
else:
|
||||
copy_needed_files(helper, lib['root'], lib['needed_files'])
|
||||
|
||||
|
||||
def helper_has_func(helper, func_name):
|
||||
return False;
|
||||
|
||||
|
||||
def helper_run_func(helper, func_name, argv):
|
||||
return None;
|
||||
|
111
scripts/project_scripts/release.py
Normal file
111
scripts/project_scripts/release.py
Normal file
@ -0,0 +1,111 @@
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
import shutil
|
||||
import json
|
||||
import collections
|
||||
|
||||
|
||||
def join_path(root, subdir):
|
||||
return os.path.normpath(os.path.join(root, subdir))
|
||||
|
||||
|
||||
OS_NAME = platform.system()
|
||||
PRJ_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
OUTPUT_DIR = join_path(PRJ_DIR, 'release')
|
||||
BIN_DIR = join_path(PRJ_DIR, 'bin')
|
||||
|
||||
|
||||
def read_file(filename):
|
||||
content = ''
|
||||
if sys.version_info >= (3, 0):
|
||||
with open(filename, 'r', encoding='utf8') as f:
|
||||
content = f.read()
|
||||
else:
|
||||
with open(filename, 'r') as f:
|
||||
content = f.read()
|
||||
return content
|
||||
|
||||
|
||||
def to_file_system_coding(s):
|
||||
if sys.version_info >= (3, 0): return s
|
||||
coding = sys.getfilesystemencoding()
|
||||
return s.encode(coding)
|
||||
|
||||
|
||||
def init_project_config():
|
||||
global CONFIG
|
||||
json_path = join_path(PRJ_DIR, 'project.json')
|
||||
if not os.path.exists(json_path):
|
||||
return
|
||||
|
||||
content = read_file(json_path)
|
||||
CONFIG = json.loads(content, object_pairs_hook=collections.OrderedDict)
|
||||
|
||||
|
||||
def get_args(args, longsopts = []) :
|
||||
list_opts = []
|
||||
for arg in args:
|
||||
if arg.startswith('--') :
|
||||
tmp_opt = ''
|
||||
for opt in longsopts:
|
||||
if arg.find(opt) > 0 :
|
||||
tmp_opt = opt
|
||||
break
|
||||
if tmp_opt != '' :
|
||||
list_opts.append(arg.split(tmp_opt)[1])
|
||||
continue
|
||||
else :
|
||||
print(arg + " not find command, command :")
|
||||
print(longsopts)
|
||||
sys.exit()
|
||||
return list_opts
|
||||
|
||||
|
||||
def release():
|
||||
if not os.path.exists(OUTPUT_DIR):
|
||||
os.makedirs(OUTPUT_DIR)
|
||||
|
||||
init_project_config()
|
||||
|
||||
assets = CONFIG['assets']
|
||||
if 'outputDir' in assets:
|
||||
res_root = to_file_system_coding(assets['outputDir'])
|
||||
assets_root = join_path(PRJ_DIR, res_root + '/assets')
|
||||
|
||||
exeName = CONFIG['appExeName']
|
||||
if exeName == '':
|
||||
exeName = 'demo'
|
||||
exeName = exeName + '.exe' if OS_NAME == 'Windows' else exeName
|
||||
|
||||
copyExe(exeName)
|
||||
copyAssets(assets_root)
|
||||
cleanFiles()
|
||||
|
||||
|
||||
def copyExe(exeName):
|
||||
output_bin_dir = join_path(OUTPUT_DIR, 'bin')
|
||||
common.copyFile(BIN_DIR, exeName, output_bin_dir, exeName)
|
||||
common.copySharedLib(BIN_DIR, output_bin_dir)
|
||||
|
||||
os.chmod(join_path(output_bin_dir, exeName), 0o755)
|
||||
|
||||
|
||||
def copyAssets(assets_root):
|
||||
common.copyFiles(assets_root, '', OUTPUT_DIR, 'assets/')
|
||||
|
||||
|
||||
def cleanFiles():
|
||||
assets = CONFIG['assets']
|
||||
if 'themes' not in assets:
|
||||
return
|
||||
|
||||
themes = assets['themes']
|
||||
|
||||
for theme in themes:
|
||||
d = join_path(OUTPUT_DIR, 'assets/' + theme + '/inc')
|
||||
shutil.rmtree(d, True)
|
||||
|
||||
|
||||
import release_common as common
|
||||
release()
|
327
scripts/res_config.py
Normal file
327
scripts/res_config.py
Normal file
@ -0,0 +1,327 @@
|
||||
import os
|
||||
import io
|
||||
import sys
|
||||
import json
|
||||
|
||||
def json_obj_load_file(file_path) :
|
||||
obj = None;
|
||||
if os.path.exists(file_path) :
|
||||
try :
|
||||
with io.open(file_path, 'r', encoding='utf-8') as file :
|
||||
obj = json.load(file);
|
||||
except Exception as e :
|
||||
print(e)
|
||||
return obj;
|
||||
|
||||
def json_obj_save_file(obj, file_path) :
|
||||
dir = os.path.dirname(file_path);
|
||||
if os.path.exists(dir) :
|
||||
try :
|
||||
with io.open(file_path, 'w', encoding='utf-8') as file :
|
||||
json.dump(obj, file, indent=4, ensure_ascii=False)
|
||||
except Exception as e :
|
||||
print(e)
|
||||
else :
|
||||
print(dir + ' is not exists')
|
||||
|
||||
def get_dict_value(dict, key, default_value) :
|
||||
if key in dict:
|
||||
return dict[key]
|
||||
else :
|
||||
return default_value
|
||||
|
||||
def set_res_config_by_script(script_path, res_config_script_argv):
|
||||
script_path = os.path.abspath(script_path)
|
||||
if os.path.exists(script_path) :
|
||||
import importlib
|
||||
script_dir = os.path.dirname(script_path)
|
||||
file_name = os.path.basename(script_path)
|
||||
module_name, ext = os.path.splitext(file_name)
|
||||
sys.path.insert(0, script_dir)
|
||||
res_config_script = importlib.import_module(module_name)
|
||||
sys.path.remove(script_dir)
|
||||
if hasattr(res_config_script, "get_res_config") :
|
||||
return res_config_script.get_res_config(res_config_script_argv)
|
||||
else :
|
||||
sys.exit(script_path + ' script not found get_res_config function')
|
||||
else :
|
||||
sys.exit('res_config_file sopt not found :' + script_path)
|
||||
return None
|
||||
|
||||
class res_multidict(dict) :
|
||||
def __getitem__(self, item) :
|
||||
try :
|
||||
return dict.__getitem__(self, item)
|
||||
except KeyError :
|
||||
value = self[item] = type(self)()
|
||||
return value
|
||||
|
||||
def deep_copy_by_dict(self, src, dst) :
|
||||
for key in dst :
|
||||
if isinstance(dst[key], dict) :
|
||||
self.deep_copy_by_dict(src[key], dst[key])
|
||||
elif isinstance(dst[key], list) :
|
||||
if not key in src :
|
||||
src[key] = list();
|
||||
src[key] += dst[key].copy();
|
||||
else :
|
||||
src[key] = dst[key];
|
||||
|
||||
def deep_copy(self, dst) :
|
||||
self.deep_copy_by_dict(self, dst);
|
||||
|
||||
class res_config:
|
||||
assets = None
|
||||
inc_res = True
|
||||
inc_bitmap = True
|
||||
inc_bitmap_font = True
|
||||
|
||||
def __init__(self) :
|
||||
self.assets = res_multidict();
|
||||
|
||||
def get_res_type_info_by_const_and_load_from(self, assets, inc_res, inc_bitmap, inc_bitmap_font) :
|
||||
const = get_dict_value(assets, 'const', None)
|
||||
loadFrom = get_dict_value(assets, 'loadFrom', None)
|
||||
if loadFrom != None and loadFrom == 'fs':
|
||||
inc_res = False
|
||||
inc_bitmap = False
|
||||
inc_bitmap_font = False
|
||||
elif const != None and const != 'all_data':
|
||||
if const == 'resource_data':
|
||||
inc_bitmap = False
|
||||
inc_bitmap_font = False
|
||||
else:
|
||||
inc_res = False
|
||||
|
||||
return inc_res, inc_bitmap, inc_bitmap_font
|
||||
|
||||
def has_themes(self) :
|
||||
if 'themes' in self.assets :
|
||||
return len(self.assets['themes']) > 0;
|
||||
return False
|
||||
|
||||
def has_theme(self, theme_name) :
|
||||
if 'themes' in self.assets :
|
||||
return theme_name in self.assets['themes'];
|
||||
return False
|
||||
|
||||
def has_lcd(self, theme_name) :
|
||||
if self.has_theme(theme_name) :
|
||||
return 'lcd' in self.assets['themes'][theme_name];
|
||||
return False
|
||||
|
||||
def has_font(self, theme_name, font_name) :
|
||||
if self.has_theme(theme_name) :
|
||||
if 'fonts' in self.assets['themes'][theme_name] :
|
||||
return font_name in self.assets['themes'][theme_name]['fonts']
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
def load_file(self, file_path) :
|
||||
obj = json_obj_load_file(file_path);
|
||||
if obj != None and 'assets' in obj :
|
||||
assets = obj['assets']
|
||||
self.assets.deep_copy(assets)
|
||||
self.inc_res, self.inc_bitmap, self.inc_bitmap_font = self.get_res_type_info_by_const_and_load_from(assets, self.inc_res, self.inc_bitmap, self.inc_bitmap_font)
|
||||
else :
|
||||
print('not found or not parsered ' + file_path + ', so use default config')
|
||||
def save_file(self, file_path) :
|
||||
res_config_dict = {
|
||||
'assets' : self.assets
|
||||
}
|
||||
json_obj_save_file(res_config_dict, file_path);
|
||||
|
||||
def reset_default(self) :
|
||||
self.set_res_actived_theme()
|
||||
self.set_res_res_root()
|
||||
self.set_res_load_from()
|
||||
self.set_res_const()
|
||||
self.set_res_dpi()
|
||||
self.set_res_language()
|
||||
self.set_res_country()
|
||||
self.set_res_lcd_orientation()
|
||||
self.set_res_lcd_fast_rotation_mode()
|
||||
|
||||
self.set_res_actived_system_bar()
|
||||
self.set_res_actived_bottom_system_bar()
|
||||
self.set_res_packaged()
|
||||
self.set_res_font_value()
|
||||
self.set_res_font_value(key='text')
|
||||
self.set_res_font_bpp()
|
||||
|
||||
self.set_res_w()
|
||||
self.set_res_h()
|
||||
self.set_res_color_depth()
|
||||
self.set_res_color_format()
|
||||
|
||||
|
||||
def get_res_themes_key(self) :
|
||||
if self.has_themes() :
|
||||
return self.assets['themes'].keys()
|
||||
return list()
|
||||
|
||||
def get_res_fonts_key(self, theme_name) :
|
||||
if self.has_themes() :
|
||||
return self.assets[theme_name]['fonts'].keys()
|
||||
return list()
|
||||
|
||||
def get_res_font_size_key(self, theme_name, font_name) :
|
||||
key = []
|
||||
if self.has_themes() :
|
||||
for name in self.assets[theme_name]['fonts'][font_name].keys() :
|
||||
if name != 'text' or name != 'bpp' :
|
||||
key.append(name)
|
||||
return key
|
||||
|
||||
def set_res_lcd_value(self, theme_name, key, value) :
|
||||
self.assets['themes'][theme_name]['lcd'][key] = value
|
||||
|
||||
def get_res_lcd_value(self, theme_name, key, default_value) :
|
||||
if self.has_lcd(theme_name) :
|
||||
return get_dict_value(self.assets['themes'][theme_name]['lcd'], key, default_value)
|
||||
return default_value;
|
||||
|
||||
def set_res_theme_value(self, theme_name, key, value) :
|
||||
self.assets['themes'][theme_name][key] = value
|
||||
|
||||
def get_res_theme_value(self, theme_name, key, default_value) :
|
||||
if self.has_theme(theme_name) :
|
||||
return get_dict_value(self.assets['themes'][theme_name], key, default_value)
|
||||
return default_value;
|
||||
|
||||
def set_res_font_bpp(self, theme_name = 'default', font_name = 'default', value = '8bits') :
|
||||
self.assets['themes'][theme_name]['fonts'][font_name]['bpp'] = value
|
||||
|
||||
def get_res_font_bpp(self, theme_name, font_name, default_value) :
|
||||
if self.has_font(theme_name, font_name) :
|
||||
return get_dict_value(self.assets['themes'][theme_name]['fonts'][font_name], 'bpp', default_value)
|
||||
return default_value;
|
||||
|
||||
def set_res_font_value(self, theme_name = 'default', font_name = 'default', key = '18', value = '') :
|
||||
self.assets['themes'][theme_name]['fonts'][font_name][key] = value
|
||||
|
||||
def get_res_font_value(self, theme_name, font_name, key, default_value) :
|
||||
if self.has_font(theme_name, font_name) :
|
||||
return get_dict_value(self.assets['themes'][theme_name]['fonts'][font_name], key, default_value)
|
||||
return default_value;
|
||||
|
||||
def set_res_packaged(self, packaged = True, theme_name = 'default') :
|
||||
return self.set_res_theme_value(theme_name, 'packaged', packaged);
|
||||
|
||||
def get_res_packaged(self, theme_name = 'default') :
|
||||
return self.get_res_theme_value(theme_name, 'packaged', True);
|
||||
|
||||
def set_res_actived_bottom_system_bar(self, bottom_system_bar='', theme_name = 'default') :
|
||||
return self.set_res_theme_value(theme_name, 'activedBottomSystemBar', bottom_system_bar);
|
||||
|
||||
def get_res_actived_bottom_system_bar(self, theme_name = 'default') :
|
||||
return self.get_res_theme_value(theme_name, 'activedBottomSystemBar', '');
|
||||
|
||||
def set_res_actived_system_bar(self, system_bar = '', theme_name = 'default') :
|
||||
return self.set_res_theme_value(theme_name, 'activedSystemBar', system_bar);
|
||||
|
||||
def get_res_actived_system_bar(self, theme_name = 'default') :
|
||||
return self.get_res_theme_value(theme_name, 'activedSystemBar', '');
|
||||
|
||||
def set_res_color_depth(self, color_depth ='rgba', theme_name = 'default') :
|
||||
return self.set_res_lcd_value(theme_name, 'colorDepth', color_depth);
|
||||
|
||||
def get_res_color_depth(self, theme_name = 'default') :
|
||||
return self.get_res_lcd_value(theme_name, 'colorDepth', 'rgba');
|
||||
|
||||
def set_res_color_format(self, color_format ='rgba', theme_name = 'default') :
|
||||
return self.set_res_lcd_value(theme_name, 'colorFormat', color_format);
|
||||
|
||||
def get_res_color_format(self, theme_name = 'default') :
|
||||
return self.get_res_lcd_value(theme_name, 'colorFormat', 'rgba');
|
||||
|
||||
def set_res_w(self, w = '800', theme_name = 'default'):
|
||||
self.set_res_lcd_value(theme_name, 'width', w)
|
||||
|
||||
def get_res_w(self, theme_name):
|
||||
return self.get_res_lcd_value(theme_name, 'width', '800');
|
||||
|
||||
def set_res_h(self, h = '480', theme_name = 'default'):
|
||||
self.set_res_lcd_value(theme_name, 'height', h)
|
||||
|
||||
def get_res_h(self, theme_name):
|
||||
return self.get_res_lcd_value(theme_name, 'height', '480');
|
||||
|
||||
def set_res_lcd_fast_rotation_mode(self, lcd_fast_rotation_mode = False):
|
||||
self.assets['lcdFastRotationMode'] = lcd_fast_rotation_mode
|
||||
|
||||
def get_res_lcd_fast_rotation_mode(self):
|
||||
return get_dict_value(self.assets, 'lcdFastRotationMode', False);
|
||||
|
||||
def set_res_lcd_orientation(self, orientation = '0', theme_name = None):
|
||||
if theme_name == None :
|
||||
self.assets['lcdOrientation'] = orientation
|
||||
else :
|
||||
self.assets['themes'][theme_name]['lcd']['orientation'] = orientation
|
||||
|
||||
def get_res_lcd_orientation(self, theme_name = ''):
|
||||
orientation = '0'
|
||||
if theme_name == '' and 'lcdOrientation' in self.assets :
|
||||
orientation = self.assets['lcdOrientation']
|
||||
elif theme_name != '' and self.has_lcd(theme_name) and 'orientation' in self.assets['themes'][theme_name]['lcd'] :
|
||||
orientation = self.assets['themes'][theme_name]['lcd']['orientation']
|
||||
return orientation
|
||||
|
||||
def set_res_actived_theme(self, actived_theme = 'default'):
|
||||
self.assets['activedTheme'] = actived_theme
|
||||
|
||||
def get_res_actived_theme(self):
|
||||
return get_dict_value(self.assets, 'activedTheme', 'default')
|
||||
|
||||
def set_res_dpi(self, dpi = 'x1'):
|
||||
self.assets['screenDPR'] = dpi
|
||||
|
||||
def get_res_dpi(self):
|
||||
return get_dict_value(self.assets, 'screenDPR', 'x1')
|
||||
|
||||
def set_res_language(self, language = 'zh'):
|
||||
self.assets['defaultLanguage'] = language
|
||||
|
||||
def get_res_language(self):
|
||||
return get_dict_value(self.assets, 'defaultLanguage', 'zh')
|
||||
|
||||
def set_res_country(self, country = 'CN'):
|
||||
self.assets['defaultCountry'] = country
|
||||
|
||||
def get_res_country(self):
|
||||
return get_dict_value(self.assets, 'defaultCountry', 'CN')
|
||||
|
||||
def set_res_res_root(self, res_root = 'res'):
|
||||
self.assets['outputDir'] = res_root
|
||||
|
||||
def get_res_res_root(self):
|
||||
res_root = get_dict_value(self.assets, 'outputDir', 'res')
|
||||
if os.path.isabs(res_root):
|
||||
return res_root
|
||||
else:
|
||||
return './' + res_root
|
||||
|
||||
def set_res_load_from(self, load_from = 'any'):
|
||||
self.assets['loadFrom'] = load_from
|
||||
self.inc_res, self.inc_bitmap, self.inc_bitmap_font = self.get_res_type_info_by_const_and_load_from(self.assets, self.inc_res, self.inc_bitmap, self.inc_bitmap_font)
|
||||
|
||||
def get_res_load_from(self):
|
||||
return get_dict_value(self.assets, 'loadFrom', 'any')
|
||||
|
||||
def set_res_const(self, const = 'all_data'):
|
||||
self.assets['const'] = const
|
||||
self.inc_res, self.inc_bitmap, self.inc_bitmap_font = self.get_res_type_info_by_const_and_load_from(self.assets, self.inc_res, self.inc_bitmap, self.inc_bitmap_font)
|
||||
|
||||
def get_res_load_from(self):
|
||||
return get_dict_value(self.assets, 'const', 'all_data')
|
||||
|
||||
def get_inc_res(self) :
|
||||
return self.inc_res
|
||||
|
||||
def get_inc_bitmap(self) :
|
||||
return self.inc_bitmap
|
||||
|
||||
def get_inc_bitmap_font(self) :
|
||||
return self.inc_bitmap_font
|
@ -96,7 +96,7 @@ def gen_res(name = 'assets', is_excluded_file_func = default_is_excluded_file_fu
|
||||
|
||||
|
||||
AWTK_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
updater.run(AWTK_ROOT, default_is_excluded_file_func)
|
||||
updater.run(AWTK_ROOT, default_is_excluded_file_func, True)
|
||||
|
||||
gen_res('assets_old', is_demouiold_excluded_file)
|
||||
gen_res('assets_all', is_null_file)
|
||||
|
@ -7,11 +7,15 @@ import collections
|
||||
|
||||
# AWTK_ROOT/scripts/update_res_common.py
|
||||
import update_res_common as common
|
||||
import res_config
|
||||
|
||||
RES_CONFIG = None
|
||||
RES_OUTPUT_DIR='./res'
|
||||
|
||||
def get_theme(i):
|
||||
return THEMES[i]
|
||||
|
||||
def use_theme_config_from_project_json():
|
||||
def use_theme_config_from_res_config(res_config_path, config = None):
|
||||
global DPI
|
||||
global THEMES
|
||||
global OUTPUT_ROOT
|
||||
@ -21,64 +25,36 @@ def use_theme_config_from_project_json():
|
||||
global APP_ROOT
|
||||
global LCD_ORIENTATION
|
||||
global LCD_FAST_ROTATION_MODE
|
||||
content = None
|
||||
|
||||
project_json = common.join_path(APP_ROOT, 'project.json')
|
||||
if not os.path.exists(project_json):
|
||||
print('project.json is not exists.')
|
||||
if config == None :
|
||||
config_json = common.join_path(APP_ROOT, res_config_path)
|
||||
if not os.path.exists(config_json) or res_config_path == '':
|
||||
config_json = common.join_path(APP_ROOT, 'project.json')
|
||||
if not os.path.exists(config_json) :
|
||||
print(config_json + ' is not exists.')
|
||||
return
|
||||
|
||||
content = common.read_file(project_json)
|
||||
content = json.loads(content, object_pairs_hook=collections.OrderedDict)
|
||||
|
||||
if not isinstance(content, dict):
|
||||
return
|
||||
|
||||
if 'assets' not in content:
|
||||
return
|
||||
assets = content['assets']
|
||||
|
||||
if 'outputDir' in assets:
|
||||
OUTPUT_ROOT = common.to_file_system_coding(assets['outputDir'])
|
||||
OUTPUT_ROOT = common.join_path(APP_ROOT, OUTPUT_ROOT+'/assets')
|
||||
|
||||
if 'activedTheme' in assets:
|
||||
APP_THEME = assets['activedTheme']
|
||||
|
||||
if LCD_FAST_ROTATION_MODE == None :
|
||||
if 'lcdFastRotationMode' in assets:
|
||||
LCD_FAST_ROTATION_MODE = assets['lcdFastRotationMode']
|
||||
content = res_config.res_config()
|
||||
content.load_file(config_json)
|
||||
else :
|
||||
LCD_FAST_ROTATION_MODE = False
|
||||
content = config;
|
||||
|
||||
if LCD_ORIENTATION == '' :
|
||||
if 'lcdOrientation' in assets:
|
||||
LCD_ORIENTATION = assets['lcdOrientation']
|
||||
else :
|
||||
LCD_ORIENTATION = '0'
|
||||
OUTPUT_ROOT = common.join_path(APP_ROOT, common.join_path(content.get_res_res_root(), 'assets'))
|
||||
APP_THEME = content.get_res_actived_theme()
|
||||
LCD_FAST_ROTATION_MODE = content.get_res_lcd_fast_rotation_mode()
|
||||
LCD_ORIENTATION = content.get_res_lcd_orientation()
|
||||
|
||||
if 'themes' not in assets:
|
||||
DPI = content.get_res_dpi()
|
||||
IS_GENERATE_INC_RES = content.get_inc_res()
|
||||
IS_GENERATE_INC_BITMAP = content.get_inc_bitmap()
|
||||
|
||||
if not content.has_themes():
|
||||
return
|
||||
|
||||
if len(assets['themes']) == 0:
|
||||
return
|
||||
|
||||
if 'loadFrom' in assets and assets['loadFrom'] == 'fs':
|
||||
IS_GENERATE_INC_BITMAP = False
|
||||
IS_GENERATE_INC_RES = False
|
||||
elif 'const' in assets and assets['const'] != 'all_data':
|
||||
if assets['const'] == 'resource_data':
|
||||
IS_GENERATE_INC_BITMAP = False
|
||||
else:
|
||||
IS_GENERATE_INC_RES = False
|
||||
|
||||
if 'screenDPR' in assets:
|
||||
DPI = assets['screenDPR']
|
||||
|
||||
for theme_name, theme_setting in assets['themes'].items():
|
||||
theme_name = common.to_file_system_coding(theme_name)
|
||||
color_format = theme_setting['lcd']['colorFormat']
|
||||
color_depth = theme_setting['lcd']['colorDepth']
|
||||
|
||||
for theme_name in content.get_res_themes_key() :
|
||||
color_format = content.get_res_color_format(theme_name)
|
||||
color_depth = content.get_res_color_depth(theme_name)
|
||||
if color_format == 'MONO':
|
||||
imagegen_options = 'mono'
|
||||
elif color_format == 'BGR(A)':
|
||||
@ -93,29 +69,27 @@ def use_theme_config_from_project_json():
|
||||
imagegen_options = 'rgba'
|
||||
|
||||
if IS_GENERATE_INC_BITMAP:
|
||||
font = theme_setting['fonts']
|
||||
config_dir = common.join_path(ASSETS_ROOT, theme_name+'/fonts/config')
|
||||
config_dir = common.join_path(ASSETS_ROOT, common.join_path(theme_name, '/fonts/config'))
|
||||
common.remove_dir(config_dir)
|
||||
common.make_dirs(config_dir)
|
||||
for font_name, font_setting in theme_setting['fonts'].items():
|
||||
for font_size, text in font_setting.items():
|
||||
if font_size.isdigit():
|
||||
for font_name in content.get_res_fonts_key(theme_name):
|
||||
for font_size in content.get_res_font_size_key(theme_name, font_name):
|
||||
font_name = common.to_file_system_coding(font_name)
|
||||
font_size = common.to_file_system_coding(font_size)
|
||||
filename = common.join_path(config_dir, font_name+'_'+font_size+'.txt')
|
||||
common.write_file(filename, text)
|
||||
common.write_file(filename, content.get_res_font_value(theme_name, font_name, font_size))
|
||||
|
||||
theme = {'name': theme_name, 'imagegen_options': imagegen_options, 'packaged': theme_setting['packaged']}
|
||||
theme = {'name': theme_name, 'imagegen_options': imagegen_options, 'packaged': content.get_res_packaged(theme_name)}
|
||||
if theme_name == 'default':
|
||||
THEMES.insert(0, theme)
|
||||
else:
|
||||
THEMES.append(theme)
|
||||
|
||||
|
||||
def use_default_theme_config():
|
||||
def use_default_theme_config(res_config_path, res_config = None):
|
||||
global THEMES
|
||||
|
||||
use_theme_config_from_project_json()
|
||||
use_theme_config_from_res_config(res_config_path, res_config)
|
||||
|
||||
if len(THEMES) == 0:
|
||||
if os.path.isdir(ASSETS_ROOT):
|
||||
@ -153,7 +127,19 @@ def on_generate_res_event():
|
||||
def getopt(args):
|
||||
return common.get_args(args);
|
||||
|
||||
def run(awtk_root, is_excluded_file_handler = None):
|
||||
def set_res_config(config) :
|
||||
global RES_CONFIG
|
||||
RES_CONFIG = config
|
||||
|
||||
def set_res_config_by_script(script_path, res_config_script_argv):
|
||||
return set_res_config(res_config.set_res_config_by_script(script_path, res_config_script_argv))
|
||||
|
||||
def get_dict_value(dict, key, default_value) :
|
||||
if key in dict :
|
||||
return dict[key]
|
||||
return default_value
|
||||
|
||||
def run(awtk_root, is_excluded_file_handler = None, is_new_usage = False) :
|
||||
global DPI
|
||||
global AWTK_ROOT
|
||||
global TOOLS_ROOT
|
||||
@ -166,12 +152,40 @@ def run(awtk_root, is_excluded_file_handler = None):
|
||||
global IS_GENERATE_INC_BITMAP
|
||||
global LCD_ORIENTATION
|
||||
global LCD_FAST_ROTATION_MODE
|
||||
global RES_CONFIG
|
||||
|
||||
common.show_usage(is_new_usage);
|
||||
|
||||
GDPI=''
|
||||
TMP_APP_ROOT = ''
|
||||
RES_OUTPUT_DIR=''
|
||||
IMAGEGEN_OPTIONS=''
|
||||
LCD_ORIENTATION=''
|
||||
LCD_FAST_ROTATION_MODE=None
|
||||
sys_args = common.get_args(sys.argv[1:])
|
||||
TMP_LCD_ORIENTATION=''
|
||||
RES_CONFIG_JSON_PATH=''
|
||||
TMP_LCD_FAST_ROTATION_MODE=None
|
||||
args = sys.argv[1:];
|
||||
if common.is_all_sopts_args(args) :
|
||||
longsots_dict = common.get_longsopts_args(args)
|
||||
common.set_action(longsots_dict['action'])
|
||||
|
||||
awtk_root = get_dict_value(longsots_dict, 'awtk_root', awtk_root)
|
||||
GDPI = get_dict_value(longsots_dict, 'dpi', GDPI)
|
||||
IMAGEGEN_OPTIONS = get_dict_value(longsots_dict, 'image_options', IMAGEGEN_OPTIONS)
|
||||
TMP_LCD_ORIENTATION = get_dict_value(longsots_dict, 'lcd_orientation', TMP_LCD_ORIENTATION)
|
||||
TMP_LCD_FAST_ROTATION_MODE = get_dict_value(longsots_dict, 'lcd_enable_fast_rotation', TMP_LCD_FAST_ROTATION_MODE)
|
||||
RES_CONFIG_JSON_PATH = get_dict_value(longsots_dict, 'res_config_file', RES_CONFIG_JSON_PATH)
|
||||
RES_OUTPUT_DIR = get_dict_value(longsots_dict, 'output_dir', RES_OUTPUT_DIR)
|
||||
TMP_APP_ROOT = get_dict_value(longsots_dict, 'app_root', TMP_APP_ROOT)
|
||||
|
||||
if 'res_config_script' in longsots_dict :
|
||||
res_config_script_argv = ''
|
||||
res_config_script = longsots_dict['res_config_script']
|
||||
if 'res_config_script_argv' in longsots_dict :
|
||||
res_config_script_argv = longsots_dict['res_config_script_argv']
|
||||
set_res_config_by_script(res_config_script, res_config_script_argv)
|
||||
|
||||
else :
|
||||
sys_args = common.get_args(args)
|
||||
if len(sys_args) > 0 :
|
||||
common.set_action(sys_args[0])
|
||||
if len(sys_args) > 1:
|
||||
@ -179,28 +193,40 @@ def run(awtk_root, is_excluded_file_handler = None):
|
||||
if len(sys_args) > 2:
|
||||
IMAGEGEN_OPTIONS = sys_args[2]
|
||||
if len(sys_args) > 3:
|
||||
LCD_ORIENTATION = sys_args[3]
|
||||
LCD_FAST_ROTATION_MODE = False
|
||||
TMP_LCD_ORIENTATION = sys_args[3]
|
||||
TMP_LCD_FAST_ROTATION_MODE = False
|
||||
|
||||
AWTK_ROOT = awtk_root
|
||||
APP_ROOT = common.getcwd()
|
||||
action = common.get_action()
|
||||
if TMP_APP_ROOT == '' :
|
||||
APP_ROOT = common.getcwd()
|
||||
if APP_ROOT.endswith('scripts'):
|
||||
APP_ROOT = os.path.dirname(APP_ROOT)
|
||||
else :
|
||||
APP_ROOT = TMP_APP_ROOT
|
||||
|
||||
os.chdir(APP_ROOT)
|
||||
|
||||
DPI = 'x1'
|
||||
THEMES = []
|
||||
APP_THEME = 'default'
|
||||
LCD_ORIENTATION = ''
|
||||
OUTPUT_ROOT = './res'
|
||||
IS_GENERATE_INC_RES = True
|
||||
IS_GENERATE_INC_BITMAP = True
|
||||
LCD_FAST_ROTATION_MODE = False
|
||||
TOOLS_ROOT = common.join_path(AWTK_ROOT, 'bin')
|
||||
AWTK_ROOT = common.join_path(APP_ROOT, AWTK_ROOT)
|
||||
ASSETS_ROOT = common.join_path(APP_ROOT, 'design')
|
||||
OUTPUT_ROOT = common.join_path(APP_ROOT, 'res/assets')
|
||||
|
||||
use_default_theme_config()
|
||||
use_default_theme_config(RES_CONFIG_JSON_PATH, RES_CONFIG)
|
||||
|
||||
if RES_OUTPUT_DIR != '' :
|
||||
OUTPUT_ROOT = common.join_path(RES_OUTPUT_DIR, 'assets')
|
||||
if TMP_LCD_ORIENTATION != '' :
|
||||
LCD_ORIENTATION = TMP_LCD_ORIENTATION
|
||||
if TMP_LCD_FAST_ROTATION_MODE != None :
|
||||
LCD_FAST_ROTATION_MODE = TMP_LCD_FAST_ROTATION_MODE
|
||||
|
||||
ASSET_C = common.join_path(OUTPUT_ROOT, '../assets.inc')
|
||||
if action == 'json':
|
||||
|
@ -329,17 +329,6 @@ def glob_asset_files(path):
|
||||
return result
|
||||
|
||||
|
||||
def read_file(filename):
|
||||
content = ''
|
||||
if sys.version_info >= (3, 0):
|
||||
with open(filename, 'r', encoding='utf8') as f:
|
||||
content = f.read()
|
||||
else:
|
||||
with open(filename, 'r') as f:
|
||||
content = f.read()
|
||||
return content
|
||||
|
||||
|
||||
def write_file(filename, s):
|
||||
if sys.version_info >= (3, 0):
|
||||
with open(filename, 'w', encoding='utf8') as f:
|
||||
@ -1221,7 +1210,112 @@ def get_args(args) :
|
||||
list_args.append(arg)
|
||||
return list_args
|
||||
|
||||
def show_usage_imlp():
|
||||
def get_opts(args) :
|
||||
import getopt
|
||||
longsots = ['awtk_root=', 'AWTK_ROOT=',
|
||||
'action=', 'ACTION=',
|
||||
'help', 'HELP',
|
||||
'dpi=', 'DPI=',
|
||||
'image_options=', 'IMAGE_OPTIONS=',
|
||||
'lcd_orientation=', 'LCD_ORIENTATION=',
|
||||
'lcd_enable_fast_rotation=', 'LCD_ENABLE_FAST_ROTATION=',
|
||||
'res_config_file=', 'RES_CONFIG_FILE=',
|
||||
'res_config_script=', 'RES_CONFIG_SCRIPT=',
|
||||
'res_config_script_argv=', 'RES_CONFIG_SCRIPT_ARGV=',
|
||||
'output_dir=', 'OUTPUT_DIR=',
|
||||
'app_root=', 'APP_ROOT',
|
||||
];
|
||||
try :
|
||||
opts, tmp_args = getopt.getopt(args, 'h', longsots);
|
||||
return opts;
|
||||
except getopt.GetoptError as err:
|
||||
print(err.msg);
|
||||
return None;
|
||||
|
||||
def is_all_sopts_args(args) :
|
||||
for arg in args:
|
||||
if not arg.startswith('--') and not arg.startswith('-'):
|
||||
return False;
|
||||
return True;
|
||||
|
||||
def get_longsopt_name_by_tuple(tuple) :
|
||||
return tuple[0][2:].lower();
|
||||
|
||||
def get_shortopt_name_by_tuple(tuple) :
|
||||
return tuple[0][1:].lower();
|
||||
|
||||
def get_longsopts_args(args) :
|
||||
opts = get_opts(args);
|
||||
if opts != None :
|
||||
data = {};
|
||||
for tmp_opts in opts :
|
||||
data[get_longsopt_name_by_tuple(tmp_opts)] = tmp_opts[1]
|
||||
return data;
|
||||
else :
|
||||
return None;
|
||||
|
||||
def show_usage_imlp(is_new_usage):
|
||||
if is_new_usage :
|
||||
print('=========================================================')
|
||||
print('Usage: python '+sys.argv[0])
|
||||
print('--action :'.ljust(30) + ' update res action, this sopt must set ')
|
||||
print(''.ljust(30) + ' use : --action=clean|web|json|all|font|image|ui|style|string|script|data|xml|assets.c')
|
||||
print(''.ljust(30) + ' clean'.ljust(10) +': clear res')
|
||||
print(''.ljust(30) + ' all'.ljust(10) +': update all res')
|
||||
print(''.ljust(30) + ' web'.ljust(10) +': update web res')
|
||||
print(''.ljust(30) + ' json'.ljust(10) +': only update json res')
|
||||
print(''.ljust(30) + ' font'.ljust(10) +': only update font res')
|
||||
print(''.ljust(30) + ' image'.ljust(10) +': only update image res')
|
||||
print(''.ljust(30) + ' ui'.ljust(10) +': only update ui res')
|
||||
print(''.ljust(30) + ' style'.ljust(10) +': only update style res')
|
||||
print(''.ljust(30) + ' string'.ljust(10) +': only update translator string res')
|
||||
print(''.ljust(30) + ' script'.ljust(10) +': only update script res')
|
||||
print(''.ljust(30) + ' data'.ljust(10) +': only update data res')
|
||||
print(''.ljust(30) + ' xml'.ljust(10) +': only update xml res')
|
||||
print(''.ljust(30) + ' assets.c'.ljust(10) +': only update assets.c file')
|
||||
|
||||
print('--awtk_root :'.ljust(30) + ' set awtk root')
|
||||
print(''.ljust(30) + ' use : --awtk_root=XXXXX')
|
||||
|
||||
print('--dpi :'.ljust(30) + ' set update res dpi')
|
||||
print(''.ljust(30) + ' use : --dpi=x1|x2|x3')
|
||||
|
||||
print('--image_options :'.ljust(30) + ' set image foramt')
|
||||
print(''.ljust(30) + ' use : --image_options=rgba|bgra+bgr565|mono')
|
||||
|
||||
print('--res_config_file :'.ljust(30) + ' set res config file path, priority : res_config_script > res_config_file')
|
||||
print(''.ljust(30) + ' use : --res_config_file=XXXXX')
|
||||
|
||||
print('--res_config_script :'.ljust(30) + ' set res config script file path, this is script must has get_res_config(argv) function ')
|
||||
print(''.ljust(30) + ' use : --res_config_script=XXXXX')
|
||||
|
||||
print('--res_config_script_argv :'.ljust(30) + ' set res config script argv, this is get_res_config() function parameter')
|
||||
print(''.ljust(30) + ' use : --res_config_script_argv=XXXXX')
|
||||
|
||||
print('--lcd_orientation :'.ljust(30) + ' set lcd orientation ')
|
||||
print(''.ljust(30) + ' use : --lcd_orientation=90/180/270')
|
||||
|
||||
print('--lcd_enable_fast_rotation :'.ljust(30) + ' set enable lcd fast rotation ')
|
||||
print(''.ljust(30) + ' use : --lcd_enable_fast_rotation=true/false')
|
||||
|
||||
print('--output_dir :'.ljust(30) + ' set res output dir, default value is ./res ')
|
||||
print(''.ljust(30) + ' use : --output_dir=XXXXX')
|
||||
|
||||
print('--app_root :'.ljust(30) + ' set app root dir, default value is getcwd() ')
|
||||
print(''.ljust(30) + ' use : --app_root=XXXXX')
|
||||
|
||||
print('--help :'.ljust(30) + ' show all usage ')
|
||||
print(''.ljust(30) + ' use : --help')
|
||||
|
||||
print('---------------------------------------------------------')
|
||||
print('Example:')
|
||||
print('python ' + sys.argv[0] + ' --action=all')
|
||||
print('python ' + sys.argv[0] + ' --action=clean')
|
||||
print('python ' + sys.argv[0] + ' --action=style --awtk_root=XXXXX ')
|
||||
print('python ' + sys.argv[0] + ' --action=all --dpi=x1 --image_options=bgra+bgr565')
|
||||
print('python ' + sys.argv[0] + ' --action=all --dpi=x1 --image_options=bgra+bgr565 --awtk_root=XXXXX')
|
||||
print('=========================================================')
|
||||
else :
|
||||
args = ' action[clean|web|json|all|font|image|ui|style|string|script|data|xml|assets.c] dpi[x1|x2] image_options[rgba|bgra+bgr565|mono] awtk_root[--awtk_root=XXXXX]'
|
||||
print('=========================================================')
|
||||
print('Usage: python '+sys.argv[0] + args)
|
||||
@ -1232,14 +1326,30 @@ def show_usage_imlp():
|
||||
print('python ' + sys.argv[0] + ' all x1 bgra+bgr565')
|
||||
print('python ' + sys.argv[0] + ' all x1 bgra+bgr565 --awtk_root=XXXXX')
|
||||
print('=========================================================')
|
||||
if exit :
|
||||
sys.exit(0)
|
||||
|
||||
def show_usage():
|
||||
def show_usage(is_new_usage = False):
|
||||
if len(sys.argv) == 1:
|
||||
show_usage_imlp()
|
||||
show_usage_imlp(is_new_usage)
|
||||
else:
|
||||
sys_args = get_args(sys.argv[1:])
|
||||
args = sys.argv[1:];
|
||||
if is_all_sopts_args(args) :
|
||||
opts = get_opts(args);
|
||||
if opts == None :
|
||||
show_usage_imlp(is_new_usage)
|
||||
else :
|
||||
find_action = False;
|
||||
for tmp_opts in opts :
|
||||
str_opt = get_longsopt_name_by_tuple(tmp_opts);
|
||||
if str_opt == 'help' or get_shortopt_name_by_tuple(tmp_opts) == 'h':
|
||||
show_usage_imlp(is_new_usage)
|
||||
elif str_opt == 'action' :
|
||||
find_action = True;
|
||||
if not find_action :
|
||||
show_usage_imlp(is_new_usage)
|
||||
else :
|
||||
sys_args = get_args(args)
|
||||
if len(sys_args) == 0 :
|
||||
show_usage_imlp()
|
||||
show_usage_imlp(is_new_usage)
|
||||
|
||||
show_usage()
|
||||
|
Loading…
Reference in New Issue
Block a user