This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Silence Win32 compiler warnings following change 25280
[perl5.git] / wince / comp.pl
1 =comments
2
3 helper script to make life for PerlCE easier.
4
5 There are different modes for running this script:
6   perl comp.pl --run [any-command-line-arguments]
7 and
8   perl comp.pl --do [any-command-line-arguments]
9 and
10   perl comp.pl --copy pc:[pc-location] ce:[ce-location]
11
12 --run executes this build of perl on CE device with arguments provided
13 --run=test will display a predefined messagebox that say everything is ok.
14
15 --do  Executes on local computer command that is presented by arguments
16       immediately following after --do
17       Most reason why you may want to execute script in this mode is that
18       arguments preprocessed to replace [p] occurrences into current perl
19       location. Typically it is handy to run
20   perl comp.pl --do cecopy pc:..\lib\Exporter.pm ce:[p]\lib
21
22 --copy copies file to CE device
23   here also [p] will be expanded to current PerlCE path, and additionally
24   when --copy=compact specified then, if filename looks like perl module,
25   then POD will be stripped away from that file
26   modules
27
28
29 =cut
30
31 use strict;
32 use Cross;
33 use Config;
34
35 # edit value of $inst_root variable to reflect your desired location of
36 # built perl
37 my $inst_root = $Config{prefix};
38
39 my %opts = (
40   # %known_opts enumerates allowed opts as well as specifies default and initial values
41   my %known_opts = (
42      'do' => '',
43      'run' => '',
44      'copy' => '',
45   ),
46   #options itself
47   my %specified_opts = (
48     (map {/^--([\-_\w]+)=(.*)$/} @ARGV),                            # --opt=smth
49     (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV),  # --opt --no-opt --noopt
50   ),
51 );
52 die "option '$_' is not recognized" for grep {!exists $known_opts{$_}} keys %specified_opts;
53 @ARGV = grep {!/^--/} @ARGV;
54
55 if ($opts{'do'}) {
56   s/\[p\]/$inst_root/g for @ARGV;
57   system(@ARGV);
58 }
59 elsif ($opts{'run'}) {
60   if ($opts{'run'} eq 'test') {
61     system("ceexec","$inst_root\\bin\\perl","-we","Win32::MessageBox(\$].qq(\n).join'','cc'..'dx')");
62   }
63   else {
64     system("ceexec","$inst_root\\bin\\perl", map {/^".*"$/s?$_:"\"$_\""} @ARGV);
65   }
66 }
67 elsif ($opts{'copy'}) {
68   if ($opts{'copy'} eq 'compact') {
69     die "todo";
70   }
71   s/\[p\]/$inst_root/g for @ARGV;
72   if ($ARGV[0]=~/^pc:/i) {system("cedel",$ARGV[1])}
73   system("cecopy",@ARGV);
74 }
75 else {
76   # todo
77 }
78
79
80 =comments
81
82   Author Vadim Konovalov.
83
84 =cut