summaryrefslogtreecommitdiff
path: root/idl
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2011-11-08 18:51:13 +0100
committerMichael Stahl <mstahl@redhat.com>2011-11-08 19:10:01 +0100
commit6adb9ad1579df1bde71be3091ccca0c71605ddb7 (patch)
tree8a392706cea7f21dfece4e6741c6724b9c2f8ce8 /idl
parent62ebb119cfb42adc5e007fb77f68d56b40de2a85 (diff)
svidl: new parameter -fM: write GNU make dependencies
Diffstat (limited to 'idl')
-rw-r--r--idl/inc/command.hxx2
-rw-r--r--idl/inc/database.hxx8
-rw-r--r--idl/source/objects/module.cxx1
-rw-r--r--idl/source/prj/command.cxx5
-rw-r--r--idl/source/prj/database.cxx27
-rw-r--r--idl/source/prj/svidl.cxx24
6 files changed, 67 insertions, 0 deletions
diff --git a/idl/inc/command.hxx b/idl/inc/command.hxx
index f8ea98a5e63f..dad01dcf0523 100644
--- a/idl/inc/command.hxx
+++ b/idl/inc/command.hxx
@@ -30,6 +30,7 @@
#define _COMMAND_HXX
#include <tools/string.hxx>
+#include <rtl/ustring.hxx>
#include <vector>
#ifndef STRING_LIST
@@ -61,6 +62,7 @@ public:
String aCSVFile;
String aExportFile;
String aDocuFile;
+ ::rtl::OUString m_DepFile;
sal_uInt32 nVerbosity;
sal_uInt32 nFlags;
diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx
index 80685e34b336..445e54b1aaa5 100644
--- a/idl/inc/database.hxx
+++ b/idl/inc/database.hxx
@@ -34,6 +34,11 @@
#include <lex.hxx>
#include <tools/pstm.hxx>
+#ifdef IDL_COMPILER
+#include <rtl/ustring.hxx>
+#include <set>
+#endif
+
class SvCommand;
#ifdef IDL_COMPILER
@@ -82,6 +87,7 @@ class SvIdlDataBase
protected:
#ifdef IDL_COMPILER
+ ::std::set< ::rtl::OUString > m_DepFiles;
SvMetaObjectMemberStack aContextStack;
String aPath;
SvIdlError aError;
@@ -153,6 +159,8 @@ public:
SvMetaType * pType = NULL );
SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& );
SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
+ void AddDepFile(String const& rFileName);
+ bool WriteDepFile(SvFileStream & rStream, ::rtl::OUString const& rTarget);
#endif
};
diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx
index 1ee58edc41ff..141323b7a336 100644
--- a/idl/source/objects/module.cxx
+++ b/idl/source/objects/module.cxx
@@ -248,6 +248,7 @@ void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase,
rBase.StartNewFile( aFullName.GetFull() );
if( aFullName.Find( rBase.GetPath() ) )
{
+ rBase.AddDepFile(aFullName.GetFull());
SvTokenStream aTokStm( aFullName.GetFull() );
if( SVSTREAM_OK == aTokStm.GetStream().GetError() )
{
diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx
index a112e3b93f83..b40e1395bec9 100644
--- a/idl/source/prj/command.cxx
+++ b/idl/source/prj/command.cxx
@@ -146,6 +146,7 @@ sal_Bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand )
for( size_t n = 0; n < rCommand.aInFileList.size(); ++n )
{
String aFileName ( *rCommand.aInFileList[ n ] );
+ pDataBase->AddDepFile(aFileName);
SvFileStream aStm( aFileName, STREAM_STD_READ | STREAM_NOCREATE );
if( aStm.GetError() == SVSTREAM_OK )
{
@@ -292,6 +293,10 @@ SvCommand::SvCommand( int argc, char ** argv )
{ // name of IDL file for the CSV file
aExportFile = aName;
}
+ else if( 'M' == aFirstChar )
+ {
+ m_DepFile = aName;
+ }
else
{
printf(
diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx
index d488023c42f9..674aeacc8a5d 100644
--- a/idl/source/prj/database.cxx
+++ b/idl/source/prj/database.cxx
@@ -227,6 +227,7 @@ sal_Bool SvIdlDataBase::ReadIdFile( const String & rFileName )
aIdFileList.push_back( new String( rFileName ) );
+ this->AddDepFile(aFullName.GetFull());
SvTokenStream aTokStm( aFullName.GetFull() );
if( aTokStm.GetStream().GetError() == SVSTREAM_OK )
{
@@ -643,6 +644,7 @@ sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported
DirEntry aFullName( String::CreateFromAscii( pTok->GetString().GetBuffer() ) );
if( aFullName.Find( rPath ) )
{
+ this->AddDepFile(aFullName.GetFull());
SvFileStream aStm( aFullName.GetFull(),
STREAM_STD_READ | STREAM_NOCREATE );
Load( aStm );
@@ -830,7 +832,32 @@ sal_Bool SvIdlWorkingBase::WriteDocumentation( SvStream & rOutStm )
return sal_True;
}
+void SvIdlDataBase::AddDepFile(String const& rFileName)
+{
+ m_DepFiles.insert(rFileName);
+}
+
+struct WriteDep
+{
+ SvFileStream & m_rStream;
+ explicit WriteDep(SvFileStream & rStream) : m_rStream(rStream) { }
+ void operator() (::rtl::OUString const& rItem)
+ {
+ m_rStream << " \\\n ";
+ m_rStream <<
+ ::rtl::OUStringToOString(rItem, RTL_TEXTENCODING_UTF8).getStr();
+ }
+};
+bool SvIdlDataBase::WriteDepFile(
+ SvFileStream & rStream, ::rtl::OUString const& rTarget)
+{
+ rStream <<
+ ::rtl::OUStringToOString(rTarget, RTL_TEXTENCODING_UTF8).getStr();
+ rStream << " : ";
+ ::std::for_each(m_DepFiles.begin(), m_DepFiles.end(), WriteDep(rStream));
+ return rStream.GetError() == SVSTREAM_OK;
+}
#endif // IDL_COMPILER
diff --git a/idl/source/prj/svidl.cxx b/idl/source/prj/svidl.cxx
index 0c7a66e7aa70..80751619ed5c 100644
--- a/idl/source/prj/svidl.cxx
+++ b/idl/source/prj/svidl.cxx
@@ -109,6 +109,7 @@ int cdecl main ( int argc, char ** argv)
String aTmpHelpIdFile;
String aTmpCSVFile;
String aTmpDocuFile;
+ String aTmpDepFile;
SvCommand aCommand( argc, argv );
@@ -226,6 +227,21 @@ int cdecl main ( int argc, char ** argv)
fprintf( stderr, "%s\n", aStr.GetBuffer() );
}
}
+ if (nExit == 0 && aCommand.m_DepFile.getLength())
+ {
+ DirEntry aDE(aCommand.m_DepFile);
+ aDE.ToAbs();
+ aTmpDepFile = aDE.GetPath().TempName().GetFull();
+ SvFileStream aOutStm( aTmpDepFile, STREAM_READWRITE | STREAM_TRUNC );
+ pDataBase->WriteDepFile(aOutStm, aCommand.aTargetFile);
+ if( aOutStm.GetError() != SVSTREAM_OK )
+ {
+ nExit = -1;
+ fprintf( stderr, "cannot write dependency file: %s\n",
+ ::rtl::OUStringToOString( aCommand.m_DepFile,
+ RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+ }
}
else
nExit = -1;
@@ -315,6 +331,14 @@ int cdecl main ( int argc, char ** argv)
aErrFile2 = aTmpDocuFile;
}
}
+ if (!bErr && aCommand.m_DepFile.getLength())
+ {
+ bErr |= !FileMove_Impl( aCommand.m_DepFile, aTmpDepFile, bDoMove );
+ if (bErr) {
+ aErrFile = aCommand.m_DepFile;
+ aErrFile2 = aTmpDepFile;
+ }
+ }
if( bErr )
{