private string QuotedIncludePaths() { string sd = SolutionDir.ToLower(); string rtn = ""; string[] includes = IncludePaths.Split(new char[1] { ';' }); foreach (string p in includes) { rtn += """; if (p.Length > sd.Length && p.Substring(0, sd.Length).ToLower() == sd) { string rp = p.Substring(sd.Length); // relative path if (rp[0] == '\\') { rp = rp.Substring(1); } rtn += "$(SolutionDir)" + rp; } else { rtn += p; } rtn += "";"; } // strip off the last semicolon to match VS if (rtn.Length > 0) { rtn = rtn.Substring(0, rtn.Length - 1); } return(rtn); }
string FindFile(string fname) { if (File.Exists(fname)) { return(fname); } // Search the include paths // iterate throught the input files string[] includeDirs = IncludePaths.Split(new char[1] { ';' }); foreach (string includePath in includeDirs) { string fpath = includePath + @"\" + fname; if (File.Exists(fpath)) { return(fpath); } } return(null); }
public override bool Execute() { try { bool firstFile = true; // iterate throught the input files string[] inputs = InputFiles.Split(';'); string[] headers = HeaderFiles.Split(';'); string[] paths = IncludePaths.Split(';'); bool hdrsChanged = false; if (headers.Length > 0 && inputs.Length > 0 && File.Exists(inputs[0])) { string outFile = OutputFileName(inputs[0]); if (File.Exists(outFile)) { DateTime last = File.GetLastWriteTime(outFile); for (int i = headers.Length - 1; i >= 0; i--) { string hdr = headers[i]; if (!Path.IsPathRooted(hdr)) { int cnt = paths.Length; for (int j = 0; j < cnt; j++) { string fp = Path.Combine(paths[j], hdr); if (File.Exists(fp)) { hdr = fp; break; } } } if (File.Exists(hdr)) { if (File.GetLastWriteTime(hdr) > last) { hdrsChanged = true; break; } } } } else { hdrsChanged = true; } } foreach (string inputFile in inputs) { if (!File.Exists(inputFile)) { // Log non-existent file Log.LogError("Cannot find file " + inputFile); return(false); } string outfile = OutputFileName(inputFile); if (outfile == null) { Log.LogError("Invalid output file from input " + inputFile, null); return(false); } if (hdrsChanged || MustRebuild(outfile, inputFile)) { File.Delete(outfile); if (!Process(inputFile, outfile, firstFile)) { Log.LogError("Build failed: " + inputFile, null); return(false); } } else { //Log.LogMessage("Nothing to be done for " + outfile); } firstFile = false; } } catch (Exception ex) { Console.WriteLine("CompileTask.Execute threw exception " + ex.Message); throw; } return(true); }