示例#1
0
        /*
         * Given:
         *   A Cl (command line compile) instruction with a /link flag- a single instruction that has been parsed before, and a CustomComponent that has this compile instruction
         * Output:
         *   A Component that can generate a project.
         *  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 resolveClInstructionIntoComponent(ClInstruction clInstruction, CustomComponent rule, Makefile mkfile)
        {
            Component result = new Component(rule.Output);
            result.IsCustomLinkStep = true;
            string target = "";
            //If the compile instruction has a /link flag, then it should ultimately become its own project.
            if (clInstruction.hasLinkFlags())
            {
                foreach (string file in clInstruction.clFiles)
                {
                    if (file.EndsWith(".c", StringComparison.CurrentCultureIgnoreCase) || file.EndsWith(".cpp", StringComparison.CurrentCultureIgnoreCase))
                    {
                        result.SourceFiles.Add(Path.GetFileNameWithoutExtension(file));
                    }
                    else if (file.Contains("lib"))
                    {
                        result.Link.Libs.Add(file);
                    }
                    else if (file.Contains("obj"))
                    {
                        result.Link.Objs.Add(file);
                        target = file;
                    }
                }
                CompileFlags flags = new CompileFlags(mkfile);
                flags.ParseString(clInstruction.clOptionsLiteral);
                result.CompilerFlags = flags;

                if (clInstruction.LinkOptionsLiteral_Words.Count > 0)
                {
                    MakefileUtil.ParseLinkFlags(mkfile, clInstruction.LinkOptionsLiteral_Words, result);
                }

            }

            string extension = Path.GetExtension(rule.Output).Replace(".", "");
            result.Type = extension;

            if (result.Name == "")
                result.setName(rule.Output);

            if (result.Link.Output == "")
                result.Link.Output = Path.GetFileName(rule.Output);
            return result;
        }
示例#2
0
 public void convertToLink(Makefile mkfile, Component cp)
 {
     MakefileUtil.ParseLinkFlags(mkfile, words, cp);
 }