merge the formfield patch from ooo-build
[ooovba.git] / soldep / bootstrp / prj.cxx
blob822bc209b318d7a86c9409f0b37df93454125dad
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: prj.cxx,v $
10 * $Revision: 1.10 $
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 ************************************************************************/
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <bootstrp/sstring.hxx>
33 #include <vos/mutex.hxx>
35 #define ENABLE_BYTESTRING_STREAM_OPERATORS
36 #include <tools/stream.hxx>
37 #include <tools/geninfo.hxx>
38 #include <soldep/prj.hxx>
39 #include <bootstrp/inimgr.hxx>
40 #include <soldep/XmlBuildList.hxx>
41 #include "XmlBuildListDef.hxx"
43 #ifndef MACOSX
44 #pragma hdrstop
45 #endif
47 //#define TEST 1
49 #ifdef MAC
50 #define putenv(x)
51 #endif
53 #if defined(DOS) || defined(WNT) || defined(OS2)
54 #define LIST_DELIMETER ';'
55 #else
56 #ifdef UNX
57 #define LIST_DELIMETER ':'
58 #else
59 #ifdef MAC
60 #define LIST_DELIMETER ','
61 #endif
62 #endif
63 #endif
65 #if defined(DOS) || defined(WNT) || defined(OS2) || defined(WIN)
66 #define PATH_DELIMETER '\\'
67 #else
68 #ifdef UNX
69 #define PATH_DELIMETER '/'
70 #else
71 #ifdef MAC
72 #define PATH_DELIMETER ':'
73 #endif
74 #endif
75 #endif
77 static const char * XML_ALL = "all";
80 // class SimpleConfig
83 /*****************************************************************************/
84 SimpleConfig::SimpleConfig( String aSimpleConfigFileName )
85 /*****************************************************************************/
87 nLine = 0;
88 aFileName = aSimpleConfigFileName;
89 aFileStream.Open ( aFileName, STREAM_READ );
92 /*****************************************************************************/
93 SimpleConfig::SimpleConfig( DirEntry& rDirEntry )
94 /*****************************************************************************/
96 nLine = 0;
97 aFileName = rDirEntry.GetFull();
98 aFileStream.Open ( aFileName, STREAM_READ );
101 /*****************************************************************************/
102 SimpleConfig::~SimpleConfig()
103 /*****************************************************************************/
105 aFileStream.Close ();
108 /*****************************************************************************/
109 ByteString SimpleConfig::GetNext()
110 /*****************************************************************************/
112 ByteString aString;
114 if ( aStringBuffer =="" )
115 while ((aStringBuffer = GetNextLine()) == "\t"); //solange bis != "\t"
116 if ( aStringBuffer =="" )
117 return ByteString();
119 aString = aStringBuffer.GetToken(0,'\t');
120 aStringBuffer.Erase(0, aString.Len()+1);
122 aStringBuffer.EraseLeadingChars( '\t' );
124 return aString;
127 /*****************************************************************************/
128 ByteString SimpleConfig::GetNextLine()
129 /*****************************************************************************/
131 ByteString aSecStr;
132 sal_Bool bStreamOk;
133 // USHORT iret = 0;
134 nLine++;
136 bStreamOk = aFileStream.ReadLine ( aTmpStr );
137 if ( (aTmpStr.Search( "#" ) == 0) )
138 return "\t";
139 aTmpStr = aTmpStr.EraseLeadingChars();
140 aTmpStr = aTmpStr.EraseTrailingChars();
141 while ( aTmpStr.SearchAndReplace(ByteString(' '),ByteString('\t') ) != STRING_NOTFOUND );
142 int nLength = aTmpStr.Len();
143 if ( bStreamOk && (nLength == 0) )
144 return "\t";
145 // USHORT nPos = 0;
146 BOOL bFound = FALSE;
147 ByteString aEraseString;
148 for ( USHORT i = 0; i<= nLength; i++)
150 #ifdef MAC
151 if ( aTmpStr.GetChar( i ) == '"')
153 if ( bFound) bFound = FALSE;
154 else bFound = TRUE;
155 aTmpStr.SetChar( i, '\t' );
157 #endif
158 if ( aTmpStr.GetChar( i ) == 0x20 && !bFound )
159 aTmpStr.SetChar( i, 0x09 );
161 return aTmpStr;
164 /*****************************************************************************/
165 ByteString SimpleConfig::GetCleanedNextLine( BOOL bReadComments )
166 /*****************************************************************************/
169 aFileStream.ReadLine ( aTmpStr );
170 if ( aTmpStr.Search( "#" ) == 0 )
171 if (bReadComments )
172 return aTmpStr;
173 else
174 while ( aTmpStr.Search( "#" ) == 0 )
176 aFileStream.ReadLine ( aTmpStr );
179 aTmpStr = aTmpStr.EraseLeadingChars();
180 aTmpStr = aTmpStr.EraseTrailingChars();
181 // while ( aTmpStr.SearchAndReplace(String(' '),String('\t') ) != (USHORT)-1 );
182 int nLength = aTmpStr.Len();
183 // USHORT nPos = 0;
184 ByteString aEraseString;
185 BOOL bFirstTab = TRUE;
186 for ( USHORT i = 0; i<= nLength; i++)
188 if ( aTmpStr.GetChar( i ) == 0x20 )
189 aTmpStr.SetChar( i, 0x09 );
191 if ( aTmpStr.GetChar( i ) == 0x09 )
193 if ( bFirstTab )
194 bFirstTab = FALSE;
195 else
197 aTmpStr.SetChar( i, 0x20 );
200 else
201 bFirstTab = TRUE;
204 aTmpStr.EraseAllChars(' ');
205 return aTmpStr;
211 // class CommandData
214 /*****************************************************************************/
215 CommandData::CommandData()
216 /*****************************************************************************/
218 nOSType = 0;
219 nCommand = 0;
220 pDepList = 0;
223 /*****************************************************************************/
224 CommandData::~CommandData()
225 /*****************************************************************************/
227 if ( pDepList )
229 ByteString *pString = pDepList->First();
230 while ( pString )
232 delete pString;
233 pString = pDepList->Next();
235 delete pDepList;
237 pDepList = NULL;
241 /*****************************************************************************/
242 ByteString CommandData::GetOSTypeString()
243 /*****************************************************************************/
245 ByteString aRetStr;
247 switch (nOSType)
249 case OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX | OS_MAC :
250 aRetStr = "all";
251 break;
252 case OS_WIN32 | OS_WIN16 :
253 aRetStr = "w";
254 break;
255 case OS_OS2 :
256 aRetStr = "p";
257 break;
258 case OS_UNX :
259 aRetStr = "u";
260 break;
261 case OS_WIN16 :
262 aRetStr = "d";
263 break;
264 case OS_WIN32 :
265 aRetStr = "n";
266 break;
267 case OS_MAC :
268 aRetStr = "m";
269 break;
270 default :
271 aRetStr = "none";
274 return aRetStr;
277 /*****************************************************************************/
278 ByteString CommandData::GetCommandTypeString()
279 /*****************************************************************************/
281 ByteString aRetStr;
283 switch (nCommand)
285 case COMMAND_NMAKE :
286 aRetStr = "nmake";
287 break;
288 case COMMAND_GET :
289 aRetStr = "get";
290 break;
291 default :
292 aRetStr = "usr";
293 aRetStr += ByteString::CreateFromInt64( nCommand + 1 - COMMAND_USER_START );
297 return aRetStr;
300 /*****************************************************************************/
301 CommandData& CommandData::operator>> ( SvStream& rStream )
302 /*****************************************************************************/
304 rStream << aPrj;
305 rStream << aLogFileName;
306 rStream << aInpath;
307 rStream << aUpd;
308 rStream << aUpdMinor;
309 rStream << aProduct;
310 rStream << aCommand;
311 rStream << aPath;
312 rStream << aPrePath;
313 rStream << aPreFix;
314 rStream << aCommandPara;
315 rStream << aComment;
316 rStream << sClientRestriction;
318 rStream << nOSType;
319 rStream << nCommand;
320 rStream << nDepth;
322 if (pDepList)
324 rStream << sal_True;
325 *pDepList >> rStream;
327 else
328 rStream << sal_False;
330 return *this;
333 /*****************************************************************************/
334 CommandData& CommandData::operator<< ( SvStream& rStream )
335 /*****************************************************************************/
337 rStream >> aPrj;
338 rStream >> aLogFileName;
339 rStream >> aInpath;
340 rStream >> aUpd;
341 rStream >> aUpdMinor;
342 rStream >> aProduct;
343 rStream >> aCommand;
344 rStream >> aPath;
345 rStream >> aPrePath;
346 rStream >> aPreFix;
347 rStream >> aCommandPara;
348 rStream >> aComment;
349 rStream >> sClientRestriction;
351 rStream >> nOSType;
352 rStream >> nCommand;
353 rStream >> nDepth;
355 BOOL bDepList;
356 rStream >> bDepList;
357 if (pDepList)
358 pDepList->CleanUp();
359 if (bDepList)
361 if (!pDepList)
362 pDepList = new SByteStringList();
363 *pDepList << rStream;
365 else
366 DELETEZ (pDepList);
368 return *this;
374 // class DepInfo
377 /*****************************************************************************/
378 DepInfo::~DepInfo()
379 /*****************************************************************************/
381 RemoveProject();
383 if ( pModeList )
385 ByteString *pString = pModeList->First();
386 while ( pString )
388 delete pString;
389 pString = pModeList->Next();
391 delete pModeList;
393 pModeList = NULL;
397 /*****************************************************************************/
398 void DepInfo::SetProject (ByteString* pStr)
399 /*****************************************************************************/
401 RemoveProject();
402 pProject = pStr;
405 /*****************************************************************************/
406 void DepInfo::RemoveProject ()
407 /*****************************************************************************/
409 if (pProject)
411 delete pProject;
412 pProject = NULL;
416 /*****************************************************************************/
417 DepInfo& DepInfo::operator<< ( SvStream& rStream )
418 /*****************************************************************************/
420 RemoveProject();
421 pProject = new ByteString();
422 rStream >> *pProject;
424 BOOL bModeList;
425 rStream >> bModeList;
426 if (pModeList)
427 pModeList->CleanUp();
428 if (bModeList)
430 if (!pModeList)
431 pModeList = new SByteStringList();
432 *pModeList << rStream;
434 else
435 DELETEZ (pModeList);
437 rStream >> bAllModes;
438 return *this;
441 /*****************************************************************************/
442 DepInfo& DepInfo::operator>> ( SvStream& rStream )
443 /*****************************************************************************/
445 rStream << *pProject;
446 if (pModeList)
448 rStream << sal_True;
449 *pModeList >> rStream;
451 else
452 rStream << sal_False;
453 rStream << bAllModes;
455 return *this;
459 // class SDepInfoList
462 /*****************************************************************************/
463 SDepInfoList::SDepInfoList()
464 /*****************************************************************************/
465 : pAllModeList(0)
469 /*****************************************************************************/
470 SDepInfoList::~SDepInfoList()
471 /*****************************************************************************/
473 if (pAllModeList)
474 delete pAllModeList;
477 /*****************************************************************************/
478 ULONG SDepInfoList::IsString( ByteString* pStr )
479 /*****************************************************************************/
481 ULONG nRet = NOT_THERE;
482 if ( (nRet = GetPrevString( pStr )) != 0 )
484 ByteString* pString = GetObject( nRet )->GetProject();
485 if ( *pString == *pStr )
486 return nRet;
487 else
488 return NOT_THERE;
490 else
492 ByteString* pString = GetObject( 0 )->GetProject();
493 if ( pString && (*pString == *pStr) )
494 return 0;
495 else
496 return NOT_THERE;
498 return nRet;
501 /*****************************************************************************/
502 ULONG SDepInfoList::GetPrevString( ByteString* pStr )
503 /*****************************************************************************/
505 ULONG nRet = 0;
506 BOOL bFound = FALSE;
507 ULONG nCount_l = Count();
508 ULONG nUpper = nCount_l;
509 ULONG nLower = 0;
510 ULONG nCurrent = nUpper / 2;
511 ULONG nRem = 0;
512 ByteString* pString;
516 if ( (nCurrent == nLower) || (nCurrent == nUpper) )
517 return nLower;
518 pString = GetObject( nCurrent )->GetProject();
519 int nResult = pStr->CompareTo( *pString );
520 if ( nResult == COMPARE_LESS )
522 nUpper = nCurrent;
523 nCurrent = (nCurrent + nLower) /2;
525 else if ( nResult == COMPARE_GREATER )
527 nLower = nCurrent;
528 nCurrent = (nUpper + nCurrent) /2;
530 else if ( nResult == COMPARE_EQUAL )
531 return nCurrent;
532 if ( nRem == nCurrent )
533 return nCurrent;
534 nRem = nCurrent;
536 while ( !bFound );
537 return nRet;
540 /*****************************************************************************/
541 void SDepInfoList::PutModeString( DepInfo* pInfoList, ByteString* pStr )
542 /*****************************************************************************/
544 SByteStringList* pList = pInfoList->GetModeList();
545 if (!pList)
547 pList = new SByteStringList;
548 pInfoList->SetModeList(pList);
552 if (pList)
554 // check if string exists
555 ByteString *pString = pList->First();
556 while ( pString )
558 if (*pString == *pStr)
560 delete pStr;
561 return;
563 pString = pList->Next();
565 pList->PutString( pStr );
567 else
568 delete pStr;
571 /*****************************************************************************/
572 ULONG SDepInfoList::PutString( ByteString* pStr)
573 /*****************************************************************************/
575 return PutString( pStr, NULL);
578 /**************************************************************************
580 * Sortiert einen ByteString in die Liste ein und gibt die Position,
581 * an der einsortiert wurde, zurueck
583 **************************************************************************/
585 ULONG SDepInfoList::PutString( ByteString* pStr, ByteString* pModeStr)
587 if (pAllModeList)
589 delete pAllModeList;
590 pAllModeList = NULL;
593 ULONG nPos = GetPrevString ( pStr );
594 if ( Count() )
597 DepInfo* pInfo = GetObject( 0 );
598 ByteString* pString = pInfo->GetProject();
599 if ( pString->CompareTo( *pStr ) == COMPARE_GREATER )
601 pInfo = new DepInfo;
602 if (pInfo)
604 pInfo->SetProject(pStr);
605 if (pModeStr)
606 PutModeString(pInfo, pModeStr);
607 else
608 pInfo->SetAllModes();
609 Insert( pInfo, (ULONG)0 );
611 return (ULONG)0;
614 ByteString* pString = GetObject( nPos )->GetProject();
615 if ( *pStr != *pString )
617 DepInfo* pInfo = new DepInfo;
618 if (pInfo)
620 pInfo->SetProject(pStr);
621 if (pModeStr)
622 PutModeString(pInfo, pModeStr);
623 else
624 pInfo->SetAllModes();
625 Insert( pInfo, nPos+1 );
627 return ( nPos +1 );
629 else
631 delete pStr;
632 DepInfo* pInfo = GetObject( nPos );
633 if (pModeStr)
634 PutModeString(pInfo, pModeStr);
635 else
636 pInfo->SetAllModes();
637 return ( nPos +1 );
640 else
642 DepInfo* pInfo = new DepInfo;
643 if (pInfo)
645 pInfo->SetProject(pStr);
646 if (pModeStr)
647 PutModeString(pInfo, pModeStr);
648 else
649 pInfo->SetAllModes();
650 Insert( pInfo);
651 return (ULONG)0;
655 delete pStr;
656 if (pModeStr)
657 delete pModeStr;
658 return NOT_THERE;
661 /*****************************************************************************/
662 ByteString* SDepInfoList::RemoveString( const ByteString& rName )
663 /*****************************************************************************/
665 ULONG i;
666 ByteString* pReturn;
667 if (pAllModeList)
669 delete pAllModeList;
670 pAllModeList = NULL;
673 for( i = 0 ; i < Count(); i++ )
675 if ( rName == *(GetObject( i )->GetProject()) )
677 pReturn = new ByteString(*(GetObject(i)->GetProject()));
678 DepInfo* pInfo;
679 pInfo = GetObject(i);
680 delete pInfo;
681 Remove(i);
682 return pReturn;
686 return NULL;
689 /*****************************************************************************/
690 SByteStringList* SDepInfoList::GetAllDepModes()
691 /*****************************************************************************/
693 if (pAllModeList)
694 return pAllModeList;
696 DepInfo *pInfo = First();
697 while ( pInfo )
699 if (!pInfo->IsAllModes() && pInfo->GetModeList())
701 if (!pAllModeList)
702 pAllModeList = new SByteStringList();
703 ByteString* pStr = pInfo->GetModeList()->First();
704 while (pStr)
706 if (pAllModeList->IsString(pStr) == NOT_THERE)
707 pAllModeList->PutString(pStr);
708 pStr = pInfo->GetModeList()->Next();
711 pInfo = Next();
713 return pAllModeList;
716 /*****************************************************************************/
717 SDepInfoList& SDepInfoList::operator<< ( SvStream& rStream )
718 /*****************************************************************************/
720 ULONG nCount_l;
721 rStream >> nCount_l;
722 for ( USHORT i = 0; i < nCount_l; i++ ) {
723 DepInfo* pDepInfo = new DepInfo();
724 *pDepInfo << rStream;
725 Insert (pDepInfo, LIST_APPEND);
727 return *this;
730 /*****************************************************************************/
731 SDepInfoList& SDepInfoList::operator>> ( SvStream& rStream )
732 /*****************************************************************************/
734 ULONG nCount_l = Count();
735 rStream << nCount_l;
736 DepInfo* pDepInfo = First();
737 while (pDepInfo) {
738 *pDepInfo >> rStream;
739 pDepInfo = Next();
742 return *this;
745 /*****************************************************************************/
746 CommandData* Prj::GetDirectoryList ( USHORT nWhatOS, USHORT nCommand )
747 /*****************************************************************************/
749 return (CommandData *)NULL;
752 /*****************************************************************************/
753 CommandData* Prj::GetDirectoryData( ByteString aLogFileName )
754 /*****************************************************************************/
756 CommandData *pData = NULL;
757 ULONG nCount_l = Count();
758 for ( ULONG i=0; i<nCount_l; i++ )
760 pData = GetObject(i);
761 if ( pData->GetLogFile() == aLogFileName )
762 return pData;
764 return NULL;
768 // class Prj
771 /*****************************************************************************/
772 Prj::Prj() :
773 pPrjInitialDepList(0),
774 pPrjDepList(0),
775 pPrjDepInfoList(0),
776 bSorted( FALSE ),
777 bHardDependencies( FALSE ),
778 bFixedDependencies( FALSE ),
779 bVisited( FALSE ),
780 bIsAvailable( TRUE )
781 /*****************************************************************************/
785 /*****************************************************************************/
786 Prj::Prj( ByteString aName ) :
787 aProjectName( aName ),
788 pPrjInitialDepList(0),
789 pPrjDepList(0),
790 pPrjDepInfoList(0),
791 bSorted( FALSE ),
792 bHardDependencies( FALSE ),
793 bFixedDependencies( FALSE ),
794 bVisited( FALSE ),
795 bIsAvailable( TRUE )
796 /*****************************************************************************/
800 /*****************************************************************************/
801 Prj::~Prj()
802 /*****************************************************************************/
804 pPrjDepList = RemoveStringList (pPrjDepList);
805 pPrjInitialDepList = RemoveStringList (pPrjInitialDepList);
806 pPrjDepInfoList = RemoveDepInfoList (pPrjDepInfoList);
809 /*****************************************************************************/
810 SByteStringList* Prj::RemoveStringList(SByteStringList* pStringList )
811 /*****************************************************************************/
813 if ( pStringList )
815 ByteString *pString = pStringList->First();
816 while ( pString )
818 delete pString;
819 pString = pStringList->Next();
822 delete pStringList;
824 pStringList = NULL;
826 return pStringList;
829 /*****************************************************************************/
830 SDepInfoList* Prj::RemoveDepInfoList(SDepInfoList* pInfoList )
831 /*****************************************************************************/
833 if ( pInfoList )
835 DepInfo *pInfo = pInfoList->First();
836 while ( pInfo )
838 delete pInfo;
839 pInfo = pInfoList->Next();
842 delete pInfoList;
844 pInfoList = NULL;
846 return pInfoList;
849 /*****************************************************************************/
850 void Prj::AddDependencies( ByteString aStr )
851 /*****************************************************************************/
854 if ( !pPrjDepInfoList )
855 pPrjDepInfoList = new SDepInfoList;
857 pPrjDepInfoList->PutString( new ByteString(aStr) );
860 /*****************************************************************************/
861 void Prj::AddDependencies( ByteString aStr, ByteString aModeStr )
862 /*****************************************************************************/
865 // needs dirty flag - not expanded
866 if ( !pPrjDepInfoList )
867 pPrjDepInfoList = new SDepInfoList;
869 pPrjDepInfoList->PutString( new ByteString(aStr), new ByteString(aModeStr) );
872 /*****************************************************************************/
873 SByteStringList* Prj::GetDependencies( BOOL bExpanded )
874 /*****************************************************************************/
876 if ( bExpanded )
878 if (!pPrjDepList)
879 SetMode (NULL);
880 return pPrjDepList;
882 else
884 if (!pPrjInitialDepList)
885 SetMode (NULL);
886 return pPrjInitialDepList;
890 /*****************************************************************************/
891 void Prj::SetMode(SByteStringList* pModList)
892 /*****************************************************************************/
894 pPrjDepList = RemoveStringList (pPrjDepList);
895 pPrjInitialDepList = RemoveStringList (pPrjInitialDepList);
897 if (!pPrjDepInfoList)
898 return;
900 pPrjDepList = new SByteStringList;
901 pPrjInitialDepList = new SByteStringList;
903 DepInfo *pInfo = pPrjDepInfoList->First();
904 while ( pInfo )
906 if (pInfo->IsAllModes() || !pInfo->GetModeList() || !pModList)
908 pPrjDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
909 pPrjInitialDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
910 //pPrjDepList->PutString( pInfo->GetProject());
911 //pPrjInitialDepList->PutString( pInfo->GetProject());
913 else
915 BOOL bStringFound = FALSE;
916 SByteStringList * pDepList = pInfo->GetModeList();
917 ByteString *pModString = pDepList->First();
918 while ( pModString )
920 ByteString *pDefModString = pModList->First();
921 while ( pDefModString )
923 if (*pDefModString == *pModString)
925 pPrjDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
926 pPrjInitialDepList->PutString( new ByteString((ByteString) *(pInfo->GetProject())));
927 //pPrjDepList->PutString( pInfo->GetProject());
928 //pPrjInitialDepList->PutString( pInfo->GetProject());
929 bStringFound = TRUE;
930 break;
932 pDefModString = pModList->Next();
934 if (bStringFound)
935 break;
936 pModString = pDepList->Next();
941 pInfo = pPrjDepInfoList->Next();
945 /*****************************************************************************/
946 BOOL Prj::InsertDirectory ( ByteString aDirName, USHORT aWhat,
947 USHORT aWhatOS, ByteString aLogFileName,
948 const ByteString &rClientRestriction )
949 /*****************************************************************************/
951 CommandData* pData = new CommandData();
953 pData->SetPath( aDirName );
954 pData->SetCommandType( aWhat );
955 pData->SetOSType( aWhatOS );
956 pData->SetLogFile( aLogFileName );
957 pData->SetClientRestriction( rClientRestriction );
959 Insert( pData );
961 return FALSE;
964 /*****************************************************************************/
966 // removes directory and existing dependencies on it
968 CommandData* Prj::RemoveDirectory ( ByteString aLogFileName )
969 /*****************************************************************************/
971 ULONG nCount_l = Count();
972 CommandData* pData;
973 CommandData* pDataFound = NULL;
974 SByteStringList* pDataDeps;
976 for ( USHORT i = 0; i < nCount_l; i++ )
978 pData = GetObject( i );
979 if ( pData->GetLogFile() == aLogFileName )
980 pDataFound = pData;
981 else
983 pDataDeps = pData->GetDependencies();
984 if ( pDataDeps )
986 ByteString* pString;
987 ULONG nDataDepsCount = pDataDeps->Count();
988 for ( ULONG j = nDataDepsCount; j > 0; j-- )
990 pString = pDataDeps->GetObject( j - 1 );
991 if ( pString->GetToken( 0, '.') == aLogFileName )
992 pDataDeps->Remove( pString );
998 Remove( pDataFound );
1000 return pDataFound;
1003 /*****************************************************************************/
1004 void Prj::ExtractDependencies()
1005 /*****************************************************************************/
1007 ULONG nPos = 0;
1008 CommandData* pData = GetObject(nPos);
1009 while (pData)
1011 SByteStringList* pDepList = pData->GetDependencies();
1012 if (pDepList)
1014 ByteString * pDepStr = pDepList->First();
1015 while (pDepStr)
1017 CommandData* pSearchData = First();
1018 while (pSearchData)
1020 if ((*pDepStr == pSearchData->GetPath()) && (pData->GetOSType() & pSearchData->GetOSType()))
1022 *pDepStr = pSearchData->GetLogFile();
1023 break;
1026 pSearchData = Next();
1029 pDepStr = pDepList->Next();
1032 nPos ++;
1033 pData = GetObject(nPos);
1037 /*****************************************************************************/
1038 Prj& Prj::operator>> ( SvStream& rStream )
1039 /*****************************************************************************/
1041 rStream << bVisited;
1042 rStream << aProjectName;
1043 rStream << aProjectPrefix;
1044 rStream << bHardDependencies;
1045 rStream << bFixedDependencies;
1046 rStream << bSorted;
1047 rStream << bIsAvailable;
1049 if (pPrjDepInfoList)
1051 rStream << sal_True;
1052 *pPrjDepInfoList >> rStream;
1054 else
1055 rStream << sal_False;
1057 ULONG nCount_l = Count();
1058 rStream << nCount_l;
1060 CommandData* pData = First();
1061 while (pData) {
1062 *pData >> rStream;
1063 pData = Next();
1066 return *this;
1069 /*****************************************************************************/
1070 Prj& Prj::operator<< ( SvStream& rStream )
1071 /*****************************************************************************/
1073 rStream >> bVisited;
1074 rStream >> aProjectName;
1075 rStream >> aProjectPrefix;
1076 rStream >> bHardDependencies;
1077 rStream >> bFixedDependencies;
1078 rStream >> bSorted;
1079 rStream >> bIsAvailable;
1081 BOOL bDepList;
1082 rStream >> bDepList;
1083 DELETEZ (pPrjDepInfoList);
1084 if (bDepList)
1086 pPrjDepInfoList = new SDepInfoList();
1087 *pPrjDepInfoList << rStream;
1090 ULONG nCount_l;
1091 rStream >> nCount_l;
1093 for ( USHORT i = 0; i < nCount_l; i++ ) {
1094 CommandData* pData = new CommandData();
1095 *pData << rStream;
1096 Insert (pData, LIST_APPEND);
1099 return *this;
1104 // class Star
1107 /*****************************************************************************/
1108 Star::Star(XmlBuildList* pXmlBuildListObj)
1109 /*****************************************************************************/
1110 : pDepMode (NULL),
1111 pAllDepMode (NULL),
1112 mpXmlBuildList (pXmlBuildListObj)
1114 // this ctor is only used by StarWriter
1117 /*****************************************************************************/
1118 Star::Star(XmlBuildList* pXmlBuildListObj, String aFileName, USHORT nMode )
1119 /*****************************************************************************/
1120 : nStarMode( nMode ),
1121 sFileName( aFileName ),
1122 pDepMode (NULL),
1123 pAllDepMode (NULL),
1124 mpXmlBuildList (pXmlBuildListObj)
1126 Read( aFileName );
1129 /*****************************************************************************/
1130 Star::Star(XmlBuildList* pXmlBuildListObj, SolarFileList *pSolarFiles )
1131 /*****************************************************************************/
1132 : nStarMode( STAR_MODE_MULTIPLE_PARSE ),
1133 pDepMode (NULL),
1134 pAllDepMode (NULL),
1135 mpXmlBuildList (pXmlBuildListObj)
1137 // this ctor is used by StarBuilder to get the information for the whole workspace
1138 Read( pSolarFiles );
1141 /*****************************************************************************/
1142 Star::Star(XmlBuildList* pXmlBuildListObj, GenericInformationList *pStandLst, ByteString &rVersion,
1143 BOOL bLocal, const char *pSourceRoot )
1144 /*****************************************************************************/
1145 : pDepMode (NULL),
1146 pAllDepMode (NULL),
1147 mpXmlBuildList (pXmlBuildListObj)
1149 UpdateFileList (pStandLst, rVersion, TRUE, bLocal, pSourceRoot);
1152 /*****************************************************************************/
1153 void Star::UpdateFileList( GenericInformationList *pStandLst, ByteString &rVersion,
1154 BOOL bRead, BOOL bLocal, const char *pSourceRoot )
1155 /*****************************************************************************/
1157 sSourceRoot=String::CreateFromAscii(""); // clear old SourceRoot
1158 ByteString sPath( rVersion );
1159 if ( pSourceRoot )
1160 sSourceRoot = String::CreateFromAscii( pSourceRoot );
1162 #ifdef UNX
1163 sPath += "/settings/UNXSOLARLIST";
1164 #else
1165 sPath += "/settings/SOLARLIST";
1166 #endif
1167 GenericInformation *pInfo = pStandLst->GetInfo( sPath, TRUE );
1169 if( pInfo && pInfo->GetValue().Len()) {
1170 ByteString sFile( pInfo->GetValue());
1171 if ( bLocal ) {
1172 IniManager aIniManager;
1173 aIniManager.ToLocal( sFile );
1175 String sFileName_l( sFile, RTL_TEXTENCODING_ASCII_US );
1176 nStarMode = STAR_MODE_SINGLE_PARSE;
1177 if (bRead)
1178 Read( sFileName_l );
1180 else {
1181 SolarFileList *pFileList = new SolarFileList();
1183 sPath = rVersion;
1184 sPath += "/drives";
1186 GenericInformation *pInfo_l = pStandLst->GetInfo( sPath, TRUE );
1187 if ( pInfo_l && pInfo_l->GetSubList()) {
1188 GenericInformationList *pDrives = pInfo_l->GetSubList();
1189 for ( ULONG i = 0; i < pDrives->Count(); i++ ) {
1190 GenericInformation *pDrive = pDrives->GetObject( i );
1191 if ( pDrive ) {
1192 DirEntry aEntry;
1193 BOOL bOk = FALSE;
1194 if ( sSourceRoot.Len()) {
1195 aEntry = DirEntry( sSourceRoot );
1196 bOk = TRUE;
1198 else {
1199 #ifdef UNX
1200 sPath = "UnixVolume";
1201 GenericInformation *pUnixVolume = pDrive->GetSubInfo( sPath );
1202 if ( pUnixVolume ) {
1203 String sRoot( pUnixVolume->GetValue(), RTL_TEXTENCODING_ASCII_US );
1204 aEntry = DirEntry( sRoot );
1205 bOk = TRUE;
1207 #else
1208 bOk = TRUE;
1209 String sRoot( *pDrive, RTL_TEXTENCODING_ASCII_US );
1210 sRoot += String::CreateFromAscii( "\\" );
1211 aEntry = DirEntry( sRoot );
1212 #endif
1214 if ( bOk ) {
1215 sPath = "projects";
1216 GenericInformation *pProjectsKey = pDrive->GetSubInfo( sPath, TRUE );
1217 if ( pProjectsKey ) {
1218 if ( !sSourceRoot.Len()) {
1219 sPath = rVersion;
1220 sPath += "/settings/PATH";
1221 GenericInformation *pPath = pStandLst->GetInfo( sPath, TRUE );
1222 if( pPath ) {
1223 ByteString sAddPath( pPath->GetValue());
1224 #ifdef UNX
1225 sAddPath.SearchAndReplaceAll( "\\", "/" );
1226 #else
1227 sAddPath.SearchAndReplaceAll( "/", "\\" );
1228 #endif
1229 String ssAddPath( sAddPath, RTL_TEXTENCODING_ASCII_US );
1230 aEntry += DirEntry( ssAddPath );
1233 sSourceRoot = aEntry.GetFull();
1234 GenericInformationList *pProjects = pProjectsKey->GetSubList();
1235 if ( pProjects ) {
1236 GenericInformation * pProject = pProjects->First();
1237 while (pProject) {
1238 String sLocalSourceRoot = sSourceRoot;
1239 ByteString sProject( *pProject );
1240 String ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
1242 ByteString aDirStr ("Directory");
1243 GenericInformation * pDir = pProject->GetSubInfo (aDirStr);
1244 if (pDir) {
1245 ByteString aDir = pDir->GetValue();
1246 DirEntry aRootEntry = aEntry.GetPath() + DirEntry(aDir);
1247 sLocalSourceRoot = aRootEntry.GetFull();
1250 String aBuildListPath = CreateFileName(ssProject, sLocalSourceRoot);
1252 pFileList->Insert( new String( aBuildListPath ), LIST_APPEND );
1253 ByteString sFile( aBuildListPath, RTL_TEXTENCODING_ASCII_US );
1254 pProject = pProjects->Next();
1263 if (!CheckFileLoadList(pFileList))
1265 ClearAvailableDeps();
1266 ClearCurrentDeps();
1267 ClearLoadedFilesList();
1268 RemoveAllPrj();
1269 bRead = TRUE; // read new list because old list is deleted
1272 if (bRead)
1273 Read( pFileList );
1274 else
1275 GenerateFileLoadList( pFileList );
1279 /*****************************************************************************/
1280 BOOL Star::CheckFileLoadList(SolarFileList *pSolarFiles)
1281 /*****************************************************************************/
1283 BOOL bRet = TRUE;
1284 if (aLoadedFilesList.Count() == 0)
1285 return bRet;
1286 StarFile * pLoadFile = aLoadedFilesList.First();
1287 while (pLoadFile)
1289 BOOL bIsAvailable = FALSE;
1290 String * pFile = pSolarFiles->First();
1291 while (pFile)
1293 if (*pFile == pLoadFile->GetName())
1295 bIsAvailable = TRUE;
1296 break;
1298 pFile = pSolarFiles->Next();
1300 if (!bIsAvailable)
1302 bRet = FALSE;
1303 break;
1305 pLoadFile = aLoadedFilesList.Next();
1307 return bRet;
1310 /*****************************************************************************/
1311 Star::~Star()
1312 /*****************************************************************************/
1314 ClearAvailableDeps();
1315 ClearCurrentDeps();
1316 ClearLoadedFilesList();
1317 RemoveAllPrj();
1320 /*****************************************************************************/
1321 void Star::GenerateFileLoadList( SolarFileList *pSolarFiles )
1322 /*****************************************************************************/
1324 SolarFileList* pNewSolarFiles = NULL;
1325 while( pSolarFiles->Count()) {
1326 StarFile *pFile = new StarFile( *pSolarFiles->GetObject(( ULONG ) 0 ));
1327 aMutex.acquire();
1328 ULONG nPos = SearchFileEntry(&aLoadedFilesList, pFile);
1329 if ( nPos == LIST_ENTRY_NOTFOUND )
1331 if (!pNewSolarFiles)
1332 pNewSolarFiles = new SolarFileList();
1334 pNewSolarFiles->Insert(new String(pFile->GetName()), LIST_APPEND );
1336 aMutex.release();
1337 delete pSolarFiles->Remove(( ULONG ) 0 );
1338 delete pFile;
1340 delete pSolarFiles;
1341 if (pNewSolarFiles)
1342 Read (pNewSolarFiles);
1345 /*****************************************************************************/
1346 SolarFileList* Star::NeedsFilesForUpdate()
1347 /*****************************************************************************/
1349 aMutex.acquire();
1350 SolarFileList* pPrjList = NULL;
1351 for ( ULONG i = 0; i < aLoadedFilesList.Count(); i++ )
1352 if ( aLoadedFilesList.GetObject( i )->NeedsUpdate()) {
1353 if (!pPrjList)
1354 pPrjList = new SolarFileList();
1356 pPrjList->Insert(new String (aLoadedFilesList.GetObject( i )->GetName()), LIST_APPEND);
1359 aMutex.release();
1360 return pPrjList;
1363 /*****************************************************************************/
1364 BOOL Star::NeedsUpdate()
1365 /*****************************************************************************/
1367 aMutex.acquire();
1368 for ( ULONG i = 0; i < aLoadedFilesList.Count(); i++ )
1369 if ( aLoadedFilesList.GetObject( i )->NeedsUpdate()) {
1370 aMutex.release();
1371 return TRUE;
1374 aMutex.release();
1375 return FALSE;
1378 /*****************************************************************************/
1379 void Star::Read( String &rFileName )
1380 /*****************************************************************************/
1382 ClearAvailableDeps ();
1383 ByteString aString;
1384 aFileList.Insert( new String( rFileName ));
1386 DirEntry aEntry( rFileName );
1387 aEntry.ToAbs();
1388 aEntry = aEntry.GetPath().GetPath().GetPath();
1389 sSourceRoot = aEntry.GetFull();
1391 while( aFileList.Count()) {
1392 String ssFileName = *aFileList.GetObject(( ULONG ) 0 );
1393 ByteString sFileName_l(ssFileName, RTL_TEXTENCODING_ASCII_US);
1394 StarFile *pFile = new StarFile( ssFileName );
1395 if ( pFile->Exists()) {
1396 if (sFileName_l.Len() >= RTL_CONSTASCII_LENGTH(XML_EXT) && ssFileName.EqualsAscii(XML_EXT, sFileName_l.Len() - RTL_CONSTASCII_LENGTH(XML_EXT), RTL_CONSTASCII_LENGTH(XML_EXT)))
1398 ReadXmlBuildList(sFileName_l);
1399 } else {
1400 SimpleConfig aSolarConfig( ssFileName );
1401 while (( aString = aSolarConfig.GetNext()) != "" )
1402 InsertToken (( char * ) aString.GetBuffer());
1405 aMutex.acquire();
1406 ReplaceFileEntry (&aLoadedFilesList, pFile);
1407 //aLoadedFilesList.Insert( pFile, LIST_APPEND );
1408 aMutex.release();
1409 aFileList.Remove(( ULONG ) 0 );
1411 // resolve all dependencies recursive
1412 Expand_Impl();
1415 /*****************************************************************************/
1416 ULONG Star::SearchFileEntry( StarFileList *pStarFiles, StarFile* pFile )
1417 /*****************************************************************************/
1419 StarFile *pSearchFile;
1420 ULONG nCount_l;
1422 nCount_l = pStarFiles->Count();
1424 for ( ULONG i=0; i<nCount_l; i++)
1426 pSearchFile = pStarFiles->GetObject(i);
1427 if ( pSearchFile->GetName() == pFile->GetName() )
1429 return i;
1432 return LIST_ENTRY_NOTFOUND;
1435 /*****************************************************************************/
1436 void Star::ReplaceFileEntry( StarFileList *pStarFiles, StarFile* pFile )
1437 /*****************************************************************************/
1439 ULONG nPos = SearchFileEntry(pStarFiles, pFile);
1440 if ( nPos != LIST_ENTRY_NOTFOUND )
1442 StarFile* pTmpStarFile = pStarFiles->GetObject(nPos);
1443 delete pTmpStarFile;
1444 pStarFiles->Replace(pFile, nPos);
1445 return;
1447 pStarFiles->Insert( pFile, LIST_APPEND );
1450 /*****************************************************************************/
1451 void Star::Read( SolarFileList *pSolarFiles )
1452 /*****************************************************************************/
1454 ClearAvailableDeps ();
1455 while( pSolarFiles->Count()) {
1456 ByteString aString;
1458 String ssFileName = *pSolarFiles->GetObject(( ULONG ) 0 );
1459 ByteString sFileName_l(ssFileName, RTL_TEXTENCODING_ASCII_US);
1460 StarFile *pFile = new StarFile( ssFileName );
1462 if ( pFile->Exists()) {
1463 if (sFileName_l.Len() >= RTL_CONSTASCII_LENGTH(XML_EXT) && ssFileName.EqualsAscii(XML_EXT, sFileName_l.Len() - RTL_CONSTASCII_LENGTH(XML_EXT), RTL_CONSTASCII_LENGTH(XML_EXT)))
1465 ReadXmlBuildList(sFileName_l);
1466 } else {
1467 SimpleConfig aSolarConfig( ssFileName );
1468 while (( aString = aSolarConfig.GetNext()) != "" )
1469 InsertToken (( char * ) aString.GetBuffer());
1472 DirEntry aEntry( pFile->GetName() );
1473 DirEntry aEntryPrj = aEntry.GetPath().GetPath();
1474 if (aEntryPrj.GetExtension() != String::CreateFromAscii( "" ))
1476 aEntryPrj.CutExtension();
1477 ByteString aPrjName = ByteString( aEntryPrj.GetName(), gsl_getSystemTextEncoding());
1478 Prj* pPrj = GetPrj(aPrjName);
1479 if (pPrj)
1480 pPrj->IsAvailable (FALSE);
1485 aMutex.acquire();
1486 ReplaceFileEntry (&aLoadedFilesList, pFile);
1487 //aLoadedFilesList.Insert( pFile, LIST_APPEND );
1488 aMutex.release();
1489 delete pSolarFiles->Remove(( ULONG ) 0 );
1491 delete pSolarFiles;
1493 Expand_Impl();
1496 /*****************************************************************************/
1497 String Star::CreateFileName( String& rProject, String& rSourceRoot )
1498 /*****************************************************************************/
1500 // this method is used to find solarlist parts of nabours (other projects)
1501 String sPrjDir( String::CreateFromAscii( "prj" ));
1502 String sBuildList( String::CreateFromAscii( "build.lst" ));
1503 String sXmlBuildList( String::CreateFromAscii( "build.xlist" ));
1505 DirEntry aEntry( rSourceRoot );
1506 aEntry += DirEntry( rProject );
1508 // if this project not exists, maybe it's a not added project of a CWS
1510 if ( !aEntry.Exists() ) {
1511 aEntry.SetExtension(String::CreateFromAscii( "lnk" ));
1512 if ( !aEntry.Exists() )
1513 aEntry.CutExtension();
1515 aEntry.SetExtension(String::CreateFromAscii( "link" ));
1516 if ( !aEntry.Exists() )
1517 aEntry.CutExtension();
1520 aEntry += DirEntry( sPrjDir );
1522 DirEntry aPossibleEntry(aEntry);
1523 aPossibleEntry += DirEntry( sXmlBuildList );
1525 aEntry += DirEntry( sBuildList );
1527 DirEntry& aActualEntry = aEntry;
1528 if (aPossibleEntry.Exists()) {
1529 aActualEntry = aPossibleEntry;
1530 } else if ( !aActualEntry.Exists() && aDBNotFoundHdl.IsSet())
1531 aDBNotFoundHdl.Call( &rProject );
1532 return aActualEntry.GetFull();
1535 /*****************************************************************************/
1536 void Star::InsertSolarList( String sProject )
1537 /*****************************************************************************/
1539 // inserts a new solarlist part of another project
1540 String sFileName_l( CreateFileName( sProject, sSourceRoot ));
1542 for ( ULONG i = 0; i < aFileList.Count(); i++ ) {
1543 if (( *aFileList.GetObject( i )) == sFileName_l )
1544 return;
1547 ByteString ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
1548 if ( HasProject( ssProject ))
1549 return;
1551 aFileList.Insert( new String( sFileName_l ), LIST_APPEND );
1554 /*****************************************************************************/
1555 void Star::ExpandPrj_Impl( Prj *pPrj, Prj *pDepPrj )
1556 /*****************************************************************************/
1558 if ( pDepPrj->bVisited )
1559 return;
1561 pDepPrj->bVisited = TRUE;
1563 SByteStringList* pPrjLst = pPrj->GetDependencies();
1564 SByteStringList* pDepLst = NULL;
1565 ByteString* pDepend;
1566 ByteString* pPutStr;
1567 Prj *pNextPrj = NULL;
1568 ULONG i, nRetPos;
1570 if ( pPrjLst ) {
1571 pDepLst = pDepPrj->GetDependencies();
1572 if ( pDepLst ) {
1573 for ( i = 0; i < pDepLst->Count(); i++ ) {
1574 pDepend = pDepLst->GetObject( i );
1575 pPutStr = new ByteString( *pDepend );
1576 nRetPos = pPrjLst->PutString( pPutStr );
1577 if( nRetPos == NOT_THERE )
1578 delete pPutStr;
1579 pNextPrj = GetPrj( *pDepend );
1580 if ( pNextPrj ) {
1581 ExpandPrj_Impl( pPrj, pNextPrj );
1588 /*****************************************************************************/
1589 void Star::Expand_Impl()
1590 /*****************************************************************************/
1592 for ( ULONG i = 0; i < Count(); i++ ) {
1593 for ( ULONG j = 0; j < Count(); j++ )
1594 GetObject( j )->bVisited = FALSE;
1596 Prj* pPrj = GetObject( i );
1597 pPrj->SetMode(pDepMode); // DepList für Mode initialisieren
1598 ExpandPrj_Impl( pPrj, pPrj );
1602 /*****************************************************************************/
1603 void Star::InsertToken ( char *yytext )
1604 /*****************************************************************************/
1606 static int i = 0;
1607 static ByteString aDirName, aWhat, aWhatOS,
1608 sClientRestriction, aLogFileName, aProjectName, aPrefix, aCommandPara;
1609 static BOOL bPrjDep = FALSE;
1610 static BOOL bHardDep = FALSE;
1611 static BOOL bFixedDep = FALSE;
1612 static int nCommandType, nOSType;
1613 CommandData* pCmdData;
1614 static SByteStringList *pStaticDepList;
1615 Prj* pPrj;
1617 switch (i)
1619 case 0:
1620 aPrefix = yytext;
1621 pStaticDepList = 0;
1622 break;
1623 case 1:
1624 aDirName = yytext;
1625 break;
1626 case 2:
1627 if ( !strcmp( yytext, ":" ))
1629 bPrjDep = TRUE;
1630 bHardDep = FALSE;
1631 bFixedDep = FALSE;
1632 i = 9;
1634 else if ( !strcmp( yytext, "::" ))
1636 bPrjDep = TRUE;
1637 bHardDep = TRUE;
1638 bFixedDep = FALSE;
1639 i = 9;
1641 else if ( !strcmp( yytext, ":::" ))
1643 bPrjDep = TRUE;
1644 bHardDep = TRUE;
1645 bFixedDep = TRUE;
1646 i = 9;
1648 else
1650 bPrjDep = FALSE;
1651 bHardDep = FALSE;
1652 bFixedDep = FALSE;
1654 aWhat = yytext;
1655 nCommandType = GetJobType(aWhat);
1657 if (bPrjDep)
1659 aProjectName = aDirName.GetToken ( 0, 0x5c);
1660 if ( HasProject( aProjectName ))
1662 RemovePrj(GetPrj(aProjectName));
1663 // Projekt exist. schon, entfernen, später neue anlegen
1666 break;
1667 case 3:
1668 if ( !bPrjDep )
1670 aWhat = yytext;
1671 if ( aWhat == "-" )
1673 aCommandPara = ByteString();
1675 else
1676 aCommandPara = aWhat;
1678 break;
1679 case 4:
1680 if ( !bPrjDep )
1682 aWhatOS = yytext;
1683 if ( aWhatOS.GetTokenCount( ',' ) > 1 ) {
1684 sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 );
1685 aWhatOS = aWhatOS.GetToken( 0, ',' );
1687 nOSType = GetOSType (aWhatOS);
1689 break;
1690 case 5:
1691 if ( !bPrjDep )
1693 aLogFileName = yytext;
1695 break;
1696 default:
1697 if ( !bPrjDep )
1699 ByteString aItem = yytext;
1700 if ( aItem == "NULL" )
1702 // Liste zu Ende
1703 i = -1;
1705 else
1707 // ggfs. Dependency liste anlegen und ergaenzen
1708 if ( !pStaticDepList )
1709 pStaticDepList = new SByteStringList;
1710 pStaticDepList->PutString( new ByteString( aItem ));
1713 else
1715 ByteString aItem = yytext;
1716 if ( aItem == "NULL" )
1718 // Liste zu Ende
1719 i = -1;
1720 bPrjDep= FALSE;
1722 else
1724 ByteString sMode;
1725 BOOL bHasModes = FALSE;
1726 if (aItem.Search(":") != STRING_NOTFOUND)
1728 sMode = aItem.GetToken ( 0, ':');
1729 aItem = aItem.GetToken ( 1, ':');
1730 bHasModes = TRUE;
1733 aProjectName = aDirName.GetToken ( 0, 0x5c);
1734 if ( HasProject( aProjectName ))
1736 pPrj = GetPrj( aProjectName );
1737 // Projekt exist. schon, neue Eintraege anhaengen
1739 else
1741 // neues Project anlegen
1742 pPrj = new Prj ( aProjectName );
1743 pPrj->SetPreFix( aPrefix );
1744 Insert(pPrj,LIST_APPEND);
1746 if (bHasModes)
1747 pPrj->AddDependencies( aItem, sMode );
1748 else
1749 pPrj->AddDependencies( aItem );
1750 pPrj->HasHardDependencies( bHardDep );
1751 pPrj->HasFixedDependencies( bFixedDep );
1754 if ( nStarMode == STAR_MODE_RECURSIVE_PARSE ) {
1755 String sItem( aItem, RTL_TEXTENCODING_ASCII_US );
1756 InsertSolarList( sItem );
1761 break;
1763 /* Wenn dieses Project noch nicht vertreten ist, in die Liste
1764 der Solar-Projekte einfuegen */
1765 if ( i == -1 )
1767 aProjectName = aDirName.GetToken ( 0, 0x5c);
1768 if ( HasProject( aProjectName ))
1770 pPrj = GetPrj( aProjectName );
1771 // Projekt exist. schon, neue Eintraege anhaengen
1773 else
1775 // neues Project anlegen
1776 pPrj = new Prj ( aProjectName );
1777 pPrj->SetPreFix( aPrefix );
1778 Insert(pPrj,LIST_APPEND);
1781 pCmdData = new CommandData;
1782 pCmdData->SetPath( aDirName );
1783 pCmdData->SetCommandType( nCommandType );
1784 pCmdData->SetCommandPara( aCommandPara );
1785 pCmdData->SetOSType( nOSType );
1786 pCmdData->SetLogFile( aLogFileName );
1787 pCmdData->SetClientRestriction( sClientRestriction );
1788 if ( pStaticDepList )
1789 pCmdData->SetDependencies( pStaticDepList );
1791 pStaticDepList = 0;
1792 pPrj->Insert ( pCmdData, LIST_APPEND );
1793 aDirName ="";
1794 aWhat ="";
1795 aWhatOS = "";
1796 sClientRestriction = "";
1797 aLogFileName = "";
1798 nCommandType = 0;
1799 nOSType = 0;
1801 i++;
1803 // und wer raeumt die depLst wieder ab ?
1804 // CommandData macht das
1807 /*****************************************************************************/
1808 BOOL Star::HasProject ( ByteString aProjectName )
1809 /*****************************************************************************/
1811 Prj *pPrj;
1812 int nCount_l;
1814 nCount_l = Count();
1816 for ( int i=0; i<nCount_l; i++)
1818 pPrj = GetObject(i);
1819 if ( pPrj->GetProjectName().ToLowerAscii() == aProjectName.ToLowerAscii() )
1820 return TRUE;
1822 return FALSE;
1825 /*****************************************************************************/
1826 Prj* Star::GetPrj ( ByteString aProjectName )
1827 /*****************************************************************************/
1829 Prj* pPrj;
1830 int nCount_l = Count();
1831 for ( int i=0;i<nCount_l;i++)
1833 pPrj = GetObject(i);
1834 if ( pPrj->GetProjectName().ToLowerAscii() == aProjectName.ToLowerAscii() )
1835 return pPrj;
1837 // return (Prj*)NULL;
1838 return 0L ;
1841 /*****************************************************************************/
1842 BOOL Star::RemovePrj ( Prj* pPrj )
1843 /*****************************************************************************/
1845 ULONG nPos = GetPos(pPrj);
1846 if (nPos != LIST_ENTRY_NOTFOUND) {
1847 delete pPrj;
1848 Remove(nPos);
1849 return TRUE;
1851 return FALSE;
1854 /*****************************************************************************/
1855 void Star::RemoveAllPrj ()
1856 /*****************************************************************************/
1858 Prj* pPrj = First();
1859 while (pPrj)
1861 delete pPrj;
1862 pPrj = Next();
1864 Clear();
1867 /*****************************************************************************/
1868 ByteString Star::GetPrjName( DirEntry &aPath )
1869 /*****************************************************************************/
1871 ByteString aRetPrj, aDirName;
1872 ByteString aFullPathName = ByteString( aPath.GetFull(), gsl_getSystemTextEncoding());
1874 USHORT nToken = aFullPathName.GetTokenCount(PATH_DELIMETER);
1875 for ( int i=0; i< nToken; i++ )
1877 aDirName = aFullPathName.GetToken( i, PATH_DELIMETER );
1878 if ( HasProject( aDirName ))
1880 aRetPrj = aDirName;
1881 break;
1885 return aRetPrj;
1888 /*****************************************************************************/
1889 void Star::ClearAvailableDeps ()
1890 /*****************************************************************************/
1892 if ( pAllDepMode )
1894 ByteString *pString = pAllDepMode->First();
1895 while ( pString )
1897 delete pString;
1898 pString = pAllDepMode->Next();
1900 delete pAllDepMode;
1901 pAllDepMode = NULL;
1905 /*****************************************************************************/
1906 void Star::ClearLoadedFilesList ()
1907 /*****************************************************************************/
1909 StarFile *pStarFile = aLoadedFilesList.First();
1910 while ( pStarFile )
1912 delete pStarFile;
1913 pStarFile = aLoadedFilesList.Next();
1915 aLoadedFilesList.Clear();
1918 /*****************************************************************************/
1919 void Star::ClearCurrentDeps ()
1920 /*****************************************************************************/
1922 if ( pDepMode )
1924 ByteString *pString = pDepMode->First();
1925 while ( pString )
1927 delete pString;
1928 pString = pDepMode->Next();
1930 delete pDepMode;
1931 pDepMode = NULL;
1935 /*****************************************************************************/
1936 SByteStringList* Star::GetAvailableDeps ()
1937 /*****************************************************************************/
1939 if ( pAllDepMode )
1940 return pAllDepMode;
1942 Prj *pPrj;
1943 ByteString* pStr;
1944 pPrj = First();
1945 while (pPrj)
1947 SByteStringList* pModeList = NULL;
1948 if (pPrj->GetModeAndDependencies() && (pModeList = pPrj->GetModeAndDependencies()->GetAllDepModes()))
1950 pStr = pModeList->First();
1951 while (pStr)
1953 if ( !pAllDepMode )
1954 pAllDepMode = new SByteStringList();
1956 if (pAllDepMode->IsString(pStr) == NOT_THERE)
1957 pAllDepMode->PutString(new ByteString(*pStr));
1959 pStr = pModeList->Next();
1962 pPrj = Next();
1964 return pAllDepMode;
1967 /*****************************************************************************/
1968 void Star::SetCurrentDeps (SByteStringList* pDepList)
1969 /*****************************************************************************/
1971 ClearCurrentDeps();
1973 if (pDepList)
1975 pDepMode = new SByteStringList();
1976 ByteString *pString = pDepList->First();
1977 while ( pString )
1979 ByteString* pStr = new ByteString (*pString);
1980 if (pDepMode->PutString(pStr) == NOT_THERE)
1981 delete pStr; // String is not in List
1982 pString = pDepList->Next();
1985 Expand_Impl();
1988 /*****************************************************************************/
1989 void Star::ReadXmlBuildList(const ByteString& sBuildLstPath) {
1990 /*****************************************************************************/
1991 if (mpXmlBuildList) {
1992 Prj* pPrj = NULL;
1994 try {
1995 mpXmlBuildList->loadXMLFile(sBuildLstPath);
1997 catch (XmlBuildListException) {
1998 DirEntry aDirEntry (sBuildLstPath);
1999 String ssPrjName = aDirEntry.GetPath().GetPath().GetBase();
2000 ByteString sPrjName = ByteString(ssPrjName, RTL_TEXTENCODING_ASCII_US);
2001 pPrj = GetPrj( sPrjName );
2002 if (pPrj)
2004 //remove old Project
2005 RemovePrj (pPrj);
2007 return;
2010 try {
2011 ByteString sProjectName = mpXmlBuildList->getModuleName();
2012 pPrj = GetPrj( sProjectName );
2013 if (pPrj)
2015 //remove old Project
2016 RemovePrj (pPrj);
2019 // insert new Project
2020 pPrj = new Prj ( sProjectName );
2021 pPrj->SetPreFix( sProjectName ); // use ProjectName as Prefix
2022 Insert(pPrj,LIST_APPEND);
2024 // get global dependencies
2025 FullByteStringListWrapper aProducts = mpXmlBuildList->getProducts();
2026 ByteString aDepType = ByteString(DEP_MD_ALWAYS_STR);
2027 if (mpXmlBuildList->hasModuleDepType(aProducts, aDepType))
2028 pPrj->HasHardDependencies( TRUE );
2030 aDepType = ByteString(DEP_MD_FORCE_STR);
2031 if (mpXmlBuildList->hasModuleDepType(aProducts, aDepType))
2033 pPrj->HasHardDependencies( TRUE );
2034 pPrj->HasFixedDependencies( TRUE );
2037 // modul dependencies
2038 ByteString sModulDepType = ByteString();
2039 FullByteStringListWrapper aModulDeps = mpXmlBuildList->getModuleDependencies(aProducts, sModulDepType);
2040 ByteString * pModulDep = aModulDeps.First();
2041 while (pModulDep)
2043 FullByteStringListWrapper aModulProducts = mpXmlBuildList->getModuleProducts(*pModulDep);
2044 ByteString *pModulePoduct = aModulProducts.First();
2045 while (pModulePoduct)
2047 if (*pModulePoduct == XML_ALL)
2048 pPrj->AddDependencies( *pModulDep );
2049 else
2050 pPrj->AddDependencies( *pModulDep, *pModulePoduct);
2052 pModulePoduct = aModulProducts.Next();
2054 pModulDep = aModulDeps.Next();
2057 // job dirs
2058 ByteString sJobType = ByteString();
2059 ByteString sJobPlatforms = ByteString();
2060 FullByteStringListWrapper aJobDirs = mpXmlBuildList->getJobDirectories(sJobType, sJobPlatforms); // all dirs
2061 ByteString* pJobDir = aJobDirs.First();
2062 while (pJobDir)
2064 FullByteStringListWrapper aJobPlatforms = mpXmlBuildList->getJobPlatforms (*pJobDir);
2065 ByteString* pJobPlatform = aJobPlatforms.First();
2066 while (pJobPlatform)
2068 ByteString sJobRestriction = ByteString();
2069 FullByteStringListWrapper aJobReq = mpXmlBuildList->getJobBuildReqs (*pJobDir, *pJobPlatform);
2070 // nur ein Req pro Platform wird zur Zeit unterstützt
2071 // mehr geht wegen der Struktur zur Zeit nicht!
2072 // lese sie trotzdem kommasepariert ein, wenn nötig
2073 if (aJobReq.Count() > 0)
2075 ByteString* pRestriction = aJobReq.First();
2076 sJobRestriction = ByteString (*pRestriction);
2077 pRestriction = aJobReq.Next();
2078 while (pRestriction)
2080 sJobRestriction += ByteString (",");
2081 sJobRestriction += ByteString (*pRestriction);
2082 pRestriction = aJobReq.Next();
2086 FullByteStringListWrapper aJobTypes = mpXmlBuildList->getJobTypes (*pJobDir);
2087 ByteString * pJobType = aJobTypes.First();
2088 while(pJobType)
2090 FullByteStringListWrapper aDirDependencies = mpXmlBuildList->getDirDependencies(*pJobDir, *pJobType, *pJobPlatform);
2091 SByteStringList *pDepList = NULL;
2092 if (aDirDependencies.Count() > 0)
2094 pDepList = new SByteStringList;
2095 ByteString* pDirDep = aDirDependencies.First();
2096 while (pDirDep)
2098 ByteString sFullDir = sProjectName;
2099 sFullDir += *pDirDep;
2100 sFullDir.SearchAndReplaceAll('/', '\\');
2101 *pDirDep = sFullDir;
2102 pDepList->PutString(pDirDep); // String wird übergeben
2103 aDirDependencies.Remove(); // Zeiger aus alter Liste löschen
2104 pDirDep = aDirDependencies.First();
2107 // insert CommandData
2108 CommandData * pCmdData = new CommandData;
2109 ByteString sRequiredPath = sProjectName;
2110 sRequiredPath += *pJobDir;
2111 sRequiredPath.SearchAndReplaceAll('/', '\\');
2112 pCmdData->SetPath(sRequiredPath);
2113 pCmdData->SetCommandType( GetJobType(*pJobType) );
2114 pCmdData->SetCommandPara( ByteString() );
2115 pCmdData->SetOSType( GetOSType(*pJobPlatform) );
2116 ByteString sLogFileName = sProjectName;
2117 sLogFileName += ByteString::CreateFromInt64( pPrj->Count() );
2118 pCmdData->SetLogFile( sLogFileName );
2119 pCmdData->SetClientRestriction( sJobRestriction );
2120 if ( pDepList )
2121 pCmdData->SetDependencies( pDepList );
2123 pPrj->Insert ( pCmdData, LIST_APPEND );
2125 pJobType = aJobTypes.Next();
2128 pJobPlatform = aJobPlatforms.Next();
2131 pJobDir = aJobDirs.Next();
2133 pPrj->ExtractDependencies();
2135 catch (XmlBuildListException) {
2136 if (pPrj)
2138 RemovePrj (pPrj);
2139 delete pPrj;
2146 /*****************************************************************************/
2147 int Star::GetOSType ( ByteString& aWhatOS ) {
2148 /*****************************************************************************/
2149 int nOSType = OS_NONE;
2150 if ( aWhatOS == "all" )
2151 nOSType = ( OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX | OS_MAC );
2152 else if ( aWhatOS == "w" || aWhatOS == "wnt" )
2153 nOSType = ( OS_WIN16 | OS_WIN32 );
2154 else if ( aWhatOS == "p" )
2155 nOSType = OS_OS2;
2156 else if ( aWhatOS == "u" || aWhatOS == "unx" )
2157 nOSType = OS_UNX;
2158 else if ( aWhatOS == "d" )
2159 nOSType = OS_WIN16;
2160 else if ( aWhatOS == "n" )
2161 nOSType = OS_WIN32;
2162 else if ( aWhatOS == "m" || aWhatOS == "mac" )
2163 nOSType = OS_MAC;
2164 return nOSType;
2168 /*****************************************************************************/
2169 int Star::GetJobType ( ByteString& JobType ) {
2170 /*****************************************************************************/
2171 int nCommandType = 0;
2172 if ( JobType == "nmake" || JobType == "make")
2173 nCommandType = COMMAND_NMAKE;
2174 else if ( JobType == "get" )
2175 nCommandType = COMMAND_GET;
2176 else {
2177 ULONG nOffset = JobType.Copy( 3 ).ToInt32();
2178 nCommandType = COMMAND_USER_START + nOffset - 1;
2180 return nCommandType;
2183 /*****************************************************************************/
2184 void Star::PutPrjIntoStream (SByteStringList* pPrjNameList, SvStream* pStream)
2185 /*****************************************************************************/
2187 aMutex.acquire();
2188 *pStream << sal_False; // not full Star / only some Projects
2190 ULONG nCount_l = pPrjNameList->Count();
2191 *pStream << nCount_l;
2192 ByteString* pStr = pPrjNameList->First();
2193 while (pStr) {
2194 Prj* pPrj = GetPrj (*pStr);
2195 *pPrj >> *pStream;
2196 pStr = pPrjNameList->Next();
2198 aMutex.release();
2201 /*****************************************************************************/
2202 Star& Star::operator>> ( SvStream& rStream )
2203 /*****************************************************************************/
2205 aMutex.acquire();
2206 rStream << sal_True; // full Star
2207 rStream << nStarMode;
2208 if (pDepMode)
2210 rStream << sal_True;
2211 *pDepMode >> rStream;
2213 else
2214 rStream << sal_False;
2216 ULONG nCount_l = Count();
2217 rStream << nCount_l;
2218 Prj* pPrj = First();
2219 while (pPrj) {
2220 *pPrj >> rStream;
2221 pPrj = Next();
2223 aMutex.release();
2225 return *this;
2228 /*****************************************************************************/
2229 Star& Star::operator<< ( SvStream& rStream )
2230 /*****************************************************************************/
2232 aMutex.acquire();
2233 BOOL bFullList;
2234 rStream >> bFullList;
2235 if (bFullList)
2237 rStream >> nStarMode;
2238 BOOL bDepMode;
2239 rStream >> bDepMode;
2240 if (pDepMode)
2241 pDepMode->CleanUp();
2242 if (bDepMode)
2244 if (!pDepMode)
2245 pDepMode = new SByteStringList();
2246 *pDepMode << rStream;
2248 else
2249 DELETEZ (pDepMode);
2252 ULONG nCount_l;
2253 rStream >> nCount_l;
2254 for ( USHORT i = 0; i < nCount_l; i++ ) {
2255 Prj* pPrj = new Prj();
2256 *pPrj << rStream;
2257 pPrj->SetMode(pDepMode);
2258 if (HasProject (pPrj->GetProjectName())) {
2259 Prj* pTmpPrj = GetPrj( pPrj->GetProjectName() );
2260 Replace (pPrj, pTmpPrj);
2261 delete pTmpPrj;
2263 else
2264 Insert (pPrj, LIST_APPEND);
2266 Expand_Impl();
2267 aMutex.release();
2268 return *this;
2274 // class StarWriter
2277 /*****************************************************************************/
2278 StarWriter::StarWriter( XmlBuildList* pXmlBuildListObj, String aFileName, BOOL bReadComments, USHORT nMode )
2279 /*****************************************************************************/
2280 : Star (pXmlBuildListObj)
2282 sFileName = aFileName;
2283 Read ( aFileName, bReadComments, nMode );
2286 /*****************************************************************************/
2287 StarWriter::StarWriter( XmlBuildList* pXmlBuildListObj, SolarFileList *pSolarFiles, BOOL bReadComments )
2288 /*****************************************************************************/
2289 : Star (pXmlBuildListObj)
2291 Read( pSolarFiles, bReadComments );
2294 /*****************************************************************************/
2295 StarWriter::StarWriter( XmlBuildList* pXmlBuildListObj, GenericInformationList *pStandLst, ByteString &rVersion,
2296 ByteString &rMinor, BOOL bReadComments, BOOL bLocal, const char *pSourceRoot )
2297 /*****************************************************************************/
2298 : Star (pXmlBuildListObj)
2300 ByteString sPath( rVersion );
2301 if ( pSourceRoot )
2302 sSourceRoot = String::CreateFromAscii( pSourceRoot );
2304 #ifdef UNX
2305 sPath += "/settings/UNXSOLARLIST";
2306 #else
2307 sPath += "/settings/SOLARLIST";
2308 #endif
2309 GenericInformation *pInfo_l = pStandLst->GetInfo( sPath, TRUE );
2311 if( pInfo_l && pInfo_l->GetValue().Len()) {
2312 ByteString sFile( pInfo_l->GetValue());
2313 if ( bLocal ) {
2314 IniManager aIniManager;
2315 aIniManager.ToLocal( sFile );
2317 String sFileName_l( sFile, RTL_TEXTENCODING_ASCII_US );
2318 nStarMode = STAR_MODE_SINGLE_PARSE;
2319 Read( sFileName_l, bReadComments );
2321 else {
2322 SolarFileList *pFileList = new SolarFileList();
2324 sPath = rVersion;
2325 sPath += "/drives";
2327 GenericInformation *pInfo_k = pStandLst->GetInfo( sPath, TRUE );
2328 if ( pInfo_k && pInfo_k->GetSubList()) {
2329 GenericInformationList *pDrives = pInfo_k->GetSubList();
2330 for ( ULONG i = 0; i < pDrives->Count(); i++ ) {
2331 GenericInformation *pDrive = pDrives->GetObject( i );
2332 if ( pDrive ) {
2333 DirEntry aEntry;
2334 BOOL bOk = FALSE;
2335 if ( sSourceRoot.Len()) {
2336 aEntry = DirEntry( sSourceRoot );
2337 bOk = TRUE;
2339 else {
2340 #ifdef UNX
2341 sPath = "UnixVolume";
2342 GenericInformation *pUnixVolume = pDrive->GetSubInfo( sPath );
2343 if ( pUnixVolume ) {
2344 String sRoot( pUnixVolume->GetValue(), RTL_TEXTENCODING_ASCII_US );
2345 aEntry = DirEntry( sRoot );
2346 bOk = TRUE;
2348 #else
2349 bOk = TRUE;
2350 String sRoot( *pDrive, RTL_TEXTENCODING_ASCII_US );
2351 sRoot += String::CreateFromAscii( "\\" );
2352 aEntry = DirEntry( sRoot );
2353 #endif
2355 if ( bOk ) {
2356 sPath = "projects";
2357 GenericInformation *pProjectsKey = pDrive->GetSubInfo( sPath, TRUE );
2358 if ( pProjectsKey ) {
2359 if ( !sSourceRoot.Len()) {
2360 sPath = rVersion;
2361 sPath += "/settings/PATH";
2362 GenericInformation *pPath = pStandLst->GetInfo( sPath, TRUE );
2363 if( pPath ) {
2364 ByteString sAddPath( pPath->GetValue());
2365 #ifdef UNX
2366 sAddPath.SearchAndReplaceAll( "\\", "/" );
2367 #else
2368 sAddPath.SearchAndReplaceAll( "/", "\\" );
2369 #endif
2370 //If Minor has been set add it to path
2371 if (rMinor.Len()>0) {
2372 sAddPath += ".";
2373 sAddPath += rMinor;
2375 String ssAddPath( sAddPath, RTL_TEXTENCODING_ASCII_US );
2377 aEntry += DirEntry( ssAddPath );
2380 sSourceRoot = aEntry.GetFull();
2381 GenericInformationList *pProjects = pProjectsKey->GetSubList();
2382 if ( pProjects ) {
2383 String sPrjDir( String::CreateFromAscii( "prj" ));
2384 String sSolarFile( String::CreateFromAscii( "build.lst" ));
2386 GenericInformation * pProject = pProjects->First();
2387 while (pProject) {
2388 ByteString sProject( *pProject);
2389 String ssProject( sProject, RTL_TEXTENCODING_ASCII_US );
2391 DirEntry aPrjEntry( aEntry );
2393 ByteString aDirStr ("Directory");
2394 GenericInformation * pDir = pProject->GetSubInfo (aDirStr);
2395 if (pDir) {
2396 ByteString aDir = pDir->GetValue();
2397 aPrjEntry = aEntry.GetPath() + DirEntry(aDir);
2400 aPrjEntry += DirEntry( ssProject );
2401 aPrjEntry += DirEntry( sPrjDir );
2402 aPrjEntry += DirEntry( sSolarFile );
2404 pFileList->Insert( new String( aPrjEntry.GetFull()), LIST_APPEND );
2406 ByteString sFile( aPrjEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
2407 fprintf( stdout, "%s\n", sFile.GetBuffer());
2408 pProject = pProjects->Next();
2416 Read( pFileList, bReadComments );
2420 /*****************************************************************************/
2421 void StarWriter::CleanUp()
2422 /*****************************************************************************/
2424 Expand_Impl();
2427 /*****************************************************************************/
2428 USHORT StarWriter::Read( String aFileName, BOOL bReadComments, USHORT nMode )
2429 /*****************************************************************************/
2431 sFileName = aFileName;
2433 nStarMode = nMode;
2435 ByteString aString;
2436 aFileList.Insert( new String( aFileName ));
2438 DirEntry aEntry( aFileName );
2439 aEntry.ToAbs();
2440 aEntry = aEntry.GetPath().GetPath().GetPath();
2441 sSourceRoot = aEntry.GetFull();
2443 while( aFileList.Count()) {
2444 String ssFileName = *aFileList.GetObject(( ULONG ) 0 );
2445 ByteString sFileName_l(ssFileName, RTL_TEXTENCODING_ASCII_US);
2446 StarFile *pFile = new StarFile( ssFileName );
2447 if ( pFile->Exists()) {
2448 if (sFileName_l.Len() >= RTL_CONSTASCII_LENGTH(XML_EXT) && ssFileName.EqualsAscii(XML_EXT, sFileName_l.Len() - RTL_CONSTASCII_LENGTH(XML_EXT), RTL_CONSTASCII_LENGTH(XML_EXT)))
2450 ReadXmlBuildList(sFileName_l);
2451 } else {
2452 SimpleConfig aSolarConfig( ssFileName );
2453 while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != "" )
2454 InsertTokenLine ( aString );
2458 aMutex.acquire();
2459 aLoadedFilesList.Insert( pFile, LIST_APPEND );
2460 aMutex.release();
2461 delete aFileList.Remove(( ULONG ) 0 );
2463 // resolve all dependencies recursive
2464 Expand_Impl();
2466 // Die gefundenen Abhaengigkeiten rekursiv aufloesen
2467 Expand_Impl();
2468 return 0;
2471 /*****************************************************************************/
2472 USHORT StarWriter::Read( SolarFileList *pSolarFiles, BOOL bReadComments )
2473 /*****************************************************************************/
2475 nStarMode = STAR_MODE_MULTIPLE_PARSE;
2477 // this ctor is used by StarBuilder to get the information for the whole workspace
2478 while( pSolarFiles->Count()) {
2479 ByteString aString;
2480 String ssFileName = *pSolarFiles->GetObject(( ULONG ) 0 );
2481 ByteString sFileName_l(ssFileName, RTL_TEXTENCODING_ASCII_US);
2482 StarFile *pFile = new StarFile( ssFileName);
2483 if ( pFile->Exists()) {
2484 if (sFileName_l.Len() >= RTL_CONSTASCII_LENGTH(XML_EXT) && ssFileName.EqualsAscii(XML_EXT, sFileName_l.Len() - RTL_CONSTASCII_LENGTH(XML_EXT), RTL_CONSTASCII_LENGTH(XML_EXT)))
2486 ReadXmlBuildList(sFileName_l);
2488 else
2490 SimpleConfig aSolarConfig( ssFileName );
2491 while (( aString = aSolarConfig.GetCleanedNextLine( bReadComments )) != "" )
2492 InsertTokenLine ( aString );
2496 aMutex.acquire();
2497 aLoadedFilesList.Insert( pFile, LIST_APPEND );
2498 aMutex.release();
2499 delete pSolarFiles->Remove(( ULONG ) 0 );
2501 delete pSolarFiles;
2503 Expand_Impl();
2504 return 0;
2507 /*****************************************************************************/
2508 USHORT StarWriter::WritePrj( Prj *pPrj, SvFileStream& rStream )
2509 /*****************************************************************************/
2511 ByteString aDataString;
2512 ByteString aTab('\t');
2513 ByteString aSpace(' ');
2514 ByteString aEmptyString("");
2515 SByteStringList* pCmdDepList;
2516 SByteStringList* pPrjDepList;
2518 CommandData* pCmdData = NULL;
2519 if ( pPrj->Count() > 0 )
2521 pCmdData = pPrj->First();
2522 if ( (pPrjDepList = pPrj->GetDependencies( FALSE )) )
2524 aDataString = pPrj->GetPreFix();
2525 aDataString += aTab;
2526 aDataString += pPrj->GetProjectName();
2527 aDataString += aTab;
2528 if ( pPrj->HasFixedDependencies())
2529 aDataString+= ByteString(":::");
2530 else if ( pPrj->HasHardDependencies())
2531 aDataString+= ByteString("::");
2532 else
2533 aDataString+= ByteString(":");
2534 aDataString += aTab;
2535 for ( USHORT i = 0; i< pPrjDepList->Count(); i++ ) {
2536 aDataString += *pPrjDepList->GetObject( i );
2537 aDataString += aSpace;
2539 aDataString+= "NULL";
2541 rStream.WriteLine( aDataString );
2543 pCmdData = pPrj->Next();
2545 if ( pCmdData ) {
2548 if (( aDataString = pCmdData->GetComment()) == aEmptyString )
2550 aDataString = pPrj->GetPreFix();
2551 aDataString += aTab;
2553 aDataString+= pCmdData->GetPath();
2554 aDataString += aTab;
2555 USHORT nPathLen = pCmdData->GetPath().Len();
2556 if ( nPathLen < 40 )
2557 for ( int i = 0; i < 9 - pCmdData->GetPath().Len() / 4 ; i++ )
2558 aDataString += aTab;
2559 else
2560 for ( int i = 0; i < 12 - pCmdData->GetPath().Len() / 4 ; i++ )
2561 aDataString += aTab;
2562 aDataString += pCmdData->GetCommandTypeString();
2563 aDataString += aTab;
2564 if ( pCmdData->GetCommandType() == COMMAND_GET )
2565 aDataString += aTab;
2566 if ( pCmdData->GetCommandPara() == aEmptyString )
2567 aDataString+= ByteString("-");
2568 else
2569 aDataString+= pCmdData->GetCommandPara();
2570 aDataString += aTab;
2571 aDataString+= pCmdData->GetOSTypeString();
2572 if ( pCmdData->GetClientRestriction().Len()) {
2573 aDataString += ByteString( "," );
2574 aDataString += pCmdData->GetClientRestriction();
2576 aDataString += aTab;
2577 aDataString += pCmdData->GetLogFile();
2578 aDataString += aSpace;
2580 pCmdDepList = pCmdData->GetDependencies();
2581 if ( pCmdDepList )
2582 for ( USHORT i = 0; i< pCmdDepList->Count(); i++ ) {
2583 aDataString += *pCmdDepList->GetObject( i );
2584 aDataString += aSpace;
2586 aDataString += "NULL";
2589 rStream.WriteLine( aDataString );
2591 pCmdData = pPrj->Next();
2592 } while ( pCmdData );
2595 return 0;
2598 /*****************************************************************************/
2599 USHORT StarWriter::Write( String aFileName )
2600 /*****************************************************************************/
2602 sFileName = aFileName;
2604 FileStat::SetReadOnlyFlag( DirEntry( aFileName ), FALSE );
2606 SvFileStream aFileStream;
2608 aFileStream.Open( aFileName, STREAM_WRITE | STREAM_TRUNC);
2609 if ( !aFileStream.IsOpen() && aFileIOErrorHdl.IsSet()) {
2610 String sError( String::CreateFromAscii( "Error: Unable to open \"" ));
2611 sError += aFileName;
2612 sError += String::CreateFromAscii( "for writing!" );
2613 aFileIOErrorHdl.Call( &sError );
2616 if ( Count() > 0 )
2618 Prj* pPrj = First();
2621 WritePrj( pPrj, aFileStream );
2622 pPrj = Next();
2623 } while ( pPrj );
2626 aFileStream.Close();
2628 return 0;
2631 /*****************************************************************************/
2632 USHORT StarWriter::WriteMultiple( String rSourceRoot )
2633 /*****************************************************************************/
2635 sSourceRoot = rSourceRoot;
2637 if ( Count() > 0 )
2639 String sPrjDir( String::CreateFromAscii( "prj" ));
2640 String sSolarFile( String::CreateFromAscii( "build.lst" ));
2642 Prj* pPrj = First();
2645 String sName( pPrj->GetProjectName(), RTL_TEXTENCODING_ASCII_US );
2647 DirEntry aEntry( rSourceRoot );
2648 aEntry += DirEntry( sName );
2649 aEntry += DirEntry( sPrjDir );
2650 aEntry += DirEntry( sSolarFile );
2652 FileStat::SetReadOnlyFlag( aEntry, FALSE );
2654 SvFileStream aFileStream;
2655 aFileStream.Open( aEntry.GetFull(), STREAM_WRITE | STREAM_TRUNC);
2657 if ( !aFileStream.IsOpen() && aFileIOErrorHdl.IsSet()) {
2658 String sError( String::CreateFromAscii( "Error: Unable to open \"" ));
2659 sError += aEntry.GetFull();
2660 sError += String::CreateFromAscii( "for writing!" );
2661 aFileIOErrorHdl.Call( &sError );
2664 WritePrj( pPrj, aFileStream );
2666 aFileStream.Close();
2668 pPrj = Next();
2669 } while ( pPrj );
2672 return 0;
2675 /*****************************************************************************/
2676 void StarWriter::InsertTokenLine ( ByteString& rString )
2677 /*****************************************************************************/
2679 int i = 0;
2680 ByteString aWhat, aWhatOS,
2681 sClientRestriction, aLogFileName, aProjectName, aPrefix, aCommandPara;
2682 static ByteString aDirName;
2683 BOOL bPrjDep = FALSE;
2684 BOOL bHardDep = FALSE;
2685 BOOL bFixedDep = FALSE;
2686 int nCommandType=0, nOSType=0;
2687 CommandData* pCmdData;
2688 SByteStringList *pDepList2 = NULL;
2689 Prj* pPrj;
2691 ByteString aEmptyString;
2692 ByteString aToken = rString.GetToken( 0, '\t' );
2693 ByteString aCommentString;
2695 const char* yytext = aToken.GetBuffer();
2697 while ( !( aToken == aEmptyString ) )
2699 switch (i)
2701 case 0:
2702 if ( rString.Search( "#" ) == 0 )
2704 i = -1;
2705 aCommentString = rString;
2706 rString = aEmptyString;
2707 if ( Count() == 0 )
2708 aDirName = "null_entry" ; //comments at begin of file
2709 break;
2711 aPrefix = yytext;
2712 pDepList2 = NULL;
2713 break;
2714 case 1:
2715 aDirName = yytext;
2716 break;
2717 case 2:
2718 if ( !strcmp( yytext, ":" ))
2720 bPrjDep = TRUE;
2721 bHardDep = FALSE;
2722 bFixedDep = FALSE;
2723 i = 9;
2725 else if ( !strcmp( yytext, "::" ))
2727 bPrjDep = TRUE;
2728 bHardDep = TRUE;
2729 bFixedDep = FALSE;
2730 i = 9;
2732 else if ( !strcmp( yytext, ":::" ))
2734 bPrjDep = TRUE;
2735 bHardDep = TRUE;
2736 bFixedDep = TRUE;
2737 i = 9;
2739 else
2741 bPrjDep = FALSE;
2742 bHardDep = FALSE;
2743 bFixedDep = FALSE;
2745 aWhat = yytext;
2746 nCommandType = GetJobType(aWhat);
2748 break;
2749 case 3:
2750 if ( !bPrjDep )
2752 aWhat = yytext;
2753 if ( aWhat == "-" )
2755 aCommandPara = ByteString();
2757 else
2758 aCommandPara = aWhat;
2760 break;
2761 case 4:
2762 if ( !bPrjDep )
2764 aWhatOS = yytext;
2765 if ( aWhatOS.GetTokenCount( ',' ) > 1 ) {
2766 sClientRestriction = aWhatOS.Copy( aWhatOS.GetToken( 0, ',' ).Len() + 1 );
2767 aWhatOS = aWhatOS.GetToken( 0, ',' );
2769 nOSType = GetOSType (aWhatOS);
2771 break;
2772 case 5:
2773 if ( !bPrjDep )
2775 aLogFileName = yytext;
2777 break;
2778 default:
2779 if ( !bPrjDep )
2781 ByteString aItem = yytext;
2782 if ( aItem == "NULL" )
2784 // Liste zu Ende
2785 i = -1;
2787 else
2789 // ggfs. Dependency liste anlegen und ergaenzen
2790 if ( !pDepList2 )
2791 pDepList2 = new SByteStringList;
2792 pDepList2->PutString( new ByteString( aItem ));
2795 else
2797 ByteString aItem = yytext;
2798 if ( aItem == "NULL" )
2800 // Liste zu Ende
2801 i = -1;
2802 bPrjDep= FALSE;
2804 else
2806 ByteString sMode;
2807 BOOL bHasModes = FALSE;
2808 if (aItem.Search(":") != STRING_NOTFOUND)
2810 sMode = aItem.GetToken ( 0, ':');
2811 aItem = aItem.GetToken ( 1, ':');
2812 bHasModes = TRUE;
2815 aProjectName = aDirName.GetToken ( 0, 0x5c);
2816 if ( HasProject( aProjectName ))
2818 pPrj = GetPrj( aProjectName );
2819 // Projekt exist. schon, neue Eintraege anhaengen
2821 else
2823 // neues Project anlegen
2824 pPrj = new Prj ( aProjectName );
2825 pPrj->SetPreFix( aPrefix );
2826 Insert(pPrj,LIST_APPEND);
2828 if (bHasModes)
2829 pPrj->AddDependencies( aItem, sMode );
2830 else
2831 pPrj->AddDependencies( aItem );
2832 pPrj->HasHardDependencies( bHardDep );
2833 pPrj->HasFixedDependencies( bFixedDep );
2836 if ( nStarMode == STAR_MODE_RECURSIVE_PARSE ) {
2837 String sItem( aItem, RTL_TEXTENCODING_ASCII_US );
2838 InsertSolarList( sItem );
2844 break;
2846 /* Wenn dieses Project noch nicht vertreten ist, in die Liste
2847 der Solar-Projekte einfuegen */
2848 if ( i == -1 )
2850 aProjectName = aDirName.GetToken ( 0, 0x5c);
2851 if ( HasProject( aProjectName ))
2853 pPrj = GetPrj( aProjectName );
2854 // Projekt exist. schon, neue Eintraege anhaengen
2856 else
2858 // neues Project anlegen
2859 pPrj = new Prj ( aProjectName );
2860 pPrj->SetPreFix( aPrefix );
2861 Insert(pPrj,LIST_APPEND);
2864 pCmdData = new CommandData;
2865 pCmdData->SetPath( aDirName );
2866 pCmdData->SetCommandType( nCommandType );
2867 pCmdData->SetCommandPara( aCommandPara );
2868 pCmdData->SetOSType( nOSType );
2869 pCmdData->SetLogFile( aLogFileName );
2870 pCmdData->SetComment( aCommentString );
2871 pCmdData->SetClientRestriction( sClientRestriction );
2872 if ( pDepList2 )
2873 pCmdData->SetDependencies( pDepList2 );
2875 pPrj->Insert ( pCmdData, LIST_APPEND );
2878 i++;
2880 rString.Erase(0, aToken.Len()+1);
2881 aToken = rString.GetToken( 0, '\t' );
2882 yytext = aToken.GetBuffer();
2885 // und wer raeumt die depLst wieder ab ?
2886 // macht CommandData selber
2889 /*****************************************************************************/
2890 BOOL StarWriter::InsertProject ( Prj* /*pNewPrj*/ )
2891 /*****************************************************************************/
2893 return FALSE;
2896 /*****************************************************************************/
2897 Prj* StarWriter::RemoveProject ( ByteString aProjectName )
2898 /*****************************************************************************/
2900 ULONG nCount_l = Count();
2901 Prj* pPrj;
2902 Prj* pPrjFound = NULL;
2903 SByteStringList* pPrjDeps;
2905 for ( USHORT i = 0; i < nCount_l; i++ )
2907 pPrj = GetObject( i );
2908 if ( pPrj->GetProjectName() == aProjectName )
2909 pPrjFound = pPrj;
2910 else
2912 pPrjDeps = pPrj->GetDependencies( FALSE );
2913 if ( pPrjDeps )
2915 ByteString* pString;
2916 ULONG nPrjDepsCount = pPrjDeps->Count();
2917 for ( ULONG j = nPrjDepsCount; j > 0; j-- )
2919 pString = pPrjDeps->GetObject( j - 1 );
2920 if ( pString->GetToken( 0, '.') == aProjectName )
2921 pPrjDeps->Remove( pString );
2927 Remove( pPrjFound );
2929 return pPrjFound;
2933 // class StarFile
2936 /*****************************************************************************/
2937 StarFile::StarFile( const String &rFile )
2938 /*****************************************************************************/
2939 : aFileName( rFile )
2941 DirEntry aEntry( aFileName );
2942 if ( aEntry.Exists()) {
2943 bExists = TRUE;
2944 FileStat aStat( aEntry );
2945 aDate = aStat.DateModified();
2946 aTime = aStat.TimeModified();
2947 aDateCreated = aStat.DateCreated();
2948 aTimeCreated = aStat.TimeCreated();
2950 else
2951 bExists = FALSE;
2954 /*****************************************************************************/
2955 BOOL StarFile::NeedsUpdate()
2956 /*****************************************************************************/
2958 DirEntry aEntry( aFileName );
2959 if ( aEntry.Exists()) {
2960 if ( !bExists ) {
2961 bExists = TRUE;
2962 return TRUE;
2964 FileStat aStat( aEntry );
2965 if (( aStat.DateModified() != aDate ) || ( aStat.TimeModified() != aTime )
2966 || ( aStat.DateCreated() != aDateCreated ) || ( aStat.TimeCreated() != aTimeCreated ))
2967 return TRUE;
2969 return FALSE;