forked from WGLab/uniline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build_uniline
executable file
·35 lines (31 loc) · 1.07 KB
/
Build_uniline
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
#!/usr/bin/env perl
use strict;
use warnings;
my $src = "src";
my $bin = "bin";
#copy all scripts from src/ to bin/
if (-d "$src") {
if (not -d "$bin") {
mkdir "$bin" or die "ERROR: mkdir() failed to create $bin/ $!\n";
}
opendir (my $src_dh,"$src") or die "ERROR: opendir() failed reading $src/ $!\n";
while (my $i = readdir $src_dh) {
next if $i eq '.' or $i eq '..';
!system("cp -f $src/$i $bin/") or die "ERROR: cp failed $!\n";
}
closedir $src_dh;
} else {
die "ERROR: $src/ does not exist!\nMake sure you are in the root folder of uniline.\n";
}
#add 'use lib $PWD/lib/perl5lib' to each perl script
opendir (my $bin_dh,"$bin") or die "ERROR: opendir() failed reading $bin/ $!\n";
my $PWD = $ENV{PWD};
while (my $i = readdir $bin_dh) {
if ($i =~ /\.pl$/) {
!system("perl -i -pe 'print \"use lib \\\"$PWD/lib/perl5lib\\\";\\n\" if \$.==2' $bin/$i") or die "ERROR: failed to write lib directory $!\n";
}
}
closedir $bin_dh;
#check dependencies
!system("$src/check_dependency.py") or die "\n";
warn("Build success!\nuniline is ready to use.\n");