bump product version to 4.1.6.2
[LibreOffice.git] / solenv / bin / mkout.pl
blob3b5b6ec17facab08bf7d9aade03e308f83bc6108
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
5 # This file is part of the LibreOffice project.
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # This file incorporates work covered by the following license notice:
13 # Licensed to the Apache Software Foundation (ASF) under one or more
14 # contributor license agreements. See the NOTICE file distributed
15 # with this work for additional information regarding copyright
16 # ownership. The ASF licenses this file to you under the Apache
17 # License, Version 2.0 (the "License"); you may not use this file
18 # except in compliance with the License. You may obtain a copy of
19 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 # mkout.pl - create output tree
26 use Cwd;
27 use Getopt::Std;
28 use File::Path;
30 #### script id #####
32 ( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
34 #### globals ####
36 $is_debug = 0;
38 $base_dir = 0; # path to module base directory
39 $dir_mode = 0755; # default directory creation mode
41 $envpath = 0; # platform/product combination
42 $opt_r = 0; # create 'remote' subdirs
44 %sub_dirs = (
45 # dirname remote(yes/no)
46 'bin' => 1,
47 'class' => 0,
48 'inc' => 0,
49 'lib' => 1,
50 'misc/logs' => 1,
51 'obj' => 1,
52 'res' => 1,
53 'slb' => 1,
54 'slo' => 1,
55 'srs' => 1
58 #### main ####
60 parse_options();
61 init_globals();
62 create_dirs();
64 exit(0);
66 #### subroutines #####
68 sub parse_options {
69 my $rc;
71 $rc = getopts('r');
73 if ( !$rc || $#ARGV > 0 ) {
74 usage();
75 exit(1);
77 $envpath = $ARGV[0] if defined($ARGV[0]);
80 sub init_globals {
81 my $umask;
82 $base_dir = get_base();
83 print "Base_Diri=$base_dir\n" if $is_debug;
85 $umask = umask();
86 if ( defined($umask) ) {
87 $dir_mode = 0777 - $umask;
89 $envpath = $ENV{INPATH} unless $envpath;
91 if ( !$envpath ) {
92 print_error("can't determine platform/environment");
93 exit(3);
95 print "Platform/Environment: $envpath\n" if $is_debug;
98 sub get_base {
99 # a module base dir contains a subdir 'prj'
100 # which in turn contains a file 'd.lst'
101 my (@field, $base, $dlst);
102 my $path = cwd();
104 @field = split(/\//, $path);
106 while ( $#field != -1 ) {
107 $base = join('/', @field);
108 $dlst = $base . '/prj/d.lst';
109 last if -e $dlst;
110 pop @field;
113 if ( $#field == -1 ) {
114 print_error("can't determine module");
115 exit(2);
117 else {
118 return $base;
122 sub create_dirs {
123 foreach $dir ( keys %sub_dirs ) {
124 $path = $base_dir . '/' . $envpath . '/' . $dir;
125 if ( $opt_r && $sub_dirs{$dir} ) {
126 $path .= "/remote";
128 eval { mkpath($path, 0, $dir_mode) };
129 if ( $@ ) {
130 print_error( "$@" );
132 print "Create path: $path\n" if $is_debug;
136 sub print_error {
137 my $message = shift;
139 print STDERR "$script_name: ERROR: $message\n";
142 sub usage {
143 print STDERR "Usage:\n$script_name [-r] [platform/environment]\n";
144 print STDERR "Options:\n -r create 'remote' directories\n";
147 # vim: set ts=4 shiftwidth=4 expandtab syntax=perl: