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