Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / bin / modules / par2script / parameter.pm
blob3a8897fbaf7362f0559091e7ad7018dc6036ab4c
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 package par2script::parameter;
22 use Cwd;
23 use par2script::files;
24 use par2script::globals;
25 use par2script::systemactions;
27 ############################################
28 # Parameter Operations
29 ############################################
31 ###############################################################################
32 # Usage:
33 # perl par2script.pl -i ..\wntmsci8.pro\par,o:\SRX645\wntmsci8.pro\par.m24
34 # @@C:\DOCUMEN~1\is\LOCALS~1\Temp\mk6pd
35 # -o ..\wntmsci8.pro\bin\osl\setup_osl.inf
36 ###############################################################################
38 sub usage
40 print <<Ende;
42 --------------------------------------------------------------
43 $par2script::globals::prog
44 The following parameter are needed:
45 -i: include paths, comma separated list
46 -o: setup script file name
47 -v: writing logfile.txt (optional)
48 \@\@list: list of all par files
50 Example:
51 perl par2script.pl -i ..\\wntmsci8\\par\,o\:\\SRX645\\wntmsci8\\par.m24
52 \@\@C\:\\DOCUMEN\~1\\is\\LOCALS\~1\\Temp\\mk6pd
53 -o ..\\wntmsci8.pro\\bin\\osl\\setup_osl.inf \[-v\]
55 --------------------------------------------------------------
56 Ende
57 exit(-1);
60 #####################################
61 # Reading parameter
62 #####################################
64 sub getparameter
66 while ( $#ARGV >= 0 )
68 my $param = shift(@ARGV);
70 if ($param eq "-o") { $par2script::globals::scriptname = shift(@ARGV); }
71 elsif ($param eq "-q") { $par2script::globals::verbose = 0; }
72 elsif ($param eq "-v") { $par2script::globals::logging = 1; }
73 elsif ($param =~ /\@\@/) { $par2script::globals::parfilelistorig = $param; }
74 elsif ($param eq "-i") { $par2script::globals::includepathlist = shift(@ARGV); }
75 elsif (($param =~ /\//) || ($param =~ /\\/)) # another include parameter!
77 $par2script::globals::includepathlist = $par2script::globals::includepathlist . "," . $param;
79 else
81 print("\n*************************************\n");
82 print("Sorry, unknown parameter: $param");
83 print("\n*************************************\n");
84 usage();
85 exit(-1);
90 ############################################
91 # Controlling the fundamental parameter
92 # (required for every process)
93 ############################################
95 sub control_parameter
97 if ($par2script::globals::includepathlist eq "")
99 print "\n************************************************\n";
100 print "Error: Include paths not set not set (-i)!";
101 print "\n************************************************\n";
102 usage();
103 exit(-1);
106 if ($par2script::globals::scriptname eq "")
108 print "\n************************************************\n";
109 print "Error: Name of the setup script not set (-o)!";
110 print "\n************************************************\n";
111 usage();
112 exit(-1);
115 if ($par2script::globals::parfilelistorig eq "")
117 print "\n************************************************\n";
118 print "Error: List of par files not set!";
119 print "\n************************************************\n";
120 usage();
121 exit(-1);
124 # The par file list has to exist
126 $par2script::globals::parfilelist = $par2script::globals::parfilelistorig;
127 $par2script::globals::parfilelist =~ s/\@\@//;
128 par2script::files::check_file($par2script::globals::parfilelist);
131 #####################################
132 # Writing parameter to shell
133 #####################################
135 sub outputparameter
137 my $outputline = "\n$par2script::globals::prog -i $par2script::globals::includepathlist $par2script::globals::parfilelistorig -o $par2script::globals::scriptname";
139 if ($par2script::globals::logging) { $outputline .= " -v"; }
141 $outputline .= "\n";
143 print $outputline;