Added testing
Preparing profiles and dependencies, but added testing to separate them from regular targets and avoid the need for a 'testing' profile which could negatively impact configuration size and readability.
This commit is contained in:
+86
-67
@@ -2,10 +2,7 @@ from pathlib import Path
|
||||
|
||||
from ..models import Optimization
|
||||
from ..models import Result
|
||||
from ..models import StdC
|
||||
from ..models import StdCpp
|
||||
from ..shell import execute
|
||||
from .._logger import logger
|
||||
from ._driver import CompilerDriver
|
||||
from ._options import CompilerOptions
|
||||
|
||||
@@ -48,17 +45,30 @@ class GnucDriver(CompilerDriver):
|
||||
for directory in options.libdirs: args.append(f"-L{str(directory)}")
|
||||
for archive in options.archives: args.append(f"-l{archive}")
|
||||
cmdstr = ' '.join(args)
|
||||
# logger.info(cmdstr)
|
||||
# self.logger.info(cmdstr)
|
||||
|
||||
result: list[Result] = [None]
|
||||
execute(
|
||||
cmdstr,
|
||||
lambda cmdstr, stdout, stderr:
|
||||
self.handle_on_data(result, str(dstpath), cmdstr, stdout, stderr),
|
||||
lambda cmdstr, stdout, stderr:
|
||||
self.handle_on_error(result, str(dstpath), cmdstr, stdout, stderr)
|
||||
result = Result(
|
||||
success = False,
|
||||
action = "Linked",
|
||||
target = str(dstpath),
|
||||
command = cmdstr,
|
||||
retcode = -1
|
||||
)
|
||||
return result[0]
|
||||
|
||||
def handle_success(retcode: int, cmdstr: str, stdout: str) -> None:
|
||||
result.success = True
|
||||
result.command = cmdstr
|
||||
result.retcode = retcode
|
||||
result.diagnostics.append(stdout)
|
||||
|
||||
def handle_failure(retcode: int, cmdstr: str, stderr: str) -> None:
|
||||
result.success = False
|
||||
result.command = cmdstr
|
||||
result.retcode = retcode
|
||||
result.diagnostics.append(stderr)
|
||||
|
||||
execute(cmdstr, handle_success, handle_failure)
|
||||
return result
|
||||
|
||||
def compile_archive(
|
||||
self,
|
||||
@@ -70,15 +80,28 @@ class GnucDriver(CompilerDriver):
|
||||
args.append(str(obj))
|
||||
cmdstr = ' '.join(args)
|
||||
|
||||
result: list[Result] = [None]
|
||||
execute(
|
||||
cmdstr,
|
||||
lambda cmdstr, stdout, stderr:
|
||||
self.handle_on_data(result, str(dstpath), cmdstr, stdout, stderr),
|
||||
lambda cmdstr, stdout, stderr:
|
||||
self.handle_on_error(result, str(dstpath), cmdstr, stdout, stderr)
|
||||
result = Result(
|
||||
success = False,
|
||||
action = "Linked",
|
||||
target = str(dstpath),
|
||||
command = cmdstr,
|
||||
retcode = -1
|
||||
)
|
||||
return result[0]
|
||||
|
||||
def handle_success(retcode: int, cmdstr: str, stdout: str) -> None:
|
||||
result.success = True
|
||||
result.command = cmdstr
|
||||
result.retcode = retcode
|
||||
result.diagnostics.append(stdout)
|
||||
|
||||
def handle_failure(retcode: int, cmdstr: str, stderr: str) -> None:
|
||||
result.success = False
|
||||
result.command = cmdstr
|
||||
result.retcode = retcode
|
||||
result.diagnostics.append(stderr)
|
||||
|
||||
execute(cmdstr, handle_success, handle_failure)
|
||||
return result
|
||||
|
||||
def compile_library(
|
||||
self,
|
||||
@@ -106,17 +129,30 @@ class GnucDriver(CompilerDriver):
|
||||
for directory in options.libdirs: args.append(f"-L{str(directory)}")
|
||||
for archive in options.archives: args.append(f"-l{archive}")
|
||||
cmdstr = ' '.join(args)
|
||||
# logger.info(cmdstr)
|
||||
# self.logger.info(cmdstr)
|
||||
|
||||
result: list[Result] = [None]
|
||||
execute(
|
||||
cmdstr,
|
||||
lambda cmdstr, stdout, stderr:
|
||||
self.handle_on_data(result, str(dstpath), cmdstr, stdout, stderr),
|
||||
lambda cmdstr, stdout, stderr:
|
||||
self.handle_on_error(result, str(dstpath), cmdstr, stdout, stderr)
|
||||
result = Result(
|
||||
success = False,
|
||||
action = "Linked",
|
||||
target = str(dstpath),
|
||||
command = cmdstr,
|
||||
retcode = -1
|
||||
)
|
||||
return result[0]
|
||||
|
||||
def handle_success(retcode: int, cmdstr: str, stdout: str) -> None:
|
||||
result.success = True
|
||||
result.command = cmdstr
|
||||
result.retcode = retcode
|
||||
result.diagnostics.append(stdout)
|
||||
|
||||
def handle_failure(retcode: int, cmdstr: str, stderr: str) -> None:
|
||||
result.success = False
|
||||
result.command = cmdstr
|
||||
result.retcode = retcode
|
||||
result.diagnostics.append(stderr)
|
||||
|
||||
execute(cmdstr, handle_success, handle_failure)
|
||||
return result
|
||||
|
||||
def compile_object(
|
||||
self,
|
||||
@@ -150,44 +186,27 @@ class GnucDriver(CompilerDriver):
|
||||
for archive in options.archives: args.append(f"-l{archive}")
|
||||
for define in options.defines: args.append(f"-D{define}")
|
||||
cmdstr = ' '.join(args)
|
||||
# logger.info(cmdstr)
|
||||
# self.logger.info(cmdstr)
|
||||
|
||||
result: list[Result] = [None]
|
||||
execute(
|
||||
cmdstr,
|
||||
lambda cmdstr, stdout, stderr:
|
||||
self.handle_on_data(result, str(dstpath), cmdstr, stdout, stderr),
|
||||
lambda cmdstr, stdout, stderr:
|
||||
self.handle_on_error(result, str(dstpath), cmdstr, stdout, stderr)
|
||||
)
|
||||
return result[0]
|
||||
|
||||
def handle_on_data(
|
||||
self,
|
||||
result: list[Result],
|
||||
target: str,
|
||||
cmdstr: str,
|
||||
stdout: str,
|
||||
stderr: str
|
||||
) -> None:
|
||||
result[0] = Result(
|
||||
success = True,
|
||||
target = target,
|
||||
command = cmdstr
|
||||
)
|
||||
result[0].diagnostics.append(stdout)
|
||||
|
||||
def handle_on_error(
|
||||
self,
|
||||
result: list[Result],
|
||||
target: str,
|
||||
cmdstr: str,
|
||||
stdout: str,
|
||||
stderr: str
|
||||
) -> None:
|
||||
result[0] = Result(
|
||||
result = Result(
|
||||
success = False,
|
||||
target = target,
|
||||
command = cmdstr
|
||||
action = "Compiled",
|
||||
target = str(dstpath),
|
||||
command = cmdstr,
|
||||
retcode = -1
|
||||
)
|
||||
result[0].diagnostics.append(stderr)
|
||||
|
||||
def handle_success(retcode: int, cmdstr: str, stdout: str) -> None:
|
||||
result.success = True
|
||||
result.command = cmdstr
|
||||
result.retcode = retcode
|
||||
result.diagnostics.append(stdout)
|
||||
|
||||
def handle_failure(retcode: int, cmdstr: str, stderr: str) -> None:
|
||||
result.success = False
|
||||
result.command = cmdstr
|
||||
result.retcode = retcode
|
||||
result.diagnostics.append(stderr)
|
||||
|
||||
execute(cmdstr, handle_success, handle_failure)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user