Update git submodules
[LibreOffice.git] / odk / config / cfgWin.js
blob9076efe426ea6cf79acd7a92e51ab9657d960a49
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_dotnet_root=getDotnetRoot();
66 var oo_sdk_java_home=getJavaHome();
67 var oo_sdk_out=getOutputDir();
68 var sdk_auto_deployment=getAutoDeployment();
70 writeBatFile(oo_user_sdk_dir, oo_user_sdk_env_script);
72 stdout.Write(
73         "\n ******************************************************************\n" +
74     " * ... \"" + oo_user_sdk_env_script + "\"\n" +
75     " * batch file has been prepared.\n" +
76     " * This batch file will be used in the future to prepare your\n" +
77         " * personal configured SDK environment.\n" +
78         " ******************************************************************\n\n");
79 //    " * For each time you want to use this configured SDK environment,\n" +
80 //    " * you have to run the \"setsdkenv_windows.bat\" file in a new shell!\n" +
82 // done -------------------------------------------------------------------------
85 function skipChoice(msg)
87         stdout.Write("\n Do you want to skip the choice of " + msg + " (YES/NO) [YES]:");
88         var sChoice = stdin.ReadLine();
89     if (sChoice == "" || sChoice.toLowerCase() == "yes")
90            return true;
92         return false;
95 function getSdkHome()
97         var sSuggestedHome = WshSysEnv("OO_SDK_HOME");
98     if (sSuggestedHome.length == 0) {
99         var scriptname = WScript.ScriptFullName;
100         sSuggestedHome = scriptname.substr(0,scriptname.length-10);
101     }
103     while(true)
104     {
105         stdout.Write("\n Enter the Office Software Development Kit directory [" +
106                      sSuggestedHome + "]:");
107         var sHome = stdin.ReadLine();
108         if (sHome.length == 0)
109         {
110             //No user input, use default.
111             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
112             {
113                 stdout.WriteLine("\n Error: Could not find directory \"" +
114                                  sSuggestedHome + "\". An SDK is required, please" +
115                                                                  " specify the path to a valid installation.");
116                 continue;
117             }
118             sHome = sSuggestedHome;
119         }
120         else
121         {
122             //validate the user input
123             if ( ! aFileSystemObject.FolderExists(sHome))
124             {
125                 stdout.WriteLine("\n Error: The directory \"" + sHome +
126                                  "\" does not exist. Please enter the path to a" +
127                                                                  "valid SDK installation.");
128                 continue;
129             }
130         }
131         //Check if this is an sdk folder by looking for the examples sub - dir
132         var examplesDir = sHome + "\\examples";
133         if (! aFileSystemObject.FolderExists(examplesDir))
134         {
135             stdout.WriteLine("\n Error: Could not find directory \"" +
136                              examplesDir + "\". An SDK is required, please specify " +
137                              "the path to a valid SDK installation.");
138             continue;
139         }
141         return sHome;
142     }
145 function getOfficeHome()
147     var sSuggestedHome = WshSysEnv("OFFICE_HOME");
148     if (sSuggestedHome.length == 0)
149     {
150         try {
151             sSuggestedHome = WshShell.RegRead(regKeyOfficeCurrentUser);
152                         //The registry entry points to the program folder but we need the
153                         //installation folder
154         } catch(exc) {}
155         if (sSuggestedHome.length == 0)
156         {
157             try {
158                 sSuggestedHome = WshShell.RegRead(regKeyOfficeLocaleMachine);
159                 //The registry entry points to the program folder but we need
160                                 //the installation folder
161             } catch (exc) {}
162         }
164                 var index=0;
165         if ((index = sSuggestedHome.lastIndexOf("\\")) != -1)
166                    sSuggestedHome = sSuggestedHome.substr(0, index);
168         if (sSuggestedHome.length == 0)
169                    sSuggestedHome = searchOffice();
170     }
172     while(true)
173     {
174         stdout.Write("\n Enter the Office base installation directory [" +
175                      sSuggestedHome + "]:");
176         var sHome = stdin.ReadLine();
177         if (sHome.length == 0)
178         {
179             //No user input, use default.
180             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
181             {
182                 stdout.WriteLine("\n Error: Could not find directory \"" +
183                                  sSuggestedHome + "\" An office installation is " +
184                                                                  "required, please specify the path to a valid " +
185                                                                  "office installation.");
186                 sSuggestedHome = "";
187                 continue;
188             }
189             sHome = sSuggestedHome;
190         } else
191         {
192             //validate the user input
193             if ( ! aFileSystemObject.FolderExists(sHome))
194             {
195                 stdout.WriteLine("\n Error: The directory \"" + sHome +
196                                  "\" does not exist. Please specify the path to " +
197                                                                  "a valid office installation.");
198                 continue;
199             }
200         }
201         //Check if this is a valid office installation folder by looking for the
202                 //program sub-directory
203         var progDir = sHome + "\\program";
204         if (! aFileSystemObject.FolderExists(progDir))
205         {
206             stdout.WriteLine("\n Error: Could not find directory \"" +
207                              progDir + "\". An office installation is required, " +
208                                                          "please specify the path to a valid office " +
209                                                          "installation.");
210             continue;
211         }
212         return sHome;
213     }
216 function searchOffice()
218         var tmp = oo_sdk_home;
220         if (aFileSystemObject.FileExists(tmp + "\\program\\soffice.exe")) {
221            return tmp;
222         }
224         return "";
227 function getMakeHome()
229     var sSuggestedHome = WshSysEnv("OO_SDK_MAKE_HOME");
231     while(true)
232     {
233         stdout.Write("\n Enter GNU make (3.79.1 or higher) tools directory [" +
234                      sSuggestedHome + "]:");
235         var sHome = stdin.ReadLine();
236         if (sHome.length == 0)
237         {
238             //No user input, use default.
239             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
240             {
241                 stdout.WriteLine("\n Error: Could not find directory \"" +
242                                                                  sSuggestedHome + "\". GNU make is required, " +
243                                                                  "please specify a GNU make tools directory.");
244                 sSuggestedHome = "";
245                 continue;
246             }
247             sHome = sSuggestedHome;
248         } else
249         {
250             //validate the user input
251             if ( ! aFileSystemObject.FolderExists(sHome))
252             {
253                 stdout.WriteLine("\n Error: The directory \"" + sHome +
254                                  "\" does not exist. GNU make is required, " +
255                                                                  "please specify a GNU make tools directory.");
256                 continue;
257             }
258         }
259         //Check for the make executable
260         var sMakePath = sHome + "\\make.exe";
261         if (! aFileSystemObject.FileExists(sMakePath))
262         {
263                 sMakePath = sHome + "\\mingw32-make.exe";
264         }
265         if (! aFileSystemObject.FileExists(sMakePath))
266         {
267             stdout.WriteLine("\n Error: Could not find \"" + sMakePath +
268                                                          "\". GNU make is required, please specify a GNU " +
269                                                          "make tools directory.");
270             continue;
271         }
272         return sHome;
273     }
276 function getZipHome()
278     var sSuggestedHome = WshSysEnv("OO_SDK_ZIP_HOME");
280     while(true)
281     {
282         stdout.Write("\n Enter a zip (2.3 or higher) tools directory [" +
283                      sSuggestedHome + "]:");
284         var sHome = stdin.ReadLine();
285         if (sHome.length == 0)
286         {
287             //No user input, use default.
288             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
289             {
290                 stdout.WriteLine("\n Error: Could not find directory \"" +
291                                                                  sSuggestedHome + "\". zip is required, please " +
292                                                                  "specify a zip tools directory.");
293                 sSuggestedHome = "";
294                 continue;
295             }
296             sHome = sSuggestedHome;
297         }
298         else
299         {
300             //validate the user input
301             if ( ! aFileSystemObject.FolderExists(sHome))
302             {
303                 stdout.WriteLine("\n Error: The directory \"" + sHome +
304                                  "\" does not exist. zip is required, please " +
305                                                                  "specify a zip tools directory.");
306                 continue;
307             }
308         }
309         //Check for the make executable
310         var sZipPath = sHome + "\\zip.exe";
311         if (! aFileSystemObject.FileExists(sZipPath))
312         {
313             stdout.WriteLine("\n Error: Could not find \"" + sZipPath +
314                              "\". zip is required, please specify a zip tools " +
315                                                          "directory.");
316             continue;
317         }
318         return sHome;
319     }
322 function getCatHome()
324     var sSuggestedHome = WshSysEnv("OO_SDK_CAT_HOME");
326     while(true)
327     {
328         stdout.Write("\n Enter a cat (2.0 or higher) tools directory [" +
329                      sSuggestedHome + "]:");
330         var sHome = stdin.ReadLine();
331         if (sHome.length == 0)
332         {
333             //No user input, use default.
334             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
335             {
336                 stdout.WriteLine("\n Error: Could not find directory \"" +
337                                  sSuggestedHome + "\". cat is required, please " +
338                                  "specify a cat tools directory." +
339                                  "\nYou can get cat from " +
340                                  "http://sourceforge.net/projects/unxutils/files/latest/download");
341                 sSuggestedHome = "";
342                 continue;
343             }
344             sHome = sSuggestedHome;
345         }
346         else
347         {
348             //validate the user input
349             if ( ! aFileSystemObject.FolderExists(sHome))
350             {
351                 stdout.WriteLine("\n Error: The directory \"" + sHome +
352                                  "\" does not exist. cat is required, please " +
353                                  "specify a cat tools directory." +
354                                  "\nYou can get cat from " +
355                                  "http://sourceforge.net/projects/unxutils/files/latest/download");
356                 continue;
357             }
358         }
359         //Check for the make executable
360         var sCatPath = sHome + "\\cat.exe";
361         if (! aFileSystemObject.FileExists(sCatPath))
362         {
363             stdout.WriteLine("\n Error: Could not find \"" + sCatPath +
364                              "\". cat is required, please specify a cat tools " +
365                              "directory." +
366                              "\nYou can get cat from " +
367                              "http://sourceforge.net/projects/unxutils/files/latest/download");
368             continue;
369         }
370         return sHome;
371     }
374 function getSedHome()
376     var sSuggestedHome = WshSysEnv("OO_SDK_SED_HOME");
378     while(true)
379     {
380         stdout.Write("\n Enter a sed (3.02 or higher) tools directory [" +
381                      sSuggestedHome + "]:");
382         var sHome = stdin.ReadLine();
383         if (sHome.length == 0)
384         {
385             //No user input, use default.
386             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
387             {
388                 stdout.WriteLine("\n Error: Could not find directory \"" +
389                                  sSuggestedHome + "\". sed is required, please " +
390                                  "specify a sed tools directory." +
391                                  "\nYou can get sed from " +
392                                  "http://sourceforge.net/projects/unxutils/files/latest/download");
393                 sSuggestedHome = "";
394                 continue;
395             }
396             sHome = sSuggestedHome;
397         }
398         else
399         {
400             //validate the user input
401             if ( ! aFileSystemObject.FolderExists(sHome))
402             {
403                 stdout.WriteLine("\n Error: The directory \"" + sHome +
404                                  "\" does not exist. sed is required, please " +
405                                  "specify a sed tools directory." +
406                                  "\nYou can get sed from " +
407                                  "http://sourceforge.net/projects/unxutils/files/latest/download");
408                 continue;
409             }
410         }
411         //Check for the make executable
412         var sSedPath = sHome + "\\sed.exe";
413         if (! aFileSystemObject.FileExists(sSedPath))
414         {
415             stdout.WriteLine("\n Error: Could not find \"" + sSedPath +
416                              "\". sed is required, please specify a sed tools " +
417                              "directory." +
418                              "\nYou can get sed from " +
419                              "http://sourceforge.net/projects/unxutils/files/latest/download");
420             continue;
421         }
422         return sHome;
423     }
426 function getCppHome()
428     var sSuggestedHome = WshSysEnv("OO_SDK_CPP_HOME");
429     if (sSuggestedHome.length == 0)
430     {
431         var sVC="";
432         try {
433             sVC = WshShell.RegRead(regKeyVCExpress90);
434         }catch (exc) {}
435         if (sVC.length == 0)
436         {
437                 try {
438                                 sVC = WshShell.RegRead(regKeyVC90);
439                         }catch (exc) {}
440                 }
441                 // check Windows SDK if VC 9
442         if (sVC.length > 0)
443         {
444                     oo_sdk_manifest_used="true";
445                         try {
446                                 oo_sdk_windowssdk = WshShell.RegRead(regKeyWindowsSDK);
447                         }catch (exc) {}
448                 }
449         if (sVC.length == 0)
450         {
451                 try {
452                                 sVC = WshShell.RegRead(regKeyVCExpress80);
453                         }catch (exc) {}
454                 if (sVC.length > 0)
455                            oo_sdk_manifest_used="true";
456                 }
457         if (sVC.length == 0)
458         {
459                 try {
460                                 sVC = WshShell.RegRead(regKeyVC80);
461                         }catch (exc) {}
462                 if (sVC.length > 0)
463                            oo_sdk_manifest_used="true";
464                 }
465         if (sVC.length == 0)
466         {
467                 try {
468                                 sVC = WshShell.RegRead(regKeyVC71);
469                         }catch (exc) {}
470                 }
471         if (sVC.length > 0)
472         {
473             sVC += "bin";
474             if (aFileSystemObject.FileExists(sVC + "\\cl.exe"))
475                 sSuggestedHome = sVC;
476         }
477     }
479     var bSkip = false;
480     while(true)
481     {
482         stdout.Write("\n Enter the directory of the C++ compiler (optional) [" +
483                      sSuggestedHome + "]:");
484         var sHome = stdin.ReadLine();
485         if (sHome.length == 0)
486         {
487             //No user input, check OO_SDK_CPP_HOME or suggested value
488             if ( sSuggestedHome.length == 0 ) {
489                 bSkip = true;
490             } else {
491                 if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
492                 {
493                     stdout.WriteLine("\n Error: Could not find directory \"" +
494                                      sSuggestedHome + "\".");
495                     sSuggestedHome = "";
496                     bSkip = true;
497                 }
498             }
500             sHome = sSuggestedHome;
501         } else
502         {
503             //validate the user input
504             if ( ! aFileSystemObject.FolderExists(sHome))
505             {
506                 stdout.WriteLine("\n Error: Could not find directory \"" +
507                                  sHome + "\".");
508                 bSkip = true;
509             }
510         }
512                 if ( !bSkip) {
513                     //Check if the C++ compiler exist
514                     var cl = sHome + "\\cl.exe";
515                     var mt = sHome + "\\mt.exe";
517                         if (! aFileSystemObject.FileExists(cl))
518                         {
519                                 stdout.WriteLine("\n Error: Could not find the C++ compiler \""
520                                                                  + cl + "\".");
521                                 sHome = "";
522                                 bSkip = true;
523                         } else {
524                             if (aFileSystemObject.FileExists(mt)) {
525                                     oo_sdk_vc8_used="true";
526                                 }
527                         }
528                 }
530                 if ( bSkip ) {
531                    if ( skipChoice("the C++ compiler") ) {
532                            return "";
533                    } else {
534                            bSkip = false;
535                            continue;
536                    }
537                 }
539         return sHome;
540     }
543 function getCliHome()
545     var sSuggestedHome = WshSysEnv("OO_SDK_CLI_HOME");
547     if (sSuggestedHome.length == 0)
548     {
549         try {
550             var _ver = WshShell.RegRead(regKeyDotNet2_0);
551             if (_ver.length > 0)
552             {
553                 sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot);
554                 sSuggestedHome += sDirDotNet2_0;
555                 if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
556                     sSuggestedHome = "";
557             }
559                         if (sSuggestedHome.length == 0)
560                         {
561                                 _ver = WshShell.RegRead(regKeyDotNet1_1);
562                                 if (_ver.length > 0)
563                                 {
564                                         sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot);
565                                         sSuggestedHome += sDirDotNet1_1;
566                                         if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
567                                            sSuggestedHome = "";
568                                 }
569                         }
570                 } catch (exc) {}
571     }
573     var bSkip = false;
574     while(true)
575     {
576         stdout.Write("\n Enter the directory of the C# and VB.NET compilers (optional) [" + sSuggestedHome + "]:");
577         var sHome = stdin.ReadLine();
578         if (sHome.length == 0)
579         {
580             //No user input, check OO_SDK_CLI_HOME or suggested value
581                         if ( sSuggestedHome.length == 0 ) {
582                             bSkip = true;
583                         } else {
584                             if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
585                                 {
586                                         stdout.WriteLine("\n Error: Could not find directory \"" +
587                                                                          sSuggestedHome + "\".");
588                                         sSuggestedHome = "";
589                                         bSkip = true;
590                                 }
591                         }
593                     sHome = sSuggestedHome;
594         }
595         else
596         {
597             //validate the user input
598             if ( ! aFileSystemObject.FolderExists(sHome))
599             {
600                 stdout.WriteLine("\n Error: The directory \"" + sHome +
601                                  "\" does not exist.");
602                 bSkip = true;
603             }
604         }
606                 if ( !bSkip ) {
607                     //Check if the C# and VB.NET compiler exist
608                     var csc = sHome + "\\csc.exe";
609                     var vbc = sHome + "\\vbc.exe";
611                         if (! aFileSystemObject.FileExists(csc))
612                         {
613                                 stdout.WriteLine("\n Error: Could not find the C# compiler \"" +
614                                                                  csc + "\".");
615                                 bSkip = true;
616                         }
617                         if (! aFileSystemObject.FileExists(vbc))
618                         {
619                                 stdout.WriteLine("\n Error: Could not find the VB.NET compiler \"" +
620                                                                  vbc + "\".");
621                                 bSkip = true;
622                         }
623                 }
625                 if ( bSkip ) {
626                    if ( skipChoice("the C# and VB.NET compilers") ) {
627                            return "";
628                    } else {
629                            bSkip = false;
630                            continue;
631                    }
632                 }
634         return sHome;
635     }
638 function getDotnetRoot()
640     var sSuggestedHome = WshSysEnv("OO_SDK_DOTNET_ROOT");
641     if (sSuggestedHome.length == 0)
642     {
643         try {
644             var sWhereResult = WshShell.Exec("where.exe dotnet.exe").StdOut.ReadLine();
645             if (sWhereResult.length > 0)
646             {
647                 sSuggestedHome = sWhereResult;
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 .NET SDK (8 or higher) installation directory (optional) [" + sSuggestedHome + "]:");
658         var sHome = stdin.ReadLine();
659         if (sHome.length == 0)
660         {
661             //No user input, check OO_SDK_DOTNET_ROOT 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 dotnet executable
688                         var dotnetExe = sHome + "\\dotnet.exe";
689                         if (! aFileSystemObject.FileExists(dotnetExe))
690                         {
691                                 stdout.WriteLine("\n Error: Could not find \"" +
692                                                                  dotnetExe + "\".");
693                                 bSkip = true;
694                         }
695         }
697                 if ( bSkip ) {
698                    if ( skipChoice("the .NET SDK") ) {
699                            return "";
700                    } else {
701                            bSkip = false;
702                            continue;
703                    }
704                 }
706         return sHome;
707     }
710 function getJavaHome()
712     var sSuggestedHome = WshSysEnv("OO_SDK_JAVA_HOME");
713     if (sSuggestedHome.length == 0)
714     {
715         try {
716             var currentVersion = WshShell.RegRead(regKeyJDK + "CurrentVersion");
717             if (currentVersion.length > 0)
718             {
719                 sSuggestedHome = WshShell.RegRead(regKeyJDK + currentVersion +
720                                                                                                   "\\JavaHome");
721                 if ( ! aFileSystemObject.FolderExists(sSuggestedHome) )
722                     sSuggestedHome = "";
723             }
724         } catch (exc) {}
725     }
727     var bSkip = false;
728     while(true)
729     {
730         stdout.Write("\n Enter JAVA SDK (1.6 or higher) installation directory (optional) [" + sSuggestedHome + "]:");
731         var sHome = stdin.ReadLine();
732         if (sHome.length == 0)
733         {
734             //No user input, check OO_SDK_JAVA_HOME or suggested value
735                         if ( sSuggestedHome.length == 0 ) {
736                             bSkip = true;
737                         } else {
738                             if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
739                                 {
740                                         stdout.WriteLine("\n Error: Could not find directory \"" +
741                                                                          sSuggestedHome + "\".");
742                                         sSuggestedHome = "";
743                                         bSkip=true;
744                                 }
745                         }
747                         sHome = sSuggestedHome;
748         } else
749         {
750             //validate the user input
751             if ( ! aFileSystemObject.FolderExists(sHome))
752             {
753                 stdout.WriteLine("\n Error: The directory \"" + sHome +
754                                  "\" does not exist.");
755                                 bSkip = true;
756             }
757         }
759                 if ( !bSkip) {
760                     //Check if this is an sdk folder by looking for the javac compiler
761                         var javacompiler = sHome + "\\bin\\javac.exe";
762                         if (! aFileSystemObject.FileExists(javacompiler))
763                         {
764                                 stdout.WriteLine("\n Error: Could not find \"" +
765                                                                  javacompiler + "\".");
766                                 bSkip = true;
767                         }
768         }
770                 if ( bSkip ) {
771                    if ( skipChoice("the Java SDK") ) {
772                            return "";
773                    } else {
774                            bSkip = false;
775                            continue;
776                    }
777                 }
779         return sHome;
780     }
783 function getOutputDir()
785         var defaultdir = "c:\\" + oo_sdk_name;
786     var sSuggestedDir = WshSysEnv("OO_SDK_OUT");
787         if (sSuggestedDir.length == 0)
788            sSuggestedDir = defaultdir;
790     var bSkip = false;
791     while(true)
792     {
793         stdout.Write(
794                         "\n Default output directory is the \"c:\\" + oo_sdk_name + "\".\n" +
795             " Enter an existent directory if you prefer a different one. But note" +
796                         " that only\n a path without spaces is allowed because of a" +
797                         " limitation of gnu make. (optional) [" + sSuggestedDir + "]:");
798         var sDir = stdin.ReadLine();
799         if (sDir.length == 0)
800         {
801             //No user input, check OO_SDK_OUT or suggested value
802                         if ( sSuggestedDir.length == 0 ) {
803                             bSkip = true;
804                         } else {
805                                 if (sSuggestedDir == oo_user_sdk_dir || sSuggestedDir == defaultdir) {
806                                     var fso = new ActiveXObject("Scripting.FileSystemObject");
807                                         if ( !fso.FolderExists(sSuggestedDir) )
808                                                 fso.CreateFolder(sSuggestedDir);
809                                 }
810                             if ( !aFileSystemObject.FolderExists(sSuggestedDir) )
811                                 {
812                                         stdout.WriteLine("\n Error: Could not find directory \"" +
813                                                                          sSuggestedDir + "\".");
814                                         sSuggestedDir = "";
815                                         bSkip = true;
816                                 }
817                         }
819             sDir = sSuggestedDir;
820         }
821         else
822         {
823                         if (sDir.indexOf(' ') != -1) {
824                                 stdout.WriteLine("\n Error: your specified output directory " +
825                                                                  "\"" + sDir + "\" " +
826                                                                  "contains one or more spaces.\n        That " +
827                                                                  "causes problems with gnu make. Please specify" +
828                                                                  " a directory without spaces.");
829                                 bSkip = true;
830                         }
831             //validate the user input
832             if ( ! aFileSystemObject.FolderExists(sDir))
833             {
834                 stdout.WriteLine("\n Error: Could not find directory \"" +
835                                  sDir + "\".");
836                 bSkip = true;
837             }
838         }
840                 if ( bSkip ) {
841                    if ( skipChoice("a special output directory") ) {
842                            return "";
843                    } else {
844                            bSkip = false;
845                            continue;
846                    }
847                 }
849         return sDir;
850     }
853 function getAutoDeployment()
855     var sSuggestedAuto = WshSysEnv("SDK_AUTO_DEPLOYMENT");
856     if (sSuggestedAuto.length == 0)
857         sSuggestedAuto = "YES";
859     while(true)
860     {
861         stdout.Write("\n Automatic deployment of UNO components (YES/NO) ["+
862                      sSuggestedAuto + "]:");
863         var sAuto = stdin.ReadLine();
864         if (sAuto.length == 0)
865             sAuto = sSuggestedAuto;
866         else
867         {
868             sAutoU = sAuto.toUpperCase();
869             if (sAutoU != "YES" && sAutoU != "NO")
870             {
871                 stdout.WriteLine("\n Error: The value \"" + sAuto + "\" is " +
872                                                                  "invalid. Please answer YES or NO.")
873                     continue;
874             }
875             sAuto = sAutoU;
876         }
877         return sAuto;
878     }
881 //The function uses sp2bv.exe to obtain a file URL from a
882 //system path. The URL is already escaped for use as bootstrap variable.
883 //($ -> \$). Then the resulting string is escaped for use in a bat file.
884 //That is % signs are made to double % (% -> %%);
885 function makeBootstrapFileUrl(systemPath)
887     var oExec = WshShell.Exec("sp2bv.exe \"" + systemPath + "\"");
888     var output="";
889     while (true)
890     {
891         if (!oExec.StdOut.AtEndOfStream)
892         {
893             var next = oExec.StdOut.Read(1);
894             if (next == '%')
895                 output += "%%";
896             else
897                 output += next;
898         }
899         else
900             break;
901     }
902     return output;
905 function writeBatFile(fdir, file)
907     var fso = new ActiveXObject("Scripting.FileSystemObject");
908     if ( !fso.FolderExists(fdir) )
909        fso.CreateFolder(fdir);
910     var newFile = fso.CreateTextFile(file, true);
912     newFile.Write(
913         "@echo off\n" +
914         "REM This script sets all environment variables, which\n" +
915         "REM are necessary for building the examples of the Office Development Kit.\n" +
916         "REM The Script was developed for the operating systems Windows.\n" +
917         "REM The SDK name\n" +
918         "REM Example: set OO_SDK_NAME=libreoffice3.4_sdk\n" +
919         "set OO_SDK_NAME=" + oo_sdk_name  +
920         "\n\n" +
921         "REM Installation directory of the Software Development Kit.\n" +
922         "REM Example: set OO_SDK_HOME=C:\\Program Files\\LibreOffice 3\\sdk\n" +
923         "set OO_SDK_HOME=" + oo_sdk_home  +
924         "\n\n" +
925         "REM Office installation directory.\n" +
926         "REM Example: set OFFICE_HOME=C:\\Program Files\\LibreOffice 3\n" +
927         "set OFFICE_HOME=" + office_home +
928         "\n\n" +
929         "REM Directory of the make command.\n" +
930         "REM Example: set OO_SDK_MAKE_HOME=D:\\NextGenerationMake\\make\n" +
931         "set OO_SDK_MAKE_HOME=" + oo_sdk_make_home +
932         "\n\n" +
933                 "REM Directory of the zip tool.\n" +
934                 "REM Example: set OO_SDK_ZIP_HOME=D:\\infozip\\bin\n" +
935                 "set OO_SDK_ZIP_HOME=" + oo_sdk_zip_home +
936         "\n\n" +
937         "REM Directory of the cat tool.\n" +
938         "REM Example: set OO_SDK_CAT_HOME=C:\\UnxUtils\\usr\\local\\wbin\n" +
939         "set OO_SDK_CAT_HOME=" + oo_sdk_cat_home +
940         "\n\n" +
941         "REM Directory of the sed tool.\n" +
942         "REM Example: set OO_SDK_SED_HOME=C:\\UnxUtils\\usr\\local\\wbin\n" +
943         "set OO_SDK_SED_HOME=" + oo_sdk_sed_home +
944         "\n\n" +
945         "REM Directory of the C++ compiler.\n" +
946         "REM Example:set OO_SDK_CPP_HOME=C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\n" +
947         "set OO_SDK_CPP_HOME=" + oo_sdk_cpp_home +
948                 "\nset CPP_MANIFEST=" + oo_sdk_manifest_used +
949                 "\nset CPP_WINDOWS_SDK=" + oo_sdk_windowssdk +
950         "\n\n" +
951         "REM Directory of the C# and VB.NET compilers.\n" +
952         "REM Example:set OO_SDK_CLI_HOME=C:\\WINXP\\Microsoft.NET\\Framework\\v1.0.3705\n" +
953         "set OO_SDK_CLI_HOME=" + oo_sdk_cli_home +
954         "\n\n" +
955         "REM .NET SDK installation directory.\n" +
956         "REM Example: set OO_SDK_DOTNET_ROOT=C:\\Program Files\\Java\\jdk1.6.0_05\n" +
957         "set OO_SDK_DOTNET_ROOT=" + oo_sdk_dotnet_root +
958         "\n\n" +
959         "REM Java SDK installation directory.\n" +
960         "REM Example: set OO_SDK_JAVA_HOME=C:\\Program Files\\Java\\jdk1.6.0_05\n" +
961         "set OO_SDK_JAVA_HOME=" + oo_sdk_java_home +
962         "\n\n" +
963         "REM Special output directory\n" +
964         "REM Example: set OO_SDK_OUT=C:\\" + oo_sdk_name + "\n" +
965         "set OO_SDK_OUT=" + oo_sdk_out +
966         "\n\n" +
967         "REM Automatic deployment\n" +
968         "REM Example: set SDK_AUTO_DEPLOYMENT=YES\n" +
969         "set SDK_AUTO_DEPLOYMENT=" + sdk_auto_deployment +
970         "\n\n" +
971         "REM Check installation path for the Office Development Kit.\n" +
972         "if not defined OO_SDK_HOME (\n" +
973         "   echo Error: the variable OO_SDK_HOME is missing!\n" +
974         "   goto :error\n" +
975         " )\n" +
976         "\n" +
977         "REM Check installation path for the office.\n" +
978         "REM if not defined OFFICE_HOME (\n" +
979         "REM    echo Error: the variable OFFICE_HOME is missing!\n" +
980         "REM    goto :error\n" +
981         "REM  )\n" +
982         "\n" +
983         "REM Check installation path for GNU make.\n" +
984         "if not defined OO_SDK_MAKE_HOME (\n" +
985         "   echo Error: the variable OO_SDK_MAKE_HOME is missing!\n" +
986         "   goto :error\n" +
987         " )\n" +
988         "\n" +
989         "REM Check installation path for the zip tool.\n" +
990         "if not defined OO_SDK_ZIP_HOME (\n" +
991         "   echo Error: the variable OO_SDK_ZIP_HOME is missing!\n" +
992         "   goto :error\n" +
993         " )\n" +
994         "\n" +
995         "REM Check installation path for the cat tool.\n" +
996         "if not defined OO_SDK_CAT_HOME (\n" +
997         "   echo Error: the variable OO_SDK_CAT_HOME is missing!\n" +
998         "   goto :error\n" +
999         " )\n" +
1000         "\n" +
1001         "REM Check installation path for the sed tool.\n" +
1002         "if not defined OO_SDK_SED_HOME (\n" +
1003         "   echo Error: the variable OO_SDK_SED_HOME is missing!\n" +
1004         "   goto :error\n" +
1005         " )\n" +
1006         "\n" +
1007         "REM Set library path. \n" +
1008         "set \"LIB=%OO_SDK_HOME%\\lib;%LIB%\"\n" +
1009         "if defined CPP_WINDOWS_SDK (\n" +
1010         "   set \"LIB=%LIB%;%CPP_WINDOWS_SDK%\\lib\"\n" +
1011         " )\n" +
1012         "\n" +
1013         "REM Set office program path.\n" +
1014         "if defined OFFICE_HOME (\n" +
1015         "   set OFFICE_PROGRAM_PATH=%OFFICE_HOME%\\program\n" +
1016         " )\n" +
1017         "\n" +
1018                 "REM Set UNO path, necessary to ensure that the cpp examples using the\n" +
1019                 "REM new UNO bootstrap mechanism use the configured office installation\n" +
1020                 "REM (only set when using an Office).\n" +
1021                 "if defined OFFICE_HOME (\n" +
1022                 "   set UNO_PATH=%OFFICE_PROGRAM_PATH%\n" +
1023                 " )\n" +
1024         "\n" +
1025         "set OO_SDK_URE_BIN_DIR=%OFFICE_PROGRAM_PATH%\n" +
1026         "set OO_SDK_URE_LIB_DIR=%OFFICE_PROGRAM_PATH%\n" +
1027         "set OO_SDK_URE_JAVA_DIR=%OFFICE_PROGRAM_PATH%\\classes\n" +
1028         "set OO_SDK_URE_DOTNET_DIR=%OFFICE_PROGRAM_PATH%\\dotnet\n" +
1029         "set OO_SDK_OFFICE_BIN_DIR=%OFFICE_PROGRAM_PATH%\n" +
1030         "set OO_SDK_OFFICE_LIB_DIR=%OFFICE_PROGRAM_PATH%\n" +
1031         "set OO_SDK_OFFICE_JAVA_DIR=%OFFICE_PROGRAM_PATH%\\classes\n" +
1032         "set OO_SDK_OFFICE_DOTNET_DIR=%OFFICE_PROGRAM_PATH%\\dotnet\n" +
1033         "\n" +
1034         "REM Set classpath\n" +
1035         "set CLASSPATH=%OO_SDK_URE_JAVA_DIR%\\libreoffice.jar;%OO_SDK_URE_JAVA_DIR%\\unoloader.jar\n" +
1036         "\n" +
1037         "REM Add directory of the SDK tools to the path.\n" +
1038         "set PATH=%OO_SDK_HOME%\\bin;%OO_SDK_URE_BIN_DIR%;%OO_SDK_OFFICE_BIN_DIR%;%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" +
1039         "\n" +
1040         "REM Set PATH appropriate to the output directory\n" +
1041         "if defined OO_SDK_OUT set PATH=%OO_SDK_OUT%\\WINexample.out\\bin;%PATH%\n" +
1042         "if not defined OO_SDK_OUT set PATH=%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" +
1043         "\n" +
1044         "REM Add directory of the command make to the path, if necessary.\n" +
1045         "if defined OO_SDK_MAKE_HOME set PATH=%OO_SDK_MAKE_HOME%;%PATH%\n" +
1046         "\n" +
1047         "REM Add directory of the zip tool to the path, if necessary.\n" +
1048         "if defined OO_SDK_ZIP_HOME set PATH=%OO_SDK_ZIP_HOME%;%PATH%\n" +
1049         "\n" +
1050         "REM Add directory of the cat tool to the path, if necessary.\n" +
1051         "if defined OO_SDK_CAT_HOME set PATH=%OO_SDK_CAT_HOME%;%PATH%\n" +
1052         "\n" +
1053         "REM Add directory of the sed tool to the path, if necessary.\n" +
1054         "if defined OO_SDK_SED_HOME set PATH=%OO_SDK_SED_HOME%;%PATH%\n" +
1055         "\n" +
1056         "REM Add directory of the C++ compiler to the path, if necessary.\n" +
1057         "if defined OO_SDK_CPP_HOME set PATH=%OO_SDK_CPP_HOME%;%PATH%\n" +
1058         "\n" +
1059         "REM Add directory of the Win SDK to the path, if necessary.\n" +
1060         "if defined CPP_WINDOWS_SDK set PATH=%CPP_WINDOWS_SDK%\\bin;%PATH%\n" +
1061         "if defined CPP_WINDOWS_SDK set INCLUDE=%CPP_WINDOWS_SDK%\\Include;%INCLUDE%\n" +
1062         "REM Add directory of the C# and VB.NET compilers to the path, if necessary.\n" +
1063         "if defined OO_SDK_CLI_HOME set PATH=%OO_SDK_CLI_HOME%;%PATH%\n" +
1064         "\n" +
1065         "REM Add directory of the dotnet command-line tool to the path, if necessary.\n" +
1066         "if defined OO_SDK_DOTNET_ROOT set PATH=%OO_SDK_DOTNET_ROOT%;%PATH%\n" +
1067         "\n" +
1068         "REM Add directory of the Java tools to the path, if necessary.\n" +
1069         "if defined OO_SDK_JAVA_HOME set PATH=%OO_SDK_JAVA_HOME%\\bin;%OO_SDK_JAVA_HOME%\\jre\\bin;%PATH%\n" +
1070         "\n" +
1071         "REM Set environment for C++ compiler tools, if necessary.\n" +
1072         "if defined OO_SDK_CPP_HOME call \"%OO_SDK_CPP_HOME%\\VCVARS32.bat\"\n" +
1073         "\n" +
1074         "REM Set title to identify the prepared shell.\n" +
1075         "title Shell prepared for SDK\n" +
1076         "\nREM Prepare shell with all necessary environment variables.\n" +
1077         "echo.\n" +
1078         "echo  ******************************************************************\n" +
1079         "echo  *\n" +
1080         "echo  * SDK environment is prepared for Windows\n" +
1081         "echo  *\n" +
1082         "echo  * SDK = %OO_SDK_HOME%\n" +
1083         "echo  * Office = %OFFICE_HOME%\n" +
1084         "echo  * Make = %OO_SDK_MAKE_HOME%\n" +
1085         "echo  * Zip = %OO_SDK_ZIP_HOME%\n" +
1086         "echo  * cat = %OO_SDK_CAT_HOME%\n" +
1087         "echo  * sed = %OO_SDK_SED_HOME%\n" +
1088         "echo  * C++ Compiler = %OO_SDK_CPP_HOME%\n" +
1089         "echo  * C# and VB.NET compilers = %OO_SDK_CLI_HOME%\n" +
1090         "echo  * Dotnet = %OO_SDK_DOTNET_ROOT%\n" +
1091         "echo  * Java = %OO_SDK_JAVA_HOME%\n" +
1092         "echo  * Special Output directory = %OO_SDK_OUT%\n" +
1093         "echo  * Auto deployment = %SDK_AUTO_DEPLOYMENT%\n" +
1094         "echo  *\n" +
1095         "echo  ******************************************************************\n" +
1096         "echo.\n" +
1097         "goto end\n" +
1098         "\n" +
1099         " :error\n" +
1100         "Error: Please insert the necessary environment variables into the batch file.\n" +
1101         "\n" +
1102         " :end\n"
1103         );
1104         newFile.Close();