New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
CPP.pm in vendors/lib/FCM/System/Make/Build/FileType – NEMO

source: vendors/lib/FCM/System/Make/Build/FileType/CPP.pm @ 10669

Last change on this file since 10669 was 10669, checked in by nicolasmartin, 5 years ago

Import latest FCM release from Github into the repository for testing

File size: 3.0 KB
Line 
1# ------------------------------------------------------------------------------
2# (C) British Crown Copyright 2006-17 Met Office.
3#
4# This file is part of FCM, tools for managing and building source code.
5#
6# FCM is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# FCM is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with FCM. If not, see <http://www.gnu.org/licenses/>.
18# ------------------------------------------------------------------------------
19use strict;
20use warnings;
21
22# ------------------------------------------------------------------------------
23package FCM::System::Make::Build::FileType::CPP;
24use base qw{FCM::System::Make::Build::FileType};
25
26use FCM::Context::Make::Build; # for FCM::Context::Make::Build::Target
27use FCM::System::Make::Build::Task::Preprocess::C;
28
29# Dependency types and CODE to extract them
30my %SOURCE_ANALYSE_DEP_OF
31    = (include => sub { $_[0] =~ qr{\A\#\s*include\s+"([\w\-+.]+)"}msx });
32
33# Handler of tasks
34my %TASK_CLASS_OF
35    = (process => 'FCM::System::Make::Build::Task::Preprocess::C');
36
37sub new {
38    my ($class, $attrib_ref) = @_;
39    bless(
40        FCM::System::Make::Build::FileType->new({
41            id                    => 'cpp',
42            file_ext              => '.c .m .cc .cp .cxx .cpp .CPP .c++ .C .mm .M',
43            source_analyse_dep_of => {%SOURCE_ANALYSE_DEP_OF},
44            source_to_targets     => \&_source_to_targets,
45            target_file_ext_of    => {},
46            task_class_of         => {%TASK_CLASS_OF},
47            %{$attrib_ref},
48        }),
49        $class,
50    );
51}
52
53# Returns a list of targets for a given build source.
54sub _source_to_targets {
55    my ($attrib_ref, $source) = @_;
56    my $TARGET = 'FCM::Context::Make::Build::Target';
57    $TARGET->new(
58        {   category      => $TARGET->CT_SRC,
59            deps          => [@{$source->get_deps()}],
60            dep_policy_of => {'include' => $TARGET->POLICY_CAPTURE},
61            info_of       => {paths => []},
62            key           => $source->get_ns(),
63            task          => 'process',
64        }
65    );
66}
67
68# ------------------------------------------------------------------------------
691;
70__END__
71
72=head1 NAME
73
74FCM::System::Make::Build::FileType::CPP
75
76=head1 SYNOPSIS
77
78    use FCM::System::Make::Build::FileType::CPP;
79    my $helper = FCM::System::Make::Build::FileType::CPP->new();
80    $helper->source_analyse($handle);
81
82=head1 DESCRIPTION
83
84A wrapper of
85L<FCM::System::Make::Build::FileType|FCM::System::Make::Build::FileType> with
86configurations to work with C source files for preprocessing.
87
88=head1 COPYRIGHT
89
90(C) Crown copyright Met Office. All rights reserved.
91
92=cut
Note: See TracBrowser for help on using the repository browser.