Skip to content

Commit

Permalink
Add log messages to debug why the wrong compiler is being used on win…
Browse files Browse the repository at this point in the history
…dows
  • Loading branch information
langmm committed Jan 9, 2024
1 parent 1dc10cd commit a3fe58a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tests/drivers/test_CMakeModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ def instance_kwargs(self, testing_options, timeout, sourcedir,
reason="GNU compiler not installed.")
def test_run_model_gcc(self, run_model_instance):
r"""Test compiling/running test model with gcc."""
run_model_instance(target_compiler='gcc')
run_model_instance(target_compiler='gcc',
remove_products=True)

def test_sbdir(self, instance, sourcedir, builddir):
r"""Test that source/build directories set correctly."""
Expand Down
2 changes: 2 additions & 0 deletions yggdrasil/drivers/CMakeModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def call(cls, args, **kwargs):
True, produced file otherwise.
"""
kwargs['verbose'] = True
try:
out = super(CMakeConfigure, cls).call(args, **kwargs)
except RuntimeError as e:
Expand Down Expand Up @@ -325,6 +326,7 @@ def get_flags(cls, sourcedir='.', builddir=None, target_compiler=None,
out.append('-D%s=%s' % (
cmake_vars['%s_flags' % k], ''))
out.append('-DCMAKE_LINKER=%s' % linker.get_executable(full_path=True))
logger.info(f"CMAKE FLAGS: {out}")
return out

@classmethod
Expand Down
14 changes: 11 additions & 3 deletions yggdrasil/drivers/CompiledModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ def tool_version(cls, **kwargs):
def call(cls, args, language=None, toolname=None, skip_flags=False,
dry_run=False, out=None, overwrite=False, products=None,
allow_error=False, working_dir=None, additional_args=None,
suffix='', cache_key=None, **kwargs):
suffix='', cache_key=None, verbose=False, **kwargs):
r"""Call the tool with the provided arguments. If the first argument
resembles the name of the tool executable, the executable will not be
added.
Expand Down Expand Up @@ -1212,6 +1212,8 @@ def call(cls, args, language=None, toolname=None, skip_flags=False,
cache_key (str, optional): Key that should be used to
cache results so that they may be used multiple
times. Defaults to None and is ignored.
verbose (bool, optional): If True, the call command and
and output will be logged as info.
**kwargs: Additional keyword arguments are passed to
cls.get_executable_command. and tools.popen_nobuffer.
Expand Down Expand Up @@ -1278,15 +1280,21 @@ def call(cls, args, language=None, toolname=None, skip_flags=False,
try:
if (not skip_flags) and ('env' not in unused_kwargs):
unused_kwargs['env'] = cls.set_env()
logger.debug('Command: "%s"' % ' '.join(cmd))
if verbose:
logger.info('Command: "%s"' % ' '.join(cmd))
else:
logger.debug('Command: "%s"' % ' '.join(cmd))
proc = tools.popen_nobuffer(cmd, **unused_kwargs)
output, err = proc.communicate()
output = output.decode("utf-8")
if (proc.returncode != 0) and (not allow_error):
raise RuntimeError("Command '%s' failed with code %d:\n%s."
% (' '.join(cmd), proc.returncode, output))
try:
logger.debug(' '.join(cmd) + '\n' + output)
if verbose:
logger.info(' '.join(cmd) + '\n' + output)
else:
logger.debug(' '.join(cmd) + '\n' + output)
except UnicodeDecodeError: # pragma: debug
tools.print_encoded(output)
except (subprocess.CalledProcessError, OSError) as e:
Expand Down

0 comments on commit a3fe58a

Please sign in to comment.