Ejemplo n.º 1
0
 private void SpawnCompiler(int currentId)
 {
     var compilation = pluginComp[currentId];
     compilation.Started();
     var source_files = compilation.plugins.SelectMany(plugin => plugin.IncludePaths).Distinct().Select(path => new CompilerFile(path)).ToList();
     source_files.AddRange(compilation.plugins.Select(plugin => new CompilerFile(plugin.ScriptName + ".cs", plugin.ScriptSource)));
     var compilerData = new CompilerData
     {
         OutputFile = compilation.name,
         SourceFiles = source_files.ToArray(),
         ReferenceFiles = compilation.references.ToArray()
     };
     var message = new CompilerMessage { Id = currentId, Data = compilerData, Type = CompilerMessageType.Compile };
     if (ready)
         client.PushMessage(message);
     else
         compQueue.Enqueue(message);
 }
Ejemplo n.º 2
0
 private void EnqueueCompilation(Compilation compilation)
 {
     if (compilation.plugins.Count < 1)
     {
         Interface.Oxide.LogDebug("EnqueueCompilation called for an empty compilation");
         return;
     }
     if (!CheckCompiler())
     {
         OnCompilerFailed("Compiler couldn't be started.");
         return;
     }
     compilation.Started();
     //Interface.Oxide.LogDebug("Compiling with references: " + compilation.references.Keys.ToSentence());
     var source_files = compilation.plugins.SelectMany(plugin => plugin.IncludePaths).Distinct().Select(path => new CompilerFile(path)).ToList();
     source_files.AddRange(compilation.plugins.Select(plugin => new CompilerFile(plugin.ScriptName + ".cs", plugin.ScriptSource)));
     //Interface.Oxide.LogDebug("Compiling files: " + source_files.Select(f => f.Name).ToSentence());
     var data = new CompilerData
     {
         OutputFile = compilation.name,
         SourceFiles = source_files.ToArray(),
         ReferenceFiles = compilation.references.Values.ToArray()
     };
     var message = new CompilerMessage { Id = compilation.id, Data = data, Type = CompilerMessageType.Compile };
     if (ready)
         client.PushMessage(message);
     else
         messageQueue.Enqueue(message);
 }
Ejemplo n.º 3
0
        private void SpawnCompiler(int currentId)
        {
            var compilation = pluginComp[currentId];
            compilation.startedAt = Interface.Oxide.Now;
            var referenceFiles = new List<CompilerFile>(compilation.references.Count);
            referenceFiles.AddRange(compilation.references.Select(reference_name => new CompilerFile { Name = reference_name + ".dll", Data = File.ReadAllBytes(Path.Combine(Interface.Oxide.ExtensionDirectory, reference_name + ".dll")) }));

            var sourceFiles = compilation.plugins.SelectMany(plugin => plugin.IncludePaths).Distinct().Select(includePath => new CompilerFile { Name = Path.GetFileName(includePath), Data = File.ReadAllBytes(includePath) }).ToList();
            sourceFiles.AddRange(compilation.plugins.Select(plugin => new CompilerFile { Name = plugin.ScriptName + ".cs", Data = plugin.ScriptEncoding.GetBytes(string.Join(Environment.NewLine, plugin.ScriptLines)) }));

            var compilerData = new CompilerData
            {
                OutputFile = (compilation.plugins.Count == 1 ? compilation.plugins[0].Name : "plugins_") + Math.Round(Interface.Oxide.Now * 10000000f) + ".dll",
                SourceFiles = sourceFiles.ToArray(),
                ReferenceFiles = referenceFiles.ToArray()
            };
            var message = new CompilerMessage {Id = currentId, Data = compilerData, Type = CompilerMessageType.Compile};
            if (ready)
                client.PushMessage(message);
            else
                compQueue.Enqueue(message);
        }