/ Check-in [4fe7c4e9]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improve readability and logging of the vsixtest script.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | vsixTest
Files: files | file ages | folders
SHA1: 4fe7c4e90b7adbb1630b4aa15709968a1fcc7d83
User & Date: mistachkin 2016-02-25 08:02:16
Context
2016-02-25
23:22
Enhance checking of prerequisites in the vsixtest tool. Closed-Leaf check-in: 799d5f09 user: mistachkin tags: vsixTest
08:02
Improve readability and logging of the vsixtest script. check-in: 4fe7c4e9 user: mistachkin tags: vsixTest
02:56
Enable all steps and add/update comments. check-in: 788f99f4 user: mistachkin tags: vsixTest
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to vsixtest/vsixtest.tcl.

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
107
108
109
110
111
112
113




114



115
116


























117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

140
141
142
143
144

145
146
147

148
149
150
151
152
153

154
155
156
157
158
159
160
161
162
163

164
165
166
167
168
169
170
171
172
173
174
175
176

177
178
179

180
181
182
183
184
185
186
187
188
189
190
191
192

193
194
195
196
197
198
199
200
201
202
203
204
205

206
207
208
209
210
211
212

213

214
215


216
217









218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240






241


242
243
244
245
246
247

248
249
250
251


252
253
254
255


256
257
258

259
260
261
262
263
264
265
266
267
268


269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
  }

  return ""
}
 
proc appendArgs { args } {
  #
  # NOTE: Returns all passed arguments joined together as a single string with
  #       no intervening spaces between arguments.
  #
  eval append result $args
}
 
proc readFile { fileName } {
  #
  # NOTE: Reads and returns the entire contents of the specified file, which
................................................................................
  fconfigure $file_id -encoding binary -translation binary
  puts -nonewline $file_id $data
  close $file_id
  return ""
}
 
proc putsAndEval { command } {




  catch {puts stdout $command}



  return [uplevel 1 $command]
}


























 
#
# NOTE: This is the entry point for this script.
#
set script [file normalize [info script]]

if {[string length $script] == 0} then {
  fail "script file currently being evaluated is unknown" true
}

set path [file dirname $script]

###############################################################################

#
# NOTE: Process and verify all the command line arguments.
#
set argc [llength $argv]
if {$argc > 1} then {fail}

if {$argc == 1} then {
  set vsixFileName [lindex $argv 0]
} else {

  set vsixFileName [file join [file dirname $path] sqlite-UWP-output.vsix]
}

if {[string length $vsixFileName] == 0} then {
  fail "invalid VSIX file name"

}

if {![file exists $vsixFileName] || ![file isfile $vsixFileName]} then {

  fail [appendArgs "VSIX file \"" $vsixFileName "\" does not exist"]
}

set versionFileName [file join [file dirname $path] VERSION]

if {![file exists $versionFileName] || ![file isfile $versionFileName]} then {

  fail [appendArgs "Version file \"" $versionFileName "\" does not exist"]
}

set projectTemplateFileName [file join $path vsixtest.vcxproj.data]
set projectFileName [file join $path vsixtest.vcxproj]

if {![file exists $projectTemplateFileName] || \
    ![file isfile $projectTemplateFileName]} then {
  fail [appendArgs \
      "Project template file \"" $projectTemplateFileName "\" does not exist"]

}

set envVarName VS140COMNTOOLS
set vsDirectory [getEnvironmentVariable $envVarName]

if {[string length $vsDirectory] == 0} then {
  fail [appendArgs \
      "Visual Studio 2015 environment variable \"" $envVarName "\" missing"]
}

if {![file exists $vsDirectory] || ![file isdirectory $vsDirectory]} then {
  fail [appendArgs \
      "Visual Studio 2015 directory \"" $vsDirectory \

      "\" does not exist"]
}


set vsixInstaller [file join [file dirname $vsDirectory] IDE VSIXInstaller.exe]

if {![file exists $vsixInstaller] || ![file isfile $vsixInstaller]} then {
  fail [appendArgs \
      "Visual Studio 2015 VSIX installer \"" $vsixInstaller \
      "\" does not exist"]
}

set envVarName ProgramFiles
set programFiles [getEnvironmentVariable $envVarName]

if {[string length $programFiles] == 0} then {
  fail [appendArgs \

      "Windows environment variable \"" $envVarName "\" missing"]
}

if {![file exists $programFiles] || ![file isdirectory $programFiles]} then {
  fail [appendArgs \
      "Program Files directory \"" $programFiles "\" does not exist"]
}

set msBuild [file join $programFiles MSBuild 14.0 Bin MSBuild.exe]

if {![file exists $msBuild] || ![file isfile $msBuild]} then {
  fail [appendArgs \
      "MSBuild 14.0 executable file \"" $msBuild "\" does not exist"]

}

set temporaryDirectory [getTemporaryPath]

if {[string length $temporaryDirectory] == 0 || \
    ![file exists $temporaryDirectory] || \
    ![file isdirectory $temporaryDirectory]} then {

  fail "cannot locate a usable temporary directory"

}



set installLogFileName [appendArgs \
    [file rootname [file tail $vsixFileName]] -install- [pid] .log]










set buildLogFileName [appendArgs \
    [file rootname [file tail $vsixFileName]] \
    -build-%configuration%-%platform%- [pid] .log]

set uninstallLogFileName [appendArgs \
    [file rootname [file tail $vsixFileName]] -uninstall- [pid] .log]

set commands(1) [list exec [file nativename $vsixInstaller] /quiet /norepair]
lappend commands(1) [appendArgs /logFile: $installLogFileName]
lappend commands(1) [file nativename $vsixFileName]

set commands(2) [list exec [file nativename $msBuild]]
lappend commands(2) [file nativename [file join $path vsixtest.sln]]
lappend commands(2) /target:Rebuild
lappend commands(2) /property:Configuration=%configuration%
lappend commands(2) /property:Platform=%platform%

lappend commands(2) [appendArgs \
    /logger:FileLogger,Microsoft.Build.Engine\;Logfile= \
    [file nativename [file join $temporaryDirectory $buildLogFileName]] \
    \;Verbosity=diagnostic]







set commands(3) [list exec [file nativename $vsixInstaller] /quiet /norepair]


lappend commands(3) [appendArgs /logFile: $uninstallLogFileName]
lappend commands(3) [appendArgs /uninstall:SQLite.UWP.2015]

###############################################################################

if {1} then {

  puts stdout [appendArgs \
      "Install log will be \"" [file nativename [file join \
      $temporaryDirectory $installLogFileName]] "\"."]



  puts stdout [appendArgs \
      "Build log will be \"" [file nativename [file join \
      $temporaryDirectory $buildLogFileName]] "\"."]



  puts stdout [appendArgs \
      "Uninstall log will be \"" [file nativename [file join \
      $temporaryDirectory $uninstallLogFileName]] "\"."]

}

###############################################################################

if {1} then {
  putsAndEval $commands(1)

  set versionNumber [string trim [readFile $versionFileName]]
  set data [readFile $projectTemplateFileName]
  set data [string map [list %versionNumber% $versionNumber] $data]


  writeFile $projectFileName $data

  set platforms [list x86 x64 ARM]
  set configurations [list Debug Release]

  foreach platform $platforms {
    foreach configuration $configurations {
      putsAndEval [string map [list \
          %platform% $platform %configuration% \
          $configuration] $commands(2)]
    }
  }

  putsAndEval $commands(3)
}







|
|







 







>
>
>
>
|
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










|
<
<
<
<
<
<
<
|




>
|


<
<
>
|
<
|
>
|




|
>
|



<

<
|

|
>





<
<
<
<
<
|


>



>
|

|








|

>
|
<
<
<
<
|




|

|
>




<
<
|
>
|
>


>
>

|
>
>
>
>
>
>
>
>
>





<
<
<
|
<
<

<







|
|

>
>
>
>
>
>
|
>
>






>
|
|
|
|
>
>
|
|
|
|
>
>
|
|
|
>










>
>








|
|





76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160







161
162
163
164
165
166
167
168
169


170
171

172
173
174
175
176
177
178
179
180
181
182
183
184

185

186
187
188
189
190
191
192
193
194





195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217




218
219
220
221
222
223
224
225
226
227
228
229
230


231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254



255


256

257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
  }

  return ""
}
 
proc appendArgs { args } {
  #
  # NOTE: Returns all passed arguments joined together as a single string
  #       with no intervening spaces between arguments.
  #
  eval append result $args
}
 
proc readFile { fileName } {
  #
  # NOTE: Reads and returns the entire contents of the specified file, which
................................................................................
  fconfigure $file_id -encoding binary -translation binary
  puts -nonewline $file_id $data
  close $file_id
  return ""
}
 
proc putsAndEval { command } {
  #
  # NOTE: Outputs a command to the standard output channel and then evaluates
  #       it in the callers context.
  #
  catch {
    puts stdout [appendArgs "Running: " [lrange $command 1 end] ...\n]
  }

  return [uplevel 1 $command]
}
 
proc isBadDirectory { directory } {
  #
  # NOTE: Returns non-zero if the directory is empty, does not exist, -OR- is
  #       not a directory.
  #
  catch {
    puts stdout [appendArgs "Checking directory \"" $directory \"...\n]
  }

  return [expr {[string length $directory] == 0 || \
      ![file exists $directory] || ![file isdirectory $directory]}]
}
 
proc isBadFile { fileName } {
  #
  # NOTE: Returns non-zero if the file name is empty, does not exist, -OR- is
  #       not a regular file.
  #
  catch {
    puts stdout [appendArgs "Checking file \"" $fileName \"...\n]
  }

  return [expr {[string length $fileName] == 0 || \
      ![file exists $fileName] || ![file isfile $fileName]}]
}
 
#
# NOTE: This is the entry point for this script.
#
set script [file normalize [info script]]

if {[string length $script] == 0} then {
  fail "script file currently being evaluated is unknown" true
}

set path [file normalize [file dirname $script]]







set argc [llength $argv]; if {$argc > 1} then {fail "" true}

if {$argc == 1} then {
  set vsixFileName [lindex $argv 0]
} else {
  set vsixFileName [file join \
      [file dirname $path] sqlite-UWP-output.vsix]
}



###############################################################################


if {[isBadFile $vsixFileName]} then {
  fail [appendArgs \
      "VSIX file \"" $vsixFileName "\" does not exist"]
}

set versionFileName [file join [file dirname $path] VERSION]

if {[isBadFile $versionFileName]} then {
  fail [appendArgs \
      "Version file \"" $versionFileName "\" does not exist"]
}

set projectTemplateFileName [file join $path vsixtest.vcxproj.data]



if {[isBadFile $projectTemplateFileName]} then {
  fail [appendArgs \
      "Project template file \"" $projectTemplateFileName \
      "\" does not exist"]
}

set envVarName VS140COMNTOOLS
set vsDirectory [getEnvironmentVariable $envVarName]






if {[isBadDirectory $vsDirectory]} then {
  fail [appendArgs \
      "Visual Studio 2015 directory \"" $vsDirectory \
      "\" from environment variable \"" $envVarName \
      "\" does not exist"]
}

set vsixInstaller [file join \
    [file dirname $vsDirectory] IDE VSIXInstaller.exe]

if {[isBadFile $vsixInstaller]} then {
  fail [appendArgs \
      "Visual Studio 2015 VSIX installer \"" $vsixInstaller \
      "\" does not exist"]
}

set envVarName ProgramFiles
set programFiles [getEnvironmentVariable $envVarName]

if {[isBadDirectory $programFiles]} then {
  fail [appendArgs \
      "Program Files directory \"" $programFiles \
      "\" from environment variable \"" $envVarName \




      "\" does not exist"]
}

set msBuild [file join $programFiles MSBuild 14.0 Bin MSBuild.exe]

if {[isBadFile $msBuild]} then {
  fail [appendArgs \
      "MSBuild v14.0 executable file \"" $msBuild \
      "\" does not exist"]
}

set temporaryDirectory [getTemporaryPath]



if {[isBadDirectory $temporaryDirectory]} then {
  fail [appendArgs \
      "Temporary directory \"" $temporaryDirectory \
      "\" does not exist"]
}

###############################################################################

set installLogFileName [appendArgs \
    [file rootname [file tail $vsixFileName]] \
    -install- [pid] .log]

set commands(1) [list exec [file nativename $vsixInstaller]]

lappend commands(1) /quiet /norepair
lappend commands(1) [appendArgs /logFile: $installLogFileName]
lappend commands(1) [file nativename $vsixFileName]

###############################################################################

set buildLogFileName [appendArgs \
    [file rootname [file tail $vsixFileName]] \
    -build-%configuration%-%platform%- [pid] .log]




set commands(2) [list exec [file nativename $msBuild]]




lappend commands(2) [file nativename [file join $path vsixtest.sln]]
lappend commands(2) /target:Rebuild
lappend commands(2) /property:Configuration=%configuration%
lappend commands(2) /property:Platform=%platform%

lappend commands(2) [appendArgs \
    /logger:FileLogger,Microsoft.Build.Engine\;Logfile= \
    [file nativename [file join $temporaryDirectory \
    $buildLogFileName]] \;Verbosity=diagnostic]

###############################################################################

set uninstallLogFileName [appendArgs \
    [file rootname [file tail $vsixFileName]] \
    -uninstall- [pid] .log]

set commands(3) [list exec [file nativename $vsixInstaller]]

lappend commands(3) /quiet /norepair
lappend commands(3) [appendArgs /logFile: $uninstallLogFileName]
lappend commands(3) [appendArgs /uninstall:SQLite.UWP.2015]

###############################################################################

if {1} then {
  catch {
    puts stdout [appendArgs \
        "Install log: \"" [file nativename [file join \
        $temporaryDirectory $installLogFileName]] \"\n]
  }

  catch {
    puts stdout [appendArgs \
        "Build logs: \"" [file nativename [file join \
        $temporaryDirectory $buildLogFileName]] \"\n]
  }

  catch {
    puts stdout [appendArgs \
        "Uninstall log: \"" [file nativename [file join \
        $temporaryDirectory $uninstallLogFileName]] \"\n]
  }
}

###############################################################################

if {1} then {
  putsAndEval $commands(1)

  set versionNumber [string trim [readFile $versionFileName]]
  set data [readFile $projectTemplateFileName]
  set data [string map [list %versionNumber% $versionNumber] $data]

  set projectFileName [file join $path vsixtest.vcxproj]
  writeFile $projectFileName $data

  set platforms [list x86 x64 ARM]
  set configurations [list Debug Release]

  foreach platform $platforms {
    foreach configuration $configurations {
      putsAndEval [string map [list \
          %platform% $platform %configuration% $configuration] \
          $commands(2)]
    }
  }

  putsAndEval $commands(3)
}