Skip to content

Commit

Permalink
fcm build: fix fortran interface generation
Browse files Browse the repository at this point in the history
Configuration logic was broken by metomi#156.
  • Loading branch information
matthewrmshin committed Dec 2, 2014
1 parent 7f183e3 commit 062e2c8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/FCM1/BuildSrc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ sub exebase {
sub interfacebase {
my $self = shift();
if (
$self->get_setting(qw/TOOL GENINTERFACE/)
defined($self->get_setting(qw/TOOL GENINTERFACE/))
&& uc($self->get_setting(qw/TOOL GENINTERFACE/)) ne 'NONE'
&& $self->progname()
&& $self->is_type_all(qw/SOURCE/)
Expand Down
2 changes: 1 addition & 1 deletion lib/FCM1/CfgFile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ sub read_cfg {
}
}

if ( $self->type()
if ( defined($self->type())
&& exists($exp_inc{uc($self->type())})
&& uc($start ? $start->label() : $label) eq $self->cfglabel('INC')
&& !defined($cont)
Expand Down
52 changes: 52 additions & 0 deletions t/fcm-build/00-geninterface.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# (C) British Crown Copyright 2006-14 Met Office.
#
# This file is part of FCM, tools for managing and building source code.
#
# FCM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FCM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FCM. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# #156 breaks interface generation. This test ensures that it is not broken
# again.
#-------------------------------------------------------------------------------
. "$(dirname "$0")/test_header"
tests 2
#-------------------------------------------------------------------------------

cat >'bld.cfg' <<'__FCM_BLD_CFG__'
cfg::type bld
dest $HERE
tool::geninterface
__FCM_BLD_CFG__

mkdir 'src'
cat >'src/hello.f90' <<'__FORTRAN__'
subroutine hello(world)
character(*), intent(in) :: world
write(*, '(a)') 'Hello ' // trim(world)
end subroutine hello
__FORTRAN__

#-------------------------------------------------------------------------------
run_pass "${TEST_KEY_BASE}-cmd" fcm build -f -s 4
file_cmp "${TEST_KEY_BASE}-interface" 'inc/hello.interface' <<'__FORTRAN__'
interface
subroutine hello(world)
character(*), intent(in) :: world
end subroutine hello
end interface
__FORTRAN__

#-------------------------------------------------------------------------------
exit
1 change: 1 addition & 0 deletions t/fcm-build/test_header

0 comments on commit 062e2c8

Please sign in to comment.