Example #1
0
        string GetSyntaxMode()
        {
            if (this.Document == null)
            {
                return("LuaSyntaxMode.xml");
            }

            LuaProject project = IdeApp.Workspace.GetProjectContainingFile(this.Document.FileName) as LuaProject;

            if (project != null)
            {
                LuaConfiguration config = project.DefaultConfiguration as LuaConfiguration;

                Console.WriteLine("Using {0} Lua highlighting", config.LangVersion);
                switch (config.LangVersion)
                {
                case LangVersion.Lua:                 // TODO: Make these use their own, maybe
                case LangVersion.Lua52:
                case LangVersion.Lua51:
                case LangVersion.LuaJIT:
                    return("LuaSyntaxMode.xml");

                case LangVersion.GarrysMod:
                    return("GarrysModLuaSyntaxMode.xml");
                }
            }

            return("LuaSyntaxMode.xml");
        }
Example #2
0
        protected override bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configuration)
        {
            // TODO: Check interpreter paths from here...
            LuaConfiguration config = this.DefaultConfiguration as LuaConfiguration;

            return(!string.IsNullOrWhiteSpace(config.MainFile));
        }
Example #3
0
        protected override BuildResult DoBuild(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            LuaConfiguration config = this.DefaultConfiguration as LuaConfiguration;

            if (config != null && config.LangVersion == LangVersion.GarrysMod)
            {
                monitor.ReportWarning("Can't build a with Garry's Mod Lua syntax!");
                return(new BuildResult("Can't build a with Garry's Mod Lua syntax!", 0, 0));
            }

            return(LuaCompilerManager.Compile(this.Items, config, configuration, monitor));
        }
Example #4
0
        static FilePath GetLuaPath(LuaConfiguration conf)
        {
            switch (conf.LangVersion)
            {
            case LangVersion.Lua:
                return((FilePath)PropertyService.Get <string>("Lua.DefaultInterpreterPath"));

            case LangVersion.Lua51:
                return((FilePath)PropertyService.Get <string>("Lua.51InterpreterPath"));

            case LangVersion.Lua52:
                return((FilePath)PropertyService.Get <string>("Lua.52InterpreterPath"));

            case LangVersion.LuaJIT:
                return((FilePath)PropertyService.Get <string>("Lua.JITInterpreterPath"));

            case LangVersion.Moai:
            case LangVersion.Love:
                return(new FilePath(conf.Launcher));
            }

            return(null);
        }
        public static BuildResult Compile(ProjectItemCollection projectItems, LuaConfiguration configuration, ConfigurationSelector configselector, IProgressMonitor monitor)
        {
//			LuaCompilerParameters compilerParameters = (LuaCompilerParameters)configuration.CompilationParameters ?? new LuaCompilerParameters ();


            var sb = new StringBuilder();

            sb.Append("-p ");

            var gacRoots = new List <string>();

            if (configuration.DebugMode)
            {
                // TODO: This
            }

            foreach (ProjectFile finfo in projectItems.GetAll <ProjectFile> ())
            {
                if (finfo.Subtype == Subtype.Directory)
                {
                    continue;
                }

                switch (finfo.BuildAction)
                {
                case "Compile":
                    AppendQuoted(sb, "", finfo.Name);
                    break;

                default:
                    continue;
                }
            }

            string output = "";
            string error  = "";

            /*
             * string luac = configuration.TargetRuntime.GetToolPath (configuration.TargetFramework, "luac");
             * if (luac == null) {
             *      BuildResult res = new BuildResult ();
             *      res.AddError(GettextCatalog.GetString ("Lua compiler (luac) not found."));
             *      return res;
             * }
             */

            string outstr = sb.ToString();

            monitor.Log.WriteLine(outstr);

            string working_dir = ".";

            if (configuration.ParentItem != null)
            {
                working_dir = configuration.ParentItem.BaseDirectory;
                if (working_dir == null)
                {
                    working_dir = ".";
                }
            }

            LoggingService.LogInfo("luac " + sb);

            var envVars  = configuration.EnvironmentVariables;
            int exitCode = DoCompilation(outstr, working_dir, envVars, gacRoots, ref output, ref error, monitor);

            BuildResult result = ParseOutput(output, error, projectItems);

            if (result.CompilerOutput.Trim().Length != 0)
            {
                monitor.Log.WriteLine(result.CompilerOutput);
            }

            //if compiler crashes, output entire error string
            if (result.ErrorCount == 0 && exitCode != 0)
            {
                if (!string.IsNullOrEmpty(error))
                {
                    result.AddError(error);
                }
                else
                {
                    result.AddError("The compiler appears to have crashed without any error output.");
                }
            }

            FileService.DeleteFile(output);
            FileService.DeleteFile(error);
            return(result);
        }
Example #6
0
        protected virtual LuaExecutionCommand CreateExecutionCommand(ConfigurationSelector configSel, LuaConfiguration configuration)
        {
            FilePath LuaPath = GetLuaPath(configuration);

            string arguments = "\"" + configuration.MainFile + "\" " + configuration.CommandLineParameters;

            var command = new LuaExecutionCommand(LuaPath)
            {
                Arguments            = arguments,
                WorkingDirectory     = BaseDirectory,
                EnvironmentVariables = configuration.GetParsedEnvironmentVariables(),
                Configuration        = configuration
            };

            return(command);
        }