def __try_load_action(self): # 通过参数p获取插件 plugin_name = core.data.arguments.get_opt("p") if not plugin_name: return plugin_list = plugin_name.split(core.GLOBAL_SEPARATED) # 获取已经存在的插件列表 folder = os.path.dirname(os.path.abspath(__file__)) file_list = os.listdir(folder) for plugin in plugin_list: plugin_name = self.plugin_name_mapping["action"] + plugin # 不存在下载 if plugin_name + ".py" not in file_list: if not self.try_download_plugin("action", plugin): raise core.TmakeException( "The plugin:" + plugin + " is not support! Please check your -p params!") # 加载插件 try: module = "core.actions." + plugin_name exec("import " + module) action = eval(module + ".new_action()") self.actions.append(action) except ImportError: raise core.TmakeException( "Can't load action plugin {} \n".format(plugin)) core.s("plugin [%s] loaded successfully!" % plugin) self.actions.sort(cmp=action_comp)
def __check(self): """ 依赖树依赖检查 :return: """ self.__filter_match_module() for name, vers in self.__deps_dict.iteritems(): if len(vers) > 1: self.__fix_origin_deps_module() self.record_deps_info() raise core.TmakeException("库版本冲突:[name:{}][version:{}]".format(name, vers.keys())) continue # 暂时去掉库不同类型版本冲突的检查 fix_name = name for item in [core.SHARED_SUFFIX, core.BINARY_SUFFIX, core.FRAMEWORK_SUFFIX]: fix_name = fix_name.replace(item, "") # 如果xxxDice及xxxDice_shared同时依赖,版本不一样也报冲突 type_version_set = None if fix_name in self.__deps_dict: type_version_set = set(self.__deps_dict[fix_name].keys() + vers.keys()) if type_version_set and len(type_version_set) > 1: self.__fix_origin_deps_module() self.record_deps_info() raise core.TmakeException("库不同类型版本冲突:[name:{}/{}][version:{}]".format(fix_name, name, type_version_set)) # 把名字转换为对象 self.__fix_deps_module() # 成功记录依赖关系 self.record_deps_info()
def __dep_analyse(self, dep): """ 分析被依赖的单个模块 :param dep: :return: """ dep_name, dep_version, custom_link_name = core.parse_dep(dep) # 在冲突里就用冲突里配置的 if dep_name in self.__conflict: conflict_solution_version = self.__conflict[dep_name] if dep_version.endswith("+") \ and LooseVersion(conflict_solution_version) < LooseVersion(dep_version[:-1]): raise core.TmakeException("tmake_customerVersion is {{'{}':'{}'}}, " "but found must bigger one:{}".format(dep_name, conflict_solution_version, dep_version)) dep_version = conflict_solution_version dep_mod = self.get_module(dep_name, dep_version) if not dep_mod: dep_mod = DepModule(dep_name, dep_version, custom_link_name) if not dep_mod.is_local: self.add_download_queue(dep_mod) self.set_module(dep_mod) return dep_mod
def execute_build_command(self, command_text): """ execute build command """ command = tmake_utils.get_cd_command() + " \"" + self.path.build_path + "\" && " + command_text core.v(command) self.__do_rm_build_bin_dir() # shell=xx,windows的线上构建报错,不要修改为false #ret = core.subprocess.call(command, shell=True) ret = subprocess.call(command, shell=True) if ret != 0: raise core.TmakeException('build failed! return code is {}'.format(ret)) if core.data.use_cmakelist or core.data.use_proj_cmakelist: if core.data.use_cmakelist: recover_cmakelists(self.path.project_folder) if core.data.arguments.tmake_cmd() == "project": src_dir = os.path.join(self.path.project_path, core.BUILD_OUTPUT_NAME) else: src_dir = os.path.join(self.path.build_path, core.BUILD_OUTPUT_NAME) # build folder arrange_dir(src_dir, src_dir) delete_empty_dir(src_dir) # export folder dst_dir = os.path.join(self.path.build_path, core.BUILD_INSTALL_PREFIX, core.BUILD_OUTPUT_NAME) copy_libs_to_export(src_dir, dst_dir) src_dir = os.path.join(self.path.build_path, core.BUILD_INSTALL_PREFIX) arrange_dir(src_dir, dst_dir) delete_empty_dir(src_dir) if core.data.use_proj_cmakelist: for external_build in self.info.external_builds: if external_build.path: path = external_build.path recover_cmakelists(path)
def load_cmake_plugin_and_generate(target, arch, write_to_file=True): """ load cmake plugin and generate CMakeList.txt """ import_cmd = "import core.cmake_gens.tmake_cmake_generator_" + target call_cmd = "core.cmake_gens.tmake_cmake_generator_" + target + ".cmake_plugin_init(arch)" try: exec import_cmd except ImportError: raise core.TmakeException( "The target:" + target + " is not support! Please check your -t params!") acg = eval(call_cmd) core.data.action_mgr.run_befor_action(TMAKE_ACTION_CMAKE_LISTS, core.data, acg) acg.generate() core.data.action_mgr.run_after_action(TMAKE_ACTION_CMAKE_LISTS, core.data, acg) if write_to_file: core.write_entire_file( os.path.join(acg.path.build_path, core.CMAKE_SCRIPT_FILE_NAME), acg.cmake_text) core.data.action_mgr.run_befor_action(TMAKE_ACTION_PUBLISH_PROJECT, core.data, acg) return acg
def param_check(self): argv = self.arguments.args() if len(argv) > 0: if "all" == argv[0]: self.run_all = True else: self.binary_set = argv[0].split(core.GLOBAL_SEPARATED) for binary in self.binary_set: if len(binary) <= 0: raise core.TmakeException( 'param %s is error , please check !' % argv[0]) if "all" in self.binary_set: raise core.TmakeException( '\'all\' is run all tests task program for all projects , ' '%s Spaced not required' % tmake.GLOBAL_SEPARATED) else: self.run_all = True
def __generate_headers(self, dir, feature_dict): """ 覆盖式写入宏定义头文件 :param path: 文件路径,相对路径或者全路径 :param feature_dict: {"section1":{"ke1":"value1"},"section2":{"ke1":"value1"}} :return: """ if not isinstance(feature_dict, dict): raise core.TmakeException("Input param2 must be a dict!!!") file_path = "" try: for key, value in feature_dict.items(): self.feature_macro_dict[key] = value file_path = os.path.join(dir, self.modules_key_word, key) if not os.path.exists(file_path): os.makedirs(file_path) file_path = os.path.join(file_path, self.feature_key_word + ".h") f = open(file_path, "w") project_name = dir.split('/')[-1] model = "#ifndef __{}__\n".format( project_name.upper() + '_' + self.feature_key_word.upper()) f.write(model) model = "#define __{}__\n\n".format( project_name.upper() + '_' + self.feature_key_word.upper()) f.write(model) macro_list = value.split(",") for item in macro_list: if not item: break macro_info = item.split("=") macro_key = macro_info[0].replace("-D", "") macro_value = macro_info[1] if macro_value.upper() == "TRUE": ret = "1" else: ret = "0" model = "#define {} {}\n".format(macro_key, ret) f.write(model) f.write("\n") model = "#endif\n" f.write(model) f.close() core.s("generate header success: {}".format(file_path)) except: core.TmakeException("generate header failed: {}".format(file_path))
def __parse_project(): """ 解析project,不成功给出提示 :return: """ if not core.data.parse_project(): core.e("work path = " + str(core.data.arguments.work_path())) raise core.TmakeException( 'project parse failed, please ensure work path is right!')
def execute_task(self, task): if core.data.target == core.data.platform.host: core.v('curr run name : %s' % task) args = [] command = string.strip(task.command) cwd = task.work_directory args += task.args core.v('command : {} , cwd : {} , args : {}'.format( command, cwd, args)) if len(command) <= 0: raise core.TmakeException( '[Possible error] tmake_host_tester_task : {} command property configuration error !!!' .format(task)) cmd_check = re.split(' *', command) core.v('pre cmd_check : {}'.format(cmd_check)) cmd_check[0] = os.path.join(self.acg.path.build_symbol_path, cmd_check[0]) if core.data.platform.host == core.PLATFORM_WINDOWS: cmd_check[0] += '.exe' core.v('post cmd_check : {}'.format(cmd_check)) if not os.path.exists(cmd_check[0]): raise core.TmakeException( '%s is not exist %s , please first build !' % (cmd_check[0], self.__common_log_info())) if len(cwd) <= 0: cwd = None elif not os.path.isabs(cwd): cwd = os.path.abspath( os.path.join(self.acg.path.project_folder, cwd)) cmd_check += args core.i('\n----> exec {} ......'.format(cmd_check)) self.env_set() ret, msg = process_utils.execute_prog_with_sysstdout( cmd_check, cwd) if ret == 0: core.s('{} test success!\n'.format(task.name)) else: raise core.TmakeException( '{} test error! {} message : {}\n'.format( task.name, ret, msg)) else: raise core.TmakeException( '%s and %s do not match , please do not add -t parameter' % (core.data.target, core.data.platform.host))
def tmake_cxx_library(name=None, version=None, publish=None, deps=None, windows_deps=None, mac_deps=None, linux_deps=None, android_deps=None, ios_deps=None, embedded_deps=None, include_dirs=None, lib_dirs=None, frameworks=None, publish_info=None, framework_properties=None, defines=None, headers=None, srcs=None, c_flags=None, cxx_flags=None, linker_flags=None, link_style=None, link_libs=None, link_all_symbol_libs=None, un_relink_deps=None, exported_headers=None, exported_headers_by_folder=None, tasks=None, valid=True, properties=None, pre_cmake_command=None, post_cmake_command=None, xctest_unit_src=None): """tmake_cxx_library""" if not valid: return if not link_style: raise core.TmakeException( "{}'s link_style can not be null !!!".format(name)) if link_style.lower() not in core.ALLOW_LINK_STYLE_LIST: raise core.TmakeException("link_style must in {}!".format( core.ALLOW_LINK_STYLE_LIST)) core.data.current_project.libraries[name] = locals()
def __init__(self, module, cond, function_and_list): """ :param module: cxx_module :param function_and_list: list类型,第一个元素是方法对象,其余的是参数 """ self.cond = cond if cond not in core.SCRIPT_TYPE_LIST: raise core.TmakeException( "tasks'key just can be {} for module {}".format(", ".join(core.SCRIPT_TYPE_LIST), module.name)) if not function_and_list: raise core.TmakeException("Value can not be empty for key %s in module %s" % (cond, module.name)) # check function function = function_and_list[0] if not callable(function): raise core.TmakeException( "%s is type of %s, is not callable for tmake_script_task" % (function.__name__, type(function))) self.function = function self.arguments = function_and_list[1:]
def check_system_version(self): if int(self.info.build_vars["CMAKE_SYSTEM_VERSION"]) < 21 \ and self.arch in core.TARGET_ANDROID_CPU_64_ALL: arch = core.data.arguments.get_opt('-a', '--architecture') if arch and arch.lower() == "all": # all的64位,抛指定异常跳过, info = "the target is [all], but the architecture [{}] " \ "is not supported bv android system version [{}]! skip it." raise SkipException(info.format(self.arch, self.info.build_vars["CMAKE_SYSTEM_VERSION"])) else: core.e(TIP_MESSAGE.format(self.info.build_vars["CMAKE_SYSTEM_VERSION"], self.arch)) raise core.TmakeException("CMAKE_SYSTEM_VERSION IS ERROR!")
def __fix_deps_module(self): """ 替换 __deps_dict里的每个module的对象 :return: """ for name in self.__deps_dict: for ver in self.__deps_dict[name]: # 实际此时每个name只有一个version了 dep_module = self.__deps_dict[name][ver] # 把字符串类型的依赖替换为depModule类型的依赖 for dep in dep_module.dep_name_version_list: module = self.get_module_by_name(dep[0]) if not module: raise core.TmakeException("can't find module by name:%s" % dep[0]) dep_module.dep_module_list.append(module)
def change_cmakelists_output(src_dir, export_path, executable_output_path, library_output_path): if NO_CHANGE_CMAKELISTS: return src_dir = src_dir.replace("\\", "/") export_path = export_path.replace("\\", "/") executable_output_path = executable_output_path.replace("\\", "/") library_output_path = library_output_path.replace("\\", "/") for f in os.listdir(src_dir): sourceF = os.path.join(src_dir, f) sourceF = sourceF.replace("\\", "/") if os.path.isfile(sourceF) and CMAKELISTS.lower() in sourceF.lower(): lines = __read_file(sourceF) is_modify, lines = __modify_cmaklists(lines, export_path, executable_output_path, library_output_path) if is_modify and lines: ret = __backup_cmakelists(sourceF) if not ret: core.TmakeException("Backup CMakelists.txt failed: {}".format(sourceF)) else: ret = __rewrite_cmakelists(sourceF, lines) if not ret: core.TmakeException("Rewrite CMakelists.txt failed: {}".format(sourceF)) if os.path.isdir(sourceF): change_cmakelists_output(sourceF, export_path, executable_output_path, library_output_path)
def tmake_config(path): """解析配置文件,返回字典""" full_path = tmake_path(path) if not os.path.exists(full_path): raise core.TmakeException("file: {} not exist!!!".format(full_path)) ver_conf = CustomConfigParser() ver_conf.readfp(open(full_path, "rb")) result_dict = {} for section in ver_conf.sections(): inner_dict = {} for item in ver_conf.options(section): inner_dict[item] = ver_conf.get(section, item) result_dict[section] = inner_dict core.log.s("parse success: {}\n{}".format(full_path, result_dict)) return result_dict
def __get_android_ndk(self): """ 参考toolchain的写法 # Android NDK if(NOT ANDROID_NDK) if(DEFINED ENV{ANDROID_NDK} AND IS_DIRECTORY "$ENV{ANDROID_NDK}") set(ANDROID_NDK "$ENV{ANDROID_NDK}") elseif(DEFINED ENV{ANDROID_NDK_HOME} AND IS_DIRECTORY "$ENV{ANDROID_NDK_HOME}") set(ANDROID_NDK "$ENV{ANDROID_NDK_HOME}") elseif(DEFINED ENV{ANDROID_HOME} AND IS_DIRECTORY "$ENV{ANDROID_HOME}/ndk-bundle") set(ANDROID_NDK "$ENV{ANDROID_HOME}/ndk-bundle") elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux AND IS_DIRECTORY "$ENV{HOME}/Android/Sdk/ndk-bundle") set(ANDROID_NDK "$ENV{HOME}/Android/Sdk/ndk-bundle") elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin AND IS_DIRECTORY "$ENV{HOME}/Library/Android/sdk/ndk-bundle") set(ANDROID_NDK "$ENV{HOME}/Library/Android/sdk/ndk-bundle") elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND IS_DIRECTORY "$ENV{LOCALAPPDATA}/Android/Sdk/ndk-bundle") set(ANDROID_NDK "$ENV{LOCALAPPDATA}/Android/Sdk/ndk-bundle") else() message(FATAL_ERROR "Android NDK unspecified.") endif() endif() """ """get android ndk path""" ndk_path = self._check_ndk_path("ANDROID_NDK", "") if not ndk_path: ndk_path = self._check_ndk_path("ANDROID_NDK_HOME", "") if not ndk_path: ndk_path = self._check_ndk_path("ANDROID_HOME", "ndk-bundle") if not ndk_path: ndk_path = self._check_ndk_path("HOME", "Android/Sdk/ndk-bundle") if not ndk_path: ndk_path = self._check_ndk_path("HOME", "Library/Android/sdk/ndk-bundle") if not ndk_path: ndk_path = self._check_ndk_path("LOCALAPPDATA", "Android/Sdk/ndk-bundle") if not ndk_path: raise core.TmakeException("ndk path not found! please check your environment path...") ndk_path = ndk_path.replace('\\', '/') core.s("ndk_path = " + ndk_path) return ndk_path
def __fix_origin_deps_module(self): """ 替换 __deps_dict里的每个module的对象,用原始的版本号查找 :return: """ for name in self.__deps_dict: for ver in self.__deps_dict[name]: # 实际此时每个name只有一个version了 dep_module = self.__deps_dict[name][ver] # 把字符串类型的依赖替换为depModule类型的依赖 for dep in dep_module.dep_name_version_list: module = self.get_module(dep[0], dep[1]) if not module: # 配置了+的可能会导致找不到,这里再通过名字找下 module = self.get_module_by_name(dep[0]) if not module: raise core.TmakeException("can't find module by name:{} version:{}".format(dep[0], dep[1])) dep_module.dep_module_list.append(module)
def tmake_config_write(path, conf_dict): """ 将字典类型的配置写入conf文件,覆盖式写入 :param path: 文件路径,相对路径或者全路径 :param conf_dict: {"section1":{"ke1":"value1"},"section2":{"ke1":"value1"}} :return: """ full_path = tmake_path(path) if not isinstance(conf_dict, dict): raise core.Exception("input param2 must be a dict!!!") ver_conf = CustomConfigParser() for key, value in conf_dict.items(): ver_conf.add_section(key) if not isinstance(value, dict): raise core.TmakeException("value must be a dict!!!") for inner_key, inner_value in value.items(): ver_conf.set(key, inner_key, inner_value) ver_conf.write(open(full_path, "w")) core.log.s("write config success: {}\n{}".format(full_path, conf_dict))
def get_module_by_name(self, name, force=True): """ 通过名字获得依赖信息 如果冲突的解决方案里有,取里面的 如果__deps_dict里有多个不同版本号的,取第一个 :param name: :return: """ arr = name.split(":") if len(arr) > 1: name = arr[0] result = None if name in self.__deps_dict: for key in self.__deps_dict[name]: result = self.__deps_dict[name][key] break if force and not result: raise core.TmakeException("Can't find dep info by name: {}".format(name)) return result
def run(self): try: arguments = core.data.arguments if not core.data.arguments.tmake_cmd(): import cmd.tmake_help cmd.tmake_help.main().run() return self.check_python_tools() if core.data.arguments.tmake_cmd() != "config": self.check_cmake_tools() core.exec_tmake_command(arguments) # core.s(core.data.arguments.tmake_cmd() + ' success!') except Exception as exception: traceback.print_exc() core.reset_color(log_attributes) if not isinstance(exception, core.TmakeException): core.e(traceback.format_exc()) raise core.TmakeException( 'use `tmake help` to get more information') sys.exit(-1)
def tmake_deps_info(dep_name): """ 返回从DEPS.conf中读取的版本信息 :param dep_name: :return: 类似这种格式 xxxMap:9.18.100.34 """ # 动态库和静态库同相同的版本。 fix_dep_name = dep_name.replace(core.SHARED_SUFFIX, "") library_deps = core.data.current_project.library_deps if fix_dep_name in library_deps: if library_deps[fix_dep_name] == "local": return fix_dep_name + ":" + library_deps[fix_dep_name] else: return dep_name + ":" + library_deps[fix_dep_name] # deps update命令解析依赖,如果不做特殊处理这里会抛找不到异常了 elif IS_DEPS_UPDATING: return "deps_updating:deps_updating" else: raise core.TmakeException( "cann't find [{}] from DEPS.conf, please check!!!".format( dep_name))
import os import core # from tmake_project_parser import parse as pparser from core.info.tmake_path_info import PathInfo from core.utils import tmake_utils import ConfigParser TMAKE_HOST = core.data.platform.host TMAKE_TARGET = core.data.arguments.get_opt("-t", "--target") TMAKE_CONFIG = core.data.arguments.get_opt("-c") TMAKE_CPU_ARCH = tmake_utils.get_archs()[0] # build/project的时候会修改这个值 if TMAKE_CONFIG and TMAKE_CONFIG not in core.CONFIG_ALL: raise core.TmakeException("build config [-c] must in {}".format( core.CONFIG_ALL)) # 解决ConfigParser大小写不敏感的问题 class CustomConfigParser(ConfigParser.ConfigParser): def __init__(self, defaults=None): import ConfigParser ConfigParser.ConfigParser.__init__(self, defaults=None) def optionxform(self, optinostr): return optinostr def tmake_config_write(path, conf_dict): """ 将字典类型的配置写入conf文件,覆盖式写入
def __download_dep(self, module, arch): """ 下载某依赖 :param module: :return: """ from core.info.tmake_deps_download import DepDownload version = module.version try_previous_version = True while True: dep_download = DepDownload(core.TMAKE_LIBRARIES_PATH, module.name, version, core.data.target, arch) # 如果是ios的下载fusion指令集的,然后设置软连接 if arch in [core.TARGET_CPU_OS, core.TARGET_CPU_SIMULATOR]: fusion_download = DepDownload(core.TMAKE_LIBRARIES_PATH, module.name, version, core.data.target, core.TARGET_CPU_FUSION) parser = self.__download_dep_module(fusion_download, module) # 设置软连接 if parser: tmake_utils.set_symlink(fusion_download.get_path(), dep_download.get_path()) else: parser = self.__download_dep_module(dep_download, module) if not parser: if try_previous_version: # 查看对应库的上一个版本是否存在,如果存在,则可能与依赖的库处于并发构建状态 version = self.get_previous_version(version) if version: try_previous_version = False else: # 前一个版本号不存在,直接抛出异常 raise core.TmakeException("download dep failed! [{}] [{}] {} ".format(core.data.target, arch, module)) else: raise core.TmakeException("download dep failed! [{}] [{}] {} ".format(core.data.target, arch, module)) else: if not try_previous_version and module.version != version: # 上一个版本的库存在,延时5min后再次下载 core.log.e("{}不存在,{}存在,可能处于并发构建,延时5min后自动再次尝试下载{}".format(module.version, version, module.name)) time.sleep(300) version = module.version else: # 下载成功,直接break break module.include_dir = [parser.include_dir] module.root_path = parser.get_root_path() module.lib_dir = [parser.lib_dir] module.link_name = parser.link_name module.origin_lib_dir = parser.lib_dir module.origin_sym_lib_dir = parser.sym_lib_dir module.origin_include_dir = parser.include_dir return parser.depslibs
def __check_name_version(self): if self != core.data.deps_mgr.get_module(self.name, self.version): raise core.TmakeException("error dep info {} {}".format(self.name, self.version))
def check_cmake_tools(self): """check cmake tools""" if not core.check_cmake(): raise core.TmakeException("please install cmake !!!")
def check_python_tools(self): """check python tools""" version = platform.python_version() if not version.startswith("2.7"): raise core.TmakeException( "please make sure python version is 2.7.x !!!")
def run_build(self): """ call cmake build """ target = core.data.target command_text = "" use_nmake = "" if PlatformInfo.is_windows_system(): vs_tools = core.data.environment.get_vs_tool_path(self.arch) if target != core.PLATFORM_ANDROID and target != core.PLATFORM_WINDOWS: raise core.TmakeException('unsupported target : ' + target) command_text += '"' + vs_tools + '" ' command_text += "&&" if core.data.use_cmakelist: command_text += tmake_utils.get_cd_command() + " \"" + self.path.project_folder + "\" && " else: command_text += tmake_utils.get_cd_command() + " \"" + self.path.build_path + "\" && " if not core.data.arguments.has_flag("nmp", "nmp") and target == core.PLATFORM_WINDOWS and not "wince" in self.arch\ and not core.data.use_cmakelist: use_nmake = '-G "NMake Makefiles JOM" ' jom_exe = os.path.join(core.data.arguments.tmake_path(), "tools", "jom.exe") use_nmake += ' -DCMAKE_MAKE_PROGRAM="' + jom_exe + '"' core.i("use_nmake = " + use_nmake) elif target == core.PLATFORM_WINDOWS and "wince" in self.arch: use_nmake = '-G "Visual Studio 9 2008 ' + core.WINCE_CPU_MAP[self.arch] + '"' else: use_nmake = '-G "NMake Makefiles" ' if core.data.use_cmakelist: command_text += '"' + self.cmake_home + '" ../../../../ ' + use_nmake + self.__build_params() else: command_text += '"' + self.cmake_home + '" . ' + use_nmake + self.__build_params() command_text += "&&" command_text += self.__build_target() if target == core.PLATFORM_WINDOWS and "wince" in self.arch: configuration = '' if self.info.build_config == core.CONFIG_DEBUG: configuration = 'Debug' elif self.info.build_config == core.CONFIG_RELWITHDEBINFO: configuration = 'RelWithDebInfo' else: configuration = 'Release' command_text += "&&" command_text += 'msbuild.exe ' + self.info.project_name + ".sln " + '/t:ReBuild ' + '/p:Configuration=' + configuration + ' /p:Platform=' + '"' + \ core.WINCE_CPU_MAP[self.arch] + '"' if core.data.use_cmakelist and target != core.PLATFORM_WINDOWS: if core.data.arguments.tmake_cmd() == "project": path_info = PathInfo(self.arch, core.data.arguments.work_path()) base_path = path_info.project_path else: base_path = core.data.project.get_build_folder(self.arch) export_path = os.path.join(base_path, core.BUILD_INSTALL_PREFIX) exectable_output_path = os.path.join(base_path, core.BUILD_OUTPUT_NAME) library_output_path = os.path.join(base_path, core.BUILD_OUTPUT_NAME) pre_command_text = '"' + self.cmake_home + '" ../../../../ ' + " -DCMAKE_INSTALL_PREFIX={}".format(export_path) + \ " -DEXECUTABLE_OUTPUT_PATH={}".format(exectable_output_path) + \ " -DLIBRARY_OUTPUT_PATH={}".format(library_output_path) + \ use_nmake + self.__build_params() pre_command_text = tmake_utils.get_cd_command() + " \"" + self.path.build_path + "\" && " + pre_command_text ret = subprocess.call(pre_command_text, shell=True) if ret != 0: raise core.TmakeException('Set CMAKE_INSTALL_PREFIX failed! return code is {}'.format(ret)) self.execute_build_command(command_text)
def run(self): """run command""" raise core.TmakeException("The method of run must be overwrite!!!")
def __exitsys(self, message): raise core.TmakeException('{}:{}'.format(self.__xmlparentpath, message))
def make_project(self, cmake_list_path, name): """ call cmake project """ if self.get_cmake_generator_name(name) == '': return target = core.data.target project_folder = self.path.project_path command_text = "" use_nmake = "" if PlatformInfo.is_windows_system(): vs_tools = core.data.environment.get_vs_tool_path(self.arch) if target != core.PLATFORM_ANDROID and target != core.PLATFORM_WINDOWS: raise core.TmakeException('unsupported target : ' + target) command_text += '"' + vs_tools + '" ' command_text += "&&" command_text += '"' + self.cmake_home + '" ' command_text += '-H"' + cmake_list_path + '" ' command_text += '-B"' + project_folder + '" ' command_text += '-G"' + self.get_cmake_generator_name(name) + '" ' command_text += use_nmake + self.__build_params() core.v(command_text) # tmake_utils.do_rm_build_bin_dir(tmake_utils.get_build_path(self.arch)) # windows用false,其余的用true if core.data.use_cmakelist: if core.data.arguments.tmake_cmd() == "project": path_info = PathInfo(self.arch, core.data.arguments.work_path()) base_path = path_info.project_path else: base_path = core.data.project.get_build_folder(self.arch) export_path = os.path.join(base_path, core.BUILD_INSTALL_PREFIX) exectable_output_path = os.path.join(base_path, core.BUILD_OUTPUT_NAME) library_output_path = os.path.join(base_path, core.BUILD_OUTPUT_NAME) # pre_command_text = '"' + self.cmake_home + '" ../../../../ ' + " -DCMAKE_INSTALL_PREFIX={}".format(export_path) + \ # " -DEXECUTABLE_OUTPUT_PATH={}".format(exectable_output_path) + \ # " -DLIBRARY_OUTPUT_PATH={}".format(library_output_path) # # pre_command_text = tmake_utils.get_cd_command() + " \"" + self.path.project_path + "\" && " + pre_command_text # # ret = core.subprocess.call(pre_command_text, shell=not PlatformInfo.is_windows_system()) # if ret != 0: # raise core.TmakeException('Set CMAKE_INSTALL_PREFIX failed! return code is {}'.format(ret)) ret = subprocess.call(command_text, shell=not PlatformInfo.is_windows_system()) if core.data.use_cmakelist: recover_cmakelists(self.path.project_folder) if core.data.use_proj_cmakelist: for external_build in self.info.external_builds: if external_build.path: path = external_build.path recover_cmakelists(path) if ret != 0: raise core.TmakeException('build failed! return code is {}'.format(ret))