diff options
Diffstat (limited to 'Software/Visual_Studio')
3 files changed, 67 insertions, 13 deletions
diff --git a/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs index fa52eb42b..dd613ac5e 100644 --- a/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs @@ -28,5 +28,44 @@ namespace Tango.Core.Helpers return false; } } + + + public static void CopyDirectory(string sourceDirName, string destDirName, bool copySubDirs) + { + // Get the subdirectories for the specified directory. + DirectoryInfo dir = new DirectoryInfo(sourceDirName); + + if (!dir.Exists) + { + throw new DirectoryNotFoundException( + "Source directory does not exist or could not be found: " + + sourceDirName); + } + + DirectoryInfo[] dirs = dir.GetDirectories(); + // If the destination directory doesn't exist, create it. + if (!Directory.Exists(destDirName)) + { + Directory.CreateDirectory(destDirName); + } + + // Get the files in the directory and copy them to the new location. + FileInfo[] files = dir.GetFiles(); + foreach (FileInfo file in files) + { + string temppath = Path.Combine(destDirName, file.Name); + file.CopyTo(temppath, false); + } + + // If copying subdirectories, copy them and their contents to new location. + if (copySubDirs) + { + foreach (DirectoryInfo subdir in dirs) + { + string temppath = Path.Combine(destDirName, subdir.Name); + CopyDirectory(subdir.FullName, temppath, copySubDirs); + } + } + } } } 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); + } } } diff --git a/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs index 57e3ddcad..577dd41b4 100644 --- a/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs @@ -21,7 +21,7 @@ namespace Tango.MobileEM.UI protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); - Emulator = new MobileEmulator(new ProtoTransporter(new TcpTransportAdapter("127.0.0.1", 9999))); + Emulator = new MobileEmulator(new ProtoTransporter(new UsbTransportAdapter("COM9"))); } } } |
