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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
package Combiner;
use strict;
use warnings;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(nop init_w32 init_w64 parallel parallel_w32 parallel_w64 newline end_parallel combiner combiners w32);
our @EXPORT = qw(nop init_w32 init_w64 parallel parallel_w32 parallel_w64 newline end_parallel combiner combiners w66);
our $w32 = '/usr/i686-w64-mingw32/sys-root/mingw/bin/';
our $w64 = '/usr/x86_64-w64-mingw32/sys-root/mingw/bin/';
sub nop() {
}
sub init_w32() {
print "export WINEPREFIX=\$HOME/.wine32\n";
}
sub init_w64() {
print "export WINEPREFIX=\$HOME/.wine64\n";
}
sub parallel() {
print "parallel -v --halt 1 --colsep ' ' <<EOF\n";
}
sub parallel_w32() {
init_w32();
parallel();
}
sub parallel_w64() {
init_w64();
parallel();
}
sub newline() {
print "\n";
}
sub end_parallel() {
print "EOF\n";
print "\n";
}
sub combiner($$) {
my ($callback, $comb) = @_;
my (@s, @n, $i, @comb, @single);
my ($j, $opts, $name, $overflow, $opname);
@comb = @$comb;
# initial state
foreach $i (0..$#comb) {
@single = @{$comb[$i]};
$s[$i] = 0;
$n[$i] = $#single;
}
$overflow = 0;
while (!$overflow) {
# actual combination of arguments in @s
$opts = "";
$name = "";
foreach $i (0..$#comb) {
$opts .= " " if ($opts and $comb[$i][$s[$i]]);
$opts .= $comb[$i][$s[$i]];
$opname = $comb[$i][$s[$i]];
$opname =~ s/^-*//;
$opname =~ s/ //g;
$name .= "-" if ($name and $opname);
$name .= $opname;
}
$callback->($name ? $name : 'default', $opts);
# next combination
$overflow = 1;
$i = 0;
while ($overflow and ($i <= $#comb)) {
$s[$i]++;
if ($s[$i] <= $n[$i]) {
$overflow = 0;
} else {
$s[$i] = 0;
$i++;
}
}
}
}
sub combiners($$$$) {
my ($inits, $ends, $callbacks, $combs) = @_;
my ($i, $j, @inits, @ends, @combs, @callbacks);
@inits = @$inits;
@ends = @$ends;
@combs = @$combs;
@callbacks = @$callbacks;
foreach $j (0..$#callbacks) {
print "date\n";
$inits[$j]->();
foreach $i (0..$#combs) {
combiner($callbacks[$j], \@{$combs[$i]});
}
$ends[$j]->();
}
}
1;
|