Inheritance: CustomInstruction
示例#1
0
        /*
         * Given:
         *   A Link instruction- a single instruction that has been parsed before, and a CustomComponent that has this link instruction
         * Output:
         *   A Component that can be used to generate a project for this .dll
         *  Note that we want to point to source files (.c, .h) instead of linking against things that are not in our current project.
         * */
        public static Component resolveLinkInstruction(LinkInstruction linkInstr, CustomComponent rule, Makefile mkfile)
        {
            Component component = new Component(mkfile);
            string componentName = "";
            componentName = rule.Name;
            component.setName(componentName);
            linkInstr.convertToLink(mkfile, component);

            //If the link instruction shares objs with the makefile's, then use its cflags. Otherwise, we assume that the link instruction has an accompanying compile instruction somewhere
            if (rule.contextSensitiveProps.Contains("OBJ_LIST_C_OBJS"))
            {
                component.CompilerFlags = new CompileFlags(mkfile);
                component.CompilerFlags.ParseString(mkfile.ResolveVariables(mkfile.CompilerFlagsStr, Makefile.VarType.RegularVariable | Makefile.VarType.PropSheetVariable, false));
            }

            string extension = Path.GetExtension(rule.Output).Replace(".", "");
            component.Type = extension;
            component.IsCustomLinkStep = true;

            return component;
        }
示例#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;
        }