(
output, objects, options, compile_cmd, cwd=None, ccache_env=None, compile_shared=False
)
| 333 | |
| 334 | |
| 335 | def _linux_compile( |
| 336 | output, objects, options, compile_cmd, cwd=None, ccache_env=None, compile_shared=False |
| 337 | ): |
| 338 | cmd = [compile_cmd] |
| 339 | if compile_cmd != "nvcc": |
| 340 | if compile_shared or output.endswith(".so") or output.endswith(".dylib"): |
| 341 | cmd += ["-shared", "-fPIC"] |
| 342 | if sys.platform == "darwin": |
| 343 | cmd += ["-undefined", "dynamic_lookup"] |
| 344 | elif output.endswith(".obj"): |
| 345 | cmd += ["-c"] |
| 346 | else: |
| 347 | if compile_shared or output.endswith(".so") or output.endswith(".dylib"): |
| 348 | cmd += ["-shared"] |
| 349 | cmd += ["-o", output] |
| 350 | if options: |
| 351 | cmd += options |
| 352 | if isinstance(objects, str): |
| 353 | cmd += [objects] |
| 354 | else: |
| 355 | cmd += objects |
| 356 | env = None |
| 357 | if ccache_env is not None: |
| 358 | if shutil.which("ccache"): |
| 359 | cmd.insert(0, "ccache") |
| 360 | env = os.environ.copy() |
| 361 | env.update(ccache_env) |
| 362 | else: |
| 363 | raise ValueError("ccache not found") |
| 364 | |
| 365 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd, env=env) |
| 366 | (out, _) = proc.communicate() |
| 367 | if proc.returncode != 0: |
| 368 | msg = "Compilation error:\n" |
| 369 | msg += out.decode("utf-8", errors="replace") |
| 370 | msg += "\nCommand line: " + " ".join(cmd) |
| 371 | raise RuntimeError(msg) |
| 372 | |
| 373 | |
| 374 | def _windows_compile(output, objects, options, cwd=None, ccache_env=None): |
no test coverage detected
searching dependent graphs…