xref: /aoo42x/main/tools/inc/bootstrp/mkcreate.hxx (revision ebc38751)
18b851043SAndrew Rist /**************************************************************
2*ebc38751Smseidel  *
38b851043SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
48b851043SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
58b851043SAndrew Rist  * distributed with this work for additional information
68b851043SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
78b851043SAndrew Rist  * to you under the Apache License, Version 2.0 (the
88b851043SAndrew Rist  * "License"); you may not use this file except in compliance
98b851043SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ebc38751Smseidel  *
118b851043SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ebc38751Smseidel  *
138b851043SAndrew Rist  * Unless required by applicable law or agreed to in writing,
148b851043SAndrew Rist  * software distributed under the License is distributed on an
158b851043SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
168b851043SAndrew Rist  * KIND, either express or implied.  See the License for the
178b851043SAndrew Rist  * specific language governing permissions and limitations
188b851043SAndrew Rist  * under the License.
19*ebc38751Smseidel  *
208b851043SAndrew Rist  *************************************************************/
218b851043SAndrew Rist 
228b851043SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _MK_CREATE_HXX
25cdf0e10cSrcweir #define _MK_CREATE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/string.hxx>
28cdf0e10cSrcweir //#include "bootstrp/sstring.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir DECLARE_LIST( UniStringList, UniString* )
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <tools/list.hxx>
33cdf0e10cSrcweir #include "bootstrp/prj.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir class SvStream;
36cdf0e10cSrcweir class SourceDirectoryList;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //
39cdf0e10cSrcweir // class SourceDirectoryDependency
40cdf0e10cSrcweir //
41cdf0e10cSrcweir 
42cdf0e10cSrcweir class CodedDependency : public ByteString
43cdf0e10cSrcweir {
44cdf0e10cSrcweir private:
45*ebc38751Smseidel 	sal_uInt16 nOSType;							// operating systems where dependency exists
46cdf0e10cSrcweir 
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir 	/* create a dependency instance with given coded directory name
49cdf0e10cSrcweir 	 */
CodedDependency(const ByteString & rCodedIdentifier,sal_uInt16 nOperatingSystems)50cdf0e10cSrcweir 	CodedDependency(
51cdf0e10cSrcweir 		const ByteString &rCodedIdentifier, // the coded name of the directory
52cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
53cdf0e10cSrcweir 	) :
54cdf0e10cSrcweir 	ByteString( rCodedIdentifier ),
55cdf0e10cSrcweir 	nOSType( nOperatingSystems )
56cdf0e10cSrcweir 	{
57cdf0e10cSrcweir 	}
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	/* returns the operating system
60cdf0e10cSrcweir 	 */
GetOperatingSystem()61cdf0e10cSrcweir 	sal_uInt16 GetOperatingSystem()
62cdf0e10cSrcweir 	{
63cdf0e10cSrcweir 		return nOSType;
64cdf0e10cSrcweir 	}
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	/* set operating system
67cdf0e10cSrcweir 	 */
SetOperatingSystem(sal_uInt16 nOperatingSystems)68cdf0e10cSrcweir 	void SetOperatingSystem( sal_uInt16 nOperatingSystems )
69cdf0e10cSrcweir 	{
70cdf0e10cSrcweir 		nOSType = nOperatingSystems;
71cdf0e10cSrcweir 	}
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	/* add operating systems if same dependency
74cdf0e10cSrcweir 	 */
TryToMerge(const ByteString & rCodedIdentifier,sal_uInt16 nOperatingSystems)75cdf0e10cSrcweir 	sal_Bool TryToMerge(
76cdf0e10cSrcweir 		const ByteString &rCodedIdentifier, // the coded name of the directory
77cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
78cdf0e10cSrcweir 	)
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		if ( rCodedIdentifier != *this )
81cdf0e10cSrcweir 			return sal_False;
82cdf0e10cSrcweir 		nOSType |= nOperatingSystems;
83cdf0e10cSrcweir 		return sal_True;
84cdf0e10cSrcweir 	}
85cdf0e10cSrcweir };
86cdf0e10cSrcweir 
87cdf0e10cSrcweir //
88cdf0e10cSrcweir // class Dependecy
89cdf0e10cSrcweir //
90cdf0e10cSrcweir 
91cdf0e10cSrcweir class Dependency : public ByteString
92cdf0e10cSrcweir {
93cdf0e10cSrcweir private:
94*ebc38751Smseidel 	sal_uInt16 nOSType;							// operating systems where dependency exists
95cdf0e10cSrcweir 
96cdf0e10cSrcweir public:
97cdf0e10cSrcweir 	/* create a dependency instance with given directory name
98cdf0e10cSrcweir 	 */
Dependency(const ByteString & rDirectoryName,sal_uInt16 nOperatingSystems)99cdf0e10cSrcweir 	Dependency(
100cdf0e10cSrcweir 		const ByteString &rDirectoryName, 	// the coded name of the directory
101cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
102cdf0e10cSrcweir 	) :
103cdf0e10cSrcweir 	ByteString( rDirectoryName ),
104cdf0e10cSrcweir 	nOSType( nOperatingSystems )
105cdf0e10cSrcweir 	{
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	/* returns the operating system
109cdf0e10cSrcweir 	 */
GetOperatingSystem()110cdf0e10cSrcweir 	sal_uInt16 GetOperatingSystem()
111cdf0e10cSrcweir 	{
112cdf0e10cSrcweir 		return nOSType;
113cdf0e10cSrcweir 	}
114cdf0e10cSrcweir };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir //
117cdf0e10cSrcweir // class SourceDirectory
118cdf0e10cSrcweir //
119cdf0e10cSrcweir 
120cdf0e10cSrcweir class SourceDirectory : public ByteString
121cdf0e10cSrcweir {
122cdf0e10cSrcweir private:
123cdf0e10cSrcweir 	SourceDirectory *pParent;				// the parent directory
124cdf0e10cSrcweir 	SourceDirectoryList *pSubDirectories;	// list of sub directories
125cdf0e10cSrcweir 	sal_uInt16 nOSType;							// operating systems where this directory is used
126cdf0e10cSrcweir 	sal_uInt16 nDepth;							// depth of directory structure (root is 0)
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	SByteStringList *pDependencies;			// dependencies on other directories in this depth
129cdf0e10cSrcweir 
130*ebc38751Smseidel 	SByteStringList *pCodedDependencies;	// dependencies on other directories in different depth
131*ebc38751Smseidel 	SByteStringList *pCodedIdentifier;		// symbolic identifier to resolve dependencies
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	/* try to resolve a single dependency
134cdf0e10cSrcweir 	 */
135cdf0e10cSrcweir 	Dependency *ResolvesDependency(
136cdf0e10cSrcweir 		CodedDependency *pCodedDependency 	// the dependency
137cdf0e10cSrcweir 	);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	/* returns the operating systems of a coded dependency
140cdf0e10cSrcweir 	 */
141cdf0e10cSrcweir 	static sal_uInt16 GetOSType(
142cdf0e10cSrcweir 		const ByteString &sDependExt 		// the corresponding dependency extension (see also prj.hxx)
143cdf0e10cSrcweir 	);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	/* removes this and all sub directories with all dependencies
146cdf0e10cSrcweir 	 */
147cdf0e10cSrcweir 	sal_Bool RemoveDirectoryTreeAndAllDependencies();
148cdf0e10cSrcweir 
149cdf0e10cSrcweir public:
150cdf0e10cSrcweir 
151*ebc38751Smseidel 	/* create a directory instance with given parent and name, no parent means this is the root
152cdf0e10cSrcweir 	 * (not the file system root but the root of the source tree, e.g. o:\569)
153cdf0e10cSrcweir 	 */
154cdf0e10cSrcweir 	SourceDirectory(
155cdf0e10cSrcweir 		const ByteString &rDirectoryName, 			// name without parent
156cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem,					// the operating systems where this directory is used
157cdf0e10cSrcweir 		SourceDirectory *pParentDirectory = NULL 	// parent (if not root)
158cdf0e10cSrcweir 	);
159cdf0e10cSrcweir 	~SourceDirectory();
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	/* returns the full absolute path of this directory
162cdf0e10cSrcweir 	 */
163cdf0e10cSrcweir 	ByteString GetFullPath();
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	/* returns a list of all sub directories
166cdf0e10cSrcweir 	 */
GetSubDirectories()167cdf0e10cSrcweir 	SourceDirectoryList *GetSubDirectories() { return pSubDirectories; }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	/* returns the Operating systems where this directory is used
170cdf0e10cSrcweir 	 */
GetOperatingSystems()171cdf0e10cSrcweir 	sal_uInt16 GetOperatingSystems() { return nOSType; }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	/* returns the given directory
174cdf0e10cSrcweir 	 */
175cdf0e10cSrcweir 	SourceDirectory *GetDirectory(
176cdf0e10cSrcweir 		const ByteString &rDirectoryName,	// full path
177cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
178cdf0e10cSrcweir 	);
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	/* create the directory and all mandatory parents
181cdf0e10cSrcweir 	 */
InsertFull(const ByteString & rDirectoryName,sal_uInt16 nOperatingSystem)182cdf0e10cSrcweir 	SourceDirectory *InsertFull(
183cdf0e10cSrcweir 		const ByteString &rDirectoryName,	// full path
184cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
185cdf0e10cSrcweir 	)
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		return GetDirectory( rDirectoryName, nOperatingSystem );
188cdf0e10cSrcweir 	}
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	/* create the directory as sub directory of this directory
191cdf0e10cSrcweir 	 */
192cdf0e10cSrcweir 	SourceDirectory *Insert(
193cdf0e10cSrcweir 		const ByteString &rDirectoryName,	// name without parent
194cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
195cdf0e10cSrcweir 	);
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 	/* get the root directory
198cdf0e10cSrcweir 	 */
199cdf0e10cSrcweir 	SourceDirectory *GetRootDirectory();
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	/* get sub directory if exists
202cdf0e10cSrcweir 	 */
203cdf0e10cSrcweir 	SourceDirectory *GetSubDirectory(
204cdf0e10cSrcweir 		const ByteString &rDirectoryPath,	// full sub path
205cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
206cdf0e10cSrcweir 	);
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	/* add a dependency for several platforms
209cdf0e10cSrcweir 	 */
210cdf0e10cSrcweir 	CodedDependency *AddCodedDependency(
211cdf0e10cSrcweir 		const ByteString &rCodedIdentifier, // the coded name of the directory
212cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
213cdf0e10cSrcweir 	);
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	/* returns the dependency list
216cdf0e10cSrcweir 	 */
GetCodedDependencies()217cdf0e10cSrcweir 	SByteStringList *GetCodedDependencies()
218cdf0e10cSrcweir 	{
219cdf0e10cSrcweir 		return pCodedDependencies;
220cdf0e10cSrcweir 	}
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	/* add symbolic identifier to resolve dependencies (to this directory and all parents)
223cdf0e10cSrcweir 	 */
224cdf0e10cSrcweir 	CodedDependency *AddCodedIdentifier(
225cdf0e10cSrcweir 		const ByteString &rCodedIdentifier, // the coded name of the directory
226cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
227cdf0e10cSrcweir 	);
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	/* returns the identifier list
230cdf0e10cSrcweir 	 */
GetCodedIdentifier()231cdf0e10cSrcweir 	SByteStringList *GetCodedIdentifier()
232cdf0e10cSrcweir 	{
233cdf0e10cSrcweir 		return pCodedIdentifier;
234cdf0e10cSrcweir 	}
235cdf0e10cSrcweir 
236*ebc38751Smseidel 	/* create dependencies on other directory, coded dependencies are used
237cdf0e10cSrcweir 	 */
238cdf0e10cSrcweir 	void ResolveDependencies();
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 	/* returns the target definition for this directory (if dependencies exist)
241cdf0e10cSrcweir 	 */
242cdf0e10cSrcweir 	ByteString GetTarget();
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	/* returns the target definition for all sub directory
245cdf0e10cSrcweir 	 */
246cdf0e10cSrcweir 	ByteString GetSubDirsTarget();
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 	/* create the full directory tree (only virtual, not in file system)
249cdf0e10cSrcweir 	 */
250cdf0e10cSrcweir 	static SourceDirectory *CreateRootDirectory(
251cdf0e10cSrcweir 		const ByteString &rRoot, 	// the root directory in file system
252*ebc38751Smseidel 		const ByteString &rVersion,	// the solar version (r.g. SRC590, SRC591 etc.)
253cdf0e10cSrcweir 		sal_Bool bAll = sal_False			// add all directories or only buildable ones
254cdf0e10cSrcweir 	);
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	/* create the makefile.rc in file system
257cdf0e10cSrcweir 	 */
258cdf0e10cSrcweir 	sal_Bool CreateRecursiveMakefile(
259*ebc38751Smseidel 		sal_Bool bAllChilds = sal_False 	// create recursive for all sub directories
260cdf0e10cSrcweir 	);
261cdf0e10cSrcweir };
262cdf0e10cSrcweir 
263cdf0e10cSrcweir //
264cdf0e10cSrcweir // class SourceDirectoryList
265cdf0e10cSrcweir //
266cdf0e10cSrcweir 
267cdf0e10cSrcweir class SourceDirectoryList : public SByteStringList
268cdf0e10cSrcweir {
269cdf0e10cSrcweir public:
270cdf0e10cSrcweir 	/* create a empty directory list
271cdf0e10cSrcweir 	 */
SourceDirectoryList()272cdf0e10cSrcweir 	SourceDirectoryList()
273cdf0e10cSrcweir 	{
274cdf0e10cSrcweir 	}
275cdf0e10cSrcweir 	~SourceDirectoryList();
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 	/* search for a directory by directory name
278cdf0e10cSrcweir 	 */
279cdf0e10cSrcweir 	SourceDirectory *Search(
280cdf0e10cSrcweir 		const ByteString &rDirectoryName	// name without parent
281cdf0e10cSrcweir 	);
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	/* insert a new directory
284cdf0e10cSrcweir 	 */
InsertSorted(SourceDirectory * pDirectory)285cdf0e10cSrcweir 	sal_uIntPtr InsertSorted(
286cdf0e10cSrcweir 		SourceDirectory *pDirectory 	// directory
287cdf0e10cSrcweir 	)
288cdf0e10cSrcweir 	{
289cdf0e10cSrcweir 		return PutString(( ByteString * ) pDirectory );
290cdf0e10cSrcweir 	}
291cdf0e10cSrcweir };
292cdf0e10cSrcweir 
293cdf0e10cSrcweir #endif
294