1// This script asks for variables, which are necessary for building the 2// examples of the Office Development Kit. The script duplicates the template 3// script and inserts the variables into the copied script. 4// The Script was developed for the operating systems Microsoft Windows. 5var regKeyOfficeCurrentUser = "HKEY_CURRENT_USER\\Software\\OpenOffice.org\\UNO\\InstallPath\\"; 6var regKeyOfficeLocaleMachine = "HKEY_LOCAL_MACHINE\\Software\\OpenOffice.org\\UNO\\InstallPath\\"; 7var regKeyDotNetInstallRoot = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\.NETFramework\\InstallRoot"; 8var regKeyDotNet1_1 = "HKLM\\Software\\Microsoft\\.NETFramework\\policy\\v1.1\\4322"; 9var sDirDotNet1_1 = "v1.1.4322"; 10var regKeyDotNet2_0 = "HKLM\\Software\\Microsoft\\.NETFramework\\Policy\\v2.0\\50727"; 11var sDirDotNet2_0 = "v2.0.50727"; 12 13var regKeyJDK = "HKLM\\Software\\JavaSoft\\Java Development Kit\\"; 14//var regKeyVC70 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"; 15//var regKeyVC71 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"; 16var regKeyVC90 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir"; 17 18//var regKeyVCExpress80 = "HKLM\\SOFTWARE\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"; 19var regKeyVCExpress90 = "HKLM\\SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC\\ProductDir"; 20 21var regKeyWindowsSDK = "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\CurrentInstallFolder"; 22 23var WshShell = WScript.CreateObject("WScript.Shell"); 24var WshSysEnv = WshShell.Environment("process"); 25var aFileSystemObject = new ActiveXObject("Scripting.FileSystemObject"); 26var stdin = WScript.StdIn; 27var stdout = WScript.StdOut; 28 29stdout.WriteLine("\n" + 30" *** Configure your SDK environment ***\n\n" + 31" NOTE: This script is working only for Windows 2000, Windows XP or newer versions!\n"); 32 33var oo_sdk_name=WshSysEnv("OO_SDK_NAME"); 34var stldebug=""; 35var oo_sdk_home=getSdkHome(); 36var oo_user_sdk_dir=WshSysEnv("APPDATA") + "\\" + oo_sdk_name; 37var oo_user_sdk_env_script=oo_user_sdk_dir + "\\setsdkenv_windows.bat"; 38 39var office_home=getOfficeHome(); 40var office_base_home=getOfficeBaseHome(); 41var oo_sdk_ure_home=getUreHome(); 42 43var oo_sdk_make_home=getMakeHome(); 44var oo_sdk_zip_home=getZipHome(); 45var oo_sdk_manifest_used=""; 46var oo_sdk_windowssdk=""; 47var oo_sdk_cpp_home=getCppHome(); 48var oo_sdk_cli_home=getCliHome(); 49var oo_sdk_java_home=getJavaHome(); 50var oo_sdk_out=getOutputDir(); 51var sdk_auto_deployment=getAutoDeployment(); 52 53writeBatFile(oo_user_sdk_dir, oo_user_sdk_env_script); 54 55stdout.Write( 56 "\n ******************************************************************\n" + 57 " * ... \"" + oo_user_sdk_env_script + "\"\n" + 58 " * batch file has been prepared.\n" + 59 " * This batch file will be used in the future to prepare your\n" + 60 " * personal configured SDK environment.\n" + 61 " ******************************************************************\n\n"); 62// " * For each time you want to use this configured SDK environment,\n" + 63// " * you have to run the \"setsdkenv_windows.bat\" file in a new shell!\n" + 64 65// done ------------------------------------------------------------------------- 66 67 68function skipChoice(msg) 69{ 70 stdout.Write("\n Do you want to skip the choice of " + msg + " (YES/NO) [YES]:"); 71 var sChoice = stdin.ReadLine(); 72 if (sChoice == "" || sChoice.toLowerCase() == "yes") 73 return true; 74 75 return false; 76} 77 78function getSdkHome() 79{ 80 var sSuggestedHome = WshSysEnv("OO_SDK_HOME"); 81 if (sSuggestedHome.length == 0) { 82 var scriptname = WScript.ScriptFullName; 83 sSuggestedHome = scriptname.substr(0,scriptname.length-10); 84 } 85 86 while(true) 87 { 88 stdout.Write("\n Enter the Office Software Development Kit directory [" + 89 sSuggestedHome + "]:"); 90 var sHome = stdin.ReadLine(); 91 if (sHome.length == 0) 92 { 93 //No user input, use default. 94 if ( ! aFileSystemObject.FolderExists(sSuggestedHome)) 95 { 96 stdout.WriteLine("\n Error: Could not find directory \"" + 97 sSuggestedHome + "\". An SDK is required, please" + 98 " specify the path to a valid installation."); 99 continue; 100 } 101 sHome = sSuggestedHome; 102 } 103 else 104 { 105 //validate the user input 106 if ( ! aFileSystemObject.FolderExists(sHome)) 107 { 108 stdout.WriteLine("\n Error: The directory \"" + sHome + 109 "\" does not exist. Please enter the path to a" + 110 "valid SDK installation."); 111 continue; 112 } 113 } 114 //Check if this is an sdk folder by looking for the idl sub - dir 115 var idlDir = sHome + "\\idl"; 116 if (! aFileSystemObject.FolderExists(idlDir)) 117 { 118 stdout.WriteLine("\n Error: Could not find directory \"" + 119 idlDir + "\". An SDK is required, please specify " + 120 "the path to a valid SDK installation."); 121 continue; 122 } 123 124 if (aFileSystemObject.FileExists(sHome + "\\lib\\stlport_vc71_stldebug.lib")) { 125 stldebug="_stldebug"; 126 } 127 128 return sHome; 129 } 130} 131 132function getOfficeOrUre() 133{ 134 var suggestion = "Office"; 135 var choice; 136 while (choice != "office" && choice != "ure") { 137 stdout.Write( 138 "\n Use an installed Office or an installed UNO Runtime" 139 + " Environment (Office/URE) [" + suggestion + "]:"); 140 choice = stdin.ReadLine(); 141 if (choice == "") { 142 choice = suggestion; 143 } 144 choice = choice.toLowerCase(); 145 } 146 return choice; 147} 148 149function getOfficeHome() 150{ 151 var sSuggestedHome = WshSysEnv("OFFICE_HOME"); 152 if (sSuggestedHome.length == 0) 153 { 154 try { 155 sSuggestedHome = WshShell.RegRead(regKeyOfficeCurrentUser); 156 //The registry entry points to the program folder but we need the 157 //installation folder 158 } catch(exc) {} 159 if (sSuggestedHome.length == 0) 160 { 161 try { 162 sSuggestedHome = WshShell.RegRead(regKeyOfficeLocaleMachine); 163 //The registry entry points to the program folder but we need 164 //the installation folder 165 } catch (exc) {} 166 } 167 168 var index=0; 169 if ((index = sSuggestedHome.lastIndexOf("\\")) != -1) 170 sSuggestedHome = sSuggestedHome.substr(0, index); 171 172 if (sSuggestedHome.length == 0) 173 sSuggestedHome = searchOffice(); 174 } 175 176 while(true) 177 { 178 stdout.Write("\n Enter the Office base installation directory [" + 179 sSuggestedHome + "]:"); 180 var sHome = stdin.ReadLine(); 181 if (sHome.length == 0) 182 { 183 //No user input, use default. 184 if ( ! aFileSystemObject.FolderExists(sSuggestedHome)) 185 { 186 stdout.WriteLine("\n Error: Could not find directory \"" + 187 sSuggestedHome + "\" An office installation is " + 188 "required, please specify the path to a valid " + 189 "office installation."); 190 sSuggestedHome = ""; 191 continue; 192 } 193 sHome = sSuggestedHome; 194 } else 195 { 196 //validate the user input 197 if ( ! aFileSystemObject.FolderExists(sHome)) 198 { 199 stdout.WriteLine("\n Error: The directory \"" + sHome + 200 "\" does not exist. Please specify the path to " + 201 "a valid office installation."); 202 continue; 203 } 204 } 205 //Check if this is a valid office installtion folder by looking for the 206 //program sub-directory 207 var progDir = sHome + "\\program"; 208 if (! aFileSystemObject.FolderExists(progDir)) 209 { 210 stdout.WriteLine("\n Error: Could not find directory \"" + 211 progDir + "\". An office installation is required, " + 212 "please specify the path to a valid office " + 213 "installation."); 214 continue; 215 } 216 return sHome; 217 } 218} 219 220function searchOffice() 221{ 222 var tmp = oo_sdk_home; 223 var officepath =""; 224 var index=-1; 225 226 if ((index = tmp.lastIndexOf("\\Basis")) != -1) { 227 tmp = tmp.substr(0, index); 228 } 229 230 if (aFileSystemObject.FileExists(tmp + "\\program\\soffice.exe")) { 231 return tmp; 232 } 233 234 return ""; 235} 236 237 238function getOfficeBaseHome() 239{ 240 var officebase = oo_sdk_home; 241 var index=officebase.lastIndexOf("\\"); 242 243 officebase = officebase.substr(0, index); 244 245 return officebase; 246} 247 248function getUreHome() 249{ 250 var tmpure = oo_sdk_home; 251 var ure = ""; 252 var index=0; 253 if ((index = tmpure.lastIndexOf("Basis")) != -1) 254 tmpure = tmpure.substr(0, index); 255 256 if (aFileSystemObject.FileExists(tmpure + "\\URE\\bin\\uno.exe")) { 257 ure = tmpure + "\URE"; 258 } 259 260 return ure; 261 262/* 263 var suggestion = WshSysEnv("OO_SDK_URE_HOME"); 264 var choice; 265 for (;;) { 266 stdout.Write( 267 "\n Enter the URE installation directory [" + suggestion + "]:"); 268 choice = stdin.ReadLine(); 269 if (choice == "") { 270 choice = suggestion; 271 } 272 if (aFileSystemObject.FileExists(choice + "\\bin\\uno.exe")) { 273 break; 274 } 275 stdout.WriteLine("\n Error: A valid URE installation is required."); 276 } 277 return choice; 278*/ 279} 280 281function getMakeHome() 282{ 283 var sSuggestedHome = WshSysEnv("OO_SDK_MAKE_HOME"); 284 285 while(true) 286 { 287 stdout.Write("\n Enter GNU make (3.79.1 or higher) tools directory [" + 288 sSuggestedHome + "]:"); 289 var sHome = stdin.ReadLine(); 290 if (sHome.length == 0) 291 { 292 //No user input, use default. 293 if ( ! aFileSystemObject.FolderExists(sSuggestedHome)) 294 { 295 stdout.WriteLine("\n Error: Could not find directory \"" + 296 sSuggestedHome + "\". GNU make is required, " + 297 "please specify a GNU make tools directory."); 298 sSuggestedHome = ""; 299 continue; 300 } 301 sHome = sSuggestedHome; 302 } else 303 { 304 //validate the user input 305 if ( ! aFileSystemObject.FolderExists(sHome)) 306 { 307 stdout.WriteLine("\n Error: The directory \"" + sHome + 308 "\" does not exist. GNU make is required, " + 309 "please specify a GNU make tools directory."); 310 continue; 311 } 312 } 313 //Check for the make executable 314 var sMakePath = sHome + "\\make.exe"; 315 if (! aFileSystemObject.FileExists(sMakePath)) 316 { 317 sMakePath = sHome + "\\mingw32-make.exe"; 318 } 319 if (! aFileSystemObject.FileExists(sMakePath)) 320 { 321 stdout.WriteLine("\n Error: Could not find \"" + sMakePath + 322 "\". GNU make is required, please specify a GNU " + 323 "make tools directory."); 324 continue; 325 } 326 return sHome; 327 } 328} 329 330function getZipHome() 331{ 332 var sSuggestedHome = WshSysEnv("OO_SDK_ZIP_HOME"); 333 334 while(true) 335 { 336 stdout.Write("\n Enter a zip (2.3 or higher) tools directory [" + 337 sSuggestedHome + "]:"); 338 var sHome = stdin.ReadLine(); 339 if (sHome.length == 0) 340 { 341 //No user input, use default. 342 if ( ! aFileSystemObject.FolderExists(sSuggestedHome)) 343 { 344 stdout.WriteLine("\n Error: Could not find directory \"" + 345 sSuggestedHome + "\". zip is required, please " + 346 "specify a zip tools directory."); 347 sSuggestedHome = ""; 348 continue; 349 } 350 sHome = sSuggestedHome; 351 } 352 else 353 { 354 //validate the user input 355 if ( ! aFileSystemObject.FolderExists(sHome)) 356 { 357 stdout.WriteLine("\n Error: The directory \"" + sHome + 358 "\" does not exist. zip is required, please " + 359 "specify a zip tools directory."); 360 continue; 361 } 362 } 363 //Check for the make executable 364 var sZipPath = sHome + "\\zip.exe"; 365 if (! aFileSystemObject.FileExists(sZipPath)) 366 { 367 stdout.WriteLine("\n Error: Could not find \"" + sZipPath + 368 "\". zip is required, please specify a zip tools " + 369 "directory."); 370 continue; 371 } 372 return sHome; 373 } 374} 375 376function getCppHome() 377{ 378 var sSuggestedHome = WshSysEnv("OO_SDK_CPP_HOME"); 379 if (sSuggestedHome.length == 0) 380 { 381 var sVC=""; 382 try { 383 sVC = WshShell.RegRead(regKeyVCExpress90); 384 }catch (exc) {} 385 if (sVC.length == 0) 386 { 387 try { 388 sVC = WshShell.RegRead(regKeyVC90); 389 }catch (exc) {} 390 } 391 // check Windows SDK if VC 9 392 if (sVC.length > 0) 393 { 394 oo_sdk_manifest_used="true"; 395 try { 396 oo_sdk_windowssdk = WshShell.RegRead(regKeyWindowsSDK); 397 }catch (exc) {} 398 } 399 if (sVC.length == 0) 400 { 401 try { 402 sVC = WshShell.RegRead(regKeyVCExpress80); 403 }catch (exc) {} 404 if (sVC.length > 0) 405 oo_sdk_manifest_used="true"; 406 } 407 if (sVC.length == 0) 408 { 409 try { 410 sVC = WshShell.RegRead(regKeyVC80); 411 }catch (exc) {} 412 if (sVC.length > 0) 413 oo_sdk_manifest_used="true"; 414 } 415 if (sVC.length == 0) 416 { 417 try { 418 sVC = WshShell.RegRead(regKeyVC71); 419 }catch (exc) {} 420 } 421 if (sVC.length > 0) 422 { 423 sVC += "bin"; 424 if (aFileSystemObject.FileExists(sVC + "\\cl.exe")) 425 sSuggestedHome = sVC; 426 } 427 } 428 429 var bSkip = false; 430 while(true) 431 { 432 stdout.Write("\n Enter the directory of the C++ compiler (optional) [" + 433 sSuggestedHome + "]:"); 434 var sHome = stdin.ReadLine(); 435 if (sHome.length == 0) 436 { 437 //No user input, check OO_SDK_CPP_HOME or suggested value 438 if ( sSuggestedHome.length == 0 ) { 439 bSkip = true; 440 } else { 441 if ( !aFileSystemObject.FolderExists(sSuggestedHome) ) 442 { 443 stdout.WriteLine("\n Error: Could not find directory \"" + 444 sSuggestedHome + "\"."); 445 sSuggestedHome = ""; 446 bSkip = true; 447 } 448 } 449 450 sHome = sSuggestedHome; 451 } else 452 { 453 //validate the user input 454 if ( ! aFileSystemObject.FolderExists(sHome)) 455 { 456 stdout.WriteLine("\n Error: Could not find directory \"" + 457 sHome + "\"."); 458 bSkip = true; 459 } 460 } 461 462 if ( !bSkip) { 463 //Check if the C++ compiler exist 464 var cl = sHome + "\\cl.exe"; 465 var mt = sHome + "\\mt.exe"; 466 467 if (! aFileSystemObject.FileExists(cl)) 468 { 469 stdout.WriteLine("\n Error: Could not find the C++ compiler \"" 470 + cl + "\"."); 471 sHome = ""; 472 bSkip = true; 473 } else { 474 if (aFileSystemObject.FileExists(mt)) { 475 oo_sdk_vc8_used="true"; 476 } 477 } 478 } 479 480 if ( bSkip ) { 481 if ( skipChoice("the C++ compiler") ) { 482 return ""; 483 } else { 484 bSkip = false; 485 continue; 486 } 487 } 488 489 return sHome; 490 } 491} 492 493function getCliHome() 494{ 495 var sSuggestedHome = WshSysEnv("OO_SDK_CLI_HOME"); 496 497 if (sSuggestedHome.length == 0) 498 { 499 try { 500 var _ver = WshShell.RegRead(regKeyDotNet2_0); 501 if (_ver.length > 0) 502 { 503 sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot); 504 sSuggestedHome += sDirDotNet2_0; 505 if ( ! aFileSystemObject.FolderExists(sSuggestedHome)) 506 sSuggestedHome = ""; 507 } 508 509 if (sSuggestedHome.length == 0) 510 { 511 _ver = WshShell.RegRead(regKeyDotNet1_1); 512 if (_ver.length > 0) 513 { 514 sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot); 515 sSuggestedHome += sDirDotNet1_1; 516 if ( ! aFileSystemObject.FolderExists(sSuggestedHome)) 517 sSuggestedHome = ""; 518 } 519 } 520 } catch (exc) {} 521 } 522 523 var bSkip = false; 524 while(true) 525 { 526 stdout.Write("\n Enter the directory of the C# and VB.NET compilers (optional) [" + sSuggestedHome + "]:"); 527 var sHome = stdin.ReadLine(); 528 if (sHome.length == 0) 529 { 530 //No user input, check OO_SDK_CLI_HOME or suggested value 531 if ( sSuggestedHome.length == 0 ) { 532 bSkip = true; 533 } else { 534 if ( !aFileSystemObject.FolderExists(sSuggestedHome) ) 535 { 536 stdout.WriteLine("\n Error: Could not find directory \"" + 537 sSuggestedHome + "\"."); 538 sSuggestedHome = ""; 539 bSkip = true; 540 } 541 } 542 543 sHome = sSuggestedHome; 544 } 545 else 546 { 547 //validate the user input 548 if ( ! aFileSystemObject.FolderExists(sHome)) 549 { 550 stdout.WriteLine("\n Error: The directory \"" + sHome + 551 "\" does not exist."); 552 bSkip = true; 553 } 554 } 555 556 if ( !bSkip ) { 557 //Check if the C# and VB.NET compiler exist 558 var csc = sHome + "\\csc.exe"; 559 var vbc = sHome + "\\vbc.exe"; 560 561 if (! aFileSystemObject.FileExists(csc)) 562 { 563 stdout.WriteLine("\n Error: Could not find the C# compiler \"" + 564 csc + "\"."); 565 bSkip = true; 566 } 567 if (! aFileSystemObject.FileExists(vbc)) 568 { 569 stdout.WriteLine("\n Error: Could not find the VB.NET compiler \"" + 570 vbc + "\"."); 571 bSkip = true; 572 } 573 } 574 575 if ( bSkip ) { 576 if ( skipChoice("the C# and VB.NET compilers") ) { 577 return ""; 578 } else { 579 bSkip = false; 580 continue; 581 } 582 } 583 584 return sHome; 585 } 586} 587 588function getJavaHome() 589{ 590 var sSuggestedHome = WshSysEnv("OO_SDK_JAVA_HOME"); 591 if (sSuggestedHome.length == 0) 592 { 593 try { 594 var currentVersion = WshShell.RegRead(regKeyJDK + "CurrentVersion"); 595 if (currentVersion.length > 0) 596 { 597 sSuggestedHome = WshShell.RegRead(regKeyJDK + currentVersion + 598 "\\JavaHome"); 599 if ( ! aFileSystemObject.FolderExists(sSuggestedHome) ) 600 sSuggestedHome = ""; 601 } 602 } catch (exc) {} 603 } 604 605 var bSkip = false; 606 while(true) 607 { 608 stdout.Write("\n Enter JAVA SDK (1.4.1_01 or higher) installation directory (optional) [" + sSuggestedHome + "]:"); 609 var sHome = stdin.ReadLine(); 610 if (sHome.length == 0) 611 { 612 //No user input, check OO_SDK_JAVA_HOME or suggested value 613 if ( sSuggestedHome.length == 0 ) { 614 bSkip = true; 615 } else { 616 if ( !aFileSystemObject.FolderExists(sSuggestedHome) ) 617 { 618 stdout.WriteLine("\n Error: Could not find directory \"" + 619 sSuggestedHome + "\"."); 620 sSuggestedHome = ""; 621 bSkip=true; 622 } 623 } 624 625 sHome = sSuggestedHome; 626 } else 627 { 628 //validate the user input 629 if ( ! aFileSystemObject.FolderExists(sHome)) 630 { 631 stdout.WriteLine("\n Error: The directory \"" + sHome + 632 "\" does not exist."); 633 bSkip = true; 634 } 635 } 636 637 if ( !bSkip) { 638 //Check if this is an sdk folder by looking for the javac compiler 639 var javacompiler = sHome + "\\bin\\javac.exe"; 640 if (! aFileSystemObject.FileExists(javacompiler)) 641 { 642 stdout.WriteLine("\n Error: Could not find \"" + 643 javacompiler + "\"."); 644 bSkip = true; 645 } 646 } 647 648 if ( bSkip ) { 649 if ( skipChoice("the Java SDK") ) { 650 return ""; 651 } else { 652 bSkip = false; 653 continue; 654 } 655 } 656 657 return sHome; 658 } 659} 660 661function getOutputDir() 662{ 663 var defaultdir = "c:\\" + oo_sdk_name; 664 var sSuggestedDir = WshSysEnv("OO_SDK_OUT"); 665 if (sSuggestedDir.length == 0) 666 sSuggestedDir = defaultdir; 667 668 var bSkip = false; 669 while(true) 670 { 671 stdout.Write( 672 "\n Default output directory is the \"c:\\" + oo_sdk_name + "\".\n" + 673 " Enter an existent directory if you prefer a different one. But note" + 674 " that only\n a path without spaces is allowed because of a" + 675 " limitation of gnu make. (optional) [" + sSuggestedDir + "]:"); 676 var sDir = stdin.ReadLine(); 677 if (sDir.length == 0) 678 { 679 //No user input, check OO_SDK_OUT or suggested value 680 if ( sSuggestedDir.length == 0 ) { 681 bSkip = true; 682 } else { 683 if (sSuggestedDir == oo_user_sdk_dir || sSuggestedDir == defaultdir) { 684 var fso = new ActiveXObject("Scripting.FileSystemObject"); 685 if ( !fso.FolderExists(sSuggestedDir) ) 686 fso.CreateFolder(sSuggestedDir); 687 } 688 if ( !aFileSystemObject.FolderExists(sSuggestedDir) ) 689 { 690 stdout.WriteLine("\n Error: Could not find directory \"" + 691 sSuggestedDir + "\"."); 692 sSuggestedDir = ""; 693 bSkip = true; 694 } 695 } 696 697 sDir = sSuggestedDir; 698 } 699 else 700 { 701 if (sDir.indexOf(' ') != -1) { 702 stdout.WriteLine("\n Error: your specified output directory " + 703 "\"" + sDir + "\" " + 704 "contains one or more spaces.\n That " + 705 "causes problems with gnu make. Please specifiy" + 706 " a directory without spaces."); 707 bSkip = true; 708 } 709 //validate the user input 710 if ( ! aFileSystemObject.FolderExists(sDir)) 711 { 712 stdout.WriteLine("\n Error: Could not find directory \"" + 713 sDir + "\"."); 714 bSkip = true; 715 } 716 } 717 718 if ( bSkip ) { 719 if ( skipChoice("a special output directory") ) { 720 return ""; 721 } else { 722 bSkip = false; 723 continue; 724 } 725 } 726 727 return sDir; 728 } 729} 730 731function getAutoDeployment() 732{ 733 var sSuggestedAuto = WshSysEnv("SDK_AUTO_DEPLOYMENT"); 734 if (sSuggestedAuto.length == 0) 735 sSuggestedAuto = "YES"; 736 737 while(true) 738 { 739 stdout.Write("\n Automatic deployment of UNO components (YES/NO) ["+ 740 sSuggestedAuto + "]:"); 741 var sAuto = stdin.ReadLine(); 742 if (sAuto.length == 0) 743 sAuto = sSuggestedAuto; 744 else 745 { 746 sAutoU = sAuto.toUpperCase(); 747 if (sAutoU != "YES" && sAutoU != "NO") 748 { 749 stdout.WriteLine("\n Error: The value \"" + sAuto + "\" is " + 750 "invalid. Please answer YES or NO.") 751 continue; 752 } 753 sAuto = sAutoU; 754 } 755 return sAuto; 756 } 757} 758 759//The function uses sp2bv.exe to obtain a file URL from a 760//system path. The URL is already escaped for use as bootstrap variable. 761//($ -> \$). Then the resulting string is escaped for use in a bat file. 762//That is % signs are made to double % (% -> %%); 763function makeBootstrapFileUrl(systemPath) 764{ 765 var oExec = WshShell.Exec("sp2bv.exe \"" + systemPath + "\""); 766 var output=""; 767 while (true) 768 { 769 if (!oExec.StdOut.AtEndOfStream) 770 { 771 var next = oExec.StdOut.Read(1); 772 if (next == '%') 773 output += "%%"; 774 else 775 output += next; 776 } 777 else 778 break; 779 } 780 return output; 781} 782 783function writeBatFile(fdir, file) 784{ 785 var fso = new ActiveXObject("Scripting.FileSystemObject"); 786 if ( !fso.FolderExists(fdir) ) 787 fso.CreateFolder(fdir); 788 var newFile = fso.CreateTextFile(file, true); 789 790 newFile.Write( 791 "@echo off\n" + 792 "REM This script sets all enviroment variables, which\n" + 793 "REM are necessary for building the examples of the Office Development Kit.\n" + 794 "REM The Script was developed for the operating systems Windows.\n" + 795 "REM The SDK name\n" + 796 "REM Example: set OO_SDK_NAME=openoffice3.0_sdk\n" + 797 "set OO_SDK_NAME=" + oo_sdk_name + 798 "\n\n" + 799 "REM Installation directory of the Software Development Kit.\n" + 800 "REM Example: set OO_SDK_HOME=C:\\Program Files\\OpenOffice.org\\Basic 3.0\\sdk\n" + 801 "set OO_SDK_HOME=" + oo_sdk_home + 802 "\n\n" + 803 "REM Office installation directory.\n" + 804 "REM Example: set OFFICE_HOME=C:\\Program Files\\OpenOffice.org 3\n" + 805 "set OFFICE_HOME=" + office_home + 806 "\n\n" + 807 "REM Example: set OFFICE_HOME=C:\\Program Files\\OpenOffice.org\\Basis 3.0\n" + 808 "set OFFICE_BASE_HOME=" + office_base_home + 809 "\n\n" + 810 "REM URE installation directory.\n" + 811 "REM Example: set OO_SDK_URE_HOME=C:\\Program Files\\OpenOffice.org\\URE\n" + 812 "set OO_SDK_URE_HOME=" + oo_sdk_ure_home + 813 "\n\n" + 814 "REM Directory of the make command.\n" + 815 "REM Example: set OO_SDK_MAKE_HOME=D:\\NextGenerationMake\\make\n" + 816 "set OO_SDK_MAKE_HOME=" + oo_sdk_make_home + 817 "\n\n" + 818 "REM Directory of the zip tool.\n" + 819 "REM Example: set OO_SDK_ZIP_HOME=D:\\infozip\\bin\n" + 820 "set OO_SDK_ZIP_HOME=" + oo_sdk_zip_home + 821 "\n\n" + 822 "REM Directory of the C++ compiler.\n" + 823 "REM Example:set OO_SDK_CPP_HOME=C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\n" + 824 "set OO_SDK_CPP_HOME=" + oo_sdk_cpp_home + 825 "\nset CPP_MANIFEST=" + oo_sdk_manifest_used + 826 "\nset CPP_WINDOWS_SDK=" + oo_sdk_windowssdk + 827 "\n\n" + 828 "REM Directory of the C# and VB.NET compilers.\n" + 829 "REM Example:set OO_SDK_CLI_HOME=C:\\WINXP\\Microsoft.NET\\Framework\\v1.0.3705\n" + 830 "set OO_SDK_CLI_HOME=" + oo_sdk_cli_home + 831 "\n\n" + 832 "REM Java SDK installation directory.\n" + 833 "REM Example: set OO_SDK_JAVA_HOME=C:\\Program Files\\Java\\jdk1.6.0_05\n" + 834 "set OO_SDK_JAVA_HOME=" + oo_sdk_java_home + 835 "\n\n" + 836 "REM Special output directory\n" + 837 "REM Example: set OO_SDK_OUT=C:\\" + oo_sdk_name + "\n" + 838 "set OO_SDK_OUT=" + oo_sdk_out + 839 "\n\n" + 840 "REM Automatic deployment\n" + 841 "REM Example: set SDK_AUTO_DEPLOYMENT=YES\n" + 842 "set SDK_AUTO_DEPLOYMENT=" + sdk_auto_deployment + 843 "\n\n" + 844 "set STLDEBUG=" + stldebug + "\n" + 845 "REM check stlport lib in 4NT shell\n" + 846 "REM if exist \"%OO_SDK_HOME%\\windows\\lib\\stlport_vc71_stldebug.lib\". (\n" + 847 "REM set STLDEBUG=_stldebug\n" + 848 "REM )\n\n" + 849 "REM Check installation path for the Office Development Kit.\n" + 850 "if not defined OO_SDK_HOME (\n" + 851 " echo Error: the variable OO_SDK_HOME is missing!\n" + 852 " goto :error\n" + 853 " )\n" + 854 "\n" + 855 "REM Check installation path for the office.\n" + 856 "REM if not defined OFFICE_HOME (\n" + 857 "REM if not defined OO_SDK_URE_HOME (\n" + 858 "REM echo Error: either of the variables OFFICE_HOME and\n" + 859 "REM echo OO_SDK_URE_HOME is missing!\n" + 860 "REM goto :error\n" + 861 "REM )\n" + 862 "REM )\n" + 863 "\n" + 864 "REM Check installation path for GNU make.\n" + 865 "if not defined OO_SDK_MAKE_HOME (\n" + 866 " echo Error: the variable OO_SDK_MAKE_HOME is missing!\n" + 867 " goto :error\n" + 868 " )\n" + 869 "\n" + 870 "REM Check installation path for the zip tool.\n" + 871 "if not defined OO_SDK_ZIP_HOME (\n" + 872 " echo Error: the variable OO_SDK_ZIP_HOME is missing!\n" + 873 " goto :error\n" + 874 " )\n" + 875 "\n" + 876 "REM Set library path. \n" + 877 "set LIB=%OO_SDK_HOME%\\lib;%LIB%\n" + 878 "if defined CPP_WINDOWS_SDK (\n" + 879 " set LIB=%LIB%;%CPP_WINDOWS_SDK%\\lib\n" + 880 " )\n" + 881 "\n" + 882 "REM Set office program path.\n" + 883 "if defined OFFICE_HOME (\n" + 884 " set OFFICE_PROGRAM_PATH=%OFFICE_HOME%\\program\n" + 885 " )\n" + 886 "\n" + 887 "REM Set office program path.\n" + 888 "if defined OFFICE_BASE_HOME (\n" + 889 " set OFFICE_BASE_PROGRAM_PATH=%OFFICE_BASE_HOME%\\program\n" + 890 " )\n" + 891 "\n" + 892 "REM Set UNO path, necessary to ensure that the cpp examples using the\n" + 893 "REM new UNO bootstrap mechanism use the configured office installation\n" + 894 "REM (only set when using an Office).\n" + 895 "if defined OFFICE_HOME (\n" + 896 " set UNO_PATH=%OFFICE_PROGRAM_PATH%\n" + 897 " )\n" + 898 "\n" + 899 "REM if defined OO_SDK_URE_HOME (\n" + 900 "set OO_SDK_URE_BIN_DIR=%OO_SDK_URE_HOME%\\bin\n" + 901 "set OO_SDK_URE_LIB_DIR=%OO_SDK_URE_HOME%\\bin\n" + 902 "set OO_SDK_URE_JAVA_DIR=%OO_SDK_URE_HOME%\\java\n" + 903 "REM ) else (\n" + 904 "set OO_SDK_OFFICE_BIN_DIR=%OFFICE_PROGRAM_PATH%\n" + 905 "set OO_SDK_OFFICE_LIB_DIR=%OFFICE_BASE_PROGRAM_PATH%\n" + 906 "set OO_SDK_OFFICE_JAVA_DIR=%OFFICE_BASE_PROGRAM_PATH%\\classes\n" + 907 "REM )\n" + 908 "\n" + 909 "REM Set classpath\n" + 910 "set CLASSPATH=%OO_SDK_URE_JAVA_DIR%\\juh.jar;%OO_SDK_URE_JAVA_DIR%\\jurt.jar;%OO_SDK_URE_JAVA_DIR%\\ridl.jar;%OO_SDK_URE_JAVA_DIR%\\unoloader.jar;%OO_SDK_OFFICE_JAVA_DIR%\\unoil.jar\n" + 911 "REM if defined OFFICE_HOME (\n" + 912 "REM set CLASSPATH=%CLASSPATH%;%OO_SDK_OFFICE_JAVA_DIR%\\unoil.jar\n" + 913 "REM )\n" + 914 "\n" + 915 "REM Add directory of the SDK tools to the path.\n" + 916 "set PATH=%OO_SDK_HOME%\\bin;%OO_SDK_URE_BIN_DIR%;%OO_SDK_OFFICE_BIN_DIR%;%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" + 917 "\n" + 918 "REM Set PATH appropriate to the output directory\n" + 919 "if defined OO_SDK_OUT (\n" + 920 " set PATH=%OO_SDK_OUT%\\WINexample.out\\bin;%PATH%\n" + 921 " ) else (\n" + 922 " set PATH=%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" + 923 " )\n" + 924 "\n" + 925 "REM Add directory of the command make to the path, if necessary.\n" + 926 "if defined OO_SDK_MAKE_HOME set PATH=%OO_SDK_MAKE_HOME%;%PATH%\n" + 927 "\n" + 928 "REM Add directory of the zip tool to the path, if necessary.\n" + 929 "if defined OO_SDK_ZIP_HOME set PATH=%OO_SDK_ZIP_HOME%;%PATH%\n" + 930 "\n" + 931 "REM Add directory of the C++ compiler to the path, if necessary.\n" + 932 "if defined OO_SDK_CPP_HOME set PATH=%OO_SDK_CPP_HOME%;%PATH%\n" + 933 "\n" + 934 "REM Add directory of the Win SDK to the path, if necessary.\n" + 935 "if defined CPP_WINDOWS_SDK (\n" + 936 " set PATH=%CPP_WINDOWS_SDK\\bin%;%PATH%\n" + 937 " set INCLUDE=%CPP_WINDOWS_SDK\\Include%;%INCLUDE%\n" + 938 ")\n" + 939 "REM Add directory of the C# and VB.NET compilers to the path, if necessary.\n" + 940 "if defined OO_SDK_CLI_HOME set PATH=%OO_SDK_CLI_HOME%;%PATH%\n" + 941 "\n" + 942 "REM Add directory of the Java tools to the path, if necessary.\n" + 943 "if defined OO_SDK_JAVA_HOME set PATH=%OO_SDK_JAVA_HOME%\\bin;%OO_SDK_JAVA_HOME%\\jre\\bin;%PATH%\n" + 944 "\n" + 945 "REM Set environment for C++ compiler tools, if necessary.\n" + 946 "if defined OO_SDK_CPP_HOME call \"%OO_SDK_CPP_HOME%\\VCVARS32.bat\"\n" + 947 "\n" + 948 "REM Set tilte to identify the prepared shell.\n" + 949 "title Shell prepared for SDK\n" + 950 "\nREM Prepare shell with all necessary environment variables.\n" + 951 "echo.\n" + 952 "echo ******************************************************************\n" + 953 "echo *\n" + 954 "echo * SDK environment is prepared for Windows\n" + 955 "echo *\n" + 956 "echo * SDK = %OO_SDK_HOME%\n" + 957 "echo * Office = %OFFICE_HOME%\n" + 958 "echo * Office Base = %OFFICE_BASE_HOME%\n" + 959 "echo * URE = %OO_SDK_URE_HOME%\n" + 960 "echo * Make = %OO_SDK_MAKE_HOME%\n" + 961 "echo * Zip = %OO_SDK_ZIP_HOME%\n" + 962 "echo * C++ Compiler = %OO_SDK_CPP_HOME%\n" + 963 "echo * C# and VB.NET compilers = %OO_SDK_CLI_HOME%\n" + 964 "echo * Java = %OO_SDK_JAVA_HOME%\n" + 965 "echo * Special Output directory = %OO_SDK_OUT%\n" + 966 "echo * Auto deployment = %SDK_AUTO_DEPLOYMENT%\n" + 967 "echo *\n" + 968 "echo ******************************************************************\n" + 969 "echo.\n" + 970 "goto end\n" + 971 "\n" + 972 " :error\n" + 973 "Error: Please insert the necessary environment variables into the batch file.\n" + 974 "\n" + 975 " :end\n" 976 ); 977 newFile.Close(); 978} 979 980 981 982