@@ -19,6 +19,8 @@ public class Xt_Build_Instances : Task
19
19
[ Required ] public String LinkToolCommand { get ; set ; }
20
20
[ Required ] public ITaskItem [ ] CurrentProject { get ; set ; }
21
21
[ Required ] public String SolutionFilePath { get ; set ; }
22
+ [ Required ] public String Configuration { get ; set ; }
23
+ [ Required ] public String Platform { get ; set ; }
22
24
23
25
class Node {
24
26
public Project project = null ;
@@ -81,11 +83,13 @@ private bool WalkProjectDependencies()
81
83
{
82
84
solution_file = SolutionFile . Parse ( SolutionFilePath ) ; // throws
83
85
84
- // by default the projects are loaded without reference to a particular solution
86
+ // By default the projects are loaded without reference to a particular solution
85
87
// but if e.g an <Import .. /> references something relative to $(SolutionDir)
86
- // then the project will fail to load without explicitly setting that property here
88
+ // then the project will fail to load without explicitly setting that property here.
89
+ // The properties read from the projects may also depend on Configuration and Platform.
87
90
project_collection = new ProjectCollection ( new Dictionary < String , String > {
88
- { "SolutionDir" , Path . GetDirectoryName ( SolutionFilePath ) + "\\ " }
91
+ { "SolutionDir" , Path . GetDirectoryName ( SolutionFilePath ) + "\\ " } ,
92
+ { "Configuration" , Configuration } , { "Platform" , Platform }
89
93
} ) ;
90
94
91
95
string my_path = CurrentProject [ 0 ] . GetMetadata ( "FullPath" ) ;
@@ -122,14 +126,15 @@ private bool WalkProjectDependencies()
122
126
return true ;
123
127
}
124
128
129
+ // note: this is currently unused
125
130
List < Node > GetChangedNodes ( )
126
131
{
127
132
// the link tool writes to a file which contains
128
133
// the guids of projects that contain .xti-s that it added instantiations to
129
134
// look up nodes corresponding to changed projects in the dependency graph
130
135
var nodes = new List < Node > ( ) ;
131
136
string guid ;
132
- System . IO . StreamReader file = new System . IO . StreamReader ( ProjectListFile ) ;
137
+ StreamReader file = new StreamReader ( ProjectListFile ) ;
133
138
while ( ( guid = file . ReadLine ( ) ) != null ) {
134
139
Node node = null ;
135
140
if ( ! guid_to_node . TryGetValue ( guid , out node ) ) {
@@ -141,6 +146,7 @@ List<Node> GetChangedNodes()
141
146
//Project project = node.project;
142
147
//Log.LogMessage(MessageImportance.High, "Found project {0} for {1}", project.FullPath, guid);
143
148
}
149
+ file . Dispose ( ) ;
144
150
return nodes ;
145
151
}
146
152
@@ -151,24 +157,29 @@ List<string> FindInstFiles() {
151
157
// by construction guid_to_node should only contain projects that
152
158
// the root project references or depends on transitively
153
159
foreach ( Node node in guid_to_node . Values ) {
154
- string [ ] props = { "Xt_InstFilePath" , "Xt_HeaderCachePath" , "Xt_InstSuffix" } ;
160
+ string [ ] props = { "Xt_InstFilePath_FromHeader" , " Xt_InstFilePath", "Xt_HeaderCachePath" , "Xt_InstSuffix" } ;
155
161
string [ ] values = props . Select ( prop => node . project . GetPropertyValue ( prop ) ) . ToArray ( ) ;
156
162
if ( values . Any ( value => value == "" ) ) continue ;
157
163
//for(int i = 0; i < props.Length; i++)
158
164
//Log.LogMessage(MessageImportance.High, "{0} = {1}", props[i], values[i]);
159
- string inst_base_path = values [ 0 ] , header_cache_path = values [ 1 ] , inst_suffix = values [ 2 ] ;
165
+ bool xti_from_header = Convert . ToBoolean ( values [ 0 ] ) ;
166
+ string inst_base_path = values [ 1 ] , header_cache_path = values [ 2 ] , inst_suffix = values [ 3 ] ;
160
167
string header_path ;
161
- System . IO . StreamReader file = new System . IO . StreamReader ( header_cache_path ) ;
168
+ StreamReader file = new StreamReader ( header_cache_path ) ;
162
169
while ( ( header_path = file . ReadLine ( ) ) != null ) {
163
- string header_name = System . IO . Path . GetFileNameWithoutExtension ( header_path ) ;
164
- string xti_path = inst_base_path + header_name + inst_suffix ;
170
+ string xti_path = ! xti_from_header ?
171
+ ( inst_base_path + Path . GetFileNameWithoutExtension ( header_path ) + inst_suffix )
172
+ : Path . ChangeExtension ( header_path , inst_suffix ) ;
165
173
//Log.LogMessage(MessageImportance.High, "xti_path = {0}", xti_path);
166
174
if ( ! File . Exists ( xti_path ) ) {
167
175
Log . LogMessage ( MessageImportance . High , "error: xti file does not exist: {0}" , xti_path ) ;
168
176
files_missing = true ;
169
177
}
170
178
inst_files . Add ( xti_path ) ;
171
179
}
180
+ // Xt_Headers_Read may touch this file right after we're done
181
+ // so make sure the file gets closed first
182
+ file . Dispose ( ) ;
172
183
}
173
184
return files_missing ? null : inst_files ;
174
185
} catch ( Exception e ) {
@@ -179,12 +190,16 @@ List<string> FindInstFiles() {
179
190
180
191
bool Init ( )
181
192
{
182
- if ( ! WalkProjectDependencies ( ) )
193
+ if ( ! WalkProjectDependencies ( ) ) {
194
+ Log . LogMessage ( MessageImportance . High , "failed to walk dependencies" ) ;
183
195
return false ;
196
+ }
184
197
185
198
List < string > inst_files = FindInstFiles ( ) ;
186
- if ( inst_files == null )
199
+ if ( inst_files == null ) {
200
+ Log . LogMessage ( MessageImportance . High , "no inst files found" ) ;
187
201
return false ;
202
+ }
188
203
189
204
string command = LinkToolCommand + " \" " + String . Join ( ";" , inst_files ) + "\" " ;
190
205
Log . LogMessage ( MessageImportance . High , "xt_inst_gen link: {0}" , command ) ;
0 commit comments