From 7c800fcdb56e292269d34cb3d09c24192c9d0f4a Mon Sep 17 00:00:00 2001 From: Max Thomas Date: Thu, 11 Aug 2022 01:19:38 -0700 Subject: [PATCH] Fix incorrect line numbers on NDS MWCC (#505) * Turn off msg_show_realref to force #line to work on NDS MWCC * Interleave stdout and stderr for sandbox run * fix formatting * feedback * formatting --- backend/coreapp/compiler_wrapper.py | 15 +++++---------- backend/coreapp/compilers.py | 2 +- backend/coreapp/sandbox.py | 3 ++- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/backend/coreapp/compiler_wrapper.py b/backend/coreapp/compiler_wrapper.py index 1ab17a9c..c2f6db1c 100644 --- a/backend/coreapp/compiler_wrapper.py +++ b/backend/coreapp/compiler_wrapper.py @@ -176,10 +176,7 @@ class CompilerWrapper: ) except subprocess.CalledProcessError as e: # Compilation failed - if e.stdout: - msg = f"{e.stdout}\n{e.stderr}" - else: - msg = e.stderr + msg = e.stdout logging.debug("Compilation failed: %s", msg) raise CompilationError(CompilerWrapper.filter_compile_errors(msg)) @@ -189,11 +186,9 @@ class CompilerWrapper: raise CompilationError(str(e)) if not object_path.exists(): - if compile_proc.stdout: - msg = f"{compile_proc.stdout}\n{compile_proc.stderr}" - else: - msg = compile_proc.stderr - error_msg = "Compiler did not create an object file: %s" % msg + error_msg = ( + "Compiler did not create an object file: %s" % compile_proc.stdout + ) logging.debug(error_msg) raise CompilationError(error_msg) @@ -202,7 +197,7 @@ class CompilerWrapper: if not object_bytes: raise CompilationError("Compiler created an empty object file") - compile_errors = CompilerWrapper.filter_compile_errors(compile_proc.stderr) + compile_errors = CompilerWrapper.filter_compile_errors(compile_proc.stdout) return CompilationResult(object_path.read_bytes(), compile_errors) diff --git a/backend/coreapp/compilers.py b/backend/coreapp/compilers.py index 037dda03..d2ff9d46 100644 --- a/backend/coreapp/compilers.py +++ b/backend/coreapp/compilers.py @@ -478,7 +478,7 @@ MWCC_43_213 = MWCCCompiler( ) # NDS_ARM9 -MWCCARM_CC = '${WINE} "${COMPILER_DIR}/mwccarm.exe" -c -proc arm946e -nostdinc -stderr ${COMPILER_FLAGS} -o "${OUTPUT}" "${INPUT}"' +MWCCARM_CC = '${WINE} "${COMPILER_DIR}/mwccarm.exe" -pragma "msg_show_realref off" -c -proc arm946e -nostdinc -stderr ${COMPILER_FLAGS} -o "${OUTPUT}" "${INPUT}"' MWCC_20_72 = MWCCCompiler( id="mwcc_20_72", diff --git a/backend/coreapp/sandbox.py b/backend/coreapp/sandbox.py index c6e141aa..d8bf4761 100644 --- a/backend/coreapp/sandbox.py +++ b/backend/coreapp/sandbox.py @@ -122,10 +122,11 @@ class Sandbox(contextlib.AbstractContextManager["Sandbox"]): logger.debug(f"Sandbox Command: {debug_env_str} {shlex.join(command)}") return subprocess.run( command, - capture_output=True, text=True, env=env, cwd=self.path, check=True, shell=False, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, )