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

Method compile

client/tool/util/compile.py:110–165  ·  view source on GitHub ↗

执行编译操作 :return:

(self, build_out="subprocc_stdout.log", build_err="subprocc_stderr.log")

Source from the content-addressed store, hash-verified

108 ).wait()
109
110 def compile(self, build_out="subprocc_stdout.log", build_err="subprocc_stderr.log"):
111 """
112 执行编译操作
113 :return:
114 """
115 build_cmd = self.build_cmd
116 if isinstance(build_cmd, str):
117 build_cmd = shlex.split(build_cmd)
118 logger.info("basic compile start.")
119 stop_on_output_str = self.stop_on_output
120
121 if stop_on_output_str:
122 self.print_log("subprocc stop_on_output mode: %s" % build_cmd)
123 stop_on_output_str = "[^(STOP_ON_OUTPUT=)]" + stop_on_output_str + "|^" + stop_on_output_str
124 pattern = re.compile(stop_on_output_str)
125
126 def compile_cmd_callback(line):
127 self.print_log(line)
128 if self.build_log_end.full():
129 self.build_log_end.get()
130 self.build_log_end.put_nowait(line)
131 if pattern.search(line):
132 logger.info("terminate cmd on pattern %s" % stop_on_output_str)
133 spc.stop()
134 self.stop_on_output_flag = True
135
136 else:
137 self.print_log("subprocc normal mode: %s" % build_cmd)
138
139 def compile_cmd_callback(line):
140 self.print_log(line)
141 if self.build_log_end.full():
142 self.build_log_end.get()
143 self.build_log_end.put_nowait(line)
144
145 self.print_log("run build cmd: %s" % " ".join(build_cmd))
146 spc = SubProcController(
147 build_cmd,
148 cwd=self.build_cwd,
149 stdout_line_callback=compile_cmd_callback,
150 stderr_line_callback=compile_cmd_callback,
151 stdout_filepath=build_out,
152 stderr_filepath=build_err,
153 env=EnvSet().get_origin_env(),
154 shell=self.shell,
155 )
156 spc.wait()
157 # 0 为常规返回码, -9为ant的返回码
158 if self.stop_on_output_flag:
159 logger.info("编译成功!")
160 logger.info("basic compile done.")
161 return
162
163 self.handle_log(spc.returncode)
164
165 logger.info("basic compile done.")
166
167 def handle_log(self, returncode):

Callers

nothing calls this directly

Calls 5

print_logMethod · 0.95
handle_logMethod · 0.95
EnvSetClass · 0.90
get_origin_envMethod · 0.80
infoMethod · 0.45

Tested by

no test coverage detected