2001-03-15 05:30:43 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-07 12:11:51 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2005-09-07 12:11:51 -05:00
|
|
|
* $RCSfile: idlcmain.cxx,v $
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2006-07-19 10:18:37 -05:00
|
|
|
* $Revision: 1.15 $
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2006-07-19 10:18:37 -05:00
|
|
|
* last change: $Author: kz $ $Date: 2006-07-19 16:18:37 $
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2005-09-07 12:11:51 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
|
|
|
*
|
2005-09-07 12:11:51 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2005-09-07 12:11:51 -05:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2005-09-07 12:11:51 -05:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2005-09-07 12:11:51 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef _IDLC_IDLC_HXX_
|
|
|
|
#include <idlc/idlc.hxx>
|
|
|
|
#endif
|
2004-10-28 10:21:26 -05:00
|
|
|
#ifndef _SAL_MAIN_H_
|
|
|
|
#include "sal/main.h"
|
|
|
|
#endif
|
2001-03-15 05:30:43 -06:00
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
|
2004-10-28 10:21:26 -05:00
|
|
|
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
|
2001-03-15 05:30:43 -06:00
|
|
|
{
|
|
|
|
Options options;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (!options.initOptions(argc, argv))
|
2002-11-13 10:24:54 -06:00
|
|
|
exit(1);
|
2001-03-15 05:30:43 -06:00
|
|
|
}
|
|
|
|
catch( IllegalArgument& e)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Illegal argument: %s\n%s",
|
2002-11-13 10:24:54 -06:00
|
|
|
e.m_message.getStr(),
|
|
|
|
options.prepareVersion().getStr());
|
2001-03-15 05:30:43 -06:00
|
|
|
exit(99);
|
|
|
|
}
|
|
|
|
|
|
|
|
setIdlc(&options);
|
|
|
|
|
2002-11-13 10:24:54 -06:00
|
|
|
sal_Int32 nErrors = 0;
|
2004-03-30 09:47:32 -06:00
|
|
|
if (options.readStdin()) {
|
|
|
|
fprintf(
|
|
|
|
stdout, "%s: compile stdin...\n",
|
|
|
|
options.getProgramName().getStr());
|
|
|
|
nErrors = compileFile(0);
|
|
|
|
if (idlc()->getWarningCount() > 0) {
|
|
|
|
fprintf(
|
2006-07-19 10:18:37 -05:00
|
|
|
stdout, "%s: detected %lu warnings compiling stdin\n",
|
|
|
|
options.getProgramName().getStr(),
|
|
|
|
sal::static_int_cast< unsigned long >(
|
|
|
|
idlc()->getWarningCount()));
|
2004-03-30 09:47:32 -06:00
|
|
|
}
|
2005-01-18 06:34:34 -06:00
|
|
|
OString outputUrl;
|
|
|
|
if (options.isValid("-O")) {
|
|
|
|
outputUrl = convertToFileUrl(options.getOption("-O"));
|
|
|
|
if (outputUrl[outputUrl.getLength() - 1] != '/') {
|
|
|
|
outputUrl += "/";
|
2004-03-30 09:47:32 -06:00
|
|
|
}
|
2005-01-18 06:34:34 -06:00
|
|
|
outputUrl += "stdin.urd";
|
|
|
|
} else {
|
|
|
|
outputUrl = convertToFileUrl("stdin.urd");
|
|
|
|
}
|
|
|
|
if (nErrors > 0) {
|
|
|
|
removeIfExists(outputUrl);
|
2004-03-30 09:47:32 -06:00
|
|
|
} else {
|
2005-01-18 06:34:34 -06:00
|
|
|
nErrors = produceFile(outputUrl);
|
2004-03-30 09:47:32 -06:00
|
|
|
}
|
|
|
|
idlc()->reset();
|
|
|
|
}
|
|
|
|
StringVector const & files = options.getInputFiles();
|
|
|
|
for (StringVector::const_iterator i(files.begin());
|
|
|
|
i != files.end() && nErrors == 0; ++i)
|
2001-03-15 05:30:43 -06:00
|
|
|
{
|
2004-05-18 07:40:57 -05:00
|
|
|
OString sysFileName( convertToAbsoluteSystemPath(*i) );
|
|
|
|
|
|
|
|
fprintf(stdout, "%s: compile '%s' ... \n",
|
|
|
|
options.getProgramName().getStr(), (*i).getStr());
|
|
|
|
nErrors = compileFile(&sysFileName);
|
|
|
|
|
|
|
|
if ( idlc()->getWarningCount() )
|
2006-07-19 10:18:37 -05:00
|
|
|
fprintf(stdout, "%s: detected %lu warnings compiling file '%s'\n",
|
|
|
|
options.getProgramName().getStr(),
|
|
|
|
sal::static_int_cast< unsigned long >(
|
|
|
|
idlc()->getWarningCount()),
|
|
|
|
(*i).getStr());
|
2004-05-18 07:40:57 -05:00
|
|
|
|
|
|
|
// prepare output file name
|
|
|
|
OString outputFileUrl;
|
|
|
|
if ( options.isValid("-O") )
|
|
|
|
{
|
|
|
|
OString strippedFileName(sysFileName.copy(sysFileName.lastIndexOf(SEPARATOR) + 1));
|
|
|
|
outputFileUrl = convertToFileUrl(options.getOption("-O"));
|
|
|
|
sal_Char c = outputFileUrl.getStr()[outputFileUrl.getLength()-1];
|
|
|
|
|
|
|
|
if ( c != '/' )
|
|
|
|
outputFileUrl += OString::valueOf('/');
|
|
|
|
|
|
|
|
outputFileUrl += strippedFileName.replaceAt(strippedFileName.getLength() -3 , 3, "urd");
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
outputFileUrl = convertToFileUrl(sysFileName.replaceAt(sysFileName.getLength() -3 , 3, "urd"));
|
2004-03-30 09:47:32 -06:00
|
|
|
}
|
2004-05-18 07:40:57 -05:00
|
|
|
|
|
|
|
if ( nErrors )
|
|
|
|
removeIfExists(outputFileUrl);
|
|
|
|
else
|
|
|
|
nErrors = produceFile(outputFileUrl);
|
|
|
|
|
2001-03-15 05:30:43 -06:00
|
|
|
idlc()->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nErrors > 0 )
|
|
|
|
{
|
2006-07-19 10:18:37 -05:00
|
|
|
fprintf(stdout, "%s: detected %ld errors%s",
|
|
|
|
options.getProgramName().getStr(),
|
|
|
|
sal::static_int_cast< long >(nErrors),
|
2004-03-30 09:47:32 -06:00
|
|
|
options.prepareVersion().getStr());
|
2001-03-15 05:30:43 -06:00
|
|
|
} else
|
|
|
|
{
|
2001-07-27 03:47:09 -05:00
|
|
|
fprintf(stdout, "%s: returned successful%s",
|
2002-11-13 10:24:54 -06:00
|
|
|
options.getProgramName().getStr(),
|
|
|
|
options.prepareVersion().getStr());
|
2001-03-15 05:30:43 -06:00
|
|
|
}
|
2006-06-19 21:49:07 -05:00
|
|
|
return nErrors;
|
2001-03-15 05:30:43 -06:00
|
|
|
}
|