|
1 /* |
|
2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 using System; |
|
19 using System.IO; |
|
20 using SymbianTree; |
|
21 using SymBuildParsingLib.Tree; |
|
22 using SymBuildParsingLib.Utils; |
|
23 using SymBuildParsingLib.Parser.BuildFile.Document; |
|
24 |
|
25 namespace SymBuildParsingLib.Parser.BuildFile.Nodes |
|
26 { |
|
27 public abstract class SymNodeBuildFileMMPEntity : SymNodeAddAsChild |
|
28 { |
|
29 #region Constructors & destructor |
|
30 public SymNodeBuildFileMMPEntity() |
|
31 { |
|
32 } |
|
33 #endregion |
|
34 |
|
35 #region Internal enumerations |
|
36 [Flags] |
|
37 private enum TAttributes |
|
38 { |
|
39 EAttributeNone = 0, |
|
40 EAttributeTidy = 1, |
|
41 EAttributeBuildAsARM = 2 |
|
42 } |
|
43 #endregion |
|
44 |
|
45 #region Properties |
|
46 public bool AttribsBuildAsARM |
|
47 { |
|
48 get |
|
49 { |
|
50 bool ret = ( iAttributes & TAttributes.EAttributeBuildAsARM ) == TAttributes.EAttributeBuildAsARM; |
|
51 return ret; |
|
52 } |
|
53 set |
|
54 { |
|
55 iAttributes &= ~TAttributes.EAttributeBuildAsARM; |
|
56 } |
|
57 } |
|
58 |
|
59 public bool AttribsTidy |
|
60 { |
|
61 get |
|
62 { |
|
63 bool ret = ( iAttributes & TAttributes.EAttributeTidy ) == TAttributes.EAttributeTidy; |
|
64 return ret; |
|
65 } |
|
66 set |
|
67 { |
|
68 iAttributes &= ~TAttributes.EAttributeTidy; |
|
69 } |
|
70 } |
|
71 |
|
72 public string FileName |
|
73 { |
|
74 get { return iFileName; } |
|
75 set |
|
76 { |
|
77 if ( !( Root is SymBuildFileDocument ) ) |
|
78 { |
|
79 throw new ArgumentException( "Node must be added to tree before using this API" ); |
|
80 } |
|
81 |
|
82 // Get bld.inf file name |
|
83 SymBuildFileDocument doc = (SymBuildFileDocument) Root; |
|
84 string bldInfPath = Path.GetFullPath( doc.Context.FileName ); |
|
85 |
|
86 // Try to intepret MMP file name |
|
87 bool valid = false; |
|
88 string rootPath = Path.GetPathRoot( value ); |
|
89 bool isRooted = Path.IsPathRooted( value ); |
|
90 // |
|
91 if ( isRooted == false || rootPath == string.Empty || rootPath == @"\" ) |
|
92 { |
|
93 // If a relative path is specified with an .mmp file, the path will be considered relative to the directory containing the bld.inf file. |
|
94 // For example, if in the prj_mmpfiles section, a certain Hello.mmp file is specified as a relative path: |
|
95 // |
|
96 // PRJ_MMPFILES |
|
97 // ProjSpec\Hello.mmp |
|
98 // and if the bld.inf file is in \MyComp\, then the full path for the location of Hello.mmp will be \MyComp\ProjSpec\Hello.mmp. |
|
99 |
|
100 iFileName = SymFileSystemUtils.MergePaths( bldInfPath, value ); |
|
101 valid = true; |
|
102 } |
|
103 else if ( isRooted ) |
|
104 { |
|
105 iFileName = SymFileSystemUtils.MergePaths( SymEnvironment.RootPath, value ); |
|
106 valid = true; |
|
107 } |
|
108 |
|
109 // Throw errors if we didn't find a valid match |
|
110 if ( valid == false ) |
|
111 { |
|
112 throw new ArgumentException( "Invalid file name: " + value ); |
|
113 } |
|
114 } |
|
115 } |
|
116 #endregion |
|
117 |
|
118 #region Data members |
|
119 private TAttributes iAttributes = TAttributes.EAttributeNone; |
|
120 private string iFileName = string.Empty; |
|
121 #endregion |
|
122 } |
|
123 |
|
124 public sealed class SymNodeBuildFileMMP : SymNodeBuildFileMMPEntity |
|
125 { |
|
126 #region Constructors & destructor |
|
127 public SymNodeBuildFileMMP() |
|
128 { |
|
129 } |
|
130 #endregion |
|
131 } |
|
132 |
|
133 public sealed class SymNodeBuildFileMakefile : SymNodeBuildFileMMPEntity |
|
134 { |
|
135 #region Constructors & destructor |
|
136 public SymNodeBuildFileMakefile() |
|
137 { |
|
138 } |
|
139 #endregion |
|
140 } |
|
141 |
|
142 public sealed class SymNodeBuildFileNMakefile : SymNodeBuildFileMMPEntity |
|
143 { |
|
144 #region Constructors & destructor |
|
145 public SymNodeBuildFileNMakefile() |
|
146 { |
|
147 } |
|
148 #endregion |
|
149 } |
|
150 |
|
151 public sealed class SymNodeBuildFileGNUMakefile : SymNodeBuildFileMMPEntity |
|
152 { |
|
153 #region Constructors & destructor |
|
154 public SymNodeBuildFileGNUMakefile() |
|
155 { |
|
156 } |
|
157 #endregion |
|
158 } |
|
159 |
|
160 } |