| 1 |
# |
| 2 |
# This file is part of the LibreOffice project. |
| 3 |
# |
| 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/. |
| 7 |
# |
| 8 |
# This file incorporates work covered by the following license notice: |
| 9 |
# |
| 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 . |
| 17 |
# |
| 18 |
|
| 19 |
|
| 20 |
package par2script::parameter; |
| 21 |
|
| 22 |
use Cwd; |
| 23 |
use par2script::files; |
| 24 |
use par2script::globals; |
| 25 |
|
| 26 |
############################################ |
| 27 |
# Parameter Operations |
| 28 |
############################################ |
| 29 |
|
| 30 |
############################################################################### |
| 31 |
# Usage: |
| 32 |
# perl par2script.pl -i ..\wntmsci8.pro\par,o:\SRX645\wntmsci8.pro\par.m24 |
| 33 |
# @@C:\DOCUMEN~1\is\LOCALS~1\Temp\mk6pd |
| 34 |
# -o ..\wntmsci8.pro\bin\osl\setup_osl.inf |
| 35 |
############################################################################### |
| 36 |
|
| 37 |
sub usage |
| 38 |
{ |
| 39 |
print <<End; |
| 40 |
|
| 41 |
-------------------------------------------------------------- |
| 42 |
$par2script::globals::prog |
| 43 |
The following parameter are needed: |
| 44 |
-i: include paths, comma separated list |
| 45 |
-o: setup script file name |
| 46 |
-v: writing logfile.txt (optional) |
| 47 |
\@\@list: list of all par files |
| 48 |
|
| 49 |
Example: |
| 50 |
perl par2script.pl -i ..\\wntmsci8\\par\,o\:\\SRX645\\wntmsci8\\par.m24 |
| 51 |
\@\@C\:\\DOCUMEN\~1\\is\\LOCALS\~1\\Temp\\mk6pd |
| 52 |
-o ..\\wntmsci8.pro\\bin\\osl\\setup_osl.inf \[-v\] |
| 53 |
|
| 54 |
-------------------------------------------------------------- |
| 55 |
End |
| 56 |
exit(-1); |
| 57 |
} |
| 58 |
|
| 59 |
##################################### |
| 60 |
# Reading parameter |
| 61 |
##################################### |
| 62 |
|
| 63 |
sub getparameter |
| 64 |
{ |
| 65 |
while ( $#ARGV >= 0 ) |
| 66 |
{ |
| 67 |
my $param = shift(@ARGV); |
| 68 |
|
| 69 |
if ($param eq "-o") { $par2script::globals::scriptname = shift(@ARGV); } |
| 70 |
elsif ($param eq "-q") { $par2script::globals::verbose = 0; } |
| 71 |
elsif ($param eq "-v") { $par2script::globals::logging = 1; } |
| 72 |
elsif ($param =~ /\@\@/) { $par2script::globals::parfilelistorig = $param; } |
| 73 |
elsif ($param eq "-i") { $par2script::globals::includepathlist = shift(@ARGV); } |
| 74 |
elsif (($param =~ /\//) || ($param =~ /\\/)) # another include parameter! |
| 75 |
{ |
| 76 |
$par2script::globals::includepathlist = $par2script::globals::includepathlist . "," . $param; |
| 77 |
} |
| 78 |
else |
| 79 |
{ |
| 80 |
print("\n*************************************\n"); |
| 81 |
print("Sorry, unknown parameter: $param"); |
| 82 |
print("\n*************************************\n"); |
| 83 |
usage(); |
| 84 |
exit(-1); |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
############################################ |
| 90 |
# Controlling the fundamental parameter |
| 91 |
# (required for every process) |
| 92 |
############################################ |
| 93 |
|
| 94 |
sub control_parameter |
| 95 |
{ |
| 96 |
if ($par2script::globals::includepathlist eq "") |
| 97 |
{ |
| 98 |
print "\n************************************************\n"; |
| 99 |
print "Error: Include paths not set not set (-i)!"; |
| 100 |
print "\n************************************************\n"; |
| 101 |
usage(); |
| 102 |
exit(-1); |
| 103 |
} |
| 104 |
|
| 105 |
if ($par2script::globals::scriptname eq "") |
| 106 |
{ |
| 107 |
print "\n************************************************\n"; |
| 108 |
print "Error: Name of the setup script not set (-o)!"; |
| 109 |
print "\n************************************************\n"; |
| 110 |
usage(); |
| 111 |
exit(-1); |
| 112 |
} |
| 113 |
|
| 114 |
if ($par2script::globals::parfilelistorig eq "") |
| 115 |
{ |
| 116 |
print "\n************************************************\n"; |
| 117 |
print "Error: List of par files not set!"; |
| 118 |
print "\n************************************************\n"; |
| 119 |
usage(); |
| 120 |
exit(-1); |
| 121 |
} |
| 122 |
|
| 123 |
# The par file list has to exist |
| 124 |
|
| 125 |
$par2script::globals::parfilelist = $par2script::globals::parfilelistorig; |
| 126 |
$par2script::globals::parfilelist =~ s/\@\@//; |
| 127 |
par2script::files::check_file($par2script::globals::parfilelist); |
| 128 |
} |
| 129 |
|
| 130 |
##################################### |
| 131 |
# Writing parameter to shell |
| 132 |
##################################### |
| 133 |
|
| 134 |
sub outputparameter |
| 135 |
{ |
| 136 |
my $outputline = "\n$par2script::globals::prog -i $par2script::globals::includepathlist $par2script::globals::parfilelistorig -o $par2script::globals::scriptname"; |
| 137 |
|
| 138 |
if ($par2script::globals::logging) { $outputline .= " -v"; } |
| 139 |
|
| 140 |
$outputline .= "\n"; |
| 141 |
|
| 142 |
print $outputline; |
| 143 |
} |
| 144 |
|
| 145 |
1; |