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