From 27ecbaa21a6d6d6f30d9a691329cdcafa07de835 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Sat, 13 Jan 2024 17:16:47 +0800 Subject: [PATCH] improve build scripts --- docs/changes.md | 3 ++ scripts/app_helper_base.py | 83 +++++++++++++++++++++----------------- scripts/compile_config.py | 51 ++++++++++++----------- 3 files changed, 77 insertions(+), 60 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index 612325350..c4c605b37 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,8 @@ # 最新动态 +2024/01/13 + * 增加一个编译参数类型用于None的情况下识别编译传参类型以及修复app和awtk编译模式不同的问题(感谢智明提供补丁) + 2024/01/12 * 实现 conf\_doc\_foreach 函数(感谢林福提供补丁) * 实现 data\_reader\_can\_read 函数(感谢林福提供补丁) diff --git a/scripts/app_helper_base.py b/scripts/app_helper_base.py index 3e0766707..ccf13271c 100644 --- a/scripts/app_helper_base.py +++ b/scripts/app_helper_base.py @@ -15,33 +15,33 @@ SRT_SCONS_CONFIG_SCRIPT = 'SCONS_CONFIG_SCRIPT' SRT_SCONS_CONFIG_SCRIPT_ARGV = 'SCONS_CONFIG_SCRIPT_ARGV' COMPILE_CONFIG = { - 'AWTK_ROOT' : { 'value' : None, 'type' : type(str), 'desc' : ['awtk root'], 'help_info' : 'set link awtk root, AWTK_ROOT=XXXXX'}, - 'LINUX_FB' : { 'value' : False, 'type' : type(bool), 'desc' : ['use linux\'s building'], 'help_info' : 'use linux\'s compile tools prefix building, value is true or false'}, - 'MVVM_ROOT' : { 'value' : None, 'type' : type(str), 'desc' : ['awtk\'s mvvm root'], 'help_info' : 'set link awtk\'s mvvm root, MVVM_ROOT=XXXXX'}, - 'WITH_MVVM' : { 'value' : False, 'type' : type(bool), 'desc' : ['use mvvm'], 'help_info' : 'use mvvm\'s lib, value is true or false'}, - 'WITH_JERRYSCRIPT' : { 'value' : False, 'type' : type(bool), 'desc' : ['use mvvm\'s js'], 'help_info' : 'use mvvm js\'s lib, value is true or false'}, - 'WITH_IOTJS' : { 'value' : False, 'type' : type(bool), 'desc' : ['use mvvm\'s iotjs'], 'help_info' : 'use mvvm iotjs\'s lib, value is true or false'}, - 'AWFLOW_ROOT' : { 'value' : None, 'type' : type(str), 'desc' : ['awtk\'s awflow root'], 'help_info' : 'set link awtk\'s awflow root, AWFLOW_ROOT=XXXXX'}, - 'WITH_AWFLOW' : { 'value' : False, 'type' : type(bool), 'desc' : ['use awflow'], 'help_info' : 'use awflow\'s lib, value is true or false'}, - SRT_SCONS_CONFIG_SCRIPT : { 'value' : None, 'type' : type(str), 'save_file' : False, 'desc' : ['set script file path, this is script has {0}(COMPILE_CONFIG, ARGUMENTS, argv) function'.format(SRT_SCONS_CONFIG_FUN)], 'help_info' : 'set res config file path, this is script must has {0}(COMPILE_CONFIG, ARGUMENTS, argv) function, {0}\'s function return compile_config\'s class, CONFIG_SCRIPT=XXXXX'.format(SRT_SCONS_CONFIG_FUN)}, - SRT_SCONS_CONFIG_SCRIPT_ARGV : { 'value' : None, 'type' : type(str), 'save_file' : False, 'desc' : ['value is {0}\s argv for script file '.format(SRT_SCONS_CONFIG_FUN)], 'help_info' : 'value is {0}\s argv for script file\'s {0}, SCONS_CONFIG_SCRIPT_ARGV=XXXXX'.format(SRT_SCONS_CONFIG_FUN)}, - 'BUILD_DIR' : { 'value' : None, 'type' : type(str), 'desc' : ['build dir, compile temp file dir'], 'help_info' : 'set build dir, save compile temp file dir or *.obj/.*o dir, BUILD_DIR=XXXXX'}, -# 'APP_BIN_DIR' : { 'value' : None, 'type' : type(str), 'desc' : ['build bin dir'], 'help_info' : 'set build bin dir, APP_BIN_DIR=XXXXX'}, -# 'APP_LIB_DIR' : { 'value' : None, 'type' : type(str), 'desc' : ['build lib dir'], 'help_info' : 'set build lib dir, APP_LIB_DIR=XXXXX'}, - 'DEBUG' : { 'value' : None, 'type' : type(bool), 'desc' : ['awtk\'s compile is debug'], 'help_info' : 'awtk\'s compile is debug, value is true or false' }, - 'PDB' : { 'value' : True, 'type' : type(bool), 'desc' : ['export pdb file'], 'help_info' : 'export pdb file, value is true or false' }, - 'FLAGS' : { 'value' : None, 'type' : type(str), 'desc' : ['compile flags'], 'help_info' : 'set compile\'s flags, so care of system and compile tools'}, - 'LIBS' : { 'value' : [], 'type' : type(list), 'desc' : ['compile libs'], 'help_info' : 'set compile\'s libs, so care of system and compile tools, use \',\' split muliple libraries '}, - 'LIBPATH' : { 'value' : [], 'type' : type(list), 'desc' : ['compile lib paths'], 'help_info' : 'set compile\'s lib paths, so care of system and compile tools, use \',\' split muliple librarie\'s paths '}, - 'CPPPATH' : { 'value' : [], 'type' : type(list), 'desc' : ['compile include paths'], 'help_info' : 'set compile\'s include paths, so care of system and compile tools, use \',\' split muliple include path '}, - 'SHARED' : { 'value' : True, 'type' : type(bool), 'desc' : ['compile is SharedLibrary'], 'help_info' : 'app\'s compile is Shared Library, value is true or false' }, - 'IDL_DEF' : { 'value' : True, 'type' : type(bool), 'desc' : ['compile build idl def file'], 'help_info' : 'app\'s compile build idl def file, value is true or false' }, - 'LCD' : { 'value' : None, 'type' : type(str), 'save_file' : False, 'desc' : ['app\'s lcd\'s size'], 'help_info' : 'app\'s lcd\'s size, value is [lcd_width]_[lcd_height], example is LCD=320_480' }, - 'LANGUAGE' : { 'value' : None, 'type' : type(str), 'save_file' : False, 'desc' : ['app\'s language'], 'help_info' : 'app\'s language, value is [country]_[language], example is LANGUAGE=zh_CH' }, - 'FONT' : { 'value' : None, 'type' : type(str), 'save_file' : False, 'desc' : ['app\'s font\'s name'], 'help_info' : 'app\'s font\'s name, FONT=XXXXX ' }, - 'THEME' : { 'value' : None, 'type' : type(str), 'save_file' : False, 'desc' : ['app\'s default\'s theme\'s name'], 'help_info' : 'app\'s default\'s theme\'s name, THEME=XXXXX ' }, - 'RES_ROOT' : { 'value' : None, 'type' : type(str), 'save_file' : False, 'desc' : ['app\'s res root'], 'help_info' : 'app\'s res root, RES_ROOT=XXXXX ' }, - 'WIN32_RES' : { 'value' : None, 'type' : type(str), 'desc' : ['app\'s win32 res path'], 'help_info' : 'app\'s win32 res path, WIN32_RES=XXXXX, value\'s default=\'awtk/win32_res/awtk.res\' ' }, + 'AWTK_ROOT' : { 'value' : None, 'type' : str.__name__, 'desc' : ['awtk root'], 'help_info' : 'set link awtk root, AWTK_ROOT=XXXXX'}, + 'LINUX_FB' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['use linux\'s building'], 'help_info' : 'use linux\'s compile tools prefix building, value is true or false'}, + 'MVVM_ROOT' : { 'value' : None, 'type' : str.__name__, 'desc' : ['awtk\'s mvvm root'], 'help_info' : 'set link awtk\'s mvvm root, MVVM_ROOT=XXXXX'}, + 'WITH_MVVM' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['use mvvm'], 'help_info' : 'use mvvm\'s lib, value is true or false'}, + 'WITH_JERRYSCRIPT' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['use mvvm\'s js'], 'help_info' : 'use mvvm js\'s lib, value is true or false'}, + 'WITH_IOTJS' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['use mvvm\'s iotjs'], 'help_info' : 'use mvvm iotjs\'s lib, value is true or false'}, + 'AWFLOW_ROOT' : { 'value' : None, 'type' : str.__name__, 'desc' : ['awtk\'s awflow root'], 'help_info' : 'set link awtk\'s awflow root, AWFLOW_ROOT=XXXXX'}, + 'WITH_AWFLOW' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['use awflow'], 'help_info' : 'use awflow\'s lib, value is true or false'}, + SRT_SCONS_CONFIG_SCRIPT : { 'value' : None, 'type' : str.__name__, 'save_file' : False, 'desc' : ['set script file path, this is script has {0}(COMPILE_CONFIG, ARGUMENTS, argv) function'.format(SRT_SCONS_CONFIG_FUN)], 'help_info' : 'set res config file path, this is script must has {0}(COMPILE_CONFIG, ARGUMENTS, argv) function, {0}\'s function return compile_config\'s class, CONFIG_SCRIPT=XXXXX'.format(SRT_SCONS_CONFIG_FUN)}, + SRT_SCONS_CONFIG_SCRIPT_ARGV : { 'value' : None, 'type' : str.__name__, 'save_file' : False, 'desc' : ['value is {0}\s argv for script file '.format(SRT_SCONS_CONFIG_FUN)], 'help_info' : 'value is {0}\s argv for script file\'s {0}, SCONS_CONFIG_SCRIPT_ARGV=XXXXX'.format(SRT_SCONS_CONFIG_FUN)}, + 'BUILD_DIR' : { 'value' : None, 'type' : str.__name__, 'desc' : ['build dir, compile temp file dir'], 'help_info' : 'set build dir, save compile temp file dir or *.obj/.*o dir, BUILD_DIR=XXXXX'}, +# 'APP_BIN_DIR' : { 'value' : None, 'type' : str.__name__, 'desc' : ['build bin dir'], 'help_info' : 'set build bin dir, APP_BIN_DIR=XXXXX'}, +# 'APP_LIB_DIR' : { 'value' : None, 'type' : str.__name__, 'desc' : ['build lib dir'], 'help_info' : 'set build lib dir, APP_LIB_DIR=XXXXX'}, + 'DEBUG' : { 'value' : None, 'type' : bool.__name__, 'desc' : ['awtk\'s compile is debug'], 'help_info' : 'awtk\'s compile is debug, value is true or false' }, + 'PDB' : { 'value' : True, 'type' : bool.__name__, 'desc' : ['export pdb file'], 'help_info' : 'export pdb file, value is true or false' }, + 'FLAGS' : { 'value' : None, 'type' : str.__name__, 'desc' : ['compile flags'], 'help_info' : 'set compile\'s flags, so care of system and compile tools'}, + 'LIBS' : { 'value' : [], 'type' : list.__name__, 'desc' : ['compile libs'], 'help_info' : 'set compile\'s libs, so care of system and compile tools, use \',\' split muliple libraries '}, + 'LIBPATH' : { 'value' : [], 'type' : list.__name__, 'desc' : ['compile lib paths'], 'help_info' : 'set compile\'s lib paths, so care of system and compile tools, use \',\' split muliple librarie\'s paths '}, + 'CPPPATH' : { 'value' : [], 'type' : list.__name__, 'desc' : ['compile include paths'], 'help_info' : 'set compile\'s include paths, so care of system and compile tools, use \',\' split muliple include path '}, + 'SHARED' : { 'value' : True, 'type' : bool.__name__, 'desc' : ['compile is SharedLibrary'], 'help_info' : 'app\'s compile is Shared Library, value is true or false' }, + 'IDL_DEF' : { 'value' : True, 'type' : bool.__name__, 'desc' : ['compile build idl def file'], 'help_info' : 'app\'s compile build idl def file, value is true or false' }, + 'LCD' : { 'value' : None, 'type' : str.__name__, 'save_file' : False, 'desc' : ['app\'s lcd\'s size'], 'help_info' : 'app\'s lcd\'s size, value is [lcd_width]_[lcd_height], example is LCD=320_480' }, + 'LANGUAGE' : { 'value' : None, 'type' : str.__name__, 'save_file' : False, 'desc' : ['app\'s language'], 'help_info' : 'app\'s language, value is [country]_[language], example is LANGUAGE=zh_CH' }, + 'FONT' : { 'value' : None, 'type' : str.__name__, 'save_file' : False, 'desc' : ['app\'s font\'s name'], 'help_info' : 'app\'s font\'s name, FONT=XXXXX ' }, + 'THEME' : { 'value' : None, 'type' : str.__name__, 'save_file' : False, 'desc' : ['app\'s default\'s theme\'s name'], 'help_info' : 'app\'s default\'s theme\'s name, THEME=XXXXX ' }, + 'RES_ROOT' : { 'value' : None, 'type' : str.__name__, 'save_file' : False, 'desc' : ['app\'s res root'], 'help_info' : 'app\'s res root, RES_ROOT=XXXXX ' }, + 'WIN32_RES' : { 'value' : None, 'type' : str.__name__, 'desc' : ['app\'s win32 res path'], 'help_info' : 'app\'s win32 res path, WIN32_RES=XXXXX, value\'s default=\'awtk/win32_res/awtk.res\' ' }, } def set_compile_config(config) : @@ -291,6 +291,11 @@ class AppHelperBase: self.WITH_IOTJS = False self.MVVM_ROOT = None self.AWFLOW_ROOT = None + if hasattr(self.awtk, 'OS_NAME') : + self.OS_NAME = self.awtk.OS_NAME; + else : + self.OS_NAME = None; + self.AWTK_OS_DEBUG = True if hasattr(self.awtk, 'OS_DEBUG') : self.AWTK_OS_DEBUG = self.awtk.OS_DEBUG @@ -298,8 +303,11 @@ class AppHelperBase: self.AWTK_OS_DEBUG = self.DEBUG self.DEBUG = self.complie_helper.get_value('DEBUG', self.AWTK_OS_DEBUG) if isinstance(self.DEBUG, str) : - from utils import strtobool - self.DEBUG = strtobool(self.DEBUG) == 1 + try : + from utils import strtobool + self.DEBUG = strtobool(self.DEBUG) == 1 + except : + self.DEBUG == self.DEBUG.lower() == 'true'; self.parseArgs(self.awtk, ARGUMENTS) self.APP_CPPPATH = [self.APP_SRC, self.APP_RES] + self.complie_helper.get_value('CPPPATH', []) @@ -580,10 +588,7 @@ class AppHelperBase: if hasattr(awtk, 'BUILD_DEBUG_FLAG') : BUILD_DEBUG_FLAG = awtk.BUILD_DEBUG_FLAG else : - if hasattr(awtk, 'CC') : - BUILD_DEBUG_FLAG = ' ' - else : - BUILD_DEBUG_FLAG = ' /MDd -D_DEBUG -DDEBUG /DEBUG /Od ' + BUILD_DEBUG_FLAG = ' ' self.APP_BIN_DIR = self.complie_helper.get_value('APP_BIN_DIR', os.path.join(self.APP_ROOT, self.BIN_DIR)) self.APP_LIB_DIR = self.complie_helper.get_value('APP_LIB_DIR', os.path.join(self.APP_ROOT, self.LIB_DIR)) @@ -710,11 +715,17 @@ class AppHelperBase: OS_SUBSYSTEM_WINDOWS=awtk.OS_SUBSYSTEM_WINDOWS) else: if self.DEBUG : - CCFLAGS += ' -D_DEBUG -DDEBUG /DEBUG /MDd /Od ' + if self.OS_NAME == 'Windows': + CCFLAGS += ' -D_DEBUG -DDEBUG /DEBUG /MDd /Od ' + elif self.OS_NAME == 'Darwin' or self.OS_NAME == 'Linux' : + CCFLAGS += ' -g -O0 ' else : - CCFLAGS += ' -DNDEBUG /MD /O2 /Oi ' + if self.OS_NAME == 'Windows': + CCFLAGS += ' -DNDEBUG /MD /O2 /Oi ' + elif self.OS_NAME == 'Darwin' or self.OS_NAME == 'Linux' : + CCFLAGS += ' -Os ' - if self.complie_helper.get_value('PDB', True) : + if self.OS_NAME == 'Windows' and self.complie_helper.get_value('PDB', True) : LINKFLAGS += ' /DEBUG ' if self.DEBUG == self.AWTK_OS_DEBUG: CCFLAGS += BUILD_DEBUG_FLAG diff --git a/scripts/compile_config.py b/scripts/compile_config.py index 2e35930cd..2785a4445 100644 --- a/scripts/compile_config.py +++ b/scripts/compile_config.py @@ -5,7 +5,6 @@ import json import shutil import importlib import collections -from utils import strtobool global COMPILE_CONFIG COMPILE_CONFIG = None @@ -85,21 +84,21 @@ class complie_helper : }) config = collections.OrderedDict({ - 'OUTPUT_DIR' : { 'value' : None, 'type' : type(str), 'desc' : ['compiled export directory '], 'help_info' : 'set awtk compiled export directory, default value is \'\', \'\' is system\'s value'}, - 'TOOLS_NAME' : { 'value' : None, 'type' : type(str), 'str_enum' : ['mingw'], 'desc' : ['value is \'mingw\' or None'], 'help_info' : 'set awtk compile\'s name, default value is None, None is system\'s value'}, - 'INPUT_ENGINE' : { 'value' : None, 'type' : type(str), 'str_enum' : ['null', 'spinyin', 't9', 't9ext', 'pinyin'], 'desc' : ['value is null/spinyin/t9/t9ext/pinyin'], 'help_info' : 'set awtk use input engine, default value is None, None is system\'s value' }, - 'VGCANVAS' : { 'value' : None, 'type' : type(str), 'str_enum' : ['NANOVG', 'NANOVG_PLUS', 'CAIRO'], 'desc' : ['value is NANOVG/NANOVG_PLUS/CAIRO'], 'help_info' : 'set awtk use render vgcanvas type, default value is None, None is system\'s value' }, - 'NANOVG_BACKEND' : { 'value' : None, 'type' : type(str), 'str_enum' : ['GLES2', 'GLES3', 'GL3', 'AGG', 'AGGE'], 'desc' : ['if NANOVG_BACKEND is valid, VGCANVAS must be NANOVG or \'\'', 'if VGCANVAS is NANOVG_PLUS, NANOVG_BACKEND must be GLES2/GLES3/GL3 or None', 'NANOVG_BACKEND is GLES2/GLES3/GL3/AGG/AGGE'], 'help_info' : 'set awtk\'s nanovg use render model, default value is None, None is system\'s value'}, - 'LCD_COLOR_FORMAT' : { 'value' : None, 'type' : type(str), 'str_enum' : ['bgr565', 'bgra8888', 'mono'], 'desc' : ['if NANOVG_BACKEND is GLES2/GLES3/GL3, LCD_COLOR_FORMAT must be bgra8888 or \'\'', 'if NANOVG_BACKEND is AGG/AGGE, LCD_COLOR_FORMAT must be bgr565/bgra8888/mono or None', 'NANOVG_BACKEND is bgr565/bgra8888/mono'], 'help_info' : 'set awtk\'s lcd color format, default value is None, None is system\'s value'}, - 'DEBUG' : { 'value' : True, 'type' : type(bool), 'desc' : ['awtk\'s compile is debug'], 'help_info' : 'awtk\'s compile is debug, value is true or false, default value is true' }, - 'PDB' : { 'value' : True, 'type' : type(bool), 'desc' : ['export pdb file'], 'help_info' : 'export pdb file, value is true or false' }, - 'SDL_UBUNTU_USE_IME' : { 'value' : False, 'type' : type(bool), 'desc' : ['ubuntu use chinese input engine'], 'help_info' : 'ubuntu use ime, this sopt is ubuntu use chinese input engine, value is true or false, default value is false' }, - 'NATIVE_WINDOW_BORDERLESS' : { 'value' : False, 'type' : type(bool), 'desc' : ['pc desktop program no borerless'], 'help_info' : 'pc desktop program no borerless, value is true or false, default value is false' }, - 'NATIVE_WINDOW_NOT_RESIZABLE' : { 'value' : False, 'type' : type(bool), 'desc' : ['pc desktop program do not resize program'], 'help_info' : 'pc desktop program do not resize program\'s size, value is true or false, default value is false' }, - 'BUILD_TESTS' : { 'value' : True, 'type' : type(bool), 'desc' : ['build awtk\'s gtest demo'], 'help_info' : 'build awtk\'s gtest demo, value is true or false, default value is true' }, - 'BUILD_DEMOS' : { 'value' : True, 'type' : type(bool), 'desc' : ['build awtk\'s demo examples'], 'help_info' : 'build awtk\'s demo examples, value is true or false, default value is true' }, - 'BUILD_TOOLS' : { 'value' : True, 'type' : type(bool), 'desc' : ['build awtk\'s tools'], 'help_info' : 'build awtk\'s tools, value is true or false, default value is true' }, - 'WIN32_RES' : { 'value' : None, 'type' : type(str), 'save_file' : False, 'desc' : ['app\'s win32 res path'], 'help_info' : 'app\'s win32 res path, WIN32_RES=XXXXX, value\'s default=\'awtk/win32_res/awtk.res\' ' }, + 'OUTPUT_DIR' : { 'value' : None, 'type' : str.__name__, 'desc' : ['compiled export directory '], 'help_info' : 'set awtk compiled export directory, default value is \'\', \'\' is system\'s value'}, + 'TOOLS_NAME' : { 'value' : None, 'type' : str.__name__, 'str_enum' : ['mingw'], 'desc' : ['value is \'mingw\' or None'], 'help_info' : 'set awtk compile\'s name, default value is None, None is system\'s value'}, + 'INPUT_ENGINE' : { 'value' : None, 'type' : str.__name__, 'str_enum' : ['null', 'spinyin', 't9', 't9ext', 'pinyin'], 'desc' : ['value is null/spinyin/t9/t9ext/pinyin'], 'help_info' : 'set awtk use input engine, default value is None, None is system\'s value' }, + 'VGCANVAS' : { 'value' : None, 'type' : str.__name__, 'str_enum' : ['NANOVG', 'NANOVG_PLUS', 'CAIRO'], 'desc' : ['value is NANOVG/NANOVG_PLUS/CAIRO'], 'help_info' : 'set awtk use render vgcanvas type, default value is None, None is system\'s value' }, + 'NANOVG_BACKEND' : { 'value' : None, 'type' : str.__name__, 'str_enum' : ['GLES2', 'GLES3', 'GL3', 'AGG', 'AGGE'], 'desc' : ['if NANOVG_BACKEND is valid, VGCANVAS must be NANOVG or \'\'', 'if VGCANVAS is NANOVG_PLUS, NANOVG_BACKEND must be GLES2/GLES3/GL3 or None', 'NANOVG_BACKEND is GLES2/GLES3/GL3/AGG/AGGE'], 'help_info' : 'set awtk\'s nanovg use render model, default value is None, None is system\'s value'}, + 'LCD_COLOR_FORMAT' : { 'value' : None, 'type' : str.__name__, 'str_enum' : ['bgr565', 'bgra8888', 'mono'], 'desc' : ['if NANOVG_BACKEND is GLES2/GLES3/GL3, LCD_COLOR_FORMAT must be bgra8888 or \'\'', 'if NANOVG_BACKEND is AGG/AGGE, LCD_COLOR_FORMAT must be bgr565/bgra8888/mono or None', 'NANOVG_BACKEND is bgr565/bgra8888/mono'], 'help_info' : 'set awtk\'s lcd color format, default value is None, None is system\'s value'}, + 'DEBUG' : { 'value' : True, 'type' : bool.__name__, 'desc' : ['awtk\'s compile is debug'], 'help_info' : 'awtk\'s compile is debug, value is true or false, default value is true' }, + 'PDB' : { 'value' : True, 'type' : bool.__name__, 'desc' : ['export pdb file'], 'help_info' : 'export pdb file, value is true or false' }, + 'SDL_UBUNTU_USE_IME' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['ubuntu use chinese input engine'], 'help_info' : 'ubuntu use ime, this sopt is ubuntu use chinese input engine, value is true or false, default value is false' }, + 'NATIVE_WINDOW_BORDERLESS' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['pc desktop program no borerless'], 'help_info' : 'pc desktop program no borerless, value is true or false, default value is false' }, + 'NATIVE_WINDOW_NOT_RESIZABLE' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['pc desktop program do not resize program'], 'help_info' : 'pc desktop program do not resize program\'s size, value is true or false, default value is false' }, + 'BUILD_TESTS' : { 'value' : True, 'type' : bool.__name__, 'desc' : ['build awtk\'s gtest demo'], 'help_info' : 'build awtk\'s gtest demo, value is true or false, default value is true' }, + 'BUILD_DEMOS' : { 'value' : True, 'type' : bool.__name__, 'desc' : ['build awtk\'s demo examples'], 'help_info' : 'build awtk\'s demo examples, value is true or false, default value is true' }, + 'BUILD_TOOLS' : { 'value' : True, 'type' : bool.__name__, 'desc' : ['build awtk\'s tools'], 'help_info' : 'build awtk\'s tools, value is true or false, default value is true' }, + 'WIN32_RES' : { 'value' : None, 'type' : str.__name__, 'save_file' : False, 'desc' : ['app\'s win32 res path'], 'help_info' : 'app\'s win32 res path, WIN32_RES=XXXXX, value\'s default=\'awtk/win32_res/awtk.res\' ' }, }) def try_load_default_config(self) : @@ -245,24 +244,28 @@ class complie_helper : if name in self.config : if isinstance(self.config[name]['value'], bool) and isinstance(value, bool): self.config[name]['value'] = value - elif isinstance(self.config[name]['value'], bool) and isinstance(value, str) : - self.config[name]['value'] = strtobool(value) == 1 - elif 'type' in self.config[name] and self.config[name]['type'] == type(bool) and isinstance(value, str) : - self.config[name]['value'] = strtobool(value) == 1 + elif (isinstance(self.config[name]['value'], bool) and isinstance(value, str)) or ('type' in self.config[name] and self.config[name]['type'] == bool.__name__ and isinstance(value, str)): + try : + from utils import strtobool + self.config[name]['value'] = strtobool(value) == 1 + except : + self.config[name]['value'] = value.lower() == 'true' elif isinstance(self.config[name]['value'], list) and isinstance(value, str) : self.config[name]['value'] = value.split(',') elif self.config[name]['value'] == None and (not 'type' in self.config[name]): self.config[name]['value'] = value - else : - self.config[name]['value'] = type(self.config[name]['type'])(value) + else: + self.config[name]['value'] = value def save_last_complie_argv(self) : json_obj_save_file(self.config, self.LAST_COMLIP_ARGV_FILE); def load_last_complie_argv(self) : if os.path.exists(self.LAST_COMLIP_ARGV_FILE) : - self.config = collections.OrderedDict(json_obj_load_file(self.LAST_COMLIP_ARGV_FILE)); - return True + obj = json_obj_load_file(self.LAST_COMLIP_ARGV_FILE); + if obj != None : + self.config = collections.OrderedDict(obj); + return True return False def output_compile_data(self, awtk_root) :