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.org\\UNO\\InstallPath\\"; 26var regKeyOfficeLocaleMachine = "HKEY_LOCAL_MACHINE\\Software\\OpenOffice.org\\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"; 40 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(regKeyVC90); 515 }catch (exc) {} 516 } 517 // check Windows SDK if VC 9 518 if (sVC.length > 0) 519 { 520 oo_sdk_manifest_used="true"; 521 try { 522 oo_sdk_windowssdk = WshShell.RegRead(regKeyWindowsSDK); 523 }catch (exc) {} 524 } 525 if (sVC.length == 0) 526 { 527 try { 528 sVC = WshShell.RegRead(regKeyVCExpress80); 529 }catch (exc) {} 530 if (sVC.length > 0) 531 oo_sdk_manifest_used="true"; 532 } 533 if (sVC.length == 0) 534 { 535 try { 536 sVC = WshShell.RegRead(regKeyVC80); 537 }catch (exc) {} 538 if (sVC.length > 0) 539 oo_sdk_manifest_used="true"; 540 } 541 if (sVC.length == 0) 542 { 543 try { 544 sVC = WshShell.RegRead(regKeyVC71); 545 }catch (exc) {} 546 } 547 if (sVC.length > 0) 548 { 549 sVC += "bin"; 550 if (aFileSystemObject.FileExists(sVC + "\\cl.exe")) 551 sSuggestedHome = sVC; 552 } 553 } 554 555 var bSkip = false; 556 while(true) 557 { 558 stdout.Write("\n Enter the directory of the C++ compiler (optional) [" + 559 sSuggestedHome + "]:"); 560 var sHome = stdin.ReadLine(); 561 if (sHome.length == 0) 562 { 563 //No user input, check OO_SDK_CPP_HOME or suggested value 564 if ( sSuggestedHome.length == 0 ) { 565 bSkip = true; 566 } else { 567 if ( !aFileSystemObject.FolderExists(sSuggestedHome) ) 568 { 569 stdout.WriteLine("\n Error: Could not find directory \"" + 570 sSuggestedHome + "\"."); 571 sSuggestedHome = ""; 572 bSkip = true; 573 } 574 } 575 576 sHome = sSuggestedHome; 577 } else 578 { 579 //validate the user input 580 if ( ! aFileSystemObject.FolderExists(sHome)) 581 { 582 stdout.WriteLine("\n Error: Could not find directory \"" + 583 sHome + "\"."); 584 bSkip = true; 585 } 586 } 587 588 if ( !bSkip) { 589 //Check if the C++ compiler exist 590 var cl = sHome + "\\cl.exe"; 591 var mt = sHome + "\\mt.exe"; 592 593 if (! aFileSystemObject.FileExists(cl)) 594 { 595 stdout.WriteLine("\n Error: Could not find the C++ compiler \"" 596 + cl + "\"."); 597 sHome = ""; 598 bSkip = true; 599 } else { 600 if (aFileSystemObject.FileExists(mt)) { 601 oo_sdk_vc8_used="true"; 602 } 603 } 604 } 605 606 if ( bSkip ) { 607 if ( skipChoice("the C++ compiler") ) { 608 return ""; 609 } else { 610 bSkip = false; 611 continue; 612 } 613 } 614 615 return sHome; 616 } 617} 618 619function getCliHome() 620{ 621 var sSuggestedHome = WshSysEnv("OO_SDK_CLI_HOME"); 622 623 if (sSuggestedHome.length == 0) 624 { 625 try { 626 var _ver = WshShell.RegRead(regKeyDotNet2_0); 627 if (_ver.length > 0) 628 { 629 sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot); 630 sSuggestedHome += sDirDotNet2_0; 631 if ( ! aFileSystemObject.FolderExists(sSuggestedHome)) 632 sSuggestedHome = ""; 633 } 634 635 if (sSuggestedHome.length == 0) 636 { 637 _ver = WshShell.RegRead(regKeyDotNet1_1); 638 if (_ver.length > 0) 639 { 640 sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot); 641 sSuggestedHome += sDirDotNet1_1; 642 if ( ! aFileSystemObject.FolderExists(sSuggestedHome)) 643 sSuggestedHome = ""; 644 } 645 } 646 } catch (exc) {} 647 } 648 649 var bSkip = false; 650 while(true) 651 { 652 stdout.Write("\n Enter the directory of the C# and VB.NET compilers (optional) [" + sSuggestedHome + "]:"); 653 var sHome = stdin.ReadLine(); 654 if (sHome.length == 0) 655 { 656 //No user input, check OO_SDK_CLI_HOME or suggested value 657 if ( sSuggestedHome.length == 0 ) { 658 bSkip = true; 659 } else { 660 if ( !aFileSystemObject.FolderExists(sSuggestedHome) ) 661 { 662 stdout.WriteLine("\n Error: Could not find directory \"" + 663 sSuggestedHome + "\"."); 664 sSuggestedHome = ""; 665 bSkip = true; 666 } 667 } 668 669 sHome = sSuggestedHome; 670 } 671 else 672 { 673 //validate the user input 674 if ( ! aFileSystemObject.FolderExists(sHome)) 675 { 676 stdout.WriteLine("\n Error: The directory \"" + sHome + 677 "\" does not exist."); 678 bSkip = true; 679 } 680 } 681 682 if ( !bSkip ) { 683 //Check if the C# and VB.NET compiler exist 684 var csc = sHome + "\\csc.exe"; 685 var vbc = sHome + "\\vbc.exe"; 686 687 if (! aFileSystemObject.FileExists(csc)) 688 { 689 stdout.WriteLine("\n Error: Could not find the C# compiler \"" + 690 csc + "\"."); 691 bSkip = true; 692 } 693 if (! aFileSystemObject.FileExists(vbc)) 694 { 695 stdout.WriteLine("\n Error: Could not find the VB.NET compiler \"" + 696 vbc + "\"."); 697 bSkip = true; 698 } 699 } 700 701 if ( bSkip ) { 702 if ( skipChoice("the C# and VB.NET compilers") ) { 703 return ""; 704 } else { 705 bSkip = false; 706 continue; 707 } 708 } 709 710 return sHome; 711 } 712} 713 714function getJavaHome() 715{ 716 var sSuggestedHome = WshSysEnv("OO_SDK_JAVA_HOME"); 717 if (sSuggestedHome.length == 0) 718 { 719 try { 720 var currentVersion = WshShell.RegRead(regKeyJDK + "CurrentVersion"); 721 if (currentVersion.length > 0) 722 { 723 sSuggestedHome = WshShell.RegRead(regKeyJDK + currentVersion + 724 "\\JavaHome"); 725 if ( ! aFileSystemObject.FolderExists(sSuggestedHome) ) 726 sSuggestedHome = ""; 727 } 728 } catch (exc) {} 729 } 730 731 var bSkip = false; 732 while(true) 733 { 734 stdout.Write("\n Enter JAVA SDK (1.4.1_01 or higher) installation directory (optional) [" + sSuggestedHome + "]:"); 735 var sHome = stdin.ReadLine(); 736 if (sHome.length == 0) 737 { 738 //No user input, check OO_SDK_JAVA_HOME or suggested value 739 if ( sSuggestedHome.length == 0 ) { 740 bSkip = true; 741 } else { 742 if ( !aFileSystemObject.FolderExists(sSuggestedHome) ) 743 { 744 stdout.WriteLine("\n Error: Could not find directory \"" + 745 sSuggestedHome + "\"."); 746 sSuggestedHome = ""; 747 bSkip=true; 748 } 749 } 750 751 sHome = sSuggestedHome; 752 } else 753 { 754 //validate the user input 755 if ( ! aFileSystemObject.FolderExists(sHome)) 756 { 757 stdout.WriteLine("\n Error: The directory \"" + sHome + 758 "\" does not exist."); 759 bSkip = true; 760 } 761 } 762 763 if ( !bSkip) { 764 //Check if this is an sdk folder by looking for the javac compiler 765 var javacompiler = sHome + "\\bin\\javac.exe"; 766 if (! aFileSystemObject.FileExists(javacompiler)) 767 { 768 stdout.WriteLine("\n Error: Could not find \"" + 769 javacompiler + "\"."); 770 bSkip = true; 771 } 772 } 773 774 if ( bSkip ) { 775 if ( skipChoice("the Java SDK") ) { 776 return ""; 777 } else { 778 bSkip = false; 779 continue; 780 } 781 } 782 783 return sHome; 784 } 785} 786 787function getOutputDir() 788{ 789 var defaultdir = "c:\\" + oo_sdk_name; 790 var sSuggestedDir = WshSysEnv("OO_SDK_OUT"); 791 if (sSuggestedDir.length == 0) 792 sSuggestedDir = defaultdir; 793 794 var bSkip = false; 795 while(true) 796 { 797 stdout.Write( 798 "\n Default output directory is the \"c:\\" + oo_sdk_name + "\".\n" + 799 " Enter an existent directory if you prefer a different one. But note" + 800 " that only\n a path without spaces is allowed because of a" + 801 " limitation of gnu make. (optional) [" + sSuggestedDir + "]:"); 802 var sDir = stdin.ReadLine(); 803 if (sDir.length == 0) 804 { 805 //No user input, check OO_SDK_OUT or suggested value 806 if ( sSuggestedDir.length == 0 ) { 807 bSkip = true; 808 } else { 809 if (sSuggestedDir == oo_user_sdk_dir || sSuggestedDir == defaultdir) { 810 var fso = new ActiveXObject("Scripting.FileSystemObject"); 811 if ( !fso.FolderExists(sSuggestedDir) ) 812 fso.CreateFolder(sSuggestedDir); 813 } 814 if ( !aFileSystemObject.FolderExists(sSuggestedDir) ) 815 { 816 stdout.WriteLine("\n Error: Could not find directory \"" + 817 sSuggestedDir + "\"."); 818 sSuggestedDir = ""; 819 bSkip = true; 820 } 821 } 822 823 sDir = sSuggestedDir; 824 } 825 else 826 { 827 if (sDir.indexOf(' ') != -1) { 828 stdout.WriteLine("\n Error: your specified output directory " + 829 "\"" + sDir + "\" " + 830 "contains one or more spaces.\n That " + 831 "causes problems with gnu make. Please specifiy" + 832 " a directory without spaces."); 833 bSkip = true; 834 } 835 //validate the user input 836 if ( ! aFileSystemObject.FolderExists(sDir)) 837 { 838 stdout.WriteLine("\n Error: Could not find directory \"" + 839 sDir + "\"."); 840 bSkip = true; 841 } 842 } 843 844 if ( bSkip ) { 845 if ( skipChoice("a special output directory") ) { 846 return ""; 847 } else { 848 bSkip = false; 849 continue; 850 } 851 } 852 853 return sDir; 854 } 855} 856 857function getAutoDeployment() 858{ 859 var sSuggestedAuto = WshSysEnv("SDK_AUTO_DEPLOYMENT"); 860 if (sSuggestedAuto.length == 0) 861 sSuggestedAuto = "YES"; 862 863 while(true) 864 { 865 stdout.Write("\n Automatic deployment of UNO components (YES/NO) ["+ 866 sSuggestedAuto + "]:"); 867 var sAuto = stdin.ReadLine(); 868 if (sAuto.length == 0) 869 sAuto = sSuggestedAuto; 870 else 871 { 872 sAutoU = sAuto.toUpperCase(); 873 if (sAutoU != "YES" && sAutoU != "NO") 874 { 875 stdout.WriteLine("\n Error: The value \"" + sAuto + "\" is " + 876 "invalid. Please answer YES or NO.") 877 continue; 878 } 879 sAuto = sAutoU; 880 } 881 return sAuto; 882 } 883} 884 885//The function uses sp2bv.exe to obtain a file URL from a 886//system path. The URL is already escaped for use as bootstrap variable. 887//($ -> \$). Then the resulting string is escaped for use in a bat file. 888//That is % signs are made to double % (% -> %%); 889function makeBootstrapFileUrl(systemPath) 890{ 891 var oExec = WshShell.Exec("sp2bv.exe \"" + systemPath + "\""); 892 var output=""; 893 while (true) 894 { 895 if (!oExec.StdOut.AtEndOfStream) 896 { 897 var next = oExec.StdOut.Read(1); 898 if (next == '%') 899 output += "%%"; 900 else 901 output += next; 902 } 903 else 904 break; 905 } 906 return output; 907} 908 909function writeBatFile(fdir, file) 910{ 911 var fso = new ActiveXObject("Scripting.FileSystemObject"); 912 if ( !fso.FolderExists(fdir) ) 913 fso.CreateFolder(fdir); 914 var newFile = fso.CreateTextFile(file, true); 915 916 newFile.Write( 917 "@echo off\n" + 918 "REM This script sets all enviroment variables, which\n" + 919 "REM are necessary for building the examples of the Office Development Kit.\n" + 920 "REM The Script was developed for the operating systems Windows.\n" + 921 "REM The SDK name\n" + 922 "REM Example: set OO_SDK_NAME=openoffice3.0_sdk\n" + 923 "set OO_SDK_NAME=" + oo_sdk_name + 924 "\n\n" + 925 "REM Installation directory of the Software Development Kit.\n" + 926 "REM Example: set OO_SDK_HOME=C:\\Program Files\\OpenOffice.org\\Basic 3.0\\sdk\n" + 927 "set OO_SDK_HOME=" + oo_sdk_home + 928 "\n\n" + 929 "REM Office installation directory.\n" + 930 "REM Example: set OFFICE_HOME=C:\\Program Files\\OpenOffice.org 3\n" + 931 "set OFFICE_HOME=" + office_home + 932 "\n\n" + 933 "REM Example: set OFFICE_HOME=C:\\Program Files\\OpenOffice.org\\Basis 3.0\n" + 934 "set OFFICE_BASE_HOME=" + office_base_home + 935 "\n\n" + 936 "REM URE installation directory.\n" + 937 "REM Example: set OO_SDK_URE_HOME=C:\\Program Files\\OpenOffice.org\\URE\n" + 938 "set OO_SDK_URE_HOME=" + oo_sdk_ure_home + 939 "\n\n" + 940 "REM Directory of the make command.\n" + 941 "REM Example: set OO_SDK_MAKE_HOME=D:\\NextGenerationMake\\make\n" + 942 "set OO_SDK_MAKE_HOME=" + oo_sdk_make_home + 943 "\n\n" + 944 "REM Directory of the zip tool.\n" + 945 "REM Example: set OO_SDK_ZIP_HOME=D:\\infozip\\bin\n" + 946 "set OO_SDK_ZIP_HOME=" + oo_sdk_zip_home + 947 "\n\n" + 948 "REM Directory of the cat tool.\n" + 949 "REM Example: set OO_SDK_CAT_HOME=C:\\UnxUtils\\usr\\local\\wbin\n" + 950 "set OO_SDK_CAT_HOME=" + oo_sdk_cat_home + 951 "\n\n" + 952 "REM Directory of the sed tool.\n" + 953 "REM Example: set OO_SDK_SED_HOME=C:\\UnxUtils\\usr\\local\\wbin\n" + 954 "set OO_SDK_SED_HOME=" + oo_sdk_sed_home + 955 "\n\n" + 956 "REM Directory of the C++ compiler.\n" + 957 "REM Example:set OO_SDK_CPP_HOME=C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\n" + 958 "set OO_SDK_CPP_HOME=" + oo_sdk_cpp_home + 959 "\nset CPP_MANIFEST=" + oo_sdk_manifest_used + 960 "\nset CPP_WINDOWS_SDK=" + oo_sdk_windowssdk + 961 "\n\n" + 962 "REM Directory of the C# and VB.NET compilers.\n" + 963 "REM Example:set OO_SDK_CLI_HOME=C:\\WINXP\\Microsoft.NET\\Framework\\v1.0.3705\n" + 964 "set OO_SDK_CLI_HOME=" + oo_sdk_cli_home + 965 "\n\n" + 966 "REM Java SDK installation directory.\n" + 967 "REM Example: set OO_SDK_JAVA_HOME=C:\\Program Files\\Java\\jdk1.6.0_05\n" + 968 "set OO_SDK_JAVA_HOME=" + oo_sdk_java_home + 969 "\n\n" + 970 "REM Special output directory\n" + 971 "REM Example: set OO_SDK_OUT=C:\\" + oo_sdk_name + "\n" + 972 "set OO_SDK_OUT=" + oo_sdk_out + 973 "\n\n" + 974 "REM Automatic deployment\n" + 975 "REM Example: set SDK_AUTO_DEPLOYMENT=YES\n" + 976 "set SDK_AUTO_DEPLOYMENT=" + sdk_auto_deployment + 977 "\n\n" + 978 "set STLDEBUG=" + stldebug + "\n" + 979 "REM check stlport lib in 4NT shell\n" + 980 "REM if exist \"%OO_SDK_HOME%\\windows\\lib\\stlport_vc71_stldebug.lib\". (\n" + 981 "REM set STLDEBUG=_stldebug\n" + 982 "REM )\n\n" + 983 "REM Check installation path for the Office Development Kit.\n" + 984 "if not defined OO_SDK_HOME (\n" + 985 " echo Error: the variable OO_SDK_HOME is missing!\n" + 986 " goto :error\n" + 987 " )\n" + 988 "\n" + 989 "REM Check installation path for the office.\n" + 990 "REM if not defined OFFICE_HOME (\n" + 991 "REM if not defined OO_SDK_URE_HOME (\n" + 992 "REM echo Error: either of the variables OFFICE_HOME and\n" + 993 "REM echo OO_SDK_URE_HOME is missing!\n" + 994 "REM goto :error\n" + 995 "REM )\n" + 996 "REM )\n" + 997 "\n" + 998 "REM Check installation path for GNU make.\n" + 999 "if not defined OO_SDK_MAKE_HOME (\n" + 1000 " echo Error: the variable OO_SDK_MAKE_HOME is missing!\n" + 1001 " goto :error\n" + 1002 " )\n" + 1003 "\n" + 1004 "REM Check installation path for the zip tool.\n" + 1005 "if not defined OO_SDK_ZIP_HOME (\n" + 1006 " echo Error: the variable OO_SDK_ZIP_HOME is missing!\n" + 1007 " goto :error\n" + 1008 " )\n" + 1009 "\n" + 1010 "REM Check installation path for the cat tool.\n" + 1011 "if not defined OO_SDK_CAT_HOME (\n" + 1012 " echo Error: the variable OO_SDK_CAT_HOME is missing!\n" + 1013 " goto :error\n" + 1014 " )\n" + 1015 "\n" + 1016 "REM Check installation path for the sed tool.\n" + 1017 "if not defined OO_SDK_SED_HOME (\n" + 1018 " echo Error: the variable OO_SDK_SED_HOME is missing!\n" + 1019 " goto :error\n" + 1020 " )\n" + 1021 "\n" + 1022 "REM Set library path. \n" + 1023 "set LIB=%OO_SDK_HOME%\\lib;%LIB%\n" + 1024 "if defined CPP_WINDOWS_SDK (\n" + 1025 " set LIB=%LIB%;%CPP_WINDOWS_SDK%\\lib\n" + 1026 " )\n" + 1027 "\n" + 1028 "REM Set office program path.\n" + 1029 "if defined OFFICE_HOME (\n" + 1030 " set OFFICE_PROGRAM_PATH=%OFFICE_HOME%\\program\n" + 1031 " )\n" + 1032 "\n" + 1033 "REM Set office program path.\n" + 1034 "if defined OFFICE_BASE_HOME (\n" + 1035 " set OFFICE_BASE_PROGRAM_PATH=%OFFICE_BASE_HOME%\\program\n" + 1036 " )\n" + 1037 "\n" + 1038 "REM Set UNO path, necessary to ensure that the cpp examples using the\n" + 1039 "REM new UNO bootstrap mechanism use the configured office installation\n" + 1040 "REM (only set when using an Office).\n" + 1041 "if defined OFFICE_HOME (\n" + 1042 " set UNO_PATH=%OFFICE_PROGRAM_PATH%\n" + 1043 " )\n" + 1044 "\n" + 1045 "REM if defined OO_SDK_URE_HOME (\n" + 1046 "set OO_SDK_URE_BIN_DIR=%OO_SDK_URE_HOME%\\bin\n" + 1047 "set OO_SDK_URE_LIB_DIR=%OO_SDK_URE_HOME%\\bin\n" + 1048 "set OO_SDK_URE_JAVA_DIR=%OO_SDK_URE_HOME%\\java\n" + 1049 "REM ) else (\n" + 1050 "set OO_SDK_OFFICE_BIN_DIR=%OFFICE_PROGRAM_PATH%\n" + 1051 "set OO_SDK_OFFICE_LIB_DIR=%OFFICE_BASE_PROGRAM_PATH%\n" + 1052 "set OO_SDK_OFFICE_JAVA_DIR=%OFFICE_BASE_PROGRAM_PATH%\\classes\n" + 1053 "REM )\n" + 1054 "\n" + 1055 "REM Set classpath\n" + 1056 "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" + 1057 "REM if defined OFFICE_HOME (\n" + 1058 "REM set CLASSPATH=%CLASSPATH%;%OO_SDK_OFFICE_JAVA_DIR%\\unoil.jar\n" + 1059 "REM )\n" + 1060 "\n" + 1061 "REM Add directory of the SDK tools to the path.\n" + 1062 "set PATH=%OO_SDK_HOME%\\bin;%OO_SDK_URE_BIN_DIR%;%OO_SDK_OFFICE_BIN_DIR%;%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" + 1063 "\n" + 1064 "REM Set PATH appropriate to the output directory\n" + 1065 "if defined OO_SDK_OUT (\n" + 1066 " set PATH=%OO_SDK_OUT%\\WINexample.out\\bin;%PATH%\n" + 1067 " ) else (\n" + 1068 " set PATH=%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" + 1069 " )\n" + 1070 "\n" + 1071 "REM Add directory of the command make to the path, if necessary.\n" + 1072 "if defined OO_SDK_MAKE_HOME set PATH=%OO_SDK_MAKE_HOME%;%PATH%\n" + 1073 "\n" + 1074 "REM Add directory of the zip tool to the path, if necessary.\n" + 1075 "if defined OO_SDK_ZIP_HOME set PATH=%OO_SDK_ZIP_HOME%;%PATH%\n" + 1076 "\n" + 1077 "REM Add directory of the cat tool to the path, if necessary.\n" + 1078 "if defined OO_SDK_CAT_HOME set PATH=%OO_SDK_CAT_HOME%;%PATH%\n" + 1079 "\n" + 1080 "REM Add directory of the sed tool to the path, if necessary.\n" + 1081 "if defined OO_SDK_SED_HOME set PATH=%OO_SDK_SED_HOME%;%PATH%\n" + 1082 "\n" + 1083 "REM Add directory of the C++ compiler to the path, if necessary.\n" + 1084 "if defined OO_SDK_CPP_HOME set PATH=%OO_SDK_CPP_HOME%;%PATH%\n" + 1085 "\n" + 1086 "REM Add directory of the Win SDK to the path, if necessary.\n" + 1087 "if defined CPP_WINDOWS_SDK (\n" + 1088 " set PATH=%CPP_WINDOWS_SDK\\bin%;%PATH%\n" + 1089 " set INCLUDE=%CPP_WINDOWS_SDK\\Include%;%INCLUDE%\n" + 1090 ")\n" + 1091 "REM Add directory of the C# and VB.NET compilers to the path, if necessary.\n" + 1092 "if defined OO_SDK_CLI_HOME set PATH=%OO_SDK_CLI_HOME%;%PATH%\n" + 1093 "\n" + 1094 "REM Add directory of the Java tools to the path, if necessary.\n" + 1095 "if defined OO_SDK_JAVA_HOME set PATH=%OO_SDK_JAVA_HOME%\\bin;%OO_SDK_JAVA_HOME%\\jre\\bin;%PATH%\n" + 1096 "\n" + 1097 "REM Set environment for C++ compiler tools, if necessary.\n" + 1098 "if defined OO_SDK_CPP_HOME call \"%OO_SDK_CPP_HOME%\\VCVARS32.bat\"\n" + 1099 "\n" + 1100 "REM Set tilte to identify the prepared shell.\n" + 1101 "title Shell prepared for SDK\n" + 1102 "\nREM Prepare shell with all necessary environment variables.\n" + 1103 "echo.\n" + 1104 "echo ******************************************************************\n" + 1105 "echo *\n" + 1106 "echo * SDK environment is prepared for Windows\n" + 1107 "echo *\n" + 1108 "echo * SDK = %OO_SDK_HOME%\n" + 1109 "echo * Office = %OFFICE_HOME%\n" + 1110 "echo * Office Base = %OFFICE_BASE_HOME%\n" + 1111 "echo * URE = %OO_SDK_URE_HOME%\n" + 1112 "echo * Make = %OO_SDK_MAKE_HOME%\n" + 1113 "echo * Zip = %OO_SDK_ZIP_HOME%\n" + 1114 "echo * cat = %OO_SDK_CAT_HOME%\n" + 1115 "echo * sed = %OO_SDK_SED_HOME%\n" + 1116 "echo * C++ Compiler = %OO_SDK_CPP_HOME%\n" + 1117 "echo * C# and VB.NET compilers = %OO_SDK_CLI_HOME%\n" + 1118 "echo * Java = %OO_SDK_JAVA_HOME%\n" + 1119 "echo * Special Output directory = %OO_SDK_OUT%\n" + 1120 "echo * Auto deployment = %SDK_AUTO_DEPLOYMENT%\n" + 1121 "echo *\n" + 1122 "echo ******************************************************************\n" + 1123 "echo.\n" + 1124 "goto end\n" + 1125 "\n" + 1126 " :error\n" + 1127 "Error: Please insert the necessary environment variables into the batch file.\n" + 1128 "\n" + 1129 " :end\n" 1130 ); 1131 newFile.Close(); 1132} 1133