From fc703faaa6326e28e146e00615db01c48ded0ece Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 16 Nov 2017 18:07:34 +0200 Subject: Implemented PMR for CCS! First test working. Parsed and returned Calculate Stub! Implemented custom proto C compiling to achieve shorter struct names! --- .../Tango.Protobuf/Compilers/CCompiler.cs | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'Software/Visual_Studio/Tango.Protobuf') diff --git a/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs b/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs index 0d97c9711..57064ec9f 100644 --- a/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs +++ b/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Helpers; namespace Tango.Protobuf.Compilers { @@ -39,22 +41,35 @@ namespace Tango.Protobuf.Compilers } /// - /// Compiles the specified .proto message file. + /// Compiles all files in the specified folder recursively. /// - /// .proto file to compile + /// The source folder /// - /// A list of compiled results. + /// Compilation result. /// - //public override IEnumerable CompileFile(string inputFile) - //{ - // var files = base.CompileFile(inputFile); + public override CompilerFolderResult CompileFolder(string sourceFolder) + { + String temp = PathHelper.GetTempFolderPath(); + PathHelper.CopyDirectory(sourceFolder, temp, true); + + List directories = Directory.GetDirectories(sourceFolder, "*", SearchOption.AllDirectories).ToList(); + + foreach (var file in Directory.GetFiles(temp, "*.proto", SearchOption.AllDirectories)) + { + String str = File.ReadAllText(file); - // foreach (var file in files) - // { - // file.Name = file.Name.Replace(".pb-c", ""); - // } + foreach (String dir in directories.Select(x => Path.GetFileName(x))) + { + str = str.Replace(dir + ".", ""); + } - // return files; - //} + var lines = str.ToLines(); + lines.RemoveAll(x => x.Contains("package ")); + str = String.Join(Environment.NewLine, lines); + File.WriteAllText(file, str); + } + + return base.CompileFolder(temp); + } } } -- cgit v1.3.1