/* * Input: A Component, and a CustomInstruction that needs to be attached to this Component. * Output: True if the instruction was identified and we attempted to take action, False if we do not know how to carry out the merge. * */ public static bool MergeInstructionWithComponent(Component cp, CustomInstruction cinstr, Makefile mkfile) { if (cinstr.isCl()) { ClInstruction clInstr = (ClInstruction)cinstr; string target = ""; foreach (string clFile in clInstr.clFiles) { if (clFile.EndsWith(".c", StringComparison.CurrentCultureIgnoreCase) || clFile.EndsWith(".cpp", StringComparison.CurrentCultureIgnoreCase)) { cp.SourceFiles.Add(Path.GetFileNameWithoutExtension(clFile)); } if (clFile.Contains(".obj")) target = clFile; } foreach (string clLib in clInstr.clLibs) { cp.Link.Libs.Add(clLib); } if (cp.CompilerFlags == null) cp.CompilerFlags = new CompileFlags(mkfile); cp.CompilerFlags.ParseString(clInstr.clOptionsLiteral); foreach (string linkOption in clInstr.linkerOptions) { cp.Link.Options.Add(new KeyValuePair<string, string>(target, linkOption)); } mkfile.GenerateSourceFileNames(cp); return true; } else if (cinstr.isRc()) { RcInstruction rcInstr = (RcInstruction)cinstr; cp.SourceFiles.Add(rcInstr.rcScript); RcFlags rcFlags = new RcFlags(mkfile); rcFlags.ParseString(rcInstr.instruction_literal); cp.CustomFlags.Add(rcInstr.rcScript, rcFlags); mkfile.GenerateSourceFileNames(cp); } else { //We cannot identify the instruction, we will assume that it must be added as a prebuild step to the component. cp.PostBuildInstructions.Add(cinstr); } return false; }
/* * Input: A Component, and a CustomInstruction that needs to be attached to this Component. * Output: True if the instruction was identified and we attempted to take action, False if we do not know how to carry out the merge. * */ public static bool MergeInstructionWithComponent(Component cp, CustomInstruction cinstr, Makefile mkfile) { if (cinstr.isCl()) { ClInstruction clInstr = (ClInstruction)cinstr; string target = ""; foreach (string clFile in clInstr.clFiles) { if (clFile.EndsWith(".c", StringComparison.CurrentCultureIgnoreCase) || clFile.EndsWith(".cpp", StringComparison.CurrentCultureIgnoreCase)) { cp.SourceFiles.Add(Path.GetFileNameWithoutExtension(clFile)); } if (clFile.Contains(".obj")) target = clFile; } foreach (string clLib in clInstr.clLibs) { cp.Link.Libs.Add(clLib); } if (cp.CompilerFlags == null) cp.CompilerFlags = new CompileFlags(mkfile); cp.CompilerFlags.ParseString(clInstr.clOptionsLiteral); foreach (string linkOption in clInstr.linkerOptions) { cp.Link.Options.Add(new KeyValuePair<string, string>(target, linkOption)); } mkfile.GenerateSourceFileNames(cp); return true; } else if (cinstr.isRc()) { RcInstruction rcInstr = (RcInstruction)cinstr; cp.SourceFiles.Add(rcInstr.rcScript); RcFlags rcFlags = new RcFlags(mkfile); rcFlags.ParseString(rcInstr.instruction_literal); cp.CustomFlags.Add(rcInstr.rcScript, rcFlags); mkfile.GenerateSourceFileNames(cp); } else { //We cannot identify the instruction, we will assume that it must be added as a prebuild step to the component. cp.PostBuildInstructions.Add(cinstr); } return false; }