aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs')
-rw-r--r--Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs39
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);
+ }
}
}