2020-08-14 16:43:12 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import json
|
|
|
|
import shutil
|
|
|
|
import platform
|
|
|
|
|
2020-11-24 09:28:40 +08:00
|
|
|
PLATFORM = platform.system()
|
|
|
|
|
|
|
|
|
|
|
|
def join_path(root, sub):
|
|
|
|
return os.path.abspath(os.path.join(root, sub))
|
|
|
|
|
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
def mkdir_if_not_exist(fullpath):
|
|
|
|
if os.path.exists(fullpath):
|
|
|
|
print(fullpath+' exist.')
|
|
|
|
else:
|
|
|
|
os.makedirs(fullpath)
|
|
|
|
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-08-30 09:01:13 +08:00
|
|
|
def load_project_json(filename):
|
|
|
|
try:
|
2020-09-18 11:31:59 +08:00
|
|
|
if sys.version_info >= (3, 0):
|
|
|
|
with open(filename, 'r', encoding='utf8') as f:
|
2020-11-24 09:28:40 +08:00
|
|
|
info = json.load(f)
|
2020-09-18 11:31:59 +08:00
|
|
|
return info
|
|
|
|
else:
|
|
|
|
with open(filename, 'r') as f:
|
2020-11-24 09:28:40 +08:00
|
|
|
info = json.load(f)
|
2020-09-18 11:31:59 +08:00
|
|
|
return info
|
2020-08-30 09:01:13 +08:00
|
|
|
except:
|
|
|
|
return None
|
|
|
|
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
def get_project_w(info, theme):
|
|
|
|
return info['assets']['themes'][theme]['lcd']['width']
|
|
|
|
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
def get_project_h(info, theme):
|
|
|
|
return info['assets']['themes'][theme]['lcd']['height']
|
|
|
|
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
def get_project_theme(info):
|
|
|
|
return info['assets']['activedTheme']
|
|
|
|
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
def get_project_language(info):
|
|
|
|
return info['assets']['defaultLanguage']
|
2020-08-30 09:01:13 +08:00
|
|
|
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
def get_project_country(info):
|
|
|
|
return info['assets']['defaultCountry']
|
2020-08-30 09:01:13 +08:00
|
|
|
|
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
class AppHelperBase:
|
|
|
|
def set_deps(self, DEPENDS_LIBS):
|
|
|
|
self.DEPENDS_LIBS = DEPENDS_LIBS
|
|
|
|
return self
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-10-13 17:43:19 +08:00
|
|
|
def set_src_dir(self, SRC_DIR):
|
|
|
|
self.SRC_DIR = SRC_DIR
|
|
|
|
return self
|
2020-08-14 16:43:12 +08:00
|
|
|
|
2020-10-14 18:16:22 +08:00
|
|
|
def set_tkc_only(self):
|
|
|
|
self.AWTK_LIBS = ['tkc']
|
2020-10-21 14:14:56 +08:00
|
|
|
self.TKC_ONLY = True
|
2020-10-14 18:16:22 +08:00
|
|
|
|
|
|
|
return self
|
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
def set_libs(self, APP_LIBS):
|
|
|
|
self.APP_LIBS = APP_LIBS
|
|
|
|
return self
|
|
|
|
|
|
|
|
def set_dll_def(self, DEF_FILE):
|
|
|
|
self.DEF_FILE = DEF_FILE
|
|
|
|
return self
|
|
|
|
|
|
|
|
def set_dll_def_processor(self, processor):
|
|
|
|
self.DEF_FILE_PROCESSOR = processor
|
|
|
|
return self
|
|
|
|
|
|
|
|
def set_ccflags(self, APP_CCFLAGS):
|
|
|
|
self.APP_CCFLAGS = APP_CCFLAGS
|
|
|
|
return self
|
|
|
|
|
|
|
|
def set_cxxflags(self, APP_CXXFLAGS):
|
|
|
|
self.APP_CXXFLAGS = APP_CXXFLAGS
|
|
|
|
return self
|
|
|
|
|
|
|
|
def add_deps(self, DEPENDS_LIBS):
|
|
|
|
self.DEPENDS_LIBS += DEPENDS_LIBS
|
|
|
|
return self
|
|
|
|
|
|
|
|
def add_libs(self, APP_LIBS):
|
|
|
|
self.APP_LIBS += APP_LIBS
|
|
|
|
return self
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-10-22 09:02:51 +08:00
|
|
|
def add_platform_libs(self, plat, PLATFORM_LIBS):
|
|
|
|
if plat == PLATFORM:
|
|
|
|
self.PLATFORM_LIBS += PLATFORM_LIBS
|
2020-09-02 16:19:53 +08:00
|
|
|
return self
|
|
|
|
|
2020-08-15 11:55:22 +08:00
|
|
|
def add_libpath(self, APP_LIBPATH):
|
|
|
|
self.APP_LIBPATH += APP_LIBPATH
|
|
|
|
return self
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-02 16:19:53 +08:00
|
|
|
def add_platform_libpath(self, plat, APP_LIBPATH):
|
2020-10-22 09:02:51 +08:00
|
|
|
if plat == PLATFORM:
|
2020-09-02 16:19:53 +08:00
|
|
|
self.APP_LIBPATH += APP_LIBPATH
|
|
|
|
return self
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
def add_cpppath(self, APP_CPPPATH):
|
|
|
|
self.APP_CPPPATH += APP_CPPPATH
|
|
|
|
return self
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-02 16:19:53 +08:00
|
|
|
def add_platform_cpppath(self, plat, APP_CPPPATH):
|
2020-10-22 09:02:51 +08:00
|
|
|
if plat == PLATFORM:
|
2020-09-02 16:19:53 +08:00
|
|
|
self.APP_CPPPATH += APP_CPPPATH
|
|
|
|
return self
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
def add_ccflags(self, APP_CCFLAGS):
|
|
|
|
self.APP_CCFLAGS += APP_CCFLAGS
|
|
|
|
return self
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-28 07:40:57 +08:00
|
|
|
def add_cflags(self, APP_CFLAGS):
|
|
|
|
self.APP_CFLAGS += APP_CFLAGS
|
|
|
|
return self
|
2020-08-14 16:43:12 +08:00
|
|
|
|
2020-09-02 16:19:53 +08:00
|
|
|
def add_platform_ccflags(self, plat, APP_CCFLAGS):
|
2020-10-22 09:02:51 +08:00
|
|
|
if plat == PLATFORM:
|
2020-09-02 16:19:53 +08:00
|
|
|
self.APP_CCFLAGS += APP_CCFLAGS
|
|
|
|
return self
|
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
def add_cxxflags(self, APP_CXXFLAGS):
|
|
|
|
self.APP_CXXFLAGS += APP_CXXFLAGS
|
|
|
|
return self
|
2020-11-24 09:28:40 +08:00
|
|
|
|
2020-09-02 16:19:53 +08:00
|
|
|
def add_platform_cxxflags(self, plat, APP_CXXFLAGS):
|
2020-10-22 09:02:51 +08:00
|
|
|
if plat == PLATFORM:
|
2020-09-02 16:19:53 +08:00
|
|
|
self.APP_CXXFLAGS += APP_CXXFLAGS
|
|
|
|
return self
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
def add_linkflags(self, APP_LINKFLAGS):
|
|
|
|
self.APP_LINKFLAGS += APP_LINKFLAGS
|
|
|
|
return self
|
|
|
|
|
2020-09-02 16:19:53 +08:00
|
|
|
def add_platform_linkflags(self, plat, APP_LINKFLAGS):
|
2020-10-22 09:02:51 +08:00
|
|
|
if plat == PLATFORM:
|
2020-09-02 16:19:53 +08:00
|
|
|
self.APP_LINKFLAGS += APP_LINKFLAGS
|
|
|
|
return self
|
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
def __init__(self, ARGUMENTS):
|
|
|
|
APP_ROOT = os.path.normpath(os.getcwd())
|
|
|
|
|
2020-10-13 17:43:19 +08:00
|
|
|
self.SRC_DIR = 'src'
|
2020-11-24 09:28:40 +08:00
|
|
|
self.TKC_ONLY = False
|
2020-09-18 11:31:59 +08:00
|
|
|
self.ARGUMENTS = ARGUMENTS
|
2020-08-14 16:43:12 +08:00
|
|
|
self.DEF_FILE = None
|
|
|
|
self.DEF_FILE_PROCESSOR = None
|
|
|
|
self.DEPENDS_LIBS = []
|
|
|
|
self.GEN_IDL_DEF = True
|
|
|
|
self.BUILD_SHARED = True
|
|
|
|
self.LINUX_FB = ARGUMENTS.get('LINUX_FB', '') != ''
|
|
|
|
self.AWTK_ROOT = self.getAwtkRoot()
|
2020-09-18 11:31:59 +08:00
|
|
|
self.awtk = self.getAwtkConfig()
|
|
|
|
self.AWTK_LIBS = self.awtk.LIBS
|
2020-09-28 07:40:57 +08:00
|
|
|
self.AWTK_CFLAGS = self.awtk.CFLAGS
|
2020-09-18 11:31:59 +08:00
|
|
|
self.AWTK_CCFLAGS = self.awtk.CCFLAGS
|
|
|
|
self.APP_ROOT = APP_ROOT
|
2020-08-14 16:43:12 +08:00
|
|
|
self.APP_BIN_DIR = os.path.join(APP_ROOT, 'bin')
|
|
|
|
self.APP_LIB_DIR = os.path.join(APP_ROOT, 'lib')
|
|
|
|
self.APP_SRC = os.path.join(APP_ROOT, 'src')
|
2020-08-17 08:43:23 +08:00
|
|
|
self.APP_RES = os.path.join(APP_ROOT, 'res')
|
2020-09-18 11:31:59 +08:00
|
|
|
self.APP_LIBS = []
|
|
|
|
self.APP_LIBPATH = [self.APP_LIB_DIR]
|
|
|
|
self.APP_LINKFLAGS = ''
|
|
|
|
self.APP_CPPPATH = [self.APP_SRC, self.APP_RES]
|
2020-10-22 09:02:51 +08:00
|
|
|
self.PLATFORM_LIBS = []
|
2020-09-18 11:31:59 +08:00
|
|
|
self.APP_TOOLS = None
|
|
|
|
|
2020-11-24 09:28:40 +08:00
|
|
|
mkdir_if_not_exist(self.APP_BIN_DIR)
|
|
|
|
mkdir_if_not_exist(self.APP_LIB_DIR)
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
os.environ['APP_SRC'] = self.APP_SRC
|
|
|
|
os.environ['APP_ROOT'] = self.APP_ROOT
|
|
|
|
os.environ['BIN_DIR'] = self.APP_BIN_DIR
|
|
|
|
os.environ['LIB_DIR'] = self.APP_LIB_DIR
|
2020-09-28 07:40:57 +08:00
|
|
|
os.environ['LINUX_FB'] = 'false'
|
|
|
|
if self.LINUX_FB:
|
2020-11-24 09:28:40 +08:00
|
|
|
os.environ['LINUX_FB'] = 'true'
|
2020-08-14 16:43:12 +08:00
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
self.parseArgs(self.awtk, ARGUMENTS)
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
print("AWTK_ROOT:" + self.AWTK_ROOT)
|
|
|
|
print(ARGUMENTS)
|
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
def getAwtkConfig(self):
|
|
|
|
sys.path.insert(0, self.AWTK_ROOT)
|
|
|
|
import awtk_config as awtk
|
|
|
|
return awtk
|
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
def saveUsesSdkInfo(self):
|
|
|
|
awtk = self.awtk
|
|
|
|
release_id = ''
|
|
|
|
filename = os.path.join(self.AWTK_ROOT, 'component.json')
|
|
|
|
if os.path.exists(filename):
|
|
|
|
with open(filename, 'r') as f:
|
|
|
|
component_content = f.read()
|
|
|
|
if len(component_content) > 0:
|
|
|
|
component_json = json.loads(component_content)
|
|
|
|
if 'release_id' in component_json:
|
|
|
|
release_id = component_json['release_id']
|
|
|
|
if sys.version_info < (3, 0):
|
|
|
|
release_id = release_id.encode('ascii')
|
|
|
|
|
|
|
|
content = '{\n'
|
|
|
|
content += ' "compileSDK": {\n'
|
|
|
|
content += ' "awtk": {\n'
|
|
|
|
content += ' "path": "' + \
|
|
|
|
self.AWTK_ROOT.replace('\\', '/') + '",\n'
|
|
|
|
content += ' "release_id": "' + release_id + '",\n'
|
|
|
|
content += ' "nanovg_backend": "' + awtk.NANOVG_BACKEND + '"\n'
|
|
|
|
content += ' }\n'
|
|
|
|
content += ' }\n'
|
|
|
|
content += '}'
|
|
|
|
|
|
|
|
filename = os.path.join(self.APP_BIN_DIR, 'uses_sdk.json')
|
|
|
|
if sys.version_info < (3, 0):
|
|
|
|
with open(filename, 'w') as f:
|
|
|
|
f.write(content)
|
|
|
|
else:
|
|
|
|
with open(filename, 'w', encoding='utf8') as f:
|
|
|
|
f.write(content)
|
|
|
|
|
|
|
|
def isBuildShared(self):
|
2020-09-18 11:31:59 +08:00
|
|
|
return 'WITH_AWTK_SO' in os.environ and os.environ['WITH_AWTK_SO'] == 'true' and self.BUILD_SHARED
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
def copyAwtkSharedLib(self):
|
2020-10-21 14:14:56 +08:00
|
|
|
if self.TKC_ONLY:
|
|
|
|
self.awtk.copySharedLib(self.AWTK_ROOT, self.APP_BIN_DIR, 'tkc')
|
|
|
|
else:
|
|
|
|
self.awtk.copySharedLib(self.AWTK_ROOT, self.APP_BIN_DIR, 'awtk')
|
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
for iter in self.DEPENDS_LIBS:
|
|
|
|
for so in iter['shared_libs']:
|
|
|
|
self.awtk.copySharedLib(iter['root'], self.APP_BIN_DIR, so)
|
|
|
|
|
|
|
|
def genIdlAndDef(self):
|
|
|
|
if self.DEF_FILE:
|
|
|
|
print(self.DEF_FILE)
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
|
|
|
|
idl_gen_tools = os.path.join(self.AWTK_ROOT, 'tools/idl_gen/index.js')
|
|
|
|
dll_def_gen_tools = os.path.join(
|
|
|
|
self.AWTK_ROOT, 'tools/dll_def_gen/index.js')
|
|
|
|
|
2020-10-13 17:43:19 +08:00
|
|
|
cmd = 'node ' + '"' + idl_gen_tools + '"' + ' idl/idl.json ' + self.SRC_DIR
|
2020-08-14 16:43:12 +08:00
|
|
|
if os.system(cmd) != 0:
|
|
|
|
print('exe cmd: ' + cmd + ' failed.')
|
|
|
|
|
|
|
|
cmd = 'node ' + '"' + dll_def_gen_tools + '"' + \
|
|
|
|
' idl/idl.json ' + self.DEF_FILE
|
|
|
|
if os.system(cmd) != 0:
|
|
|
|
print('exe cmd: ' + cmd + ' failed.')
|
|
|
|
else:
|
|
|
|
if self.DEF_FILE_PROCESSOR != None:
|
|
|
|
self.DEF_FILE_PROCESSOR()
|
|
|
|
|
|
|
|
def showHelp(self):
|
|
|
|
print('Options default values:')
|
|
|
|
print(' LCD=320_480')
|
|
|
|
print(' LANGUAGE=zh_CH')
|
|
|
|
print(' FONT="default"')
|
|
|
|
print(' THEME="default"')
|
|
|
|
print(' SHARED=true')
|
|
|
|
print(' LINUX_FB=false')
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
def parseArgs(self, awtk, ARGUMENTS):
|
2020-09-18 11:31:59 +08:00
|
|
|
APP_RES_ROOT = '../res'
|
|
|
|
APP_THEME = 'default'
|
2020-08-14 16:43:12 +08:00
|
|
|
LCD_WIDTH = '320'
|
|
|
|
LCD_HEIGHT = '480'
|
|
|
|
APP_DEFAULT_FONT = 'default'
|
|
|
|
APP_DEFAULT_LANGUAGE = 'zh'
|
|
|
|
APP_DEFAULT_COUNTRY = 'CN'
|
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
config = load_project_json('project.json')
|
|
|
|
if config and 'assets' in config:
|
|
|
|
APP_THEME = get_project_theme(config)
|
|
|
|
LCD_WIDTH = get_project_w(config, APP_THEME)
|
|
|
|
LCD_HEIGHT = get_project_h(config, APP_THEME)
|
|
|
|
APP_DEFAULT_LANGUAGE = get_project_language(config)
|
|
|
|
APP_DEFAULT_COUNTRY = get_project_country(config)
|
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
if ARGUMENTS.get('HELP', ''):
|
|
|
|
self.showHelp()
|
|
|
|
|
|
|
|
LCD = ARGUMENTS.get('LCD', '')
|
|
|
|
if len(LCD) > 0:
|
|
|
|
wh = LCD.split('_')
|
|
|
|
if len(wh) >= 1:
|
|
|
|
LCD_WIDTH = wh[0]
|
|
|
|
if len(wh) >= 2:
|
|
|
|
LCD_HEIGHT = wh[1]
|
|
|
|
|
|
|
|
FONT = ARGUMENTS.get('FONT', '')
|
|
|
|
if len(FONT) > 0:
|
|
|
|
APP_DEFAULT_FONT = FONT
|
|
|
|
|
|
|
|
THEME = ARGUMENTS.get('THEME', '')
|
|
|
|
if len(THEME) > 0:
|
|
|
|
APP_THEME = THEME
|
|
|
|
|
|
|
|
LANGUAGE = ARGUMENTS.get('LANGUAGE', '')
|
|
|
|
if len(LANGUAGE) > 0:
|
|
|
|
lan = LANGUAGE.split('_')
|
|
|
|
if len(lan) >= 1:
|
|
|
|
APP_DEFAULT_LANGUAGE = lan[0]
|
|
|
|
if len(lan) >= 2:
|
|
|
|
APP_DEFAULT_COUNTRY = lan[1]
|
|
|
|
|
2020-08-15 15:23:43 +08:00
|
|
|
RES_ROOT = ARGUMENTS.get('RES_ROOT', '')
|
|
|
|
if len(RES_ROOT) > 0:
|
|
|
|
APP_RES_ROOT = RES_ROOT
|
2020-11-24 09:28:40 +08:00
|
|
|
self.APP_RES = os.path.abspath(
|
|
|
|
os.path.join(self.APP_BIN_DIR, RES_ROOT))
|
2020-08-15 15:23:43 +08:00
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
SHARED = ARGUMENTS.get('SHARED', '')
|
2020-09-18 11:31:59 +08:00
|
|
|
if len(SHARED) > 0:
|
|
|
|
self.BUILD_SHARED = not SHARED.lower().startswith('f')
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
IDL_DEF = ARGUMENTS.get('IDL_DEF', '')
|
2020-09-18 11:31:59 +08:00
|
|
|
if len(IDL_DEF) > 0:
|
|
|
|
self.GEN_IDL_DEF = not IDL_DEF.lower().startswith('f')
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
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 + '\\\" '
|
|
|
|
APP_CCFLAGS = APP_CCFLAGS + ' -DAPP_RES_ROOT=\"\\\"' + APP_RES_ROOT + '\\\"\" '
|
|
|
|
APP_CCFLAGS = APP_CCFLAGS + ' -DAPP_DEFAULT_LANGUAGE=\\\"' + \
|
|
|
|
APP_DEFAULT_LANGUAGE + '\\\" '
|
|
|
|
APP_CCFLAGS = APP_CCFLAGS + ' -DAPP_DEFAULT_COUNTRY=\\\"' + \
|
|
|
|
APP_DEFAULT_COUNTRY + '\\\" '
|
|
|
|
APP_CCFLAGS = APP_CCFLAGS + ' -DAPP_ROOT=\"\\\"' + \
|
|
|
|
self.APP_ROOT + '\\\"\" '
|
2020-11-24 09:28:40 +08:00
|
|
|
self.APP_CFLAGS = ''
|
2020-09-18 11:31:59 +08:00
|
|
|
self.APP_CCFLAGS = APP_CCFLAGS
|
|
|
|
self.APP_CXXFLAGS = self.APP_CCFLAGS
|
2020-08-14 16:43:12 +08:00
|
|
|
|
2020-10-22 09:02:51 +08:00
|
|
|
if PLATFORM == 'Linux':
|
2020-09-18 11:31:59 +08:00
|
|
|
self.APP_LINKFLAGS += ' -Wl,-rpath=' + self.APP_BIN_DIR + ' '
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
if not self.isBuildShared() and hasattr(awtk, 'AWTK_CCFLAGS'):
|
2020-09-18 11:31:59 +08:00
|
|
|
self.AWTK_CCFLAGS = awtk.AWTK_CCFLAGS
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
if self.isBuildShared():
|
2020-09-18 11:31:59 +08:00
|
|
|
self.AWTK_LIBS = awtk.SHARED_LIBS
|
|
|
|
self.APP_LIBPATH = [self.APP_BIN_DIR, self.APP_LIB_DIR]
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
if hasattr(awtk, 'TOOLS_NAME') and awtk.TOOLS_NAME != '':
|
2020-09-18 11:31:59 +08:00
|
|
|
self.APP_TOOLS = [awtk.TOOLS_NAME]
|
2020-08-14 16:43:12 +08:00
|
|
|
|
2020-09-18 11:31:59 +08:00
|
|
|
os.environ['BUILD_SHARED'] = str(self.isBuildShared())
|
2020-08-30 08:52:17 +08:00
|
|
|
print(LCD_WIDTH, LCD_HEIGHT)
|
2020-09-18 11:31:59 +08:00
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
def prepare(self):
|
|
|
|
if self.GEN_IDL_DEF and not self.LINUX_FB:
|
|
|
|
self.genIdlAndDef()
|
|
|
|
|
|
|
|
if self.isBuildShared():
|
|
|
|
self.copyAwtkSharedLib()
|
|
|
|
|
|
|
|
self.saveUsesSdkInfo()
|
|
|
|
|
|
|
|
def getAwtkRoot(self):
|
2020-09-21 18:02:27 +08:00
|
|
|
AWTK_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
if self.LINUX_FB:
|
2020-11-24 09:28:40 +08:00
|
|
|
AWTK_ROOT = os.path.join(
|
|
|
|
os.path.dirname(AWTK_ROOT), 'awtk-linux-fb')
|
2020-09-21 18:02:27 +08:00
|
|
|
return AWTK_ROOT
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
def call(self, DefaultEnvironment):
|
|
|
|
awtk = self.awtk
|
|
|
|
CPPPATH = awtk.CPPPATH + self.APP_CPPPATH
|
|
|
|
LINKFLAGS = awtk.LINKFLAGS + self.APP_LINKFLAGS
|
2020-12-03 10:04:47 +08:00
|
|
|
LIBS = self.AWTK_LIBS + self.PLATFORM_LIBS
|
2020-08-14 16:43:12 +08:00
|
|
|
LIBPATH = self.APP_LIBPATH + awtk.LIBPATH
|
2020-09-28 07:40:57 +08:00
|
|
|
CFLAGS = self.APP_CFLAGS + self.AWTK_CFLAGS
|
2020-08-14 16:43:12 +08:00
|
|
|
CCFLAGS = self.APP_CCFLAGS + self.AWTK_CCFLAGS
|
|
|
|
TARGET_ARCH = awtk.TARGET_ARCH
|
|
|
|
APP_TOOLS = self.APP_TOOLS
|
|
|
|
CXXFLAGS = self.APP_CXXFLAGS
|
|
|
|
|
2020-10-30 11:34:46 +08:00
|
|
|
if self.TKC_ONLY:
|
|
|
|
CCFLAGS += ' -DTKC_ONLY=1 '
|
2020-10-31 17:38:09 +08:00
|
|
|
else:
|
|
|
|
CCFLAGS += ' -DWITH_AWTK=1 '
|
2020-10-30 11:34:46 +08:00
|
|
|
|
2020-08-14 16:43:12 +08:00
|
|
|
for iter in self.DEPENDS_LIBS:
|
|
|
|
if 'shared_libs' in iter:
|
2020-08-18 15:22:36 +08:00
|
|
|
LIBS = iter['shared_libs'] + LIBS
|
2020-08-14 16:43:12 +08:00
|
|
|
if 'static_libs' in iter:
|
2020-08-18 15:22:36 +08:00
|
|
|
LIBS = iter['static_libs'] + LIBS
|
2020-11-24 09:28:40 +08:00
|
|
|
if 'cxxflags' in iter:
|
|
|
|
CXXFLAGS += " " + iter['cxxflags'] + " "
|
|
|
|
if 'cflags' in iter:
|
|
|
|
CFLAGS += " " + iter['cflags'] + " "
|
|
|
|
if 'ccflags' in iter:
|
|
|
|
CCFLAGS += " " + iter['ccflags'] + " "
|
|
|
|
|
|
|
|
if 'cpppath' in iter:
|
|
|
|
for f in iter['cpppath']:
|
|
|
|
CPPPATH = CPPPATH + [join_path(iter['root'], f)]
|
|
|
|
else:
|
|
|
|
CPPPATH += [join_path(iter['root'], 'src')]
|
|
|
|
|
|
|
|
if 'libpath' in iter:
|
|
|
|
for f in iter['libpath']:
|
|
|
|
LIBPATH = LIBPATH + [join_path(iter['root'], f)]
|
|
|
|
else:
|
|
|
|
LIBPATH += [join_path(iter['root'], 'lib')]
|
|
|
|
LIBPATH += [join_path(iter['root'], 'bin')]
|
2020-12-03 10:04:47 +08:00
|
|
|
LIBS = self.APP_LIBS + LIBS
|
2020-08-14 16:43:12 +08:00
|
|
|
|
|
|
|
self.prepare()
|
|
|
|
if hasattr(awtk, 'CC'):
|
|
|
|
DefaultEnvironment(
|
|
|
|
CC=awtk.CC,
|
|
|
|
CXX=awtk.CXX,
|
|
|
|
LD=awtk.LD,
|
|
|
|
AR=awtk.AR,
|
|
|
|
STRIP=awtk.STRIP,
|
2020-11-04 08:46:56 +08:00
|
|
|
RANLIB=awtk.RANLIB,
|
2020-08-14 16:43:12 +08:00
|
|
|
TOOLS=APP_TOOLS,
|
|
|
|
CPPPATH=CPPPATH,
|
|
|
|
LINKFLAGS=LINKFLAGS,
|
|
|
|
LIBS=LIBS,
|
|
|
|
LIBPATH=LIBPATH,
|
|
|
|
CCFLAGS=CCFLAGS,
|
2020-09-28 07:40:57 +08:00
|
|
|
CFLAGS=CFLAGS,
|
2020-08-14 16:43:12 +08:00
|
|
|
CXXFLAGS=CXXFLAGS,
|
|
|
|
TARGET_ARCH=awtk.TARGET_ARCH,
|
|
|
|
OS_SUBSYSTEM_CONSOLE=awtk.OS_SUBSYSTEM_CONSOLE,
|
|
|
|
OS_SUBSYSTEM_WINDOWS=awtk.OS_SUBSYSTEM_WINDOWS)
|
|
|
|
else:
|
|
|
|
DefaultEnvironment(
|
|
|
|
TOOLS=APP_TOOLS,
|
|
|
|
CPPPATH=CPPPATH,
|
|
|
|
LINKFLAGS=LINKFLAGS,
|
|
|
|
LIBS=LIBS,
|
|
|
|
LIBPATH=LIBPATH,
|
2020-09-28 07:40:57 +08:00
|
|
|
CFLAGS=CFLAGS,
|
2020-08-14 16:43:12 +08:00
|
|
|
CCFLAGS=CCFLAGS,
|
|
|
|
CXXFLAGS=CXXFLAGS,
|
|
|
|
TARGET_ARCH=awtk.TARGET_ARCH,
|
|
|
|
OS_SUBSYSTEM_CONSOLE=awtk.OS_SUBSYSTEM_CONSOLE,
|
|
|
|
OS_SUBSYSTEM_WINDOWS=awtk.OS_SUBSYSTEM_WINDOWS)
|