This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/scripts/make_eclipselgt.js
pmoura 36a326908c Logtalk 2.28.2 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1711 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2006-11-07 17:11:47 +00:00

125 lines
4.3 KiB
JavaScript

// =================================================================
// Logtalk - Object oriented extension to Prolog
// Release 2.28.2
//
// Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
// =================================================================
if (ScriptEngineMajorVersion() < 5 || ScriptEngineMajorVersion() == 5 && ScriptEngineMinorVersion() < 6) {
WScript.Echo('Error! WSH 5.6 or later version needed for running this script.');
WScript.Quit(1);
}
if (WScript.Arguments.Unnamed.Length > 0) {
usage_help();
WScript.Quit(0);
}
WScript.Echo('');
WScript.Echo('Creating a shortcut named "Logtalk - ECLiPSe" for running Logtalk with');
WScript.Echo('ECLiPSe 5.10 (edit this script if you are using a different version)...');
WScript.Echo('');
var WshShell = new ActiveXObject("WScript.Shell");
var prolog_path = WshShell.RegRead("HKLM\\Software\\IC-Parc\\Eclipse\\5.10\\ECLIPSEDIR") + "\\lib\\i386_nt\\eclipse.exe";
var FSObject = new ActiveXObject("Scripting.FileSystemObject");
if (!FSObject.FileExists(prolog_path)) {
WScript.Echo("Error! Cannot find eclipse.exe at the expected place!");
WScript.Echo("Please, edit the script and update the location of the eclipse.exe executable.");
WScript.Quit(1);
}
var WshSystemEnv = WshShell.Environment("SYSTEM");
var WshUserEnv = WshShell.Environment("USER");
var logtalk_home;
if (WshSystemEnv.Item("LOGTALKHOME"))
logtalk_home = WshSystemEnv.Item("LOGTALKHOME");
else if (WshUserEnv.Item("LOGTALKHOME"))
logtalk_home = WshUserEnv.Item("LOGTALKHOME")
else {
WScript.Echo("Error! The system environment variable LOGTALKHOME must be defined first!");
usage_help();
WScript.Quit(1);
}
if (!FSObject.FolderExists(logtalk_home)) {
WScript.Echo("The environment variable LOGTALKHOME points to a non-existing directory!");
WScript.Echo("Its current value is: %LOGTALKHOME%");
WScript.Echo("The variable must be set to your Logtalk installation directory!");
WScript.Echo("");
usage_help();
WScript.Quit(1);
}
logtalk_home = logtalk_home.replace(/\\/g, "\\\\");
if (!FSObject.FolderExists(logtalk_home + "\\bin"))
FSObject.CreateFolder(logtalk_home + "\\bin");
var f1 = FSObject.CreateTextFile(logtalk_home + "\\bin\\logtalk_comp_eclipse.pl", true);
var f2 = FSObject.OpenTextFile(logtalk_home + "\\compiler\\logtalk.pl", 1);
var line;
f1.WriteLine(":- pragma(system).");
f1.WriteLine(":- pragma(nodebug).");
while (!f2.AtEndOfStream) {
line = f2.ReadLine();
f1.WriteLine(line);
}
f1.Close();
f2.Close();
f = FSObject.CreateTextFile(logtalk_home + "\\bin\\logtalk_eclipse.pl", true);
f.WriteLine(":- ensure_loaded(library(toplevel)).");
f.WriteLine(":- cd('$LOGTALKUSER').");
f.WriteLine(":- compile('configs/eclipseiso.config').");
f.WriteLine(":- cd('$LOGTALKHOME').");
f.WriteLine(":- compile('bin/logtalk_comp_eclipse.pl').");
f.WriteLine(":- cd('$LOGTALKUSER').");
f.WriteLine(":- compile('libpaths/libpaths.pl').");
f.Close();
var ProgramsPath = WshShell.SpecialFolders("AllUsersPrograms");
if (!FSObject.FolderExists(ProgramsPath + "\\Logtalk"))
FSObject.CreateFolder(ProgramsPath + "\\Logtalk");
var link = WshShell.CreateShortcut(ProgramsPath + "\\Logtalk\\Logtalk - ECLiPSe.lnk");
link.Arguments = '-b "%LOGTALKHOME%\\bin\\logtalk_eclipse.pl"';
link.Description = 'Runs Logtalk with ECLiPSe';
link.IconLocation = 'app.exe,1';
link.TargetPath = prolog_path;
link.WindowStyle = 1;
link.WorkingDirectory = '%LOGTALKUSER%';
link.Save();
WScript.Echo('Done. The "Logtalk - ECLiPSe" shortcut was been added to the');
WScript.Echo('Start Menu Programs. Make sure that the environment variables');
WScript.Echo('LOGTALKHOME and LOGTALKUSER are defined for all users wishing');
WScript.Echo('to use the shortcut.');
WScript.Echo('');
WScript.Echo('Users must run the batch script "cplgtdirs" before using the');
WScript.Echo('"Logtalk - ECLiPSe" shortcut.');
WScript.Echo('');
WScript.Quit(0);
function usage_help() {
WScript.Echo('');
WScript.Echo('This script creates a shortcut named "Logtalk - ECLiPSe" for running Logtalk');
WScript.Echo('with ECLiPSe. The script must be run by a user with administrative rights.');
WScript.Echo('The LOGTALKHOME environment variable must be defined before running this');
WScript.Echo('script.');
WScript.Echo('');
WScript.Echo('Usage:');
WScript.Echo(' ' + WScript.ScriptName + ' help');
WScript.Echo(' ' + WScript.ScriptName);
WScript.Echo('');
}