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