-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.pl
86 lines (69 loc) · 3.15 KB
/
build.pl
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
#!/usr/bin/perl
use strict;
use TryCatch;
use File::Path;
use File::Copy;
use File::Copy::Recursive qw(fcopy rcopy dircopy);
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
sub END {
print STDERR "Ok";
sleep(1);
}
my $closureCompiler = './closureJS/closure-compiler-v20211107.jar --warning_level=QUIET --language_in=ECMASCRIPT_2017';
my $build_dir = './build_dir/';
my $compile_check_dir = './compile_dir/';
my $target_dir = './target_dir';
my @files = ('lib', 'modules', 'img', 'fancy-settings', '_locales', 'video');
try {
rmtree( $build_dir, 1) or print SYSERR $!;
rmtree( $build_dir, 1) or print SYSERR $!;
rmtree( $compile_check_dir, 1) or print SYSERR $!;
mkdir $build_dir or die $!;
mkdir $compile_check_dir or die $!;
foreach(@files)
{
dircopy("./$_","./$build_dir/$_") or die $!;
}
my @files = glob("./*.*");
for my $file (@files) {
if($file ne './build.pl'){
print STDERR $file."\n";
copy("./$file", $build_dir) or die "Copy failed: $!";
}
}
print STDERR "Obfuscete: background.js, park.js, popup.js, utils.js...";
`java -jar $closureCompiler --js $build_dir/park.js --js_output_file $build_dir/park.js`; die "Exit code: $?" if $? > 0;
#{if($? != 0) { print "Exit code: $?"; die();}};
# Syntax Check...
my $compiler_options = "--warning_level VERBOSE ";
`java -jar $closureCompiler $compiler_options --jscomp_warning=checkVars --js $build_dir/background.js --language_in ECMASCRIPT_2018 --js_output_file $compile_check_dir/background.js`; die "Exit code: $?" if $? > 0;
`java -jar $closureCompiler $compiler_options --jscomp_warning=checkVars --js $build_dir/popup.js --js $build_dir/modules/errorsProcessing.js --js_output_file $compile_check_dir/popup.js`; die "Exit code: $?" if $? > 0;
`java -jar $closureCompiler $compiler_options --js $build_dir/utils.js --js_output_file $compile_check_dir/utils.js`; die "Exit code: $?" if $? > 0;
`java -jar $closureCompiler $compiler_options --js $build_dir/inject.js --js_output_file $compile_check_dir/inject.js`; die "Exit code: $?" if $? > 0;
print STDERR "Ok\n";
# Just test for JS error no really used obfuscated files.
my @files = glob("$build_dir/modules/*.js");
#push (@files, glob("$build_dir/modules/*.js"));
for my $file (@files) {
if($file ne './build.pl'){
print "Check modules syntax $file...";
`java -jar $closureCompiler --js $file --js_output_file $compile_check_dir/syntax_check.js`;
print "OK\n";
}
}
#print STDERR "Check all JS syntax...\n";
#my $command = "java -jar ".$closureCompiler." --js ".$build_dir."modules/*.js --js ".$build_dir."*.js --js_output_file ./tmp/dummy.js";
#print STDERR $command;
#`$command`;
#print STDERR "Ok\n";
#Park minimize
`java -jar $closureCompiler --js park.js --js_output_file $build_dir/park.js`;
mkdir $target_dir or print SYSERR $!;
my $zip = Archive::Zip->new() or die $!;
my $dir_member = $zip->addTree( $build_dir ) or print SYSERR $!;
my $status = $zip->writeToFileNamed( "$target_dir/AutomaticTabsCleanerSuspender.zip" ) or print SYSERR $!;
}
catch ($err)
{
print STDERR $err;
}