isCl() 공개 메소드

public isCl ( ) : bool
리턴 bool
예제 #1
0
        /*
         * 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;
        }
예제 #2
0
        /*
         * Given:
         *   A CustomComponent that creates a .dll. This CustomComponent should have a link instruction.
         * Output:
         *   A Component that can be used to generate a project for this .dll
         *
         * */
        public static Component generateComponentFromRule(CustomComponent rule, Makefile mkfile)
        {
            Component result = new Component(rule.Name);
            result.Owner = mkfile;
            List<CustomInstruction> preBuildInstrs = new List<CustomInstruction>();
            List<CustomInstruction> postBuildInstrs = new List<CustomInstruction>();

            bool afterLinkInstruction = false;

            foreach (string instr in rule.CustomInstructions)
            {
                CustomInstruction cinstr = new CustomInstruction(instr);
                if (cinstr.isNmake())
                {
                    LinkInstruction linkInstr = new LinkInstruction(cinstr);
                    result = resolveLinkInstruction(linkInstr,rule,mkfile);
                    afterLinkInstruction = true;
                }
                else if (cinstr.isCl())
                {
                    ClInstruction compileInstruction = new ClInstruction(cinstr);
                    foreach (string sourceFile in compileInstruction.clFiles)
                        result.SourceFileNames.Add(sourceFile);

                }
                else if (!afterLinkInstruction)
                {
                    preBuildInstrs.Add(cinstr);
                }
                else
                {
                    postBuildInstrs.Add(cinstr);
                }

            }
            result.PreBuildInstructions = preBuildInstrs;
            result.PostBuildInstructions = postBuildInstrs;
            return result;
        }