//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void ParseDependencyLine(string line) { if (string.IsNullOrWhiteSpace(line)) { return; } // // Remove a trailing '\' character used to signify the list continues on the next line. // if (line.EndsWith(@"\")) { line = line.Substring(0, line.Length - 1); } line.Trim(); // // Now iterate through the line which can contain zero or more dependencies. // Although they are seperated by spaces we can't use Split() here since filenames // can also contain spaces that are escaped using backslash. For some reason only // spaces are escaped. Even literal backslash chars don't need escaping. // while ((line.Length > 0) && (!string.IsNullOrWhiteSpace(line))) { int end = FindEndOfFilename(line); string filename = line.Substring(0, end); if (!string.IsNullOrWhiteSpace(filename)) { // // Files with spaces in look like this: // C:\Program\ Files\ (x86)\ARM\Mali\ Developer\ Tools\OpenGL\ ES\ 1.1\ Emulator\ v1.0\include/GLES2/gl2ext.h \ // filename = PathUtils.UnescapePath(filename); filename = PathUtils.ConvertPathCygwinToWindows(filename); if (!m_dependencies.ContainsKey(filename)) { m_dependencies.Add(filename, new TaskItem(filename)); } } if (end == line.Length) { break; } line = line.Substring(end + 1).Trim(); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void Parse(string dependencyFile) { // // Parse GCC and Java-style dependency files. // // GCC: // AndroidMT/Debug/native-media-jni.obj: \ // C:/Users/Justin/documents/visual\ studio\ 2010/Projects/native-media/native-media/jni/native-media-jni.c \ // // JAVA: // AndroidMT/Debug/native-media-jni.class \ // : C:/Users/Justin/documents/visual\ studio\ 2010/Projects/native-media/native-media/jni/native-media-jni.java \ // // // To reading variable ':' placement headers easier, we read the entire file and reconstitute it around ': ' and ' \'. // string fileContents = File.ReadAllText(dependencyFile); fileContents = fileContents.Replace(System.Environment.NewLine, ""); string [] dependencyEntries = fileContents.Split(new string [] { ": \\", " \\", ": " }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < dependencyEntries.Length; ++i) { string line = dependencyEntries [i].Replace(": ", "").Replace(" \\", "").Trim(); if (!string.IsNullOrWhiteSpace(line)) { if (i == 0) { string outputFilePath = PathUtils.UnescapePath(line); m_outputFile = new TaskItem(outputFilePath); m_dependencies = new Dictionary <string, ITaskItem> (dependencyEntries.Length); } else { ParseDependencyLine(line); } } } }