diff --git a/changelog b/changelog index 3a69f580dc..f6483e56d1 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ + 8) PR #3371 towards #3012. Add workaround to bypass psyclonefc fixed-from + issues. + 7) PR #3374 for 3366. Removes LFRicSymbolTable. 6) PR #3369 towards #1658. Switches NEMO scripts to use all of the diff --git a/src/psyclone/psyclonefc_cli.py b/src/psyclone/psyclonefc_cli.py index 2deaece34d..cd36352cba 100644 --- a/src/psyclone/psyclonefc_cli.py +++ b/src/psyclone/psyclonefc_cli.py @@ -82,6 +82,10 @@ def compiler_wrapper(arguments): ''' fortran_compiler = os.getenv("PSYCLONE_COMPILER", default=None) psyclone_options = os.getenv("PSYCLONE_OPTS", default="").split(' ') + # TODO #3012: How does this interact with the script FILES_TO_SKIP + psyclone_exclude_files = ( + os.getenv("PSYCLONEFC_EXCLUDE_FILES", default="").split(',') + ) # Validate mandatory PSYCLONE_COMPILER if fortran_compiler is None: @@ -119,7 +123,12 @@ def compiler_wrapper(arguments): # And it will be followed by each of the original arguments ... for argument in arguments: # ... but for each fortran file: - if argument.endswith(FORTRAN_EXTENSIONS): + + filename = Path(argument).name + if ( + argument.endswith(FORTRAN_EXTENSIONS) and + (filename not in psyclone_exclude_files) + ): # 1) Run the preprocessor # TODO #3012: preprocessing is currently ignored, this is not a # problem for NEMO because the build system does the proprocessor @@ -128,6 +137,8 @@ def compiler_wrapper(arguments): # 2) Run psyclone stem = Path(argument).stem suffix = Path(argument).suffix + # TODO #3012: Keeping the suffix is wrong as psyclone processed + # files are always free-form output = f"{stem}.psycloned{suffix}" # Always add an include to the current directory, because even if # it is the default, psyclone removes it when adding another -I. diff --git a/src/psyclone/tests/psyclonefc_cli_test.py b/src/psyclone/tests/psyclonefc_cli_test.py index 24aac810d0..a30bf99007 100644 --- a/src/psyclone/tests/psyclonefc_cli_test.py +++ b/src/psyclone/tests/psyclonefc_cli_test.py @@ -87,19 +87,23 @@ def test_psyclonefc(monkeypatch, capsys): assert "-o source.psycloned.f90 source.f90" in stdout assert "true source.psycloned.f90 -c -o source.o" in stdout - # Now with PSYCONE_OPTS and multiple files + # Now with PSYCONE_OPTS, PSYCLONEFC_EXCLUDE_FILES and multiple files monkeypatch.setattr(os, 'environ', { 'PSYCLONE_COMPILER': 'true', # Also check that multi-spaces are fine 'PSYCLONE_OPTS': ' -l output ', + 'PSYCLONEFC_EXCLUDE_FILES': 'source3.f90', }) with pytest.raises(SystemExit) as err: - compiler_wrapper(['source1.f90', 'source2.f90', '-c', '-o', 'app.exe']) + compiler_wrapper(['source1.f90', 'source2.f90', 'source3.f90', '-c', + '-o', 'app.exe']) assert err.value.code == 0 stdout, _ = capsys.readouterr() # This will execute: assert "psyclone -l output -I " in stdout assert "-o source1.psycloned.f90 source1.f90" in stdout assert "-o source2.psycloned.f90 source2.f90" in stdout - assert ("true source1.psycloned.f90 source2.psycloned.f90 -c -o app.exe" - in stdout) + # source3 is ignored from the psyclonefc command conversion + assert "-o source3.psycloned.f90 source3.f90" not in stdout + assert ("true source1.psycloned.f90 source2.psycloned.f90 source3.f90 " + "-c -o app.exe" in stdout)