update dev300-m58
[ooovba.git] / soltools / testhxx / create.pl
blob05603acb49eabcbeeb007d1d5d5a7aa642213eb0
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: create.pl,v $
11 # $Revision: 1.4 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 $solarversion = $ENV{SOLARVERSION};
33 $solarversion =~ s![^0-9A-Za-z]!\\$&!g;
34 $in = <> || die 'no input';
35 chomp $in;
36 if ($ENV{OS} eq 'LINUX') {
37 1 while $in =~ s!\s+-I\s*[^/]\S*\s*! !g; # discard relative includes
38 $in =~ s!(\s+-I\s*)$solarversion(\S*)!$1\${SOLARVERSION}$2!og;
39 # macrofy includes to solver
40 $in =~ s!\s+-o\s*\S+! -o /dev/null! || die 'bad input: no -o';
41 $in =~ s!\S+/testhxx.cxx!-x c++ /proc/self/fd/0!
42 || die 'bad input: no source file';
43 print STDOUT '#!/bin/bash', "\n";
44 print STDOUT $in,
45 ' <<<"#include \\"`echo $(if [ ${1%/*} != $1 ];then cd ${1%/*};fi;',
46 '/bin/pwd)/${1##*/}`\\""', "\n";
47 } elsif ($ENV{OS} eq 'SOLARIS') {
48 1 while $in =~ s!\s+-I\s*[^/]\S*\s*! !g; # discard relative includes
49 $in =~ s!(\s+-I\s*)$solarversion(\S*)!$1\${SOLARVERSION}$2!og;
50 # macrofy includes to solver
51 $in =~ s!\s+-o\s*\S+! -o /dev/null! || die 'bad input: no -o';
52 $in =~ s!\S+/testhxx.cxx!\${my_tmp}!
53 || die 'bad input: no source file';
54 print STDOUT '#!/bin/sh', "\n";
55 print STDOUT
56 'my_tmp=${TMPDIR:-/tmp}/`/usr/xpg4/bin/id -u`_$$_include.cc', "\n";
57 print STDOUT 'my_pat=`dirname $1`', "\n";
58 print STDOUT 'my_fil=`basename $1`', "\n";
59 print STDOUT 'my_org=${PWD}', "\n";
60 print STDOUT 'cd $my_pat || exit 1', "\n";
61 print STDOUT 'my_pat=`pwd`', "\n";
62 print STDOUT 'cd $my_org || exit 1', "\n";
63 print STDOUT
64 'echo "#include \\"${my_pat}/${my_fil}\\"" > ${my_tmp} || exit 1', "\n";
65 print STDOUT $in, ' > ${my_tmp}.out 2>&1', "\n";
66 print STDOUT 'my_ret=$?', "\n";
67 print STDOUT
68 'if [ ${my_ret} -ne 0 ] ; then echo $1 >&2 ; cat ${my_tmp}.out >&2 ;',
69 ' fi', "\n";
70 print STDOUT 'unlink ${my_tmp} || exit 1', "\n";
71 print STDOUT 'unlink ${my_tmp}.out || exit 1', "\n";
72 print STDOUT 'exit ${my_ret}', "\n";
73 } elsif ($ENV{OS} eq 'WNT' and $ENV{USE_SHELL} eq '4nt') {
74 1 while $in =~ s!\s+-I\s*\.\S*\s*! !g; # discard relative includes
75 $in =~ s!(\s+-I\s*)(?i:$solarversion)(\S*)!$1%SOLARVERSION%$2!og;
76 # macrofy includes to solver
77 $in =~ s!\s+-Fo\s*\S+! -Fo%my_tmp%.obj! || die 'bad input: no -Fo';
78 $in =~ s!\s+-Zi\s! !;
79 $in =~ s!\s+-Fd\s*\S+!!;
80 $in =~ s!\S+\\testhxx.cxx!%my_tmp%!
81 || die 'bad input: no source file';
82 print STDOUT '@ECHO OFF', "\n";
83 print STDOUT 'SET my_tmp=%TMP%\%_PID%_include.cc', "\n";
84 print STDOUT 'ECHO #include "%@REPLACE[\\,/,%@FULL[%1]]" > %my_tmp%', "\n";
85 print STDOUT $in, ' > %my_tmp%.out', "\n";
86 print STDOUT 'SET my_ret=%ERRORLEVEL%', "\n";
87 print STDOUT 'IF %my_ret% != 0',
88 ' sed -e s!%@FILENAME[%my_tmp%]!%@REPLACE[\\,\\\\,%1]! %my_tmp%.out',
89 ' 1>&2', "\n";
90 print STDOUT 'DEL /EQ %my_tmp% %my_tmp%.obj %my_tmp%.pdb %my_tmp%.out',
91 "\n";
92 print STDOUT 'QUIT %my_ret%', "\n";
93 } elsif ($ENV{OS} eq 'WNT' and $ENV{USE_SHELL} ne '4nt') {
94 if ($ENV{COM} eq 'GCC') {
95 1 while $in =~ s!\s+-I\s*\.\S*\s*! !g; # discard relative includes
96 $in =~ s!(\s+-I\s*)(?i:$solarversion)(\S*)!$1\${SOLARVERSION}$2!og;
97 # macrofy includes to solver
98 $in =~ s!\s+-o\s*\S+! -o /dev/null! || die 'bad input: no -o';
99 $in =~ s!\S+/testhxx.cxx!\${my_tmp}!
100 || die 'bad input: no source file';
101 print STDOUT '#!/bin/sh', "\n";
102 print STDOUT
103 'my_tmp=${TMPDIR:-/tmp}/`id -u`_$$_include.cc', "\n";
104 print STDOUT 'my_pat=`dirname $1`', "\n";
105 print STDOUT 'my_fil=`basename $1`', "\n";
106 print STDOUT 'my_org=${PWD}', "\n";
107 print STDOUT 'cd $my_pat || exit 1', "\n";
108 print STDOUT 'my_pat=`cygpath -m \`pwd\``', "\n";
109 print STDOUT 'cd $my_org || exit 1', "\n";
110 print STDOUT
111 'echo "#include \\"${my_pat}/${my_fil}\\"" > ${my_tmp} || exit 1', "\n";
112 print STDOUT $in, ' > ${my_tmp}.out 2>&1', "\n";
113 print STDOUT 'my_ret=$?', "\n";
114 print STDOUT
115 'if [ ${my_ret} -ne 0 ] ; then echo $1 >&2 ; cat ${my_tmp}.out >&2 ;',
116 ' fi', "\n";
117 print STDOUT 'unlink ${my_tmp} || exit 1', "\n";
118 print STDOUT 'unlink ${my_tmp}.out || exit 1', "\n";
119 print STDOUT 'exit ${my_ret}', "\n";
120 } else {
121 1 while $in =~ s!\s+-I\s*\.\S*\s*! !g; # discard relative includes
122 $in =~ s!(\s+-I\s*)(?i:$solarversion)(\S*)!$1\${SOLARVERSION}$2!og;
123 # macrofy includes to solver
124 $in =~ s!\s+-Fo\s*\S+! -Fo$[my_tmp}obj! || die 'bad input: no -Fo';
125 $in =~ s!\s+-Zi\s! !;
126 $in =~ s!\s+-Fd\s*\S+!!;
127 print STDOUT '#!/bin/sh', "\n";
128 print STDOUT
129 'my_tmp=${TMPDIR:-/tmp}/`id -u`_$$_include.cc', "\n";
130 print STDOUT 'my_pat=`dirname $1`', "\n";
131 print STDOUT 'my_fil=`basename $1`', "\n";
132 print STDOUT 'my_org=${PWD}', "\n";
133 print STDOUT 'cd $my_pat || exit 1', "\n";
134 print STDOUT 'my_pat=`pwd`', "\n";
135 print STDOUT 'cd $my_org || exit 1', "\n";
136 print STDOUT
137 'echo "#include \\"${my_pat}/${my_fil}\\"" > ${my_tmp} || exit 1', "\n";
138 print STDOUT $in, ' > ${my_tmp}.out 2>&1', "\n";
139 print STDOUT 'my_ret=$?', "\n";
140 print STDOUT
141 'if [ ${my_ret} -ne 0 ] ; then echo $1 >&2 ; cat ${my_tmp}.out >&2 ;',
142 ' fi', "\n";
143 print STDOUT 'unlink ${my_tmp} || exit 1', "\n";
144 print STDOUT 'unlink ${my_tmp}.out || exit 1', "\n";
145 print STDOUT 'exit ${my_ret}', "\n";
147 } else {
148 print STDOUT 'echo \'no testhxx on this platform\'', "\n";