mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 1 | #!/usr/bin/tclsh |
| 2 | # |
| 3 | # This script is used to generate a VSIX (Visual Studio Extension) file for |
| 4 | # SQLite usable by Visual Studio. |
mistachkin | 7c5dbdf | 2012-10-19 00:23:31 +0000 | [diff] [blame] | 5 | # |
| 6 | # PREREQUISITES |
| 7 | # |
| 8 | # 1. Tcl 8.4 and later are supported, earlier versions have not been tested. |
| 9 | # |
| 10 | # 2. The "sqlite3.h" file is assumed to exist in the parent directory of the |
| 11 | # directory containing this script. The [optional] second command line |
| 12 | # argument to this script may be used to specify an alternate location. |
| 13 | # This script also assumes that the "sqlite3.h" file corresponds with the |
| 14 | # version of the binaries to be packaged. This assumption is not verified |
| 15 | # by this script. |
| 16 | # |
| 17 | # 3. The temporary directory specified in the TEMP or TMP environment variables |
| 18 | # must refer to an existing directory writable by the current user. |
| 19 | # |
| 20 | # 4. The "zip" and "unzip" command line tools must be located either in a |
| 21 | # directory contained in the PATH environment variable or specified as the |
| 22 | # exact file names to execute in the "ZipTool" and "UnZipTool" environment |
| 23 | # variables, respectively. |
| 24 | # |
| 25 | # 5. The template VSIX file (which is basically a zip file) must be located in |
| 26 | # a "win" directory inside the directory containing this script. It should |
| 27 | # not contain any executable binaries. It should only contain dynamic |
| 28 | # textual content files to be processed using [subst] and/or static content |
| 29 | # files to be copied verbatim. |
| 30 | # |
| 31 | # 6. The executable and other compiled binary files to be packaged into the |
| 32 | # final VSIX file (e.g. DLLs, LIBs, and PDBs) must be located in a single |
| 33 | # directory tree. The top-level directory of the tree must be specified as |
| 34 | # the first command line argument to this script. The second level |
| 35 | # sub-directory names must match those of the build configuration (e.g. |
| 36 | # "Debug" or "Retail"). The third level sub-directory names must match |
| 37 | # those of the platform (e.g. "x86", "x64", and "ARM"). For example, the |
| 38 | # binary files to be packaged would need to be organized as follows when |
| 39 | # packaging the "Debug" and "Retail" build configurations for the "x86" and |
| 40 | # "x64" platforms (in this example, "C:\temp" is the top-level directory as |
| 41 | # specified in the first command line argument): |
| 42 | # |
| 43 | # C:\Temp\Debug\x86\sqlite3.lib |
| 44 | # C:\Temp\Debug\x86\sqlite3.dll |
| 45 | # C:\Temp\Debug\x86\sqlite3.pdb |
| 46 | # C:\Temp\Debug\x64\sqlite3.lib |
| 47 | # C:\Temp\Debug\x64\sqlite3.dll |
| 48 | # C:\Temp\Debug\x64\sqlite3.pdb |
| 49 | # C:\Temp\Retail\x86\sqlite3.lib |
| 50 | # C:\Temp\Retail\x86\sqlite3.dll |
| 51 | # C:\Temp\Retail\x86\sqlite3.pdb |
| 52 | # C:\Temp\Retail\x64\sqlite3.lib |
| 53 | # C:\Temp\Retail\x64\sqlite3.dll |
| 54 | # C:\Temp\Retail\x64\sqlite3.pdb |
| 55 | # |
| 56 | # The above directory tree organization is performed automatically if the |
| 57 | # "tool\build-all-msvc.bat" batch script is used to build the binary files |
| 58 | # to be packaged. |
| 59 | # |
| 60 | # USAGE |
| 61 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 62 | # The first argument to this script is required and must be the name of the |
| 63 | # top-level directory containing the directories and files organized into a |
| 64 | # tree as described in item 6 of the PREREQUISITES section, above. The second |
| 65 | # argument is optional and if present must contain the name of the directory |
| 66 | # containing the root of the source tree for SQLite. The third argument is |
| 67 | # optional and if present must contain the flavor the VSIX package to build. |
mistachkin | 441aa09 | 2014-05-06 21:26:34 +0000 | [diff] [blame] | 68 | # Currently, the only supported package flavors are "WinRT", "WinRT81", "WP80", |
mistachkin | f574259 | 2014-05-06 21:30:25 +0000 | [diff] [blame] | 69 | # "WP81", and "Win32". The fourth argument is optional and if present must be |
| 70 | # a string containing a list of platforms to include in the VSIX package. The |
| 71 | # platform list is "platform1,platform2,platform3". The fifth argument is |
| 72 | # optional and if present must contain the version of Visual Studio required by |
| 73 | # the package. Currently, the only supported versions are "2012" and "2013". |
| 74 | # The package flavors "WinRT81" and "WP81" are only supported when the Visual |
| 75 | # Studio version is "2013". Typically, when on Windows, this script is |
| 76 | # executed using commands similar to the following from a normal Windows |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 77 | # command prompt: |
mistachkin | 7c5dbdf | 2012-10-19 00:23:31 +0000 | [diff] [blame] | 78 | # |
| 79 | # CD /D C:\dev\sqlite\core |
| 80 | # tclsh85 tool\mkvsix.tcl C:\Temp |
| 81 | # |
| 82 | # In the example above, "C:\dev\sqlite\core" represents the root of the source |
| 83 | # tree for SQLite and "C:\Temp" represents the top-level directory containing |
| 84 | # the executable and other compiled binary files, organized into a directory |
| 85 | # tree as described in item 6 of the PREREQUISITES section, above. |
| 86 | # |
| 87 | # This script should work on non-Windows platforms as well, provided that all |
| 88 | # the requirements listed in the PREREQUISITES section are met. |
| 89 | # |
| 90 | # NOTES |
| 91 | # |
| 92 | # The temporary directory is used as a staging area for the final VSIX file. |
| 93 | # The template VSIX file is extracted, its contents processed, and then the |
| 94 | # resulting files are packaged into the final VSIX file. |
| 95 | # |
| 96 | package require Tcl 8.4 |
| 97 | |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 98 | proc fail { {error ""} {usage false} } { |
| 99 | if {[string length $error] > 0} then { |
| 100 | puts stdout $error |
| 101 | if {!$usage} then {exit 1} |
| 102 | } |
| 103 | |
| 104 | puts stdout "usage:\ |
| 105 | [file tail [info nameofexecutable]]\ |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 106 | [file tail [info script]] <binaryDirectory> \[sourceDirectory\]\ |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 107 | \[packageFlavor\] \[platformNames\] \[vsVersion\]" |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 108 | |
| 109 | exit 1 |
| 110 | } |
| 111 | |
| 112 | proc getEnvironmentVariable { name } { |
| 113 | # |
| 114 | # NOTE: Returns the value of the specified environment variable or an empty |
| 115 | # string for environment variables that do not exist in the current |
| 116 | # process environment. |
| 117 | # |
| 118 | return [expr {[info exists ::env($name)] ? $::env($name) : ""}] |
| 119 | } |
| 120 | |
| 121 | proc getTemporaryPath {} { |
| 122 | # |
| 123 | # NOTE: Returns the normalized path to the first temporary directory found |
| 124 | # in the typical set of environment variables used for that purpose |
| 125 | # or an empty string to signal a failure to locate such a directory. |
| 126 | # |
| 127 | set names [list] |
| 128 | |
| 129 | foreach name [list TEMP TMP] { |
| 130 | lappend names [string toupper $name] [string tolower $name] \ |
| 131 | [string totitle $name] |
| 132 | } |
| 133 | |
| 134 | foreach name $names { |
| 135 | set value [getEnvironmentVariable $name] |
| 136 | |
| 137 | if {[string length $value] > 0} then { |
| 138 | return [file normalize $value] |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | return "" |
| 143 | } |
| 144 | |
| 145 | proc appendArgs { args } { |
| 146 | # |
| 147 | # NOTE: Returns all passed arguments joined together as a single string with |
| 148 | # no intervening spaces between arguments. |
| 149 | # |
| 150 | eval append result $args |
| 151 | } |
| 152 | |
| 153 | proc readFile { fileName } { |
| 154 | # |
| 155 | # NOTE: Reads and returns the entire contents of the specified file, which |
| 156 | # may contain binary data. |
| 157 | # |
| 158 | set file_id [open $fileName RDONLY] |
| 159 | fconfigure $file_id -encoding binary -translation binary |
| 160 | set result [read $file_id] |
| 161 | close $file_id |
| 162 | return $result |
| 163 | } |
| 164 | |
| 165 | proc writeFile { fileName data } { |
| 166 | # |
| 167 | # NOTE: Writes the entire contents of the specified file, which may contain |
| 168 | # binary data. |
| 169 | # |
| 170 | set file_id [open $fileName {WRONLY CREAT TRUNC}] |
| 171 | fconfigure $file_id -encoding binary -translation binary |
| 172 | puts -nonewline $file_id $data |
| 173 | close $file_id |
| 174 | return "" |
| 175 | } |
| 176 | |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 177 | # |
| 178 | # TODO: Modify this procedure when a new version of Visual Studio is released. |
| 179 | # |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 180 | proc getMinVsVersionXmlChunk { vsVersion } { |
| 181 | switch -exact $vsVersion { |
| 182 | 2012 { |
| 183 | return [appendArgs \ |
| 184 | "\r\n " {MinVSVersion="11.0"}] |
| 185 | } |
| 186 | 2013 { |
| 187 | return [appendArgs \ |
| 188 | "\r\n " {MinVSVersion="12.0"}] |
| 189 | } |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 190 | 2015 { |
| 191 | return [appendArgs \ |
| 192 | "\r\n " {MinVSVersion="14.0"}] |
| 193 | } |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 194 | default { |
| 195 | return "" |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 200 | # |
| 201 | # TODO: Modify this procedure when a new version of Visual Studio is released. |
| 202 | # |
mistachkin | 1273614 | 2014-05-10 17:28:45 +0000 | [diff] [blame] | 203 | proc getMaxPlatformVersionXmlChunk { packageFlavor vsVersion } { |
| 204 | # |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 205 | # NOTE: Only Visual Studio 2013 and later support this attribute within the |
| 206 | # SDK manifest. |
mistachkin | 1273614 | 2014-05-10 17:28:45 +0000 | [diff] [blame] | 207 | # |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 208 | if {![string equal $vsVersion 2013] && \ |
| 209 | ![string equal $vsVersion 2015]} then { |
mistachkin | 1273614 | 2014-05-10 17:28:45 +0000 | [diff] [blame] | 210 | return "" |
| 211 | } |
| 212 | |
| 213 | switch -exact $packageFlavor { |
| 214 | WinRT { |
| 215 | return [appendArgs \ |
| 216 | "\r\n " {MaxPlatformVersion="8.0"}] |
| 217 | } |
| 218 | WinRT81 { |
| 219 | return [appendArgs \ |
| 220 | "\r\n " {MaxPlatformVersion="8.1"}] |
| 221 | } |
| 222 | WP80 { |
| 223 | return [appendArgs \ |
| 224 | "\r\n " {MaxPlatformVersion="8.0"}] |
| 225 | } |
mistachkin | 7964073 | 2014-05-10 17:33:11 +0000 | [diff] [blame] | 226 | WP81 { |
| 227 | return [appendArgs \ |
| 228 | "\r\n " {MaxPlatformVersion="8.1"}] |
| 229 | } |
mistachkin | 1273614 | 2014-05-10 17:28:45 +0000 | [diff] [blame] | 230 | default { |
| 231 | return "" |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 236 | # |
| 237 | # TODO: Modify this procedure when a new version of Visual Studio is released. |
| 238 | # |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 239 | proc getExtraFileListXmlChunk { packageFlavor vsVersion } { |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 240 | # |
mistachkin | 441aa09 | 2014-05-06 21:26:34 +0000 | [diff] [blame] | 241 | # NOTE: Windows Phone 8.0 does not require any extra attributes in its VSIX |
mistachkin | 7964073 | 2014-05-10 17:33:11 +0000 | [diff] [blame] | 242 | # package SDK manifests; however, it appears that Windows Phone 8.1 |
| 243 | # does. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 244 | # |
mistachkin | 441aa09 | 2014-05-06 21:26:34 +0000 | [diff] [blame] | 245 | if {[string equal $packageFlavor WP80]} then { |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 246 | return "" |
| 247 | } |
| 248 | |
| 249 | set appliesTo [expr {[string equal $packageFlavor Win32] ? \ |
| 250 | "VisualC" : "WindowsAppContainer"}] |
| 251 | |
| 252 | switch -exact $vsVersion { |
| 253 | 2012 { |
| 254 | return [appendArgs \ |
| 255 | "\r\n " AppliesTo=\" $appliesTo \" \ |
| 256 | "\r\n " {DependsOn="Microsoft.VCLibs, version=11.0"}] |
| 257 | } |
| 258 | 2013 { |
| 259 | return [appendArgs \ |
| 260 | "\r\n " AppliesTo=\" $appliesTo \" \ |
| 261 | "\r\n " {DependsOn="Microsoft.VCLibs, version=12.0"}] |
| 262 | } |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 263 | 2015 { |
| 264 | # |
| 265 | # TODO: Is the ".AppLocal" suffix always needed here? |
| 266 | # |
| 267 | return [appendArgs \ |
| 268 | "\r\n " AppliesTo=\" $appliesTo \" \ |
| 269 | "\r\n " {DependsOn="Microsoft.VCLibs.AppLocal, version=14.0"}] |
| 270 | } |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 271 | default { |
| 272 | return "" |
| 273 | } |
| 274 | } |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 275 | } |
| 276 | |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 277 | proc replaceFileNameTokens { fileName name buildName platformName } { |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 278 | # |
| 279 | # NOTE: Returns the specified file name containing the platform name instead |
| 280 | # of platform placeholder tokens. |
| 281 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 282 | return [string map [list <build> $buildName <platform> $platformName \ |
| 283 | <name> $name] $fileName] |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 284 | } |
| 285 | |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 286 | proc substFile { fileName } { |
| 287 | # |
| 288 | # NOTE: Performs all Tcl command, variable, and backslash substitutions in |
| 289 | # the specified file and then rewrites the contents of that same file |
| 290 | # with the substituted data. |
| 291 | # |
| 292 | return [writeFile $fileName [uplevel 1 [list subst [readFile $fileName]]]] |
| 293 | } |
| 294 | |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 295 | # |
| 296 | # NOTE: This is the entry point for this script. |
| 297 | # |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 298 | set script [file normalize [info script]] |
| 299 | |
| 300 | if {[string length $script] == 0} then { |
| 301 | fail "script file currently being evaluated is unknown" true |
| 302 | } |
| 303 | |
| 304 | set path [file dirname $script] |
| 305 | set rootName [file rootname [file tail $script]] |
| 306 | |
| 307 | ############################################################################### |
| 308 | |
| 309 | # |
| 310 | # NOTE: Process and verify all the command line arguments. |
| 311 | # |
| 312 | set argc [llength $argv] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 313 | if {$argc < 1 || $argc > 5} then {fail} |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 314 | |
| 315 | set binaryDirectory [lindex $argv 0] |
| 316 | |
| 317 | if {[string length $binaryDirectory] == 0} then { |
| 318 | fail "invalid binary directory" |
| 319 | } |
| 320 | |
| 321 | if {![file exists $binaryDirectory] || \ |
| 322 | ![file isdirectory $binaryDirectory]} then { |
| 323 | fail "binary directory does not exist" |
| 324 | } |
| 325 | |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 326 | if {$argc >= 2} then { |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 327 | set sourceDirectory [lindex $argv 1] |
| 328 | } else { |
| 329 | # |
| 330 | # NOTE: Assume that the source directory is the parent directory of the one |
| 331 | # that contains this script file. |
| 332 | # |
| 333 | set sourceDirectory [file dirname $path] |
| 334 | } |
| 335 | |
| 336 | if {[string length $sourceDirectory] == 0} then { |
| 337 | fail "invalid source directory" |
| 338 | } |
| 339 | |
| 340 | if {![file exists $sourceDirectory] || \ |
| 341 | ![file isdirectory $sourceDirectory]} then { |
| 342 | fail "source directory does not exist" |
| 343 | } |
| 344 | |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 345 | if {$argc >= 3} then { |
| 346 | set packageFlavor [lindex $argv 2] |
| 347 | } else { |
| 348 | # |
| 349 | # NOTE: Assume the package flavor is WinRT. |
| 350 | # |
| 351 | set packageFlavor WinRT |
| 352 | } |
| 353 | |
| 354 | if {[string length $packageFlavor] == 0} then { |
| 355 | fail "invalid package flavor" |
| 356 | } |
| 357 | |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 358 | if {$argc >= 4} then { |
| 359 | set platformNames [list] |
| 360 | |
| 361 | foreach platformName [split [lindex $argv 3] ", "] { |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 362 | set platformName [string trim $platformName] |
| 363 | |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 364 | if {[string length $platformName] > 0} then { |
| 365 | lappend platformNames $platformName |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 370 | if {$argc >= 5} then { |
| 371 | set vsVersion [lindex $argv 4] |
| 372 | } else { |
| 373 | set vsVersion 2012 |
| 374 | } |
| 375 | |
| 376 | if {[string length $vsVersion] == 0} then { |
| 377 | fail "invalid Visual Studio version" |
| 378 | } |
| 379 | |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 380 | if {![string equal $vsVersion 2012] && ![string equal $vsVersion 2013] && \ |
| 381 | ![string equal $vsVersion 2015]} then { |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 382 | fail [appendArgs \ |
| 383 | "unsupported Visual Studio version, must be one of: " \ |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 384 | [list 2012 2013 2015]] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | set shortNames(WinRT,2012) SQLite.WinRT |
| 388 | set shortNames(WinRT,2013) SQLite.WinRT.2013 |
| 389 | set shortNames(WinRT81,2013) SQLite.WinRT81 |
| 390 | set shortNames(WP80,2012) SQLite.WP80 |
| 391 | set shortNames(WP80,2013) SQLite.WP80.2013 |
| 392 | set shortNames(WP81,2013) SQLite.WP81 |
| 393 | set shortNames(Win32,2012) SQLite.Win32 |
| 394 | set shortNames(Win32,2013) SQLite.Win32.2013 |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 395 | set shortNames(UAP,2015) SQLite.UAP.2015 |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 396 | |
| 397 | set displayNames(WinRT,2012) "SQLite for Windows Runtime" |
| 398 | set displayNames(WinRT,2013) "SQLite for Windows Runtime" |
| 399 | set displayNames(WinRT81,2013) "SQLite for Windows Runtime (Windows 8.1)" |
| 400 | set displayNames(WP80,2012) "SQLite for Windows Phone" |
| 401 | set displayNames(WP80,2013) "SQLite for Windows Phone" |
| 402 | set displayNames(WP81,2013) "SQLite for Windows Phone 8.1" |
| 403 | set displayNames(Win32,2012) "SQLite for Windows" |
| 404 | set displayNames(Win32,2013) "SQLite for Windows" |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 405 | set displayNames(UAP,2015) "SQLite for Universal App Platform" |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 406 | |
| 407 | if {[string equal $packageFlavor WinRT]} then { |
| 408 | set shortName $shortNames($packageFlavor,$vsVersion) |
| 409 | set displayName $displayNames($packageFlavor,$vsVersion) |
| 410 | set targetPlatformIdentifier Windows |
| 411 | set targetPlatformVersion v8.0 |
| 412 | set minVsVersion [getMinVsVersionXmlChunk $vsVersion] |
mistachkin | 1273614 | 2014-05-10 17:28:45 +0000 | [diff] [blame] | 413 | set maxPlatformVersion \ |
| 414 | [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 415 | set extraSdkPath "" |
| 416 | set extraFileListAttributes \ |
| 417 | [getExtraFileListXmlChunk $packageFlavor $vsVersion] |
| 418 | } elseif {[string equal $packageFlavor WinRT81]} then { |
| 419 | if {$vsVersion ne "2013"} then { |
| 420 | fail [appendArgs \ |
| 421 | "unsupported combination, package flavor " $packageFlavor \ |
| 422 | " is only supported with Visual Studio 2013"] |
| 423 | } |
| 424 | set shortName $shortNames($packageFlavor,$vsVersion) |
| 425 | set displayName $displayNames($packageFlavor,$vsVersion) |
| 426 | set targetPlatformIdentifier Windows |
| 427 | set targetPlatformVersion v8.1 |
| 428 | set minVsVersion [getMinVsVersionXmlChunk $vsVersion] |
mistachkin | 1273614 | 2014-05-10 17:28:45 +0000 | [diff] [blame] | 429 | set maxPlatformVersion \ |
| 430 | [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 431 | set extraSdkPath "" |
| 432 | set extraFileListAttributes \ |
| 433 | [getExtraFileListXmlChunk $packageFlavor $vsVersion] |
| 434 | } elseif {[string equal $packageFlavor WP80]} then { |
| 435 | set shortName $shortNames($packageFlavor,$vsVersion) |
| 436 | set displayName $displayNames($packageFlavor,$vsVersion) |
| 437 | set targetPlatformIdentifier "Windows Phone" |
| 438 | set targetPlatformVersion v8.0 |
| 439 | set minVsVersion [getMinVsVersionXmlChunk $vsVersion] |
mistachkin | 1273614 | 2014-05-10 17:28:45 +0000 | [diff] [blame] | 440 | set maxPlatformVersion \ |
| 441 | [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 442 | set extraSdkPath "\\..\\$targetPlatformIdentifier" |
| 443 | set extraFileListAttributes \ |
| 444 | [getExtraFileListXmlChunk $packageFlavor $vsVersion] |
| 445 | } elseif {[string equal $packageFlavor WP81]} then { |
| 446 | if {$vsVersion ne "2013"} then { |
| 447 | fail [appendArgs \ |
| 448 | "unsupported combination, package flavor " $packageFlavor \ |
| 449 | " is only supported with Visual Studio 2013"] |
| 450 | } |
| 451 | set shortName $shortNames($packageFlavor,$vsVersion) |
| 452 | set displayName $displayNames($packageFlavor,$vsVersion) |
| 453 | set targetPlatformIdentifier WindowsPhoneApp |
| 454 | set targetPlatformVersion v8.1 |
| 455 | set minVsVersion [getMinVsVersionXmlChunk $vsVersion] |
mistachkin | 7964073 | 2014-05-10 17:33:11 +0000 | [diff] [blame] | 456 | set maxPlatformVersion \ |
| 457 | [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 458 | set extraSdkPath "\\..\\$targetPlatformIdentifier" |
| 459 | set extraFileListAttributes \ |
| 460 | [getExtraFileListXmlChunk $packageFlavor $vsVersion] |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 461 | } elseif {[string equal $packageFlavor UAP]} then { |
| 462 | if {$vsVersion ne "2015"} then { |
| 463 | fail [appendArgs \ |
| 464 | "unsupported combination, package flavor " $packageFlavor \ |
| 465 | " is only supported with Visual Studio 2015"] |
| 466 | } |
| 467 | set shortName $shortNames($packageFlavor,$vsVersion) |
| 468 | set displayName $displayNames($packageFlavor,$vsVersion) |
| 469 | set targetPlatformIdentifier UAP |
| 470 | set targetPlatformVersion v0.8.0.0 |
| 471 | set minVsVersion [getMinVsVersionXmlChunk $vsVersion] |
| 472 | set maxPlatformVersion \ |
| 473 | [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion] |
| 474 | set extraSdkPath "\\..\\$targetPlatformIdentifier" |
| 475 | set extraFileListAttributes \ |
| 476 | [getExtraFileListXmlChunk $packageFlavor $vsVersion] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 477 | } elseif {[string equal $packageFlavor Win32]} then { |
| 478 | set shortName $shortNames($packageFlavor,$vsVersion) |
| 479 | set displayName $displayNames($packageFlavor,$vsVersion) |
| 480 | set targetPlatformIdentifier Windows |
| 481 | set targetPlatformVersion v8.0 |
| 482 | set minVsVersion [getMinVsVersionXmlChunk $vsVersion] |
mistachkin | 1273614 | 2014-05-10 17:28:45 +0000 | [diff] [blame] | 483 | set maxPlatformVersion \ |
| 484 | [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 485 | set extraSdkPath "" |
| 486 | set extraFileListAttributes \ |
| 487 | [getExtraFileListXmlChunk $packageFlavor $vsVersion] |
| 488 | } else { |
| 489 | fail [appendArgs \ |
| 490 | "unsupported package flavor, must be one of: " \ |
mistachkin | f659cf4 | 2015-04-19 23:39:05 +0000 | [diff] [blame] | 491 | [list WinRT WinRT81 WP80 WP81 UAP Win32]] |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 492 | } |
| 493 | |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 494 | ############################################################################### |
| 495 | |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 496 | # |
| 497 | # NOTE: Evaluate the user-specific customizations file, if it exists. |
| 498 | # |
| 499 | set userFile [file join $path [appendArgs \ |
| 500 | $rootName . $tcl_platform(user) .tcl]] |
| 501 | |
| 502 | if {[file exists $userFile] && \ |
| 503 | [file isfile $userFile]} then { |
| 504 | source $userFile |
| 505 | } |
| 506 | |
| 507 | ############################################################################### |
| 508 | |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 509 | set templateFile [file join $path win sqlite.vsix] |
| 510 | |
| 511 | if {![file exists $templateFile] || \ |
| 512 | ![file isfile $templateFile]} then { |
| 513 | fail [appendArgs "template file \"" $templateFile "\" does not exist"] |
| 514 | } |
| 515 | |
| 516 | set currentDirectory [pwd] |
mistachkin | ecf42d5 | 2012-10-28 19:35:55 +0000 | [diff] [blame] | 517 | set outputFile [file join $currentDirectory [appendArgs sqlite- \ |
| 518 | $packageFlavor -output.vsix]] |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 519 | |
| 520 | if {[file exists $outputFile]} then { |
| 521 | fail [appendArgs "output file \"" $outputFile "\" already exists"] |
| 522 | } |
| 523 | |
| 524 | ############################################################################### |
| 525 | |
| 526 | # |
| 527 | # NOTE: Make sure that a valid temporary directory exists. |
| 528 | # |
| 529 | set temporaryDirectory [getTemporaryPath] |
| 530 | |
| 531 | if {[string length $temporaryDirectory] == 0 || \ |
| 532 | ![file exists $temporaryDirectory] || \ |
| 533 | ![file isdirectory $temporaryDirectory]} then { |
| 534 | fail "cannot locate a usable temporary directory" |
| 535 | } |
| 536 | |
| 537 | # |
| 538 | # NOTE: Setup the staging directory to have a unique name inside of the |
| 539 | # configured temporary directory. |
| 540 | # |
| 541 | set stagingDirectory [file normalize [file join $temporaryDirectory \ |
| 542 | [appendArgs $rootName . [pid]]]] |
| 543 | |
| 544 | ############################################################################### |
| 545 | |
| 546 | # |
| 547 | # NOTE: Configure the external zipping tool. First, see if it has already |
| 548 | # been pre-configured. If not, try to query it from the environment. |
| 549 | # Finally, fallback on the default of simply "zip", which will then |
| 550 | # be assumed to exist somewhere along the PATH. |
| 551 | # |
| 552 | if {![info exists zip]} then { |
| 553 | if {[info exists env(ZipTool)]} then { |
| 554 | set zip $env(ZipTool) |
| 555 | } |
| 556 | if {![info exists zip] || ![file exists $zip]} then { |
| 557 | set zip zip |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | # |
| 562 | # NOTE: Configure the external unzipping tool. First, see if it has already |
| 563 | # been pre-configured. If not, try to query it from the environment. |
| 564 | # Finally, fallback on the default of simply "unzip", which will then |
| 565 | # be assumed to exist somewhere along the PATH. |
| 566 | # |
| 567 | if {![info exists unzip]} then { |
| 568 | if {[info exists env(UnZipTool)]} then { |
| 569 | set unzip $env(UnZipTool) |
| 570 | } |
| 571 | if {![info exists unzip] || ![file exists $unzip]} then { |
| 572 | set unzip unzip |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | ############################################################################### |
| 577 | |
| 578 | # |
| 579 | # NOTE: Attempt to extract the SQLite version from the "sqlite3.h" header file |
| 580 | # in the source directory. This script assumes that the header file has |
| 581 | # already been generated by the build process. |
| 582 | # |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 583 | set pattern {^#define\s+SQLITE_VERSION\s+"(.*)"$} |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 584 | set data [readFile [file join $sourceDirectory sqlite3.h]] |
| 585 | |
| 586 | if {![regexp -line -- $pattern $data dummy version]} then { |
| 587 | fail [appendArgs "cannot locate SQLITE_VERSION value in \"" \ |
| 588 | [file join $sourceDirectory sqlite3.h] \"] |
| 589 | } |
| 590 | |
| 591 | ############################################################################### |
| 592 | |
| 593 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 594 | # NOTE: Setup all the master file list data. This includes the source file |
| 595 | # names, the destination file names, and the file processing flags. The |
| 596 | # possible file processing flags are: |
| 597 | # |
| 598 | # "buildNeutral" -- This flag indicates the file location and content do |
| 599 | # not depend on the build configuration. |
| 600 | # |
| 601 | # "platformNeutral" -- This flag indicates the file location and content |
| 602 | # do not depend on the build platform. |
| 603 | # |
| 604 | # "subst" -- This flag indicates that the file contains dynamic textual |
| 605 | # content that needs to be processed using [subst] prior to |
| 606 | # packaging the file into the final VSIX package. The primary |
| 607 | # use of this flag is to insert the name of the VSIX package, |
| 608 | # some package flavor-specific value, or the SQLite version |
| 609 | # into a file. |
| 610 | # |
| 611 | # "noDebug" -- This flag indicates that the file should be skipped when |
| 612 | # processing the debug build. |
| 613 | # |
| 614 | # "noRetail" -- This flag indicates that the file should be skipped when |
| 615 | # processing the retail build. |
| 616 | # |
| 617 | # "move" -- This flag indicates that the file should be moved from the |
| 618 | # source to the destination instead of being copied. |
| 619 | # |
| 620 | # This file metadata may be overridden, either in whole or in part, via |
| 621 | # the user-specific customizations file. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 622 | # |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 623 | if {![info exists fileNames(source)]} then { |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 624 | set fileNames(source) [list "" "" \ |
| 625 | [file join $stagingDirectory DesignTime <build> <platform> sqlite3.props] \ |
| 626 | [file join $sourceDirectory sqlite3.h] \ |
| 627 | [file join $binaryDirectory <build> <platform> sqlite3.lib] \ |
| 628 | [file join $binaryDirectory <build> <platform> sqlite3.dll]] |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 629 | |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 630 | if {![info exists no(symbols)]} then { |
| 631 | lappend fileNames(source) \ |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 632 | [file join $binaryDirectory <build> <platform> sqlite3.pdb] |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 633 | } |
| 634 | } |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 635 | |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 636 | if {![info exists fileNames(destination)]} then { |
| 637 | set fileNames(destination) [list \ |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 638 | [file join $stagingDirectory extension.vsixmanifest] \ |
| 639 | [file join $stagingDirectory SDKManifest.xml] \ |
| 640 | [file join $stagingDirectory DesignTime <build> <platform> <name>.props] \ |
| 641 | [file join $stagingDirectory DesignTime <build> <platform> sqlite3.h] \ |
| 642 | [file join $stagingDirectory DesignTime <build> <platform> sqlite3.lib] \ |
| 643 | [file join $stagingDirectory Redist <build> <platform> sqlite3.dll]] |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 644 | |
| 645 | if {![info exists no(symbols)]} then { |
| 646 | lappend fileNames(destination) \ |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 647 | [file join $stagingDirectory Redist <build> <platform> sqlite3.pdb] |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 648 | } |
| 649 | } |
| 650 | |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 651 | if {![info exists fileNames(flags)]} then { |
| 652 | set fileNames(flags) [list \ |
| 653 | [list buildNeutral platformNeutral subst] \ |
| 654 | [list buildNeutral platformNeutral subst] \ |
| 655 | [list buildNeutral platformNeutral subst move] \ |
| 656 | [list buildNeutral platformNeutral] \ |
| 657 | [list] [list] [list noRetail]] |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 658 | |
| 659 | if {![info exists no(symbols)]} then { |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 660 | lappend fileNames(flags) [list noRetail] |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 661 | } |
| 662 | } |
| 663 | |
| 664 | ############################################################################### |
| 665 | |
| 666 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 667 | # NOTE: Setup the list of builds supported by this script. These may be |
| 668 | # overridden via the user-specific customizations file. |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 669 | # |
| 670 | if {![info exists buildNames]} then { |
| 671 | set buildNames [list Debug Retail] |
| 672 | } |
| 673 | |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 674 | ############################################################################### |
| 675 | |
| 676 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 677 | # NOTE: Setup the list of platforms supported by this script. These may be |
| 678 | # overridden via the command line or the user-specific customizations |
| 679 | # file. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 680 | # |
mistachkin | 897f683 | 2014-05-06 00:09:46 +0000 | [diff] [blame] | 681 | if {![info exists platformNames] || [llength $platformNames] == 0} then { |
mistachkin | 50afa2a | 2012-07-31 08:15:56 +0000 | [diff] [blame] | 682 | set platformNames [list x86 x64 ARM] |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 683 | } |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 684 | |
| 685 | ############################################################################### |
| 686 | |
| 687 | # |
| 688 | # NOTE: Make sure the staging directory exists, creating it if necessary. |
| 689 | # |
| 690 | file mkdir $stagingDirectory |
| 691 | |
| 692 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 693 | # NOTE: Build the Tcl command used to extract the template VSIX package to |
| 694 | # the staging directory. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 695 | # |
| 696 | set extractCommand [list exec -- $unzip $templateFile -d $stagingDirectory] |
| 697 | |
| 698 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 699 | # NOTE: Extract the template VSIX package to the staging directory. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 700 | # |
| 701 | eval $extractCommand |
| 702 | |
| 703 | ############################################################################### |
| 704 | |
| 705 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 706 | # NOTE: Process each file in the master file list. There are actually three |
mistachkin | 2189012 | 2012-10-15 20:28:22 +0000 | [diff] [blame] | 707 | # parallel lists that contain the source file names, the destination file |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 708 | # names, and the file processing flags. If the "buildNeutral" flag is |
| 709 | # present, the file location and content do not depend on the build |
| 710 | # configuration and "CommonConfiguration" will be used in place of the |
| 711 | # build configuration name. If the "platformNeutral" flag is present, |
| 712 | # the file location and content do not depend on the build platform and |
| 713 | # "neutral" will be used in place of the build platform name. If the |
| 714 | # "subst" flag is present, the file is assumed to be a text file that may |
| 715 | # contain Tcl variable, command, and backslash replacements, to be |
| 716 | # dynamically replaced during processing using the Tcl [subst] command. |
| 717 | # If the "noDebug" flag is present, the file will be skipped when |
| 718 | # processing for the debug build. If the "noRetail" flag is present, the |
| 719 | # file will be skipped when processing for the retail build. If the |
| 720 | # "move" flag is present, the source file will be deleted after it is |
| 721 | # copied to the destination file. If the source file name is an empty |
| 722 | # string, the destination file name will be assumed to already exist in |
| 723 | # the staging directory and will not be copied; however, Tcl variable, |
| 724 | # command, and backslash replacements may still be performed on the |
| 725 | # destination file prior to the final VSIX package being built if the |
| 726 | # "subst" flag is present. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 727 | # |
mistachkin | 2189012 | 2012-10-15 20:28:22 +0000 | [diff] [blame] | 728 | foreach sourceFileName $fileNames(source) \ |
| 729 | destinationFileName $fileNames(destination) \ |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 730 | fileFlags $fileNames(flags) { |
| 731 | # |
| 732 | # NOTE: Process the file flags into separate boolean variables that may be |
| 733 | # used within the loop. |
| 734 | # |
| 735 | set isBuildNeutral [expr {[lsearch $fileFlags buildNeutral] != -1}] |
| 736 | set isPlatformNeutral [expr {[lsearch $fileFlags platformNeutral] != -1}] |
| 737 | set isMove [expr {[lsearch $fileFlags move] != -1}] |
| 738 | set useSubst [expr {[lsearch $fileFlags subst] != -1}] |
| 739 | |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 740 | # |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 741 | # NOTE: If the current file is build-neutral, then only one build will |
| 742 | # be processed for it, namely "CommonConfiguration"; otherwise, each |
| 743 | # supported build will be processed for it individually. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 744 | # |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 745 | foreach buildName \ |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 746 | [expr {$isBuildNeutral ? [list CommonConfiguration] : $buildNames}] { |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 747 | # |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 748 | # NOTE: Should the current file be skipped for this build? |
mistachkin | 391b364 | 2012-07-31 00:43:31 +0000 | [diff] [blame] | 749 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 750 | if {[lsearch $fileFlags no${buildName}] != -1} then { |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 751 | continue |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | # |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 755 | # NOTE: If the current file is platform-neutral, then only one platform |
| 756 | # will be processed for it, namely "neutral"; otherwise, each |
| 757 | # supported platform will be processed for it individually. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 758 | # |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 759 | foreach platformName \ |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 760 | [expr {$isPlatformNeutral ? [list neutral] : $platformNames}] { |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 761 | # |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 762 | # NOTE: Use the actual platform name in the destination file name. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 763 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 764 | set newDestinationFileName [replaceFileNameTokens $destinationFileName \ |
| 765 | $shortName $buildName $platformName] |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 766 | |
| 767 | # |
| 768 | # NOTE: Does the source file need to be copied to the destination file? |
| 769 | # |
| 770 | if {[string length $sourceFileName] > 0} then { |
| 771 | # |
| 772 | # NOTE: First, make sure the destination directory exists. |
| 773 | # |
| 774 | file mkdir [file dirname $newDestinationFileName] |
| 775 | |
| 776 | # |
| 777 | # NOTE: Then, copy the source file to the destination file verbatim. |
| 778 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 779 | set newSourceFileName [replaceFileNameTokens $sourceFileName \ |
| 780 | $shortName $buildName $platformName] |
| 781 | |
| 782 | file copy $newSourceFileName $newDestinationFileName |
| 783 | |
| 784 | # |
| 785 | # NOTE: If this is a move instead of a copy, delete the source file |
| 786 | # now. |
| 787 | # |
| 788 | if {$isMove} then { |
| 789 | file delete $newSourceFileName |
| 790 | } |
mistachkin | 0ec0744 | 2012-10-12 18:06:07 +0000 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | # |
| 794 | # NOTE: Does the destination file contain dynamic replacements that must |
| 795 | # be processed now? |
| 796 | # |
| 797 | if {$useSubst} then { |
| 798 | # |
| 799 | # NOTE: Perform any dynamic replacements contained in the destination |
| 800 | # file and then re-write it in-place. |
| 801 | # |
| 802 | substFile $newDestinationFileName |
| 803 | } |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 804 | } |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | ############################################################################### |
| 809 | |
| 810 | # |
| 811 | # NOTE: Change the current directory to the staging directory so that the |
| 812 | # external archive building tool can pickup the necessary files using |
| 813 | # relative paths. |
| 814 | # |
| 815 | cd $stagingDirectory |
| 816 | |
| 817 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 818 | # NOTE: Build the Tcl command used to archive the final VSIX package in the |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 819 | # output directory. |
| 820 | # |
| 821 | set archiveCommand [list exec -- $zip -r $outputFile *] |
| 822 | |
| 823 | # |
mistachkin | 0f80170 | 2012-10-20 08:40:05 +0000 | [diff] [blame] | 824 | # NOTE: Build the final VSIX package archive in the output directory. |
mistachkin | 4868019 | 2012-07-27 02:36:06 +0000 | [diff] [blame] | 825 | # |
| 826 | eval $archiveCommand |
| 827 | |
| 828 | # |
| 829 | # NOTE: Change back to the previously saved current directory. |
| 830 | # |
| 831 | cd $currentDirectory |
| 832 | |
| 833 | # |
| 834 | # NOTE: Cleanup the temporary staging directory. |
| 835 | # |
| 836 | file delete -force $stagingDirectory |
| 837 | |
| 838 | ############################################################################### |
| 839 | |
| 840 | # |
| 841 | # NOTE: Success, emit the fully qualified path of the generated VSIX file. |
| 842 | # |
| 843 | puts stdout $outputFile |