/// <summary> /// Orders the given set of source files if necessary /// </summary> /// <param name="project">Project being processed</param> /// <param name="files">Input sequence</param> /// <returns>Output sequence</returns> protected override IEnumerable<SuiteRelativePath> OrderSourceFiles(Project project, IEnumerable<SuiteRelativePath> files) { if (project.HasParameters("order")) { var order = project.GetParameters<FsharpFileOrder>("order"); var remaining = new HashSet<SuiteRelativePath>(files); foreach (string file in order.OrderedFiles) { var path = new SuiteRelativePath( Path.Combine(Suite.SuiteRoot.GetRelativePath(project.RootDirectory), "fs", file)); if (remaining.Contains(path)) { remaining.Remove(path); yield return path; } } foreach (var path in remaining) yield return path; } else { foreach (var file in base.OrderSourceFiles(project, files)) yield return file; } }
/// <summary> /// Removes a file from the set /// </summary> /// <param name="path">Path of the file relative to the suite root</param> public void Remove(SuiteRelativePath path) { Contract.Requires(Files.Contains(path)); Contract.Ensures(!files.Contains(path)); files.Remove(path); }
/// <summary> /// Maps a project file to a project /// </summary> /// <param name="project">The project model</param> /// <param name="path">Suite relative path to the visual studio project file</param> public void RegisterProjectFile(Project project, SuiteRelativePath path) { lock (sync) { map.Add(project, path); } }
protected override void WriteAdditionalOptions(XmlWriter writer, Project project, SuiteRelativePath suiteRelativePath) { base.WriteAdditionalOptions(writer, project, suiteRelativePath); var relativePath = ToProjectRelativePath(project, suiteRelativePath, "resources"); writer.WriteElementString("Link", Path.Combine("_Resources", relativePath)); }
/// <summary> /// Orders the given set of source files if necessary /// </summary> /// <param name="project">Project being processed</param> /// <param name="files">Input sequence</param> /// <returns>Output sequence</returns> protected override IEnumerable <SuiteRelativePath> OrderSourceFiles(Project project, IEnumerable <SuiteRelativePath> files) { if (project.HasParameters("order")) { var order = project.GetParameters <FsharpFileOrder>("order"); var remaining = new HashSet <SuiteRelativePath>(files); foreach (string file in order.OrderedFiles) { var path = new SuiteRelativePath( Path.Combine(Suite.SuiteRoot.GetRelativePath(project.RootDirectory), "fs", file)); if (remaining.Contains(path)) { remaining.Remove(path); yield return(path); } } foreach (var path in remaining) { yield return(path); } } else { foreach (var file in base.OrderSourceFiles(project, files)) { yield return(file); } } }
/// <summary> /// Adds a file to the set /// </summary> /// <param name="path">Path of the file relative to the suite root</param> public void Add(SuiteRelativePath path) { Contract.Requires(!string.IsNullOrWhiteSpace(path)); Contract.Requires(!Path.IsPathRooted(path)); Contract.Ensures(files.Contains(path)); files.Add(path); }
protected override bool FilterOut(SuiteRelativePath path) { return(IsTLBorIDL(path) || IsDllDataC(path) || IsIdlHeader(path) || IsGuidDefinition(path) || IsProxyStub(path)); }
protected override string GetLogicalPath(Project project, SuiteRelativePath file, string sourceSetType) { var path = base.GetLogicalPath(project, file, sourceSetType); if (path.StartsWith("wpf\\")) return path.Substring(4).Replace('\\', '/'); else return PrefixWithRootNamespace(project, PrefixNumericComponents(path)).Replace('\\', '.'); }
public SimplePythonBuildScript(SuiteRelativePath scriptPath, [SuiteRoot] IFileSystemDirectory suiteRoot) { name = Path.GetFileNameWithoutExtension(scriptPath); using (var reader = suiteRoot.ReadTextFile(scriptPath)) { script = reader.ReadToEnd(); } }
public SimplePythonPostProcessorScript(SuiteRelativePath scriptPath, [SuiteRoot] IFileSystemDirectory suiteRoot) { name = Path.GetFileNameWithoutExtension(scriptPath); using (var reader = suiteRoot.ReadTextFile(scriptPath)) { script = reader.ReadToEnd(); } }
protected override bool FilterOut(SuiteRelativePath path) { return IsTLBorIDL(path) || IsDllDataC(path) || IsIdlHeader(path) || IsGuidDefinition(path) || IsProxyStub(path); }
/// <summary> /// Gets the visual studio project file for a given project /// </summary> /// <param name="project">The project model</param> /// <returns>Returns the suite relative path to the project file, or <c>null</c> if this is not a visual studio project</returns> public SuiteRelativePath GetProjectFile(Project project) { lock (sync) { SuiteRelativePath result = null; map.TryGetValue(project, out result); return(result); } }
protected override void WriteItem(XmlWriter writer, Project project, SuiteRelativePath file, string relativePath, SourceSetType sourceSetType, string logicalPath) { var resrelativePath = ToProjectRelativePath(project, file, "resources"); if (!resrelativePath.StartsWith("win32" + Path.DirectorySeparatorChar)) { base.WriteItem(writer, project, file, relativePath, sourceSetType, logicalPath); } }
private static bool IsTLBorIDL(SuiteRelativePath path) { string ext = Path.GetExtension(path.ToString()); if (ext != null) { var extl = ext.ToLowerInvariant(); return extl == ".tlb" || extl == ".idl"; } return false; }
public void Compile(SuiteRelativePath scriptPath, TargetRelativePath targetPath, string version, Goal targetGoal) { var platform = targetGoal.Has("x64") ? "x64" : "x86"; Run(suiteRoot, "/dVERSION=" + version, "/dPLATFORM=" + platform, "/dGOAL=" + targetGoal.Name, "/o" + Path.GetDirectoryName(Path.Combine(suiteRoot.GetRelativePath(targetRoot), targetPath)), scriptPath); }
public void Compile(SuiteRelativePath scriptPath, TargetRelativePath targetPath, string version, Goal targetGoal) { var platform = targetGoal.Has("x64") ? "x64" : "x86"; Run(suiteRoot, "/dVERSION="+version, "/dPLATFORM="+platform, "/dGOAL="+targetGoal.Name, "/o"+Path.GetDirectoryName(Path.Combine(suiteRoot.GetRelativePath(targetRoot), targetPath)), scriptPath); }
private static bool IsTLBorIDL(SuiteRelativePath path) { string ext = Path.GetExtension(path.ToString()); if (ext != null) { var extl = ext.ToLowerInvariant(); return(extl == ".tlb" || extl == ".idl"); } return(false); }
protected override string GetLogicalPath(Project project, SuiteRelativePath file, string sourceSetType) { var path = base.GetLogicalPath(project, file, sourceSetType); if (path.StartsWith("wpf\\")) { return(path.Substring(4).Replace('\\', '/')); } else { return(PrefixWithRootNamespace(project, PrefixNumericComponents(path)).Replace('\\', '.')); } }
protected virtual void WriteItem(XmlWriter writer, Project project, SuiteRelativePath file, string relativePath, SourceSetType sourceSetType, string logicalPath) { writer.WriteStartElement(GetElementNameFor(project, file)); writer.WriteAttributeString("Include", relativePath); if (ProjectSourceSetName != sourceSetType) { writer.WriteElementString("LogicalName", logicalPath); } WriteAdditionalOptions(writer, project, file); writer.WriteEndElement(); }
private void Copy(SuiteRelativePath sourcePath, string relativePath) { var relativeDir = Path.GetDirectoryName(relativePath); var fileName = Path.GetFileName(relativePath); var targetDir = targetRoot.GetChildDirectory(project.Module.Name, createIfMissing: true); IFileSystemDirectory realTargetDir = String.IsNullOrWhiteSpace(relativeDir) ? targetDir : targetDir.GetChildDirectory(relativeDir, createIfMissing: true); using (var source = suiteRoot.ReadBinaryFile(sourcePath)) using (var target = realTargetDir.CreateBinaryFile(fileName)) StreamOperations.Copy(source, target); }
/// <summary> /// Provides the ability to add extra content to a given project source file /// </summary> /// <param name="writer">The project file writer</param> /// <param name="project">Project model</param> /// <param name="suiteRelativePath">Suite relative path of the source item</param> protected override void WriteAdditionalOptions(XmlWriter writer, Project project, SuiteRelativePath suiteRelativePath) { base.WriteAdditionalOptions(writer, project, suiteRelativePath); var projectRelativePath = ToProjectRelativePath(project, suiteRelativePath, ProjectSourceSetName); if (projectRelativePath == "stdafx.cpp") { var platform = platformManagement.GetDefaultPlatform(project); writer.WriteStartElement("PrecompiledHeader"); writer.WriteAttributeString("Condition", string.Format("'$(Configuration)|$(Platform)' == 'Bari|{0}' ", platform)); writer.WriteString("Create"); writer.WriteEndElement(); } }
/// <summary> /// Recursively adds every file in a given directory to a source set (<see cref="SourceSet"/>) /// </summary> /// <param name="target">The target source set to be extended</param> /// <param name="dir">The root directory for the operation</param> /// <param name="ignoreList">Ignore list for the target source set</param> private void AddAllFiles(SourceSet target, IFileSystemDirectory dir, SourceSetIgnoreList ignoreList) { foreach (var fileName in dir.Files) { var suiteRelativePath = new SuiteRelativePath(Path.Combine(suiteRoot.GetRelativePath(dir), fileName)); if (!ignoreList.IsIgnored(suiteRelativePath)) { target.Add(suiteRelativePath); } } foreach (var childDirectory in dir.ChildDirectories) { AddAllFiles(target, dir.GetChildDirectory(childDirectory), ignoreList); } }
private bool IsDllDataC(SuiteRelativePath path) { // DllData.c is a special file generated by MIDL var fileName = Path.GetFileName(path); if (fileName != null && fileName.ToLowerInvariant() == "dlldata.c") { using (var reader = sourceSetRoot.ReadTextFile(GetSourceSetRelativePath(path))) { var contents = reader.ReadToEnd(); if (contents.StartsWith(dllDataCHeader)) return true; } } return false; }
private void SetupInnoSetupPackagerFor(Product product, SuiteRelativePath scriptPath) { log.InfoFormat("Found InnoSetup script for product {0} at {1}", product.Name, scriptPath); if (product.Packager == null) { product.Packager = new PackagerDefinition(new PackagerId("innosetup"), new InnoSetupPackagerParameters {ScriptPath = scriptPath}); } else { if (product.Packager.PackagerType == new PackagerId("innosetup")) { var parameters = product.Packager.Parameters as InnoSetupPackagerParameters; if (parameters != null) parameters.ScriptPath = scriptPath; } } }
/// <summary> /// Constructs the fingerprint based on the deserialized protocol data /// </summary> /// <param name="proto">The protocol data which was deserialized from a stream</param> public SourceSetFingerprint(SourceSetFingerprintProtocol proto) { fullDependency = proto.FullDependency; fileNames = new SortedSet <SuiteRelativePath>(); lastModifiedDates = new Dictionary <SuiteRelativePath, DateTime>(); lastSizes = new Dictionary <SuiteRelativePath, long>(); proto.Files.Do(pair => { var path = new SuiteRelativePath(pair.Key); fileNames.Add(path); if (fullDependency) { lastModifiedDates.Add(path, pair.Value.LastModifiedDate); lastSizes.Add(path, pair.Value.LastSize); } }); }
private bool IsDllDataC(SuiteRelativePath path) { // DllData.c is a special file generated by MIDL var fileName = Path.GetFileName(path); if (fileName != null && fileName.ToLowerInvariant() == "dlldata.c") { using (var reader = sourceSetRoot.ReadTextFile(GetSourceSetRelativePath(path))) { var contents = reader.ReadToEnd(); if (contents.StartsWith(dllDataCHeader)) { return(true); } } } return(false); }
private bool HasExtensionAndContainsLine(SuiteRelativePath path, string extension, string expectedLine) { var ext = Path.GetExtension(path); if (ext != null && ext.ToLowerInvariant() == extension) { using (var reader = sourceSetRoot.ReadTextFile(GetSourceSetRelativePath(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line == expectedLine) { return(true); } } } } return(false); }
private void SetupInnoSetupPackagerFor(Product product, SuiteRelativePath scriptPath) { log.InfoFormat("Found InnoSetup script for product {0} at {1}", product.Name, scriptPath); if (product.Packager == null) { product.Packager = new PackagerDefinition(new PackagerId("innosetup"), new InnoSetupPackagerParameters { ScriptPath = scriptPath }); } else { if (product.Packager.PackagerType == new PackagerId("innosetup")) { var parameters = product.Packager.Parameters as InnoSetupPackagerParameters; if (parameters != null) { parameters.ScriptPath = scriptPath; } } } }
/// <summary> /// Provides the ability to add extra content to a given project source file /// </summary> /// <param name="writer">The project file writer</param> /// <param name="project">Project model</param> /// <param name="suiteRelativePath">Suite relative path of the source item</param> protected virtual void WriteAdditionalOptions(XmlWriter writer, Project project, SuiteRelativePath suiteRelativePath) { }
/// <summary> /// The filter function /// </summary> /// <param name="path">Path to the file in the source set</param> /// <returns>Returns <c>true</c> if the file should be filtered out</returns> protected abstract bool FilterOut(SuiteRelativePath path);
public bool IsIgnored(SuiteRelativePath path) { return(ignoreExpressions.Any(expression => expression.IsMatch(path))); }
protected override void WriteAdditionalOptions(XmlWriter writer, Project project, SuiteRelativePath suiteRelativePath) { var projectRelativePath = ToProjectRelativePath(project, suiteRelativePath, ProjectSourceSetName); // Extra options for XAML pages var ext = Path.GetExtension(projectRelativePath).ToLowerInvariant(); if (ext == ".xaml") { writer.WriteElementString("SubType", "Designer"); writer.WriteElementString("Generator", "MSBuild:Compile"); } // Extra options for XAML page code-behind files if (projectRelativePath.ToLowerInvariant().EndsWith(".xaml.cs")) { var fileName = Path.GetFileName(projectRelativePath); writer.WriteElementString("DependentUpon", fileName.Substring(0, fileName.Length - 3)); } // Settings file if (projectRelativePath.Equals("Properties" + Path.DirectorySeparatorChar + "Settings.Designer.cs", StringComparison.InvariantCultureIgnoreCase)) { writer.WriteElementString("AutoGen", "True"); writer.WriteElementString("DesignTimeSharedInput", "True"); writer.WriteElementString("DependentUpon", "Settings.settings"); } else if (projectRelativePath.Equals("Properties" + Path.DirectorySeparatorChar + "Settings.settings", StringComparison.InvariantCultureIgnoreCase)) { writer.WriteElementString("Generator", "PublicSettingsSingleFileGenerator"); writer.WriteElementString("LastGenOutput", "Settings.Designer.cs"); } // WCF service references if (projectRelativePath.StartsWith("Service References" + Path.DirectorySeparatorChar, StringComparison.InvariantCultureIgnoreCase)) { if (ext == ".cs") { writer.WriteElementString("AutoGen", "True"); writer.WriteElementString("DesignTime", "True"); writer.WriteElementString("DependentUpon", Path.GetFileNameWithoutExtension(projectRelativePath) + ".svcmap"); } else if (ext == ".xsd") { writer.WriteElementString("SubType", "Designer"); } else if (ext == ".svcmap") { writer.WriteElementString("Generator", "WCF Proxy Generator"); writer.WriteElementString("LastGenOutput", Path.GetFileNameWithoutExtension(projectRelativePath) + ".cs"); } } base.WriteAdditionalOptions(writer, project, suiteRelativePath); }
private string GetSourceSetRelativePath(SuiteRelativePath path) { return(suiteRoot.GetRelativePathFrom(sourceSetRoot, path)); }
private bool IsIdlHeader(SuiteRelativePath path) { return(HasExtensionAndContainsLine(path, ".h", idlInterfaceHeader)); }
protected virtual string GetLogicalPath(Project project, SuiteRelativePath file, SourceSetType sourceSetType) { return ToProjectRelativePath(project, file, sourceSetType); }
protected override void WriteAdditionalOptions(XmlWriter writer, Project project, SuiteRelativePath suiteRelativePath) { base.WriteAdditionalOptions(writer, project, suiteRelativePath); var relativePath = ToProjectRelativePath(project, suiteRelativePath, "resources"); if (relativePath.StartsWith("wpf" + Path.DirectorySeparatorChar)) { relativePath = GetLogicalPath(project, suiteRelativePath, "resources"); } else { relativePath = Path.Combine("_Resources", relativePath); } writer.WriteElementString("Link", relativePath); }
private string GetSourceSetRelativePath(SuiteRelativePath path) { return suiteRoot.GetRelativePathFrom(sourceSetRoot, path); }
protected virtual string GetLogicalPath(Project project, SuiteRelativePath file, SourceSetType sourceSetType) { return(ToProjectRelativePath(project, file, sourceSetType)); }
public bool IsIgnored(SuiteRelativePath path) { return ignoreExpressions.Any(expression => expression.IsMatch(path)); }
private bool IsIdlHeader(SuiteRelativePath path) { return HasExtensionAndContainsLine(path, ".h", idlInterfaceHeader); }
private bool IsProxyStub(SuiteRelativePath path) { return(HasExtensionAndContainsLine(path, ".c", proxyStubHeader)); }
private bool IsGuidDefinition(SuiteRelativePath path) { return HasExtensionAndContainsLine(path, ".c", guidHeader); }
private bool IsGuidDefinition(SuiteRelativePath path) { return(HasExtensionAndContainsLine(path, ".c", guidHeader)); }
private bool IsProxyStub(SuiteRelativePath path) { return HasExtensionAndContainsLine(path, ".c", proxyStubHeader); }
private bool HasExtensionAndContainsLine(SuiteRelativePath path, string extension, string expectedLine) { var ext = Path.GetExtension(path); if (ext != null && ext.ToLowerInvariant() == extension) { using (var reader = sourceSetRoot.ReadTextFile(GetSourceSetRelativePath(path))) { string line; while ((line = reader.ReadLine()) != null) { if (line == expectedLine) return true; } } } return false; }
protected override void WriteAdditionalOptions(XmlWriter writer, Project project, SuiteRelativePath suiteRelativePath) { var projectRelativePath = ToProjectRelativePath(project, suiteRelativePath, ProjectSourceSetName); // Extra options for XAML pages var ext = Path.GetExtension(projectRelativePath).ToLowerInvariant(); if (ext == ".xaml") { writer.WriteElementString("SubType", "Designer"); writer.WriteElementString("Generator", "MSBuild:Compile"); } // Extra options for XAML page code-behind files if (projectRelativePath.ToLowerInvariant().EndsWith(".xaml.cs")) { writer.WriteElementString("DependentUpon", projectRelativePath.Substring(0, projectRelativePath.Length - 3)); } // Settings file if (projectRelativePath.Equals("Properties\\Settings.Designer.cs", StringComparison.InvariantCultureIgnoreCase)) { writer.WriteElementString("AutoGen", "True"); writer.WriteElementString("DesignTimeSharedInput", "True"); writer.WriteElementString("DependentUpon", "Settings.settings"); } else if (projectRelativePath.Equals("Properties\\Settings.settings", StringComparison.InvariantCultureIgnoreCase)) { writer.WriteElementString("Generator", "PublicSettingsSingleFileGenerator"); writer.WriteElementString("LastGenOutput", "Settings.Designer.cs"); } // WCF service references if (projectRelativePath.StartsWith("Service References\\", StringComparison.InvariantCultureIgnoreCase)) { if (ext == ".cs") { writer.WriteElementString("AutoGen", "True"); writer.WriteElementString("DesignTime", "True"); writer.WriteElementString("DependentUpon", Path.GetFileNameWithoutExtension(projectRelativePath) + ".svcmap"); } else if (ext == ".xsd") { writer.WriteElementString("SubType", "Designer"); } else if (ext == ".svcmap") { writer.WriteElementString("Generator", "WCF Proxy Generator"); writer.WriteElementString("LastGenOutput", Path.GetFileNameWithoutExtension(projectRelativePath) + ".cs"); } } base.WriteAdditionalOptions(writer, project, suiteRelativePath); }
protected override void WriteAdditionalOptions(XmlWriter writer, Project project, SuiteRelativePath suiteRelativePath) { base.WriteAdditionalOptions(writer, project, suiteRelativePath); var relativePath = ToProjectRelativePath(project, suiteRelativePath, "resources"); if (relativePath.StartsWith("wpf" + Path.DirectorySeparatorChar)) relativePath = GetLogicalPath(project, suiteRelativePath, "resources"); else relativePath = Path.Combine("_Resources", relativePath); writer.WriteElementString("Link", relativePath); }