MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / generate_shell_file

Method generate_shell_file

client/tool/util/compile.py:61–89  ·  view source on GitHub ↗

将编译命令保存到bash/bat的脚本文件中,并赋予可执行权限,返回执行该脚本文件的命令 :param cmd: 编译命令字符串 :param log_flag: 是否输出命令,默认输出 :param shell_name: 生成的shell文件名 :return: 执行该脚本文件的命令

(cmd, log_flag=True, shell_name="tca_build")

Source from the content-addressed store, hash-verified

59
60 @staticmethod
61 def generate_shell_file(cmd, log_flag=True, shell_name="tca_build"):
62 """
63 将编译命令保存到bash/bat的脚本文件中,并赋予可执行权限,返回执行该脚本文件的命令
64 :param cmd: 编译命令字符串
65 :param log_flag: 是否输出命令,默认输出
66 :param shell_name: 生成的shell文件名
67 :return: 执行该脚本文件的命令
68 """
69 work_dir = os.getcwd()
70 if platform.system() == "Windows":
71 file_name = f"{shell_name}.bat"
72 else:
73 file_name = f"{shell_name}.sh"
74 shell_filepath = os.path.join(work_dir, file_name)
75 # 格式化文件路径
76 shell_filepath = PathMgr().format_path(shell_filepath)
77 with open(shell_filepath, "w") as wf:
78 wf.write(cmd)
79 # 给文件授权可执行权限
80 os.chmod(shell_filepath, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
81
82 if log_flag:
83 logger.info("Cmd:\n%s" % cmd)
84 logger.info("Generated shell file: %s" % shell_filepath)
85
86 if platform.system() == "Windows":
87 return shell_filepath
88 else:
89 return "bash %s" % shell_filepath
90
91 def pre_cmd(self):
92 pre_cmd = self.params.get("pre_cmd", None)

Callers 13

compileMethod · 0.80
compileMethod · 0.80
compileMethod · 0.80
compileMethod · 0.80
compileMethod · 0.80
compileMethod · 0.80
__run_clangMethod · 0.80
analyzeMethod · 0.80
compileMethod · 0.80
compileMethod · 0.80
compileMethod · 0.80
compileMethod · 0.80

Calls 2

writeMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected