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