xref: /aoo42x/main/tools/inc/bootstrp/mkcreate.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _MK_CREATE_HXX
29*cdf0e10cSrcweir #define _MK_CREATE_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/string.hxx>
32*cdf0e10cSrcweir //#include "bootstrp/sstring.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir DECLARE_LIST( UniStringList, UniString* )
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <tools/list.hxx>
37*cdf0e10cSrcweir #include "bootstrp/prj.hxx"
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir class SvStream;
40*cdf0e10cSrcweir class SourceDirectoryList;
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir //
43*cdf0e10cSrcweir // class SourceDirectoryDependency
44*cdf0e10cSrcweir //
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir class CodedDependency : public ByteString
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir private:
49*cdf0e10cSrcweir 	sal_uInt16 nOSType;							// operating systems where dependeny exists
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir public:
52*cdf0e10cSrcweir 	/* create a dependency instance with given coded directory name
53*cdf0e10cSrcweir 	 */
54*cdf0e10cSrcweir 	CodedDependency(
55*cdf0e10cSrcweir 		const ByteString &rCodedIdentifier, // the coded name of the directory
56*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
57*cdf0e10cSrcweir 	) :
58*cdf0e10cSrcweir 	ByteString( rCodedIdentifier ),
59*cdf0e10cSrcweir 	nOSType( nOperatingSystems )
60*cdf0e10cSrcweir 	{
61*cdf0e10cSrcweir 	}
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	/* returns the operating system
64*cdf0e10cSrcweir 	 */
65*cdf0e10cSrcweir 	sal_uInt16 GetOperatingSystem()
66*cdf0e10cSrcweir 	{
67*cdf0e10cSrcweir 		return nOSType;
68*cdf0e10cSrcweir 	}
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 	/* set operating system
71*cdf0e10cSrcweir 	 */
72*cdf0e10cSrcweir 	void SetOperatingSystem( sal_uInt16 nOperatingSystems )
73*cdf0e10cSrcweir 	{
74*cdf0e10cSrcweir 		nOSType = nOperatingSystems;
75*cdf0e10cSrcweir 	}
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	/* add operating systems if same dependency
78*cdf0e10cSrcweir 	 */
79*cdf0e10cSrcweir 	sal_Bool TryToMerge(
80*cdf0e10cSrcweir 		const ByteString &rCodedIdentifier, // the coded name of the directory
81*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
82*cdf0e10cSrcweir 	)
83*cdf0e10cSrcweir 	{
84*cdf0e10cSrcweir 		if ( rCodedIdentifier != *this )
85*cdf0e10cSrcweir 			return sal_False;
86*cdf0e10cSrcweir 		nOSType |= nOperatingSystems;
87*cdf0e10cSrcweir 		return sal_True;
88*cdf0e10cSrcweir 	}
89*cdf0e10cSrcweir };
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir //
92*cdf0e10cSrcweir // class Dependecy
93*cdf0e10cSrcweir //
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir class Dependency : public ByteString
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir private:
98*cdf0e10cSrcweir 	sal_uInt16 nOSType;							// operating systems where dependecy exists
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir public:
101*cdf0e10cSrcweir 	/* create a dependency instance with given directory name
102*cdf0e10cSrcweir 	 */
103*cdf0e10cSrcweir 	Dependency(
104*cdf0e10cSrcweir 		const ByteString &rDirectoryName, 	// the coded name of the directory
105*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
106*cdf0e10cSrcweir 	) :
107*cdf0e10cSrcweir 	ByteString( rDirectoryName ),
108*cdf0e10cSrcweir 	nOSType( nOperatingSystems )
109*cdf0e10cSrcweir 	{
110*cdf0e10cSrcweir 	}
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 	/* returns the operating system
113*cdf0e10cSrcweir 	 */
114*cdf0e10cSrcweir 	sal_uInt16 GetOperatingSystem()
115*cdf0e10cSrcweir 	{
116*cdf0e10cSrcweir 		return nOSType;
117*cdf0e10cSrcweir 	}
118*cdf0e10cSrcweir };
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir //
121*cdf0e10cSrcweir // class SourceDirectory
122*cdf0e10cSrcweir //
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir class SourceDirectory : public ByteString
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir private:
127*cdf0e10cSrcweir 	SourceDirectory *pParent;				// the parent directory
128*cdf0e10cSrcweir 	SourceDirectoryList *pSubDirectories;	// list of sub directories
129*cdf0e10cSrcweir 	sal_uInt16 nOSType;							// operating systems where this directory is used
130*cdf0e10cSrcweir 	sal_uInt16 nDepth;							// depth of directory structure (root is 0)
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 	SByteStringList *pDependencies;			// dependencies on other directories in this depth
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	SByteStringList *pCodedDependencies;   	// dependencies on other directories in different depth
135*cdf0e10cSrcweir 	SByteStringList *pCodedIdentifier;     	// symbolic identifier to resolve dependencies
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	/* try to resolve a single dependency
138*cdf0e10cSrcweir 	 */
139*cdf0e10cSrcweir 	Dependency *ResolvesDependency(
140*cdf0e10cSrcweir 		CodedDependency *pCodedDependency 	// the dependency
141*cdf0e10cSrcweir 	);
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	/* returns the operating systems of a coded dependency
144*cdf0e10cSrcweir 	 */
145*cdf0e10cSrcweir 	static sal_uInt16 GetOSType(
146*cdf0e10cSrcweir 		const ByteString &sDependExt 		// the corresponding dependency extension (see also prj.hxx)
147*cdf0e10cSrcweir 	);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	/* removes this and all sub directories with all dependencies
150*cdf0e10cSrcweir 	 */
151*cdf0e10cSrcweir 	sal_Bool RemoveDirectoryTreeAndAllDependencies();
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir public:
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     /* create a directory instance with given parent and name, no parent means this is the root
156*cdf0e10cSrcweir 	 * (not the file system root but the root of the source tree, e.g. o:\569)
157*cdf0e10cSrcweir 	 */
158*cdf0e10cSrcweir 	SourceDirectory(
159*cdf0e10cSrcweir 		const ByteString &rDirectoryName, 			// name without parent
160*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem,					// the operating systems where this directory is used
161*cdf0e10cSrcweir 		SourceDirectory *pParentDirectory = NULL 	// parent (if not root)
162*cdf0e10cSrcweir 	);
163*cdf0e10cSrcweir 	~SourceDirectory();
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	/* returns the full absolute path of this directory
166*cdf0e10cSrcweir 	 */
167*cdf0e10cSrcweir 	ByteString GetFullPath();
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 	/* returns a list of all sub directories
170*cdf0e10cSrcweir 	 */
171*cdf0e10cSrcweir 	SourceDirectoryList *GetSubDirectories() { return pSubDirectories; }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	/* returns the Operating systems where this directory is used
174*cdf0e10cSrcweir 	 */
175*cdf0e10cSrcweir 	sal_uInt16 GetOperatingSystems() { return nOSType; }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	/* returns the given directory
178*cdf0e10cSrcweir 	 */
179*cdf0e10cSrcweir 	SourceDirectory *GetDirectory(
180*cdf0e10cSrcweir 		const ByteString &rDirectoryName,	// full path
181*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
182*cdf0e10cSrcweir 	);
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	/* create the directory and all mandatory parents
185*cdf0e10cSrcweir 	 */
186*cdf0e10cSrcweir 	SourceDirectory *InsertFull(
187*cdf0e10cSrcweir 		const ByteString &rDirectoryName,	// full path
188*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
189*cdf0e10cSrcweir 	)
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		return GetDirectory( rDirectoryName, nOperatingSystem );
192*cdf0e10cSrcweir 	}
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 	/* create the directory as sub directory of this directory
195*cdf0e10cSrcweir 	 */
196*cdf0e10cSrcweir 	SourceDirectory *Insert(
197*cdf0e10cSrcweir 		const ByteString &rDirectoryName,	// name without parent
198*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
199*cdf0e10cSrcweir 	);
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	/* get the root directory
202*cdf0e10cSrcweir 	 */
203*cdf0e10cSrcweir 	SourceDirectory *GetRootDirectory();
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 	/* get sub directory if exists
206*cdf0e10cSrcweir 	 */
207*cdf0e10cSrcweir 	SourceDirectory *GetSubDirectory(
208*cdf0e10cSrcweir 		const ByteString &rDirectoryPath,	// full sub path
209*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystem				// the operating systems where this directory is used
210*cdf0e10cSrcweir 	);
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 	/* add a dependency for several platforms
213*cdf0e10cSrcweir 	 */
214*cdf0e10cSrcweir 	CodedDependency *AddCodedDependency(
215*cdf0e10cSrcweir 		const ByteString &rCodedIdentifier, // the coded name of the directory
216*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
217*cdf0e10cSrcweir 	);
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	/* returns the dependency list
220*cdf0e10cSrcweir 	 */
221*cdf0e10cSrcweir 	SByteStringList *GetCodedDependencies()
222*cdf0e10cSrcweir 	{
223*cdf0e10cSrcweir 		return pCodedDependencies;
224*cdf0e10cSrcweir 	}
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 	/* add symbolic identifier to resolve dependencies (to this directory and all parents)
227*cdf0e10cSrcweir 	 */
228*cdf0e10cSrcweir 	CodedDependency *AddCodedIdentifier(
229*cdf0e10cSrcweir 		const ByteString &rCodedIdentifier, // the coded name of the directory
230*cdf0e10cSrcweir 		sal_uInt16 nOperatingSystems			// the operating systems where this dependency exists
231*cdf0e10cSrcweir 	);
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	/* returns the identifier list
234*cdf0e10cSrcweir 	 */
235*cdf0e10cSrcweir 	SByteStringList *GetCodedIdentifier()
236*cdf0e10cSrcweir 	{
237*cdf0e10cSrcweir 		return pCodedIdentifier;
238*cdf0e10cSrcweir 	}
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	/* create dependencies on other directory, coded dependecies are used
241*cdf0e10cSrcweir 	 */
242*cdf0e10cSrcweir 	void ResolveDependencies();
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 	/* returns the target definition for this directory (if dependencies exist)
245*cdf0e10cSrcweir 	 */
246*cdf0e10cSrcweir 	ByteString GetTarget();
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 	/* returns the target definition for all sub directory
249*cdf0e10cSrcweir 	 */
250*cdf0e10cSrcweir 	ByteString GetSubDirsTarget();
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	/* create the full directory tree (only virtual, not in file system)
253*cdf0e10cSrcweir 	 */
254*cdf0e10cSrcweir 	static SourceDirectory *CreateRootDirectory(
255*cdf0e10cSrcweir 		const ByteString &rRoot, 	// the root directory in file system
256*cdf0e10cSrcweir 		const ByteString &rVersion,	// the solar verion (r.g. SRC590, SRC591 etc.)
257*cdf0e10cSrcweir 		sal_Bool bAll = sal_False			// add all directories or only buildable ones
258*cdf0e10cSrcweir 	);
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 	/* create the makefile.rc in file system
261*cdf0e10cSrcweir 	 */
262*cdf0e10cSrcweir 	sal_Bool CreateRecursiveMakefile(
263*cdf0e10cSrcweir 		sal_Bool bAllChilds = sal_False 	// create rcursive for all sub directories
264*cdf0e10cSrcweir 	);
265*cdf0e10cSrcweir };
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir //
268*cdf0e10cSrcweir // class SourceDirectoryList
269*cdf0e10cSrcweir //
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir class SourceDirectoryList : public SByteStringList
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir public:
274*cdf0e10cSrcweir 	/* create a empty directory list
275*cdf0e10cSrcweir 	 */
276*cdf0e10cSrcweir 	SourceDirectoryList()
277*cdf0e10cSrcweir 	{
278*cdf0e10cSrcweir 	}
279*cdf0e10cSrcweir 	~SourceDirectoryList();
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 	/* search for a directory by directory name
282*cdf0e10cSrcweir 	 */
283*cdf0e10cSrcweir 	SourceDirectory *Search(
284*cdf0e10cSrcweir 		const ByteString &rDirectoryName	// name without parent
285*cdf0e10cSrcweir 	);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 	/* insert a new directory
288*cdf0e10cSrcweir 	 */
289*cdf0e10cSrcweir 	sal_uIntPtr InsertSorted(
290*cdf0e10cSrcweir 		SourceDirectory *pDirectory 	// directory
291*cdf0e10cSrcweir 	)
292*cdf0e10cSrcweir 	{
293*cdf0e10cSrcweir 		return PutString(( ByteString * ) pDirectory );
294*cdf0e10cSrcweir 	}
295*cdf0e10cSrcweir };
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir #endif
298