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.
Script.pm in vendors/lib/FCM/System/Make/Build/FileType – NEMO

source: vendors/lib/FCM/System/Make/Build/FileType/Script.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.2 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::Script;
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::Install;
28use File::Basename qw{basename};
29
30# RE: file (base) name
31my $RE_FILE = qr{[\w\-+.]+}imsx;
32
33# Dependency types and CODE to extract them
34my %SOURCE_ANALYSE_DEP_OF
35    = (bin => sub { $_[0] =~ qr{\A\s*(?:\#|;)\s*calls\s*:\s*($RE_FILE)}imsx });
36
37# Alias
38my $TARGET = 'FCM::Context::Make::Build::Target';
39
40# Handler of tasks
41my %TASK_CLASS_OF = (install => 'FCM::System::Make::Build::Task::Install');
42
43sub new {
44    my ($class, $attrib_ref) = @_;
45    $attrib_ref->{dest_keys} ||= [$TARGET->CT_INCLUDE, 'o', 'o.special'];
46    my $SOURCE_TO_TARGETS
47        = sub {_source_to_targets($attrib_ref->{dest_keys}, @_)};
48    bless(
49        FCM::System::Make::Build::FileType->new({
50            id                    => 'script',
51            file_she              => q{}, # Value not used, for file type match
52            file_ext              => q{},
53            source_analyse_dep_of => {%SOURCE_ANALYSE_DEP_OF},
54            source_to_targets     => \&_source_to_targets,
55            task_class_of         => {%TASK_CLASS_OF},
56            %{$attrib_ref},
57        }),
58        $class,
59    );
60}
61
62# Returns a list of targets for a given build source.
63sub _source_to_targets {
64    my ($attrib_ref, $source, $prop_hash_ref) = @_;
65    my $key = basename($source->get_path());
66    $TARGET->new(
67        {   category      => $TARGET->CT_BIN,
68            deps          => [@{$source->get_deps()}],
69            dep_policy_of => {'bin', $TARGET->POLICY_CAPTURE},
70            key           => $key,
71            task          => 'install',
72        }
73    );
74}
75
76# ------------------------------------------------------------------------------
771;
78__END__
79
80=head1 NAME
81
82FCM::System::Make::Build::FileType::Script
83
84=head1 SYNOPSIS
85
86    use FCM::System::Make::Build::FileType::Script;
87    my $helper = FCM::System::Make::Build::FileType::Script->new();
88    $helper->source_analyse($handle);
89
90=head1 DESCRIPTION
91
92A wrapper of
93L<FCM::System::Make::Build::FileType|FCM::System::Make::Build::FileType>
94with configurations to work with some UKMO script files.
95
96=head1 COPYRIGHT
97
98(C) Crown copyright Met Office. All rights reserved.
99
100=cut
Note: See TracBrowser for help on using the repository browser.