1#! perl
2# Copyright (C) 2010-2015, Parrot Foundation.
3
4=head1 NAME
5
6tools/dev/mk_nci_thunks.pl - (re)generate core NCI thunk files
7
8=head1 SYNOPSIS
9
10  > perl tools/dev/mk_nci_thunks.pl
11
12=head1 DESCRIPTION
13
14This script generates the core NCI thunk C files from lists of signatures
15provided in accompanying C<.nci> files.
16These are needed for static signatures without libffi.
17
18=cut
19
20use strict;
21use warnings;
22use File::Spec;
23
24my $nci_thunk_gen = File::Spec->catfile(qw(tools dev nci_thunk_gen.pir));
25my $parrot = $^O eq 'MSWin32' ? "parrot" : "./parrot";
26
27foreach (qw( core_thunks extra_thunks )) {
28    my $c_file   = File::Spec->catfile("src", "nci", "$_.c");
29    my $nci_file = File::Spec->catfile("src", "nci", "$_.nci");
30    my $loader_name = "Parrot_nci_load_$_";
31    my $cmd = "$parrot $nci_thunk_gen " .
32            "--core " .
33            "--loader-name=$loader_name " .
34            "--output=$c_file " .
35            "--no-warn-dups " .
36            "<$nci_file";
37    print $cmd,"\n";
38    system($cmd);
39}
40
41# Local Variables:
42#   mode: cperl
43#   cperl-indent-level: 4
44#   fill-column: 100
45# End:
46# vim: expandtab shiftwidth=4:
47