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); }
public override void Write(CustomFileWriter writer) { writer.WriteLine(Kind.GetValue() + ":"); using (writer.Indent()) { if (Branches.Length > 0) { writer.WriteLine("branches:"); using (writer.Indent()) { Branches.ForEach(x => writer.WriteLine($"- {x}")); } } if (Tags.Length > 0) { writer.WriteLine("tags:"); using (writer.Indent()) { Tags.ForEach(x => writer.WriteLine($"- {x}")); } } if (IncludePaths.Length > 0 || ExcludePaths.Length > 0) { writer.WriteLine("paths:"); using (writer.Indent()) { IncludePaths.ForEach(x => writer.WriteLine($"- {x}")); ExcludePaths.ForEach(x => writer.WriteLine($"- !{x}")); } } } }
// All include paths being added are resolved against projectBasePath public void AddIncludePath(string path) { if (String.IsNullOrEmpty(_projectBasePath)) { return; } else if (path.Equals(".") || path.Equals("\\\".\\\"")) { IncludePaths.Add(path); return; } bool isAbsolutePath; try { isAbsolutePath = System.IO.Path.IsPathRooted(path); } catch (System.ArgumentException) { // seems like an invalid path, ignore return; } if (isAbsolutePath) // absolute path { IncludePaths.Add(path); } else { // Relative path - converting to absolute String pathForCombine = path.Replace("\"", String.Empty).TrimStart('\\', '/'); IncludePaths.Add(Path.GetFullPath(Path.Combine(_projectBasePath, pathForCombine))); // Workaround for Path.Combine bugs } }
public override void Register(BuildRulesConfig Config) { BuildType = BuildOutputTypes.Executable; IgnoreAllWarnings = true; DependencyModules.Add("FW_Core"); IncludePaths.Add("Source/ELFIO"); }
public override void Write(CustomFileWriter writer) { writer.WriteLine($"{Kind.GetValue()}:"); void WriteValue(string value) => writer.WriteLine($"- {value.SingleQuoteIfNeeded('*', '!')}"); using (writer.Indent()) { if (Branches.Length > 0) { writer.WriteLine("branches:"); using (writer.Indent()) { Branches.ForEach(WriteValue); } } if (BranchesIgnore.Length > 0) { writer.WriteLine("branches-ignore:"); using (writer.Indent()) { BranchesIgnore.ForEach(WriteValue); } } if (Tags.Length > 0) { writer.WriteLine("tags:"); using (writer.Indent()) { Tags.ForEach(WriteValue); } } if (TagsIgnore.Length > 0) { writer.WriteLine("tags-ignore:"); using (writer.Indent()) { TagsIgnore.ForEach(WriteValue); } } if (IncludePaths.Length > 0 || ExcludePaths.Length > 0) { writer.WriteLine("paths:"); using (writer.Indent()) { IncludePaths.ForEach(WriteValue); ExcludePaths.Select(x => $"!{x}").ForEach(WriteValue); } } } }
public void AddIncludePath(string path) { if (path.StartsWith(@"\")) { IncludePaths.Add(Directory.GetCurrentDirectory() + path); } else { IncludePaths.Add(path); } }
public bool IsIncluded <TEntity>(Expression <Func <TEntity, object> > exp) { var path = CommonUtils.GetPropertyPath <TEntity>(exp); if (string.IsNullOrEmpty(path)) { return(false); } return(IncludePaths != null && IncludePaths.Contains(path)); }
public virtual EntityReference Clone() { var result = new EntityReference(EntityType) { IsOptional = IsOptional }; result.IncludePaths = IncludePaths.Clone(result); return(result); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { var hash = 41; // Suitable nullity checks etc, of course :) if (Automatic != null) { hash = hash * 57 + Automatic.GetHashCode(); } if (IndexingMode != null) { hash = hash * 57 + IndexingMode.GetHashCode(); } if (IncludePaths != null) { hash = hash * 57 + IncludePaths.GetHashCode(); } if (IndexType != null) { hash = hash * 57 + IndexType.GetHashCode(); } if (NumericPrecision != null) { hash = hash * 57 + NumericPrecision.GetHashCode(); } if (StringPrecision != null) { hash = hash * 57 + StringPrecision.GetHashCode(); } if (Path != null) { hash = hash * 57 + Path.GetHashCode(); } if (ExcludePaths != null) { hash = hash * 57 + ExcludePaths.GetHashCode(); } return(hash); } }
/// <summary> /// Returns true if IndexingPolicy instances are equal /// </summary> /// <param name="other">Instance of IndexingPolicy to be compared</param> /// <returns>Boolean</returns> public bool Equals(IndexingPolicy other) { // credit: http://stackoverflow.com/a/10454552/677735 if (other == null) { return(false); } return (( Automatic == other.Automatic || Automatic != null && Automatic.Equals(other.Automatic) ) && ( IndexingMode == other.IndexingMode || IndexingMode != null && IndexingMode.SequenceEqual(other.IndexingMode) ) && ( IncludePaths == other.IncludePaths || IncludePaths != null && IncludePaths.Equals(other.IncludePaths) ) && ( IndexType == other.IndexType || IndexType != null && IndexType.Equals(other.IndexType) ) && ( NumericPrecision == other.NumericPrecision || NumericPrecision != null && NumericPrecision.Equals(other.NumericPrecision) ) && ( StringPrecision == other.StringPrecision || StringPrecision != null && StringPrecision.Equals(other.StringPrecision) ) && ( Path == other.Path || Path != null && Path.Equals(other.Path) ) && ( ExcludePaths == other.ExcludePaths || ExcludePaths != null && ExcludePaths.Equals(other.ExcludePaths) )); }
public virtual void Print(ExpressionPrinter expressionPrinter) { expressionPrinter.Append($"{nameof(EntityReference)}: {EntityType.DisplayName()}"); if (IsOptional) { expressionPrinter.Append("[Optional]"); } if (IncludePaths.Count > 0) { // TODO: fully render nested structure of include tree expressionPrinter.Append( " | IncludePaths: " + string.Join( " ", IncludePaths.Select(ip => ip.Value.Count() > 0 ? ip.Key.Name + "->..." : ip.Key.Name))); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (IncludePaths != null) { hashCode = hashCode * 59 + IncludePaths.GetHashCode(); } if (ExporterUser != null) { hashCode = hashCode * 59 + ExporterUser.GetHashCode(); } return(hashCode); } }
public IEnumerable <Platform> FilterPlatforms(IEnumerable <Platform> platforms, string?resolvedProductVersion) { if (IncludeProductVersions?.Any() ?? false) { string includeProductVersionsPattern = GetFilterRegexPattern(IncludeProductVersions.ToArray()); if (resolvedProductVersion is not null && !Regex.IsMatch(resolvedProductVersion, includeProductVersionsPattern, RegexOptions.IgnoreCase)) { return(Enumerable.Empty <Platform>()); } } if (!string.IsNullOrEmpty(IncludeArchitecture)) { string archRegexPattern = GetFilterRegexPattern(IncludeArchitecture); platforms = platforms.Where(platform => Regex.IsMatch(platform.Architecture.GetDockerName(), archRegexPattern, RegexOptions.IgnoreCase)); } if (!string.IsNullOrEmpty(IncludeOsType)) { string osTypeRegexPattern = GetFilterRegexPattern(IncludeOsType); platforms = platforms.Where(platform => Regex.IsMatch(platform.OS.GetDockerName(), osTypeRegexPattern, RegexOptions.IgnoreCase)); } if (IncludePaths?.Any() ?? false) { string pathsRegexPattern = GetFilterRegexPattern(IncludePaths.ToArray()); platforms = platforms.Where(platform => Regex.IsMatch(platform.Dockerfile, pathsRegexPattern, RegexOptions.IgnoreCase)); } if (IncludeOsVersions?.Any() ?? false) { string includeOsVersionsPattern = GetFilterRegexPattern(IncludeOsVersions.ToArray()); platforms = platforms.Where(platform => Regex.IsMatch(platform.OsVersion ?? string.Empty, includeOsVersionsPattern, RegexOptions.IgnoreCase)); } return(platforms.ToArray()); }
/// <summary> /// Creates a compilation options /// </summary> /// <param name="enableNativeMinification">Flag that indicating to use of native minification</param> /// <returns>Compilation options</returns> private CompilationOptions CreateCompilationOptions(bool enableNativeMinification) { IList <string> processedIncludePaths = IncludePaths .Select(p => SassCompiler.FileManager.ToAbsolutePath(p)) .ToList() ; var options = new CompilationOptions { IncludePaths = processedIncludePaths, IndentType = Utils.GetEnumFromOtherEnum <BtIndentType, LshIndentType>(IndentType), IndentWidth = IndentWidth, LineFeedType = Utils.GetEnumFromOtherEnum <BtLineFeedType, LshLineFeedType>(LineFeedType), OutputStyle = enableNativeMinification ? OutputStyle.Compressed : OutputStyle.Expanded, Precision = Precision, SourceComments = SourceComments }; return(options); }
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 FilterBase Include <TEntity>(Expression <Func <TEntity, object> > exp) { var path = CommonUtils.GetPropertyPath <TEntity>(exp); if (string.IsNullOrEmpty(path)) { throw new Exception("Invalid property path to include in filter."); } if (IncludePaths == null) { IncludePaths = new string[] { path }; return(this); } if (!IncludePaths.Contains(path)) { IncludePaths = IncludePaths.Concat(new[] { path }).ToArray(); } return(this); }
private async void AddIncludePath(object param) { var fbd = new OpenFolderDialog(); fbd.InitialDirectory = Model.CurrentDirectory; var result = await fbd.ShowAsync(); if (result != string.Empty) { var newInclude = Model.CurrentDirectory.MakeRelativePath(result); if (newInclude == string.Empty) { newInclude = "\\"; } IncludePaths.Add(newInclude); } UpdateCompileString(); }
protected override void Execute(CodeActivityContext context) { console = ActivityConsole.GetDefaultOrNew(context); hideConsoleOutput = SuppressConsoleOutput.Get(context); List <string> includePaths = IncludePaths.Get(context); string outputFile = OutputFile.Get(context); string comment = Comment.Get(context) ?? string.Empty; try { using (ZipStorer zipStorer = ZipStorer.Create(outputFile, comment)) { foreach (string includePath in includePaths) { FileAttributes attr = File.GetAttributes(includePath); DirectoryInfo directoryInfo = new DirectoryInfo(includePath); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { AddDirectory(zipStorer, directoryInfo, string.Empty, 0); } else { AddFile(zipStorer, includePath, directoryInfo.Name, string.Empty, 0); } } } } catch { try { File.Delete(outputFile); } catch { } throw; } }
private async void AddIncludePath() { var fbd = new OpenFolderDialog(); fbd.InitialDirectory = Model.CurrentDirectory; var result = await fbd.ShowAsync(); if (!string.IsNullOrEmpty(result)) { var newInclude = Model.CurrentDirectory.MakeRelativePath(result); if (newInclude == string.Empty) { // TODO Platform specific? newInclude = "\\"; } IncludePaths.Add(newInclude); } UpdateCompileString(); }
/// <summary> /// Returns true if ComAdobeCqScheduledExporterImplScheduledExporterImplProperties instances are equal /// </summary> /// <param name="other">Instance of ComAdobeCqScheduledExporterImplScheduledExporterImplProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(ComAdobeCqScheduledExporterImplScheduledExporterImplProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( IncludePaths == other.IncludePaths || IncludePaths != null && IncludePaths.Equals(other.IncludePaths) ) && ( ExporterUser == other.ExporterUser || ExporterUser != null && ExporterUser.Equals(other.ExporterUser) )); }
/// <summary> /// コンパイルオプションのチェック。 /// </summary> /// <param name="args"></param> private void CheckCompileOptions(string[] args) { // オプションの読み取り Func <string, string> getPath = (s) => { string result = s; if (!(s.EndsWith("/") || s.EndsWith("\\"))) { result = s + "/"; } return(result); }; int offset = 1; for (int i = 0; i < args.Length; i += offset) { string arg = args[i]; switch (arg) { // 出力ファイル case "-o": case "-O": if ((i + 1) < args.Length) { OutputFile = args[i + 1]; } offset = 2; break; // コンフィグファイル case "-c": case "-C": if ((i + 1) < args.Length) { ConfigFilePath = args[i + 1]; } offset = 2; break; // ヘッダファイルのディレクトリパス case "-i": case "-I": if ((i + 1) < args.Length) { string arg2 = args[i + 1]; string[] includes = arg2.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string inc in includes) { IncludePaths.Add(getPath(inc)); } } offset = 2; break; // マクロ定義 case "-d": case "-D": if ((i + 1) < args.Length) { string arg2 = args[i + 1]; string[] macros = arg2.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string macro in macros) { Macros.Add(macro); } } offset = 2; break; // 開発対象 case "-t": case "-T": if ((i + 1) < args.Length) { string arg2 = args[i + 1].ToLower(); switch (arg2) { case "win32": case "win_32": case "windows32": case "windows_32": case "winx86": case "win_x86": case "windowsx86": case "windows_x86": case "x86win": case "x86_win": case "x86windows": case "x86_windows": Target = DevelopmentTarget.WindowsX86; break; case "win64": case "win_64": case "windows64": case "windows_64": case "winx64": case "win_x64": case "windowsx64": case "windows_x64": case "x64win": case "x64_win": case "x64windows": case "x64_windows": Target = DevelopmentTarget.WindowsX64; break; case "linux32": case "linux_32": case "linuxx86": case "linux_x86": case "x86linux": case "x86_linux": Target = DevelopmentTarget.LinuxX86; break; case "linux64": case "linux_64": case "linuxx64": case "linux_x64": case "x64linux": case "x64_linux": Target = DevelopmentTarget.LinuxX64; break; case "linuxarm": case "linux_arm": case "armlinux": case "arm_linux": Target = DevelopmentTarget.LinuxARM; break; case "linuxarm64": case "linux_arm64": case "arm64linux": case "arm64_linux": Target = DevelopmentTarget.LinuxARM64; break; case "mac": case "macos": case "mac64": case "macos64": case "mac_64": case "macos_64": case "macx64": case "macosx64": case "mac_x64": case "macos_x64": case "x64mac": case "x64macos": case "x64_mac": case "x64_macos": Target = DevelopmentTarget.macOSX64; break; default: break; } } offset = 2; break; // 開発環境 case "-e": case "-E": if ((i + 1) < args.Length) { string arg2 = args[i + 1].ToLower(); switch (arg2) { case "vs": case "visualstudio": case "visual_studio": case "vc": case "vc++": case "visualc": case "visualc++": case "visual_c": case "visual_c++": Environment = DevelopmentEnvironment.VisualStudio; break; case "gcc": case "g++": Environment = DevelopmentEnvironment.GCC; break; case "clang": case "llvm": case "mingw": Environment = DevelopmentEnvironment.Clang; break; default: break; } } offset = 2; break; // ソースのルートフォルダ case "-r": case "-R": if ((i + 1) < args.Length) { string arg2 = args[i + 1]; SourceRootPath = getPath(arg2); } offset = 2; break; // ヘルプ case "--help": break; // バージョン case "--virsion": break; // 入力ファイル default: // 未知のオプションでないかチェック if (arg[0] != '-') { // 入力ファイルの追加 SourceFiles.Add(arg); } offset = 1; break; } } }
public void Initialize(Entity root) { ProjectEntity project = ProjectEntity.Decorate(root); TemplateEntity template = TemplateEntity.Decorate(root); Target[] availableTargets = sdkRepository.GetAllTargets().ToArray(); ICodeModel codeModel = root.Value <ICodeModel>(); SetProjectName(); SetProjectNamespace(); SetProjectType(); SetProjectTargets(); SetProjectEntities(); SetProjectIncludes(); void SetProjectName() { ProjectName = null; if (fileSystem.FileExists(System.IO.Path.Combine(root.Path, Constants.ProjectFileName))) { ProjectName = root.Name; } } void SetProjectNamespace() { ProjectNamespace = CodeEntity.Decorate(project).Namespace; } void SetProjectType() { ProjectType = project.Type; } void SetProjectTargets() { TargetsResult targetsResult = targetParser.Targets(project, false); ProjectTargets = targetsResult.ValidTargets .Select(t => new ProjectTarget(t, availableTargets.Any(at => t.Name == at.Name && at.LongVersion == t.LongVersion))); Exceptions = targetsResult.Errors; } void SetProjectEntities() { IEnumerable <CodeEntity> entities = template.EntityHierarchy.Select(e => { CodeEntity codeEntity = CodeEntity.Decorate(e); return(codeEntity); } ); ProjectCodeEntities = entities.Select(e => { TemplateEntity te = TemplateEntity.Decorate(e); return(e, te.RelatedEntites.Where(en => !en.Type.Contains("project"))); }) .Where(e => !e.Item1.Type.Contains("project")).ToDictionary(p => p.Item1, p => p.Item2); } void SetProjectIncludes() { IEnumerable <SdkInformation> relevantSdks = ProjectTargets.Select(t => availableTargets.FirstOrDefault(at => t.Target.Name == at.Name && at.LongVersion == t.Target.LongVersion)) .Where(t => t != null) .Select(sdkRepository.GetSdk) .Where(sdk => sdk != null) .Distinct(); IncludePaths = relevantSdks.SelectMany(sdk => sdk.IncludePaths) .Concat(relevantSdks.SelectMany(sdk => sdk.CompilerInformation.IncludePaths)) .Distinct() .ToDictionary(x => x, x => true); foreach (KeyValuePair <string, VirtualDirectory> codeModelIncludeDirectory in codeModel.IncludeDirectories) { if (!IncludePaths.ContainsKey(codeModelIncludeDirectory.Key)) { IncludePaths.Add(codeModelIncludeDirectory.Key, codeModelIncludeDirectory.Value != 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); }