def using_cmake(path, output_path, cmake_build_args=""): """ :param path: project path :param output_path: :param cmake_build_args: :return: status: Checking and execution result build_path: cmake outer_build path """ filename = os.path.join(path, "CMakeLists.txt") if not os.path.exists(filename): return False, None build_folder_path = os.path.join(output_path, "build") if not os.path.exists(build_folder_path): os.makedirs(build_folder_path) else: shutil.rmtree(build_folder_path) os.makedirs(build_folder_path) cmd = "cmake {} {}".format(path, cmake_build_args) (returncode, out, err) = capture_util.subproces_calling(cmd, cwd=build_folder_path) if returncode == 0: return True, build_folder_path return False, None
def command_exec_worker(get_item_func): logger.info("Thread: %s start." % pool.threading.currentThread().getName()) is_empty = False while not is_empty: try: job_dict = get_item_func(block=True, timeout=1.0) except queue.Empty: is_empty = True continue directory = job_dict.get("directory", None) file = job_dict.get("file", None) command = job_dict.get("command", None) if file and command: (returncode, out, err) = capture_util.subproces_calling(command, cwd=directory) else: logger.warning("Illegal compile_command object: %s" % json.dumps(job_dict)) continue logger.info(" CC Building {}".format(file)) if out: logger.debug(out.decode("utf-8")) if returncode != 0: logger.info("compile: %s fail" % file) else: logger.info("compile: %s success" % file) logger.info("Thread: %s stop." % pool.threading.currentThread().getName()) return
def excute_quote_code(s, build_dir): s_regax = re.match("`(.*)`(.*)", s) excute_cmd = s_regax.group(1) (returncode, out, err) = capture_util.subproces_calling(excute_cmd, cwd=build_dir) out = out.decode("utf8") value = out.strip("\n") + s_regax.group(2) return value
def create_command_infos(build_path, output, makefile_name=None, make_args=""): make_file = makefile_name try: is_exist = check_makefile(build_path, makefile_name) except IOError: logger.warning("Project checking Makefile fail.") return None if is_exist: cmd = "make -nkw {}".format(make_args) else: cmd = "make -nkw -f {} {}".format(make_file, make_args) (returncode, out, err) = capture_util.subproces_calling(cmd, cwd=build_path) output.write(out.decode("utf8")) return output
def create_data_base_infos(root_path, output, makefile_name="Makefile", make_args=None): """ :param root_path: :param output_path: :param makefile_name: :param make_args: :return: """ make_file = root_path + os.path.sep + makefile_name if not os.path.exists(make_file): raise IOError("No Makefile in " + root_path) cmd = "make -qp " if make_args: cmd += make_args (returncode, out, err) = capture_util.subproces_calling(cmd, cwd=root_path) output.writelines(out.decode("utf-8")) return output
def using_configure(path, output_path, configure_args=""): filename = os.path.join(path, "configure") if not os.path.exists(filename): return False, None build_folder_path = os.path.join(output_path, "build") if not os.path.exists(build_folder_path): os.makedirs(build_folder_path) else: shutil.rmtree(build_folder_path) os.makedirs(build_folder_path) cmd = "{} {}".format(filename, configure_args) (returncode, out, err) = capture_util.subproces_calling(cmd, cwd=build_folder_path) if returncode == 0: return True, build_folder_path return False, None
def create_command_infos(build_path, output, origin_verbose_list, build_args=""): """ Use try-match to checking which is the useful dry-run verbose. :param build_path: project building path. :param output: result and temp data output path. :param origin_verbose_list: the origin verbose name list. :param build_args: scons command execution arguments. :return: """ is_exist = check_sconstruct_exist(build_path) if not is_exist: logger.warning("There is no SConstruct in %s" % build_path) return None has_verbose = False outlines = None verbose_list = copy.copy(origin_verbose_list) # TODO: Move these flag list to config file. for value in ("1", "True", "true", "TRUE", "ON", "on"): verbose_list += list( map(lambda verbose: "{}={}".format(verbose, value), origin_verbose_list)) for verbose in verbose_list: cmd = "scons -n {} {}".format(build_args, verbose) (returncode, out, err) = capture_util.subproces_calling(cmd, cwd=build_path) if check_command_format(out): has_verbose = True outlines = out.decode("utf-8") break logger.info("scons verbose name [%s] check fail." % verbose) logger.debug("SCons Build fail info: %s" % out) if has_verbose: output.write(outlines) return output
def create_command_infos(build_path, output, origin_verbose_list, build_args=""): """ Use try-match to checking which is the useful dry-run verbose. :param build_path: project building path. :param output: result and temp data output path. :param origin_verbose_list: the origin verbose name list. :param build_args: scons command execution arguments. :return: """ is_exist = check_sconstruct_exist(build_path) if not is_exist: logger.warning("There is no SConstruct in %s" % build_path) return None has_verbose = False outlines = None verbose_list = copy.copy(origin_verbose_list) # TODO: Move these flag list to config file. for value in ("1", "True", "true", "TRUE", "ON", "on"): verbose_list += list(map(lambda verbose: "{}={}".format(verbose, value), origin_verbose_list)) for verbose in verbose_list: cmd = "scons -n {} {}".format(build_args, verbose) (returncode, out, err) = capture_util.subproces_calling(cmd, cwd=build_path) if check_command_format(out): has_verbose = True outlines = out.decode("utf-8") break logger.info("scons verbose name [%s] check fail." % verbose) logger.debug("SCons Build fail info: %s" % out) if has_verbose: output.write(outlines) return output