File: make_package.pl.in

package info (click to toggle)
geogram 1.9.6-1
  • links: PTS, VCS
  • area: contrib
  • in suites: sid
  • size: 15,436 kB
  • sloc: cpp: 143,890; ansic: 10,098; perl: 1,430; sh: 1,199; yacc: 522; lex: 182; python: 157; javascript: 149; makefile: 17
file content (78 lines) | stat: -rwxr-xr-x 2,083 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use Getopt::Long();
use File::Glob();

# This script is a wrapper on top of CPack that allows to generate packages
# for a specified list of components. If called without arguments, generate
# packages for all components.

my $OS_WIN = $^O =~ /win/;
my $CPACK_PACKAGE_FILE_NAME = '@CPACK_PACKAGE_FILE_NAME@';
my $CPACK_SYSTEM_NAME = '@CPACK_SYSTEM_NAME@';
my $BUILD_TYPE;

Getopt::Long::GetOptions(
    'config' => \$BUILD_TYPE,
) or exit(1);

if($OS_WIN) {
    if(not defined($BUILD_TYPE)) {
        die("Error: missing option --config to specify project configuration\n");
    }
}

if(not @ARGV) {
    # When called without arguments, run "make package" to generate
    # packages for all components.

    my $status = $OS_WIN ?
        system("cmake --build . --config $BUILD_TYPE --target PACKAGE") :
        system("make package");

    if($status != 0) {
        exit(1);
    }
} else {
    # When called with arguments, create a temporary CPack config file which
    # includes the standard CPack config, and overwrites the components to
    # generate with the list of specified components

    my $fh;
    if(not open($fh, '>', 'CPackTmpConfig.cmake')) {
        die("Error: could not create CPackTmpConfig.cmake: $!\n");
    }

    print $fh <<END;
include(CPackConfig.cmake)
set(CPACK_COMPONENTS_ALL @ARGV)
END
    close($fh);

    my $status = $OS_WIN ?
        system("cpack -C $BUILD_TYPE --config CPackTmpConfig.cmake") :
        system("cpack --config CPackTmpConfig.cmake");

    if($status != 0) {
        exit(1);
    }
}

# Rename binary packages so that they include the name of the platform

foreach my $package (File::Glob::glob("$CPACK_PACKAGE_FILE_NAME-*")) {
    if($package =~ /-doc-/) {
        # Do not rename doc packages
        next;
    }
    if($package =~ /-$CPACK_SYSTEM_NAME-/o) {
        # Package already contains the plaform name
        next;
    }

    my $new_name = $package;
    $new_name =~ s{$CPACK_PACKAGE_FILE_NAME-}{$&$CPACK_SYSTEM_NAME-};
    rename($package, $new_name);
}