File: build-lives-rfx-plugin-multi

package info (click to toggle)
lives 1.6.2~ds1-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 21,016 kB
  • sloc: ansic: 149,382; sh: 12,577; perl: 8,710; python: 7,078; cpp: 2,589; makefile: 1,370; yacc: 291; sed: 16
file content (243 lines) | stat: -rwxr-xr-x 5,045 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/perl


# build-lives-rfx-plugin-multi - Copyright G. Finch (salsaman) 2005 - 2012
# Released under the GPL 3 or later - see file COPYING or www.gnu.org for details


#########################################################

if ($^O eq "MSWin32") {
    use File::Path qw(make_path);


    $installdir="C:\\Program Files\\LiVES";

    $login = getlogin;
    $home="C:\\users\\$login\\Application Data\\LiVES";

    $smogcmd="perl \"$installdir\\smogrify\"";
    $home_dir_extra="\\Config\\Plugins\\effects\\";
    $dir_extra="\\Plugins\\effects\\";
    $builder="$installdir\\build-lives-rfx-plugin";
}
else {
    $smogcmd="smogrify";
    $home_dir_extra="/.lives-dir/plugins/effects/";
    $dir_extra="/lives/plugins/effects/";
    $builder="build-lives-rfx-plugin";
}


my $type="builtin"; # default

#########################################################

my ($scripts_dir);
my ($exec_dir);
my ($builder_location);

if (defined $ARGV[0]) {
    $type=$ARGV[0];
}


if (defined $ARGV[1] && $ARGV[1] ne "") {
    $scripts_dir=$ARGV[1];
}

if (defined $ARGV[2] && $ARGV[2] ne "") {
    $exec_dir=$ARGV[2];
}

if (defined $ARGV[3] && $ARGV[3] ne "") {
    $build_bindir=$ARGV[3];
}

if (!defined($scripts_dir)) {
    if ($^O ne "MSWin32") {


#get <tempdir>
    `\"$smogcmd\" get_tempdir rfx_builder`;
    open IN,"< /tmp/.smogrify.rfx_builder";
    read IN,$tmpdir,512;
    close IN;
    unlink "/tmp/.smogrify.rfx_builder";
    
    if ($tmpdir eq "") {
	$tmpdir="/tmp";
    }
    
    
# check we have the plugin builder
    `\"$smogcmd\" get_location $builder rfx builder`;
    open IN,"< $tmpdir/.smogval.rfx.builder";
    read IN,$builder_location,512;
    close IN;
    unlink "$tmpdir/.smogval.rfx.builder";
    
    if ($builder_location eq "") {
	print "Unable to locate $builder. Exiting.\n";
	exit 3;
    }
    
    }

    if ($type eq "builtin") {
# get the prefix_dir from ~/.lives
	`\"$smogcmd\" get_pref prefix_dir rfx builder`;
	open IN,"< $tmpdir/.smogval.rfx.builder";
	read IN,$dir,512;
	close IN;
	unlink "$tmpdir/.smogval.rfx.builder";
	chomp($dir);
	$scripts_dir="$dir/share";
	$exec_dir="$dir/lib";  # guessing
    }
    else {
	if ($^O eq "MSWin32") {
	    $login = getlogin;
	    $scripts_dir=$home;
	}
	else {
	    $scripts_dir=$ENV{"HOME"};
	}
	chomp($scripts_dir);
	$exec_dir=$scripts_dir;
    }
}

if ($type eq "builtin") {
    $scripts_dir.=$dir_extra;
    $indir=$scripts_dir."RFXscripts/";
    unlink glob "$indir/*~";
    $exec_dir.=$dir_extra;
    $outdir=$exec_dir."rendered/";
}
elsif ($type eq "custom") {
    $scripts_dir.=$home_dir_extra;
    $indir=$scripts_dir."RFXscripts/custom/";
    unlink glob "$indir/*~";
    $exec_dir.=$home_dir_extra;
    $outdir=$exec_dir."rendered/custom/";
}
elsif ($type eq "test") {
    $scripts_dir.=$home_dir_extra;
    $indir=$scripts_dir."RFXscripts/test/";
    unlink glob "$indir/*~";
    $exec_dir.=$home_dir_extra;
    $outdir=$exec_dir."rendered/test/";
}
elsif ($type eq "builtinx") {
    $indir=$scripts_dir;
    $outdir=$exec_dir;
    unlink glob "$indir/*~";
}

else {
    print "error: unknown RFX type\n";
    exit 1;
}

print "Deleting scripted plugins from $outdir\n";
&remove_scripted_plugins($outdir);

print "Building all in $indir\n";

if ($^O eq "MSWin32") {
    make_path("$outdir");
} else {
    `/bin/mkdir -p $outdir`;
}

opendir DIR,$indir;
while ($plugin=readdir(DIR)) {
    unless ($plugin =~ /^\./) {
	print "building $indir$plugin \n";
	if (defined $build_bindir) {
	    if ($^O eq "MSWin32") {
		system("perl \"$build_bindir\\$builder\" \"$indir$plugin\" \"$outdir\"");
	    } else {
		system("\"$build_bindir/$builder\" \"$indir$plugin\" \"$outdir\"");
	    }
	}
	else {
	    if ($^O eq "MSWin32") {
		system("perl \"$builder\" \"$indir$plugin\" \"$outdir\"");
	    } else {
		system("$builder \"$indir$plugin\" \"$outdir\"");
	    }
	}
    }
}
close DIR;

if ($type eq "test" || $type eq "custom") {
    rmdir $outdir;
}

exit 0;

######################################################################

sub remove_scripted_plugins {
    # remove only plugins with properties&0x8000, and "broken" plugins
    my ($outdir)=@_;
    my $file;
    my $cmd;

    if ($^O eq "MSWin32") {
	# filter by file ext
	my $ext=&get_ext("$plugin");
	if ($ext eq ".py") {
	    $cmd="python";
	}
	else {
	    $cmd="perl";
	}
    }
    else {
	$cmd="";
    }

    opendir DIR,$outdir;
    while ($file=readdir(DIR)) {
	unless ($file =~ /^\./) {
	    if (-x "$outdir$file" || $^O eq "MSWin32") {
		my ($fx_caps)=`$cmd \"$outdir$file\" get_capabilities`;
		if ($fx_caps&0x8000||$fx_caps eq ""||$? != 0) {
		    unlink "$outdir$file";
		}
	    }
	}
    }
    closedir DIR;
}


sub location {
    # return the location of an executable
    my ($command)=@_;
    if ($^O eq "MSWin32") {
	return "$command.exe";
    }
    my ($location)=`which $command 2>/dev/null`;
    chomp($location);
    $location;
}


sub get_ext {
    my $fname=shift;

    my $ext=(split(/\./,$fname))[-1];

    if ($ext=~/(.*)\"$/) {
	$ext=$1;
    }

    return ".".$ext;
}