public bool GetCorrespondingBuildUnit(string fileName, out BuildUnit buildUnit) { string className; string baseClassName; BuildUnit.GetClassNamesFromFileName(fileName, out className, out baseClassName); return GetBuildUnitForClass(className, out buildUnit); }
/// <summary> /// Compile the supplied Quick markup file into the indicate JavaScript and Css files. /// Return true if successful, false if there were errors. /// </summary> private bool Compile(string quiFile, out BuildUnit buildUnit) { string quiFileName = Path.GetFileName(quiFile); Console.WriteLine(quiFileName); MarkupControlClass control; try { using (StreamReader markupReader = new StreamReader(quiFile)) { // Do the actual compile. control = MarkupCompiler.Compile(markupReader); } } catch (Exception e) { Console.Error.WriteLine("qc: " + e.Message); buildUnit = null; return false; } //string outputFileNameBase = control.Name; /* Pick output file names. For a class Foo with a base class * called Base, we want to end up with output files Foo.Base.js * and Foo.Base.css. * * Most of the time, this would be fine -- as long as the class * Foo is defined in a file called Foo.qui. The file name is * all the ProjectScanner has to go by when looking for files that * need to be recompiled. So if class Foo is defined in a file * called something like Bar.qui, then output files like Foo.Base.js * couldn't be correctly identified as an output for Bar.qui. * The build process would keep trying to build Bar.qui each time * a build was run. * * To avoid this, we name the output file a combination of the input * file name and the base class name (which is ignored by the * scanner). So a class Foo defined in a file Bar.qui will generate * output files Bar.Base.js and Bar.Base.css. */ string outputFileNameBase = Path.GetFileNameWithoutExtension(quiFileName); if (!String.IsNullOrEmpty(control.BaseClassName) && control.BaseClassName != "Control") { outputFileNameBase += "." + control.BaseClassName; } string jsFileName = GetOutputFilePath(outputFileNameBase, Project.fileExtensionJs); string cssFileName = GetOutputFilePath(outputFileNameBase, Project.fileExtensionCss); WriteOutputFile(control.JavaScript(), jsFileName); WriteOutputFile(control.Css(), cssFileName); buildUnit = new BuildUnit(jsFileName); return true; }
/// <summary> /// Return true if the JS or CSS of the given build unit is missing /// or older than the source Quick markup file. /// </summary> private bool RequiresCompilation(string quiFile, BuildUnit previousBuildUnit) { return RequiresCompilation(quiFile, previousBuildUnit.JsFileName) || RequiresCompilation(quiFile, previousBuildUnit.CssFileName); }
public void Add(BuildUnit unit) { BuildUnits.Add(unit); }
private bool GetBuildUnitForClass(string className, out BuildUnit buildUnit) { buildUnit = BuildUnits.FirstOrDefault(buildFile => buildFile.ClassName == className); return buildUnit != null; }