diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-11-16 18:07:34 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-11-16 18:07:34 +0200 |
| commit | fc703faaa6326e28e146e00615db01c48ded0ece (patch) | |
| tree | 26b8b3134ab8562d8a7bf3c04bf99b897c5c3edb /Software/Visual_Studio/Tango.Protobuf | |
| parent | 4be586d903da2b0dbba23f4978e14ad7d51edcbf (diff) | |
| download | Tango-fc703faaa6326e28e146e00615db01c48ded0ece.tar.gz Tango-fc703faaa6326e28e146e00615db01c48ded0ece.zip | |
Implemented PMR for CCS!
First test working.
Parsed and returned Calculate Stub!
Implemented custom proto C compiling to achieve shorter struct names!
Diffstat (limited to 'Software/Visual_Studio/Tango.Protobuf')
| -rw-r--r-- | Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs | 39 |
1 files changed, 27 insertions, 12 deletions
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 } /// <summary> - /// Compiles the specified .proto message file. + /// Compiles all files in the specified folder recursively. /// </summary> - /// <param name="inputFile">.proto file to compile</param> + /// <param name="sourceFolder">The source folder</param> /// <returns> - /// A list of compiled results. + /// Compilation result. /// </returns> - //public override IEnumerable<CompilerFileResult> CompileFile(string inputFile) - //{ - // var files = base.CompileFile(inputFile); + public override CompilerFolderResult CompileFolder(string sourceFolder) + { + String temp = PathHelper.GetTempFolderPath(); + PathHelper.CopyDirectory(sourceFolder, temp, true); + + List<String> 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); + } } } |
