1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prj.cxx,v $
10 * $Revision: 1.29.40.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_tools.hxx"
35 #include "bootstrp/sstring.hxx"
36 #include <vos/mutex.hxx>
38 #include <tools/stream.hxx>
39 #include <tools/geninfo.hxx>
40 #include "bootstrp/prj.hxx"
41 #include "bootstrp/inimgr.hxx"
45 #if defined(WNT) || defined(OS2)
46 #define LIST_DELIMETER ';'
47 #define PATH_DELIMETER '\\'
49 #define LIST_DELIMETER ':'
50 #define PATH_DELIMETER '/'
53 Link
Star::aDBNotFoundHdl
;
59 /*****************************************************************************/
60 SimpleConfig::SimpleConfig( String aSimpleConfigFileName
)
61 /*****************************************************************************/
64 aFileName
= aSimpleConfigFileName
;
65 aFileStream
.Open ( aFileName
, STREAM_READ
);
68 /*****************************************************************************/
69 SimpleConfig::SimpleConfig( DirEntry
& rDirEntry
)
70 /*****************************************************************************/
73 aFileName
= rDirEntry
.GetFull();
74 aFileStream
.Open ( aFileName
, STREAM_READ
);
77 /*****************************************************************************/
78 SimpleConfig::~SimpleConfig()
79 /*****************************************************************************/
84 /*****************************************************************************/
85 ByteString
SimpleConfig::GetNext()
86 /*****************************************************************************/
90 if ( aStringBuffer
=="" )
91 while ((aStringBuffer
= GetNextLine()) == "\t") ; //solange bis != "\t"
92 if ( aStringBuffer
=="" )
95 aString
= aStringBuffer
.GetToken(0,'\t');
96 aStringBuffer
.Erase(0, aString
.Len()+1);
98 aStringBuffer
.EraseLeadingChars( '\t' );
103 /*****************************************************************************/
104 ByteString
SimpleConfig::GetNextLine()
105 /*****************************************************************************/
110 aFileStream
.ReadLine ( aTmpStr
);
111 if ( aTmpStr
.Search( "#" ) == 0 )
113 aTmpStr
= aTmpStr
.EraseLeadingChars();
114 aTmpStr
= aTmpStr
.EraseTrailingChars();
115 while ( aTmpStr
.SearchAndReplace(ByteString(' '),ByteString('\t') ) != STRING_NOTFOUND
) ;
116 int nLength
= aTmpStr
.Len();
118 ByteString aEraseString
;
119 for ( USHORT i
= 0; i
<= nLength
; i
++)
121 if ( aTmpStr
.GetChar( i
) == 0x20 && !bFound
)
122 aTmpStr
.SetChar( i
, 0x09 );
127 /*****************************************************************************/
128 ByteString
SimpleConfig::GetCleanedNextLine( BOOL bReadComments
)
129 /*****************************************************************************/
132 aFileStream
.ReadLine ( aTmpStr
);
133 if ( aTmpStr
.Search( "#" ) == 0 )
138 while ( aTmpStr
.Search( "#" ) == 0 )
140 aFileStream
.ReadLine ( aTmpStr
);
144 aTmpStr
= aTmpStr
.EraseLeadingChars();
145 aTmpStr
= aTmpStr
.EraseTrailingChars();
146 // while ( aTmpStr.SearchAndReplace(String(' '),String('\t') ) != (USHORT)-1 );
147 int nLength
= aTmpStr
.Len();
148 ByteString aEraseString
;
149 BOOL bFirstTab
= TRUE
;
150 for ( USHORT i
= 0; i
<= nLength
; i
++)
152 if ( aTmpStr
.GetChar( i
) == 0x20 )
153 aTmpStr
.SetChar( i
, 0x09 );
155 if ( aTmpStr
.GetChar( i
) == 0x09 )
161 aTmpStr
.SetChar( i
, 0x20 );
168 aTmpStr
.EraseAllChars(' ');
178 /*****************************************************************************/
179 CommandData::CommandData()
180 /*****************************************************************************/
187 /*****************************************************************************/
188 CommandData::~CommandData()
189 /*****************************************************************************/
193 ByteString
*pString
= pDepList
->First();
197 pString
= pDepList
->Next();
205 /*****************************************************************************/
206 ByteString
CommandData::GetOSTypeString()
207 /*****************************************************************************/
213 case OS_WIN16
| OS_WIN32
| OS_OS2
| OS_UNX
:
216 case OS_WIN32
| OS_WIN16
:
238 /*****************************************************************************/
239 ByteString
CommandData::GetCommandTypeString()
240 /*****************************************************************************/
254 aRetStr
+= ByteString::CreateFromInt64( nCommand
+ 1 - COMMAND_USER_START
);
261 /*****************************************************************************/
262 CommandData
* Prj::GetDirectoryList ( USHORT
, USHORT
)
263 /*****************************************************************************/
265 return (CommandData
*)NULL
;
268 /*****************************************************************************/
269 CommandData
* Prj::GetDirectoryData( ByteString aLogFileName
)
270 /*****************************************************************************/
272 CommandData
*pData
= NULL
;
273 ULONG nObjCount
= Count();
274 for ( ULONG i
=0; i
<nObjCount
; i
++ )
276 pData
= GetObject(i
);
277 if ( pData
->GetLogFile() == aLogFileName
)
287 /*****************************************************************************/
290 pPrjInitialDepList(0),
292 bHardDependencies( FALSE
),
294 /*****************************************************************************/
298 /*****************************************************************************/
299 Prj::Prj( ByteString aName
) :
301 aProjectName( aName
),
302 pPrjInitialDepList(0),
304 bHardDependencies( FALSE
),
306 /*****************************************************************************/
310 /*****************************************************************************/
312 /*****************************************************************************/
316 ByteString
*pString
= pPrjDepList
->First();
320 pString
= pPrjDepList
->Next();
327 if ( pPrjInitialDepList
)
329 ByteString
*pString
= pPrjInitialDepList
->First();
333 pString
= pPrjInitialDepList
->Next();
335 delete pPrjInitialDepList
;
337 pPrjInitialDepList
= NULL
;
341 /*****************************************************************************/
342 void Prj::AddDependencies( ByteString aStr
)
343 /*****************************************************************************/
346 // needs dirty flag - not expanded
348 pPrjDepList
= new SByteStringList
;
350 pPrjDepList
->PutString( new ByteString(aStr
) );
352 if ( !pPrjInitialDepList
)
353 pPrjInitialDepList
= new SByteStringList
;
355 pPrjInitialDepList
->PutString( new ByteString(aStr
) );
358 /*****************************************************************************/
359 SByteStringList
* Prj::GetDependencies( BOOL bExpanded
)
360 /*****************************************************************************/
365 return pPrjInitialDepList
;
370 /*****************************************************************************/
371 BOOL
Prj::InsertDirectory ( ByteString aDirName
, USHORT aWhat
,
372 USHORT aWhatOS
, ByteString aLogFileName
,
373 const ByteString
&rClientRestriction
)
374 /*****************************************************************************/
376 CommandData
* pData
= new CommandData();
378 pData
->SetPath( aDirName
);
379 pData
->SetCommandType( aWhat
);
380 pData
->SetOSType( aWhatOS
);
381 pData
->SetLogFile( aLogFileName
);
382 pData
->SetClientRestriction( rClientRestriction
);
389 /*****************************************************************************/
391 // removes directory and existing dependencies on it
393 CommandData
* Prj::RemoveDirectory ( ByteString aLogFileName
)
394 /*****************************************************************************/
396 ULONG nCountMember
= Count();
398 CommandData
* pDataFound
= NULL
;
399 SByteStringList
* pDataDeps
;
401 for ( USHORT i
= 0; i
< nCountMember
; i
++ )
403 pData
= GetObject( i
);
404 if ( pData
->GetLogFile() == aLogFileName
)
408 pDataDeps
= pData
->GetDependencies();
412 ULONG nDataDepsCount
= pDataDeps
->Count();
413 for ( ULONG j
= nDataDepsCount
; j
> 0; j
-- )
415 pString
= pDataDeps
->GetObject( j
- 1 );
416 if ( pString
->GetToken( 0, '.') == aLogFileName
)
417 pDataDeps
->Remove( pString
);
423 Remove( pDataFound
);
432 /*****************************************************************************/
434 /*****************************************************************************/
436 // this ctor is only used by StarWriter
439 /*****************************************************************************/
440 Star::Star(String aFileName
, USHORT nMode
)
441 /*****************************************************************************/
447 /*****************************************************************************/
448 Star::Star( SolarFileList
*pSolarFiles
)
449 /*****************************************************************************/
450 : nStarMode( STAR_MODE_MULTIPLE_PARSE
)
452 // this ctor is used by StarBuilder to get the information for the whole workspace
456 /*****************************************************************************/
457 Star::Star( GenericInformationList
*pStandLst
, ByteString
&rVersion
,
458 BOOL bLocal
, const char *pSourceRoot
)
459 /*****************************************************************************/
461 ByteString
sPath( rVersion
);
464 sSrcRoot
= String::CreateFromAscii( pSourceRoot
);
467 sPath
+= "/settings/UNXSOLARLIST";
469 sPath
+= "/settings/SOLARLIST";
471 GenericInformation
*pInfo
= pStandLst
->GetInfo( sPath
, TRUE
);
473 if( pInfo
&& pInfo
->GetValue().Len()) {
474 ByteString
sFile( pInfo
->GetValue());
476 IniManager aIniManager
;
477 aIniManager
.ToLocal( sFile
);
479 String
sFileName( sFile
, RTL_TEXTENCODING_ASCII_US
);
480 nStarMode
= STAR_MODE_SINGLE_PARSE
;
484 SolarFileList
*pFileList
= new SolarFileList();
489 GenericInformation
*pInfo2
= pStandLst
->GetInfo( sPath
, TRUE
);
490 if ( pInfo2
&& pInfo2
->GetSubList()) {
491 GenericInformationList
*pDrives
= pInfo2
->GetSubList();
492 for ( ULONG i
= 0; i
< pDrives
->Count(); i
++ ) {
493 GenericInformation
*pDrive
= pDrives
->GetObject( i
);
497 if ( sSrcRoot
.Len()) {
498 aEntry
= DirEntry( sSrcRoot
);
503 sPath
= "UnixVolume";
504 GenericInformation
*pUnixVolume
= pDrive
->GetSubInfo( sPath
);
506 String
sRoot( pUnixVolume
->GetValue(), RTL_TEXTENCODING_ASCII_US
);
507 aEntry
= DirEntry( sRoot
);
512 String
sRoot( *pDrive
, RTL_TEXTENCODING_ASCII_US
);
513 sRoot
+= String::CreateFromAscii( "\\" );
514 aEntry
= DirEntry( sRoot
);
519 GenericInformation
*pProjectsKey
= pDrive
->GetSubInfo( sPath
, TRUE
);
520 if ( pProjectsKey
) {
521 if ( !sSrcRoot
.Len()) {
523 sPath
+= "/settings/PATH";
524 GenericInformation
*pPath
= pStandLst
->GetInfo( sPath
, TRUE
);
526 ByteString
sAddPath( pPath
->GetValue());
528 sAddPath
.SearchAndReplaceAll( "\\", "/" );
530 sAddPath
.SearchAndReplaceAll( "/", "\\" );
532 String
ssAddPath( sAddPath
, RTL_TEXTENCODING_ASCII_US
);
533 aEntry
+= DirEntry( ssAddPath
);
536 GenericInformationList
*pProjects
= pProjectsKey
->GetSubList();
538 String
sPrjDir( String::CreateFromAscii( "prj" ));
539 String
sSolarFile( String::CreateFromAscii( "build.lst" ));
541 for ( ULONG j
= 0; j
< pProjects
->Count(); j
++ ) {
542 ByteString
sProject( *pProjects
->GetObject( j
));
543 String
ssProject( sProject
, RTL_TEXTENCODING_ASCII_US
);
545 DirEntry
aPrjEntry( aEntry
);
547 aPrjEntry
+= DirEntry( ssProject
);
548 aPrjEntry
+= DirEntry( sPrjDir
);
549 aPrjEntry
+= DirEntry( sSolarFile
);
551 pFileList
->Insert( new String( aPrjEntry
.GetFull()), LIST_APPEND
);
553 ByteString
sFile( aPrjEntry
.GetFull(), RTL_TEXTENCODING_ASCII_US
);
565 /*****************************************************************************/
567 /*****************************************************************************/
571 /*****************************************************************************/
572 BOOL
Star::NeedsUpdate()
573 /*****************************************************************************/
576 for ( ULONG i
= 0; i
< aLoadedFilesList
.Count(); i
++ )
577 if ( aLoadedFilesList
.GetObject( i
)->NeedsUpdate()) {
586 /*****************************************************************************/
587 void Star::Read( String
&rFileName
)
588 /*****************************************************************************/
591 aFileList
.Insert( new String( rFileName
));
593 DirEntry
aEntry( rFileName
);
595 aEntry
= aEntry
.GetPath().GetPath().GetPath();
596 sSourceRoot
= aEntry
.GetFull();
598 while( aFileList
.Count()) {
599 StarFile
*pFile
= new StarFile( *aFileList
.GetObject(( ULONG
) 0 ));
600 if ( pFile
->Exists()) {
601 SimpleConfig
aSolarConfig( *aFileList
.GetObject(( ULONG
) 0 ));
602 while (( aString
= aSolarConfig
.GetNext()) != "" )
603 InsertToken (( char * ) aString
.GetBuffer());
606 aLoadedFilesList
.Insert( pFile
, LIST_APPEND
);
608 aFileList
.Remove(( ULONG
) 0 );
610 // resolve all dependencies recursive
614 /*****************************************************************************/
615 void Star::Read( SolarFileList
*pSolarFiles
)
616 /*****************************************************************************/
618 while( pSolarFiles
->Count()) {
621 StarFile
*pFile
= new StarFile( *pSolarFiles
->GetObject(( ULONG
) 0 ));
622 if ( pFile
->Exists()) {
623 SimpleConfig
aSolarConfig( *pSolarFiles
->GetObject(( ULONG
) 0 ));
624 while (( aString
= aSolarConfig
.GetNext()) != "" )
625 InsertToken (( char * ) aString
.GetBuffer());
629 aLoadedFilesList
.Insert( pFile
, LIST_APPEND
);
631 delete pSolarFiles
->Remove(( ULONG
) 0 );
638 /*****************************************************************************/
639 String
Star::CreateFileName( String sProject
)
640 /*****************************************************************************/
642 // this method is used to find solarlist parts of nabours (other projects)
643 String
sPrjDir( String::CreateFromAscii( "prj" ));
644 String
sSolarFile( String::CreateFromAscii( "build.lst" ));
646 DirEntry
aEntry( sSourceRoot
);
647 aEntry
+= DirEntry( sProject
);
648 aEntry
+= DirEntry( sPrjDir
);
649 aEntry
+= DirEntry( sSolarFile
);
651 if ( !aEntry
.Exists() && aDBNotFoundHdl
.IsSet())
652 aDBNotFoundHdl
.Call( &sProject
);
654 return aEntry
.GetFull();
657 /*****************************************************************************/
658 void Star::InsertSolarList( String sProject
)
659 /*****************************************************************************/
661 // inserts a new solarlist part of another project
662 String
sFileName( CreateFileName( sProject
));
664 for ( ULONG i
= 0; i
< aFileList
.Count(); i
++ ) {
665 if (( *aFileList
.GetObject( i
)) == sFileName
)
669 ByteString
ssProject( sProject
, RTL_TEXTENCODING_ASCII_US
);
670 if ( HasProject( ssProject
))
673 aFileList
.Insert( new String( sFileName
), LIST_APPEND
);
676 /*****************************************************************************/
677 void Star::ExpandPrj_Impl( Prj
*pPrj
, Prj
*pDepPrj
)
678 /*****************************************************************************/
680 if ( pDepPrj
->bVisited
)
683 pDepPrj
->bVisited
= TRUE
;
685 SByteStringList
* pPrjLst
= pPrj
->GetDependencies();
686 SByteStringList
* pDepLst
= NULL
;
689 Prj
*pNextPrj
= NULL
;
693 pDepLst
= pDepPrj
->GetDependencies();
695 for ( i
= 0; i
< pDepLst
->Count(); i
++ ) {
696 pDepend
= pDepLst
->GetObject( i
);
697 pPutStr
= new ByteString( *pDepend
);
698 nRetPos
= pPrjLst
->PutString( pPutStr
);
699 if( nRetPos
== NOT_THERE
)
701 pNextPrj
= GetPrj( *pDepend
);
703 ExpandPrj_Impl( pPrj
, pNextPrj
);
710 /*****************************************************************************/
711 void Star::Expand_Impl()
712 /*****************************************************************************/
714 for ( ULONG i
= 0; i
< Count(); i
++ ) {
715 for ( ULONG j
= 0; j
< Count(); j
++ )
716 GetObject( j
)->bVisited
= FALSE
;
718 Prj
* pPrj
= GetObject( i
);
719 ExpandPrj_Impl( pPrj
, pPrj
);
723 /*****************************************************************************/
724 void Star::InsertToken ( char *yytext
)
725 /*****************************************************************************/
728 static ByteString aDirName
, aWhat
, aWhatOS
,
729 sClientRestriction
, aLogFileName
, aProjectName
, aPrefix
, aCommandPara
;
730 static BOOL bPrjDep
= FALSE
;
731 static BOOL bHardDep
= FALSE
;
732 static USHORT nCommandType
, nOSType
;
733 CommandData
* pCmdData
;
734 static SByteStringList
*pStaticDepList
;
747 if ( !strcmp( yytext
, ":" ))
753 else if ( !strcmp( yytext
, "::" ))
765 if ( aWhat
== "nmake" )
766 nCommandType
= COMMAND_NMAKE
;
767 else if ( aWhat
== "get" )
768 nCommandType
= COMMAND_GET
;
770 ULONG nOffset
= aWhat
.Copy( 3 ).ToInt32();
771 nCommandType
= sal::static_int_cast
< USHORT
>(
772 COMMAND_USER_START
+ nOffset
- 1);
782 aCommandPara
= ByteString();
785 aCommandPara
= aWhat
;
792 if ( aWhatOS
.GetTokenCount( ',' ) > 1 ) {
793 sClientRestriction
= aWhatOS
.Copy( aWhatOS
.GetToken( 0, ',' ).Len() + 1 );
794 aWhatOS
= aWhatOS
.GetToken( 0, ',' );
796 if ( aWhatOS
== "all" )
797 nOSType
= ( OS_WIN16
| OS_WIN32
| OS_OS2
| OS_UNX
);
798 else if ( aWhatOS
== "w" )
799 nOSType
= ( OS_WIN16
| OS_WIN32
);
800 else if ( aWhatOS
== "p" )
802 else if ( aWhatOS
== "u" )
804 else if ( aWhatOS
== "d" )
806 else if ( aWhatOS
== "n" )
815 aLogFileName
= yytext
;
821 ByteString aItem
= yytext
;
822 if ( aItem
== "NULL" )
829 // ggfs. Dependency liste anlegen und ergaenzen
830 if ( !pStaticDepList
)
831 pStaticDepList
= new SByteStringList
;
832 pStaticDepList
->PutString( new ByteString( aItem
));
837 ByteString aItem
= yytext
;
838 if ( aItem
== "NULL" )
846 aProjectName
= aDirName
.GetToken ( 0, '\\');
847 if ( HasProject( aProjectName
))
849 pPrj
= GetPrj( aProjectName
);
850 // Projekt exist. schon, neue Eintraege anhaengen
854 // neues Project anlegen
855 pPrj
= new Prj ( aProjectName
);
856 pPrj
->SetPreFix( aPrefix
);
857 Insert(pPrj
,LIST_APPEND
);
859 pPrj
->AddDependencies( aItem
);
860 pPrj
->HasHardDependencies( bHardDep
);
862 if ( nStarMode
== STAR_MODE_RECURSIVE_PARSE
) {
863 String
sItem( aItem
, RTL_TEXTENCODING_ASCII_US
);
864 InsertSolarList( sItem
);
870 /* Wenn dieses Project noch nicht vertreten ist, in die Liste
871 der Solar-Projekte einfuegen */
874 aProjectName
= aDirName
.GetToken ( 0, '\\');
875 if ( HasProject( aProjectName
))
877 pPrj
= GetPrj( aProjectName
);
878 // Projekt exist. schon, neue Eintraege anhaengen
882 // neues Project anlegen
883 pPrj
= new Prj ( aProjectName
);
884 pPrj
->SetPreFix( aPrefix
);
885 Insert(pPrj
,LIST_APPEND
);
888 pCmdData
= new CommandData
;
889 pCmdData
->SetPath( aDirName
);
890 pCmdData
->SetCommandType( nCommandType
);
891 pCmdData
->SetCommandPara( aCommandPara
);
892 pCmdData
->SetOSType( nOSType
);
893 pCmdData
->SetLogFile( aLogFileName
);
894 pCmdData
->SetClientRestriction( sClientRestriction
);
895 if ( pStaticDepList
)
896 pCmdData
->SetDependencies( pStaticDepList
);
899 pPrj
->Insert ( pCmdData
, LIST_APPEND
);
903 sClientRestriction
= "";
910 // und wer raeumt die depLst wieder ab ?
913 /*****************************************************************************/
914 BOOL
Star::HasProject ( ByteString aProjectName
)
915 /*****************************************************************************/
920 nCountMember
= Count();
922 for ( int i
=0; i
<nCountMember
; i
++)
925 if ( pPrj
->GetProjectName().EqualsIgnoreCaseAscii(aProjectName
) )
931 /*****************************************************************************/
932 Prj
* Star::GetPrj ( ByteString aProjectName
)
933 /*****************************************************************************/
936 int nCountMember
= Count();
937 for ( int i
=0;i
<nCountMember
;i
++)
940 if ( pPrj
->GetProjectName().EqualsIgnoreCaseAscii(aProjectName
) )
943 // return (Prj*)NULL;
947 /*****************************************************************************/
948 ByteString
Star::GetPrjName( DirEntry
&aPath
)
949 /*****************************************************************************/
951 ByteString aRetPrj
, aDirName
;
952 ByteString aFullPathName
= ByteString( aPath
.GetFull(), gsl_getSystemTextEncoding());
954 xub_StrLen nToken
= aFullPathName
.GetTokenCount(PATH_DELIMETER
);
955 for ( xub_StrLen i
=0; i
< nToken
; i
++ )
957 aDirName
= aFullPathName
.GetToken( i
, PATH_DELIMETER
);
958 if ( HasProject( aDirName
))
973 /*****************************************************************************/
974 StarWriter::StarWriter( String aFileName
, BOOL bReadComments
, USHORT nMode
)
975 /*****************************************************************************/
977 Read ( aFileName
, bReadComments
, nMode
);
980 /*****************************************************************************/
981 StarWriter::StarWriter( SolarFileList
*pSolarFiles
, BOOL bReadComments
)
982 /*****************************************************************************/
984 Read( pSolarFiles
, bReadComments
);
987 /*****************************************************************************/
988 StarWriter::StarWriter( GenericInformationList
*pStandLst
, ByteString
&rVersion
,
989 BOOL bLocal
, const char *pSourceRoot
)
990 /*****************************************************************************/
992 ByteString
sPath( rVersion
);
995 sSrcRoot
= String::CreateFromAscii( pSourceRoot
);
998 sPath
+= "/settings/UNXSOLARLIST";
1000 sPath
+= "/settings/SOLARLIST";
1002 GenericInformation
*pInfo
= pStandLst
->GetInfo( sPath
, TRUE
);
1004 if( pInfo
&& pInfo
->GetValue().Len()) {
1005 ByteString
sFile( pInfo
->GetValue());
1007 IniManager aIniManager
;
1008 aIniManager
.ToLocal( sFile
);
1010 String
sFileName( sFile
, RTL_TEXTENCODING_ASCII_US
);
1011 nStarMode
= STAR_MODE_SINGLE_PARSE
;
1015 SolarFileList
*pFileList
= new SolarFileList();
1020 GenericInformation
*pInfo2
= pStandLst
->GetInfo( sPath
, TRUE
);
1021 if ( pInfo2
&& pInfo2
->GetSubList()) {
1022 GenericInformationList
*pDrives
= pInfo2
->GetSubList();
1023 for ( ULONG i
= 0; i
< pDrives
->Count(); i
++ ) {
1024 GenericInformation
*pDrive
= pDrives
->GetObject( i
);
1028 if ( sSrcRoot
.Len()) {
1029 aEntry
= DirEntry( sSrcRoot
);
1034 sPath
= "UnixVolume";
1035 GenericInformation
*pUnixVolume
= pDrive
->GetSubInfo( sPath
);
1036 if ( pUnixVolume
) {
1037 String
sRoot( pUnixVolume
->GetValue(), RTL_TEXTENCODING_ASCII_US
);
1038 aEntry
= DirEntry( sRoot
);
1043 String
sRoot( *pDrive
, RTL_TEXTENCODING_ASCII_US
);
1044 sRoot
+= String::CreateFromAscii( "\\" );
1045 aEntry
= DirEntry( sRoot
);
1050 GenericInformation
*pProjectsKey
= pDrive
->GetSubInfo( sPath
, TRUE
);
1051 if ( pProjectsKey
) {
1052 if ( !sSrcRoot
.Len()) {
1054 sPath
+= "/settings/PATH";
1055 GenericInformation
*pPath
= pStandLst
->GetInfo( sPath
, TRUE
);
1057 ByteString
sAddPath( pPath
->GetValue());
1059 sAddPath
.SearchAndReplaceAll( "\\", "/" );
1061 sAddPath
.SearchAndReplaceAll( "/", "\\" );
1063 String
ssAddPath( sAddPath
, RTL_TEXTENCODING_ASCII_US
);
1064 aEntry
+= DirEntry( ssAddPath
);
1067 GenericInformationList
*pProjects
= pProjectsKey
->GetSubList();
1069 String
sPrjDir( String::CreateFromAscii( "prj" ));
1070 String
sSolarFile( String::CreateFromAscii( "build.lst" ));
1072 for ( ULONG j
= 0; j
< pProjects
->Count(); j
++ ) {
1073 ByteString
sProject( *pProjects
->GetObject( j
));
1074 String
ssProject( sProject
, RTL_TEXTENCODING_ASCII_US
);
1076 DirEntry
aPrjEntry( aEntry
);
1078 aPrjEntry
+= DirEntry( ssProject
);
1079 aPrjEntry
+= DirEntry( sPrjDir
);
1080 aPrjEntry
+= DirEntry( sSolarFile
);
1082 pFileList
->Insert( new String( aPrjEntry
.GetFull()), LIST_APPEND
);
1084 ByteString
sFile( aPrjEntry
.GetFull(), RTL_TEXTENCODING_ASCII_US
);
1085 fprintf( stdout
, "%s\n", sFile
.GetBuffer());
1097 /*****************************************************************************/
1098 void StarWriter::CleanUp()
1099 /*****************************************************************************/
1104 /*****************************************************************************/
1105 USHORT
StarWriter::Read( String aFileName
, BOOL bReadComments
, USHORT nMode
)
1106 /*****************************************************************************/
1111 aFileList
.Insert( new String( aFileName
));
1113 DirEntry
aEntry( aFileName
);
1115 aEntry
= aEntry
.GetPath().GetPath().GetPath();
1116 sSourceRoot
= aEntry
.GetFull();
1118 while( aFileList
.Count()) {
1120 StarFile
*pFile
= new StarFile( *aFileList
.GetObject(( ULONG
) 0 ));
1121 if ( pFile
->Exists()) {
1122 SimpleConfig
aSolarConfig( *aFileList
.GetObject(( ULONG
) 0 ));
1123 while (( aString
= aSolarConfig
.GetCleanedNextLine( bReadComments
)) != "" )
1124 InsertTokenLine ( aString
);
1128 aLoadedFilesList
.Insert( pFile
, LIST_APPEND
);
1130 delete aFileList
.Remove(( ULONG
) 0 );
1132 // resolve all dependencies recursive
1135 // Die gefundenen Abhaengigkeiten rekursiv aufloesen
1140 /*****************************************************************************/
1141 USHORT
StarWriter::Read( SolarFileList
*pSolarFiles
, BOOL bReadComments
)
1142 /*****************************************************************************/
1144 nStarMode
= STAR_MODE_MULTIPLE_PARSE
;
1146 // this ctor is used by StarBuilder to get the information for the whole workspace
1147 while( pSolarFiles
->Count()) {
1150 StarFile
*pFile
= new StarFile( *pSolarFiles
->GetObject(( ULONG
) 0 ));
1151 if ( pFile
->Exists()) {
1152 SimpleConfig
aSolarConfig( *pSolarFiles
->GetObject(( ULONG
) 0 ));
1153 while (( aString
= aSolarConfig
.GetCleanedNextLine( bReadComments
)) != "" )
1154 InsertTokenLine ( aString
);
1158 aLoadedFilesList
.Insert( pFile
, LIST_APPEND
);
1160 delete pSolarFiles
->Remove(( ULONG
) 0 );
1168 /*****************************************************************************/
1169 USHORT
StarWriter::WritePrj( Prj
*pPrj
, SvFileStream
& rStream
)
1170 /*****************************************************************************/
1172 ByteString aDataString
;
1173 ByteString
aTab('\t');
1174 ByteString
aSpace(' ');
1175 ByteString
aEmptyString("");
1176 SByteStringList
* pCmdDepList
;
1178 CommandData
* pCmdData
= NULL
;
1179 if ( pPrj
->Count() > 0 )
1181 pCmdData
= pPrj
->First();
1182 SByteStringList
* pPrjDepList
= pPrj
->GetDependencies( FALSE
);
1183 if ( pPrjDepList
!= 0 )
1185 aDataString
= pPrj
->GetPreFix();
1186 aDataString
+= aTab
;
1187 aDataString
+= pPrj
->GetProjectName();
1188 aDataString
+= aTab
;
1189 if ( pPrj
->HasHardDependencies())
1190 aDataString
+= ByteString("::");
1192 aDataString
+= ByteString(":");
1193 aDataString
+= aTab
;
1194 for ( USHORT i
= 0; i
< pPrjDepList
->Count(); i
++ ) {
1195 aDataString
+= *pPrjDepList
->GetObject( i
);
1196 aDataString
+= aSpace
;
1198 aDataString
+= "NULL";
1200 rStream
.WriteLine( aDataString
);
1202 pCmdData
= pPrj
->Next();
1207 if (( aDataString
= pCmdData
->GetComment()) == aEmptyString
)
1209 aDataString
= pPrj
->GetPreFix();
1210 aDataString
+= aTab
;
1212 aDataString
+= pCmdData
->GetPath();
1213 aDataString
+= aTab
;
1214 USHORT nPathLen
= pCmdData
->GetPath().Len();
1215 if ( nPathLen
< 40 )
1216 for ( int i
= 0; i
< 9 - pCmdData
->GetPath().Len() / 4 ; i
++ )
1217 aDataString
+= aTab
;
1219 for ( int i
= 0; i
< 12 - pCmdData
->GetPath().Len() / 4 ; i
++ )
1220 aDataString
+= aTab
;
1221 aDataString
+= pCmdData
->GetCommandTypeString();
1222 aDataString
+= aTab
;
1223 if ( pCmdData
->GetCommandType() == COMMAND_GET
)
1224 aDataString
+= aTab
;
1225 if ( pCmdData
->GetCommandPara() == aEmptyString
)
1226 aDataString
+= ByteString("-");
1228 aDataString
+= pCmdData
->GetCommandPara();
1229 aDataString
+= aTab
;
1230 aDataString
+= pCmdData
->GetOSTypeString();
1231 if ( pCmdData
->GetClientRestriction().Len()) {
1232 aDataString
+= ByteString( "," );
1233 aDataString
+= pCmdData
->GetClientRestriction();
1235 aDataString
+= aTab
;
1236 aDataString
+= pCmdData
->GetLogFile();
1237 aDataString
+= aSpace
;
1239 pCmdDepList
= pCmdData
->GetDependencies();
1241 for ( USHORT i
= 0; i
< pCmdDepList
->Count(); i
++ ) {
1242 aDataString
+= *pCmdDepList
->GetObject( i
);
1243 aDataString
+= aSpace
;
1245 aDataString
+= "NULL";
1248 rStream
.WriteLine( aDataString
);
1250 pCmdData
= pPrj
->Next();
1251 } while ( pCmdData
);
1257 /*****************************************************************************/
1258 USHORT
StarWriter::Write( String aFileName
)
1259 /*****************************************************************************/
1261 SvFileStream aFileStream
;
1263 aFileStream
.Open( aFileName
, STREAM_WRITE
| STREAM_TRUNC
);
1267 Prj
* pPrj
= First();
1270 WritePrj( pPrj
, aFileStream
);
1275 aFileStream
.Close();
1280 /*****************************************************************************/
1281 USHORT
StarWriter::WriteMultiple( String rSourceRoot
)
1282 /*****************************************************************************/
1286 String
sPrjDir( String::CreateFromAscii( "prj" ));
1287 String
sSolarFile( String::CreateFromAscii( "build.lst" ));
1289 Prj
* pPrj
= First();
1292 String
sName( pPrj
->GetProjectName(), RTL_TEXTENCODING_ASCII_US
);
1294 DirEntry
aEntry( rSourceRoot
);
1295 aEntry
+= DirEntry( sName
);
1296 aEntry
+= DirEntry( sPrjDir
);
1297 aEntry
+= DirEntry( sSolarFile
);
1299 SvFileStream aFileStream
;
1300 aFileStream
.Open( aEntry
.GetFull(), STREAM_WRITE
| STREAM_TRUNC
);
1302 WritePrj( pPrj
, aFileStream
);
1304 aFileStream
.Close();
1313 /*****************************************************************************/
1314 void StarWriter::InsertTokenLine ( ByteString
& rString
)
1315 /*****************************************************************************/
1318 ByteString aWhat
, aWhatOS
,
1319 sClientRestriction
, aLogFileName
, aProjectName
, aPrefix
, aCommandPara
;
1320 static ByteString aDirName
;
1321 BOOL bPrjDep
= FALSE
;
1322 BOOL bHardDep
= FALSE
;
1323 USHORT nCommandType
= 0;
1325 CommandData
* pCmdData
;
1326 SByteStringList
*pDepList2
= NULL
;
1329 ByteString aEmptyString
;
1330 ByteString aToken
= rString
.GetToken( 0, '\t' );
1331 ByteString aCommentString
;
1333 const char* yytext
= aToken
.GetBuffer();
1335 while ( !( aToken
== aEmptyString
) )
1340 if ( rString
.Search( "#" ) == 0 )
1343 aCommentString
= rString
;
1344 rString
= aEmptyString
;
1346 aDirName
= "null_entry" ; //comments at begin of file
1356 if ( !strcmp( yytext
, ":" ))
1362 else if ( !strcmp( yytext
, "::" ))
1374 if ( aWhat
== "nmake" )
1375 nCommandType
= COMMAND_NMAKE
;
1376 else if ( aWhat
== "get" )
1377 nCommandType
= COMMAND_GET
;
1379 ULONG nOffset
= aWhat
.Copy( 3 ).ToInt32();
1380 nCommandType
= sal::static_int_cast
< USHORT
>(
1381 COMMAND_USER_START
+ nOffset
- 1);
1391 aCommandPara
= ByteString();
1394 aCommandPara
= aWhat
;
1401 if ( aWhatOS
.GetTokenCount( ',' ) > 1 ) {
1402 sClientRestriction
= aWhatOS
.Copy( aWhatOS
.GetToken( 0, ',' ).Len() + 1 );
1403 aWhatOS
= aWhatOS
.GetToken( 0, ',' );
1405 aWhatOS
= aWhatOS
.GetToken( 0, ',' );
1406 if ( aWhatOS
== "all" )
1407 nOSType
= ( OS_WIN16
| OS_WIN32
| OS_OS2
| OS_UNX
);
1408 else if ( aWhatOS
== "w" )
1409 nOSType
= ( OS_WIN16
| OS_WIN32
);
1410 else if ( aWhatOS
== "p" )
1412 else if ( aWhatOS
== "u" )
1414 else if ( aWhatOS
== "d" )
1416 else if ( aWhatOS
== "n" )
1425 aLogFileName
= yytext
;
1431 ByteString aItem
= yytext
;
1432 if ( aItem
== "NULL" )
1439 // ggfs. Dependency liste anlegen und ergaenzen
1441 pDepList2
= new SByteStringList
;
1442 pDepList2
->PutString( new ByteString( aItem
));
1447 ByteString aItem
= yytext
;
1448 if ( aItem
== "NULL" )
1456 aProjectName
= aDirName
.GetToken ( 0, '\\');
1457 if ( HasProject( aProjectName
))
1459 pPrj
= GetPrj( aProjectName
);
1460 // Projekt exist. schon, neue Eintraege anhaengen
1464 // neues Project anlegen
1465 pPrj
= new Prj ( aProjectName
);
1466 pPrj
->SetPreFix( aPrefix
);
1467 Insert(pPrj
,LIST_APPEND
);
1469 pPrj
->AddDependencies( aItem
);
1470 pPrj
->HasHardDependencies( bHardDep
);
1472 if ( nStarMode
== STAR_MODE_RECURSIVE_PARSE
) {
1473 String
sItem( aItem
, RTL_TEXTENCODING_ASCII_US
);
1474 InsertSolarList( sItem
);
1481 /* Wenn dieses Project noch nicht vertreten ist, in die Liste
1482 der Solar-Projekte einfuegen */
1485 aProjectName
= aDirName
.GetToken ( 0, '\\');
1486 if ( HasProject( aProjectName
))
1488 pPrj
= GetPrj( aProjectName
);
1489 // Projekt exist. schon, neue Eintraege anhaengen
1493 // neues Project anlegen
1494 pPrj
= new Prj ( aProjectName
);
1495 pPrj
->SetPreFix( aPrefix
);
1496 Insert(pPrj
,LIST_APPEND
);
1499 pCmdData
= new CommandData
;
1500 pCmdData
->SetPath( aDirName
);
1501 pCmdData
->SetCommandType( nCommandType
);
1502 pCmdData
->SetCommandPara( aCommandPara
);
1503 pCmdData
->SetOSType( nOSType
);
1504 pCmdData
->SetLogFile( aLogFileName
);
1505 pCmdData
->SetComment( aCommentString
);
1506 pCmdData
->SetClientRestriction( sClientRestriction
);
1508 pCmdData
->SetDependencies( pDepList2
);
1510 pPrj
->Insert ( pCmdData
, LIST_APPEND
);
1515 rString
.Erase(0, aToken
.Len()+1);
1516 aToken
= rString
.GetToken( 0, '\t' );
1517 yytext
= aToken
.GetBuffer();
1520 // und wer raeumt die depLst wieder ab ?
1523 /*****************************************************************************/
1524 BOOL
StarWriter::InsertProject ( Prj
* )
1525 /*****************************************************************************/
1530 /*****************************************************************************/
1531 Prj
* StarWriter::RemoveProject ( ByteString aProjectName
)
1532 /*****************************************************************************/
1534 ULONG nCountMember
= Count();
1536 Prj
* pPrjFound
= NULL
;
1537 SByteStringList
* pPrjDeps
;
1539 for ( USHORT i
= 0; i
< nCountMember
; i
++ )
1541 pPrj
= GetObject( i
);
1542 if ( pPrj
->GetProjectName() == aProjectName
)
1546 pPrjDeps
= pPrj
->GetDependencies( FALSE
);
1549 ByteString
* pString
;
1550 ULONG nPrjDepsCount
= pPrjDeps
->Count();
1551 for ( ULONG j
= nPrjDepsCount
; j
> 0; j
-- )
1553 pString
= pPrjDeps
->GetObject( j
- 1 );
1554 if ( pString
->GetToken( 0, '.') == aProjectName
)
1555 pPrjDeps
->Remove( pString
);
1561 Remove( pPrjFound
);
1570 /*****************************************************************************/
1571 StarFile::StarFile( const String
&rFile
)
1572 /*****************************************************************************/
1573 : aFileName( rFile
)
1575 DirEntry
aEntry( aFileName
);
1576 if ( aEntry
.Exists()) {
1578 FileStat
aStat( aEntry
);
1579 aDate
= aStat
.DateModified();
1580 aTime
= aStat
.TimeModified();
1586 /*****************************************************************************/
1587 BOOL
StarFile::NeedsUpdate()
1588 /*****************************************************************************/
1590 DirEntry
aEntry( aFileName
);
1591 if ( aEntry
.Exists()) {
1596 FileStat
aStat( aEntry
);
1597 if (( aStat
.DateModified() > aDate
) ||
1598 (( aStat
.DateModified() == aDate
) && ( aStat
.TimeModified() > aTime
)))