2001-05-08 04:56:35 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 07:07:11 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-05-08 04:56:35 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-05-08 04:56:35 -05:00
|
|
|
*
|
2008-04-11 07:07:11 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-05-08 04:56:35 -05:00
|
|
|
*
|
2008-04-11 07:07:11 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-05-08 04:56:35 -05:00
|
|
|
*
|
2008-04-11 07:07:11 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-05-08 04:56:35 -05:00
|
|
|
*
|
2008-04-11 07:07:11 -05:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-05-08 04:56:35 -05:00
|
|
|
*
|
2008-04-11 07:07:11 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-05-08 04:56:35 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 18:49:23 -05:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_tools.hxx"
|
2001-05-08 04:56:35 -05:00
|
|
|
#ifdef UNX
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2006-06-19 07:21:59 -05:00
|
|
|
#include "bootstrp/prj.hxx"
|
2010-01-27 09:23:59 -06:00
|
|
|
#include "sal/main.h"
|
2001-05-08 04:56:35 -05:00
|
|
|
|
2007-06-27 16:07:17 -05:00
|
|
|
#include <tools/string.hxx>
|
|
|
|
#include <tools/list.hxx>
|
|
|
|
#include <tools/fsys.hxx>
|
|
|
|
#include <tools/stream.hxx>
|
2001-05-08 04:56:35 -05:00
|
|
|
|
|
|
|
#include "cppdep.hxx"
|
|
|
|
|
2010-06-17 04:30:15 -05:00
|
|
|
#if defined WNT
|
|
|
|
#if !defined HAVE_GETOPT
|
2010-06-16 12:57:33 -05:00
|
|
|
#define __STDC__ 1
|
|
|
|
#define __GNU_LIBRARY__
|
|
|
|
#include <external/glibc/getopt.h>
|
2010-06-17 04:30:15 -05:00
|
|
|
#else
|
|
|
|
#include <getopt.h>
|
|
|
|
#endif
|
2010-06-16 12:57:33 -05:00
|
|
|
#endif
|
|
|
|
|
2001-05-08 04:56:35 -05:00
|
|
|
class RscHrcDep : public CppDep
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RscHrcDep();
|
|
|
|
virtual ~RscHrcDep();
|
|
|
|
|
|
|
|
virtual void Execute();
|
|
|
|
};
|
|
|
|
|
|
|
|
RscHrcDep::RscHrcDep() :
|
|
|
|
CppDep()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RscHrcDep::~RscHrcDep()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RscHrcDep::Execute()
|
|
|
|
{
|
|
|
|
CppDep::Execute();
|
|
|
|
}
|
|
|
|
|
2002-02-07 09:34:45 -06:00
|
|
|
//static String aDelim;
|
|
|
|
|
2010-01-27 09:23:59 -06:00
|
|
|
SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
|
2001-05-08 04:56:35 -05:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
char aBuf[255];
|
2008-10-15 03:43:33 -05:00
|
|
|
char pFileNamePrefix[255];
|
2001-05-08 04:56:35 -05:00
|
|
|
char pOutputFileName[255];
|
2004-04-08 09:11:09 -05:00
|
|
|
char pSrsFileName[255];
|
2001-05-08 04:56:35 -05:00
|
|
|
String aSrsBaseName;
|
|
|
|
BOOL bSource = FALSE;
|
|
|
|
ByteString aRespArg;
|
2009-03-24 07:17:31 -05:00
|
|
|
// who needs anything but '/' ?
|
|
|
|
// String aDelim = String(DirEntry::GetAccessDelimiter());
|
|
|
|
String aDelim = '/';
|
2001-05-08 04:56:35 -05:00
|
|
|
|
|
|
|
RscHrcDep *pDep = new RscHrcDep;
|
|
|
|
|
2004-04-08 09:11:09 -05:00
|
|
|
pOutputFileName[0] = 0;
|
|
|
|
pSrsFileName[0] = 0;
|
|
|
|
|
2001-05-08 04:56:35 -05:00
|
|
|
for ( int i=1; i<argc; i++)
|
|
|
|
{
|
|
|
|
strcpy( aBuf, (const char *)argv[i] );
|
2008-10-15 03:43:33 -05:00
|
|
|
if ( aBuf[0] == '-' && aBuf[1] == 'p' && aBuf[2] == '=' )
|
|
|
|
{
|
|
|
|
strcpy(pFileNamePrefix, &aBuf[3]);
|
|
|
|
//break;
|
|
|
|
}
|
2004-07-13 11:10:02 -05:00
|
|
|
if ( aBuf[0] == '-' && aBuf[1] == 'f' && aBuf[2] == 'o' && aBuf[3] == '=' )
|
2001-05-08 04:56:35 -05:00
|
|
|
{
|
2004-07-13 11:10:02 -05:00
|
|
|
strcpy(pOutputFileName, &aBuf[4]);
|
2001-05-08 04:56:35 -05:00
|
|
|
//break;
|
|
|
|
}
|
2004-07-13 11:10:02 -05:00
|
|
|
if ( aBuf[0] == '-' && aBuf[1] == 'f' && aBuf[2] == 'p' && aBuf[3] == '=' )
|
2001-05-08 04:56:35 -05:00
|
|
|
{
|
2004-07-13 11:10:02 -05:00
|
|
|
strcpy(pSrsFileName, &aBuf[4]);
|
2004-04-08 09:11:09 -05:00
|
|
|
String aName( pSrsFileName, gsl_getSystemTextEncoding());
|
2001-05-08 04:56:35 -05:00
|
|
|
DirEntry aDest( aName );
|
2004-04-08 09:11:09 -05:00
|
|
|
aSrsBaseName = aDest.GetBase();
|
2001-05-08 04:56:35 -05:00
|
|
|
//break;
|
|
|
|
}
|
|
|
|
if (aBuf[0] == '-' && aBuf[1] == 'i' )
|
|
|
|
{
|
|
|
|
//printf("Include : %s\n", &aBuf[2] );
|
|
|
|
pDep->AddSearchPath( &aBuf[2] );
|
|
|
|
}
|
|
|
|
if (aBuf[0] == '-' && aBuf[1] == 'I' )
|
|
|
|
{
|
|
|
|
//printf("Include : %s\n", &aBuf[2] );
|
|
|
|
pDep->AddSearchPath( &aBuf[2] );
|
|
|
|
}
|
|
|
|
if (aBuf[0] == '@' )
|
|
|
|
{
|
|
|
|
ByteString aToken;
|
|
|
|
String aRespName( &aBuf[1], gsl_getSystemTextEncoding());
|
|
|
|
SimpleConfig aConfig( aRespName );
|
|
|
|
while ( (aToken = aConfig.GetNext()) != "")
|
|
|
|
{
|
|
|
|
char aBuf2[255];
|
|
|
|
(void) strcpy( aBuf2, aToken.GetBuffer());
|
2008-10-15 03:43:33 -05:00
|
|
|
if ( aBuf[0] == '-' && aBuf[1] == 'p' && aBuf[2] == '=' )
|
|
|
|
{
|
|
|
|
strcpy(pFileNamePrefix, &aBuf[3]);
|
|
|
|
//break;
|
|
|
|
}
|
2001-05-08 04:56:35 -05:00
|
|
|
if ( aBuf2[0] == '-' && aBuf2[1] == 'f' && aBuf2[2] == 'o' )
|
|
|
|
{
|
|
|
|
strcpy(pOutputFileName, &aBuf2[3]);
|
|
|
|
//break;
|
|
|
|
}
|
|
|
|
if ( aBuf2[0] == '-' && aBuf2[1] == 'f' && aBuf2[2] == 'p' )
|
|
|
|
{
|
2004-04-08 09:11:09 -05:00
|
|
|
strcpy(pSrsFileName, &aBuf2[3]);
|
|
|
|
String aName( pSrsFileName, gsl_getSystemTextEncoding());
|
2001-05-08 04:56:35 -05:00
|
|
|
DirEntry aDest( aName );
|
|
|
|
aSrsBaseName = aDest.GetBase();
|
|
|
|
//break;
|
|
|
|
}
|
|
|
|
if (aBuf2[0] == '-' && aBuf2[1] == 'i' )
|
|
|
|
{
|
|
|
|
//printf("Include : %s\n", &aBuf[2] );
|
|
|
|
pDep->AddSearchPath( &aBuf2[2] );
|
|
|
|
}
|
|
|
|
if (aBuf2[0] == '-' && aBuf2[1] == 'I' )
|
|
|
|
{
|
|
|
|
//printf("Include : %s\n", &aBuf[2] );
|
|
|
|
pDep->AddSearchPath( &aBuf2[2] );
|
|
|
|
}
|
|
|
|
if (( aBuf2[0] != '-' ) && ( aBuf2[0] != '@' ))
|
|
|
|
{
|
|
|
|
pDep->AddSource( &aBuf2[0] );
|
|
|
|
aRespArg += " ";
|
|
|
|
aRespArg += &aBuf2[0];
|
|
|
|
bSource = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while( 1 )
|
|
|
|
{
|
2010-05-18 07:05:20 -05:00
|
|
|
c = getopt( argc, argv,
|
2002-01-25 07:50:04 -06:00
|
|
|
"_abcdefghi:jklmnopqrstuvwxyzABCDEFGHI:JKLMNOPQRSTUVWXYZ1234567890/-+=.\\()\"");
|
2001-05-08 04:56:35 -05:00
|
|
|
if ( c == -1 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch( c )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 'a' :
|
|
|
|
#ifdef DEBUG_VERBOSE
|
|
|
|
printf("option a\n");
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'l' :
|
|
|
|
#ifdef DEBUG_VERBOSE
|
|
|
|
printf("option l with Value %s\n", optarg );
|
|
|
|
#endif
|
|
|
|
pDep->AddSource( optarg );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'h' :
|
|
|
|
case 'H' :
|
|
|
|
case '?' :
|
|
|
|
printf("RscDep 1.0 (c)2000 StarOffice\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
#ifdef DEBUG_VERBOSE
|
|
|
|
printf("Unknown getopt error\n");
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DirEntry aEntry(".");
|
|
|
|
aEntry.ToAbs();
|
2008-10-15 03:43:33 -05:00
|
|
|
// String aCwd = aEntry.GetName();
|
|
|
|
String aCwd(pFileNamePrefix, gsl_getSystemTextEncoding());
|
2001-05-08 04:56:35 -05:00
|
|
|
/* USHORT nPos;
|
|
|
|
#ifndef UNX
|
|
|
|
while ( (nPos = aCwd.Search('\\') != STRING_NOTFOUND ))
|
|
|
|
#else
|
|
|
|
while ( (nPos = aCwd.Search('/') != STRING_NOTFOUND ))
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
String attt = aCwd.Copy( 0, nPos );
|
|
|
|
aCwd.Erase( 0, nPos );
|
|
|
|
} */
|
|
|
|
SvFileStream aOutStream;
|
|
|
|
String aOutputFileName( pOutputFileName, gsl_getSystemTextEncoding());
|
|
|
|
DirEntry aOutEntry( aOutputFileName );
|
|
|
|
String aOutPath = aOutEntry.GetPath().GetFull();
|
|
|
|
|
|
|
|
String aFileName( aOutPath );
|
|
|
|
aFileName += aDelim;
|
|
|
|
aFileName += aCwd;
|
|
|
|
aFileName += String(".", gsl_getSystemTextEncoding());
|
|
|
|
aFileName += aSrsBaseName;
|
2003-08-25 09:36:59 -05:00
|
|
|
aFileName += String(".dprr", gsl_getSystemTextEncoding());
|
2001-05-08 04:56:35 -05:00
|
|
|
//fprintf( stderr, "OutFileName : %s \n",aFileName.GetStr());
|
|
|
|
aOutStream.Open( aFileName, STREAM_WRITE );
|
|
|
|
|
|
|
|
ByteString aString;
|
|
|
|
if ( optind < argc )
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_VERBOSE
|
|
|
|
printf("further arguments : ");
|
|
|
|
#endif
|
2004-04-08 09:11:09 -05:00
|
|
|
aString = ByteString( pSrsFileName );
|
2009-03-24 07:17:31 -05:00
|
|
|
aString.SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US ));
|
2001-05-08 04:56:35 -05:00
|
|
|
aString += ByteString(" : " );
|
|
|
|
|
|
|
|
while ( optind < argc )
|
|
|
|
{
|
|
|
|
if (!bSource )
|
|
|
|
{
|
|
|
|
aString += ByteString(" " );
|
|
|
|
aString += ByteString( argv[optind]);
|
|
|
|
pDep->AddSource( argv[optind++]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
optind++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aString += aRespArg;
|
|
|
|
pDep->Execute();
|
|
|
|
ByteStringList *pLst = pDep->GetDepList();
|
|
|
|
ULONG nCount = pLst->Count();
|
|
|
|
if ( nCount == 0 )
|
|
|
|
{
|
|
|
|
aOutStream.WriteLine( aString );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aString += ByteString( "\\" );
|
|
|
|
aOutStream.WriteLine( aString );
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( ULONG j=0; j<nCount; j++ )
|
|
|
|
{
|
|
|
|
ByteString *pStr = pLst->GetObject(j);
|
2001-06-13 07:59:43 -05:00
|
|
|
pStr->SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US ));
|
2001-05-08 04:56:35 -05:00
|
|
|
if ( j != (nCount-1) )
|
|
|
|
*pStr += ByteString( "\\" );
|
|
|
|
aOutStream.WriteLine( *pStr );
|
|
|
|
}
|
|
|
|
delete pDep;
|
|
|
|
aOutStream.Close();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|