Esempio n. 1
0
        static void Main(string[] args)
        {
            SetupData setup = SetupData.getDefault();

            var libManager = Factory.makeLibManager(setup);
            var project    = Factory.makeProject(setup, libManager);

            project.newProject();

            var boards = project.selectedConfiguration.boards;

            foreach (var board in boards)
            {
                Console.WriteLine(board.name);
            }

            Console.WriteLine("\nMakefile-----------------------------------------\n");

            project.selectedConfiguration.selectedBoard = boards.Last();
            Console.WriteLine(Makefile.generate(project, libManager, setup));


            while (!Console.KeyAvailable)
            {
                ;
            }
        }
Esempio n. 2
0
        public Makefile Deploy(AutotoolsContext ctx, SolutionItem entry, IProgressMonitor monitor)
        {
            Makefile           mkfile  = new Makefile();
            TranslationProject project = (TranslationProject)entry;

            StringBuilder files = new StringBuilder();

            foreach (Translation t in project.Translations)
            {
                files.Append("\\\n\t" + t.FileName);
            }

            string dir;

            if (project.OutputType == TranslationOutputType.SystemPath)
            {
                dir = ctx.DeployContext.GetResolvedPath(TargetDirectory.CommonApplicationDataRoot, "locale");
            }
            else
            {
                dir = ctx.DeployContext.GetResolvedPath(TargetDirectory.ProgramFiles, project.RelPath);
            }
            dir = dir.Replace("@prefix@", "$(prefix)");
            dir = dir.Replace("@PACKAGE@", "$(PACKAGE)");

            TemplateEngine templateEngine = new TemplateEngine();

            templateEngine.Variables ["TOP_SRCDIR"]  = FileService.AbsoluteToRelativePath(project.BaseDirectory, ctx.TargetSolution.BaseDirectory);
            templateEngine.Variables ["FILES"]       = files.ToString();
            templateEngine.Variables ["BUILD_DIR"]   = ".";
            templateEngine.Variables ["INSTALL_DIR"] = "$(DESTDIR)" + dir;
            templateEngine.Variables ["ALL_TARGET"]  = (ctx.TargetSolution.BaseDirectory == project.BaseDirectory) ? "all-local" : "all";

            StringWriter sw = new StringWriter();

            string mt;

            if (ctx.MakefileType == MakefileType.AutotoolsMakefile)
            {
                mt = "Makefile.am.template";
            }
            else
            {
                mt = "Makefile.template";
            }

            using (Stream stream = GetType().Assembly.GetManifestResourceStream(mt))
            {
                StreamReader reader = new StreamReader(stream);

                templateEngine.Process(reader, sw);
                reader.Close();
            }

            mkfile.Append(sw.ToString());

            return(mkfile);
        }
        /// <summary>
        /// Deploys a makefile to build the default configuration.
        /// </summary>
        /// <remarks>
        /// TODO: Make configuration-based targets as advertised.
        /// </remarks>
        public Makefile Deploy(AutotoolsContext ctx, MonoDevelop.Projects.SolutionItem entry, MonoDevelop.Core.IProgressMonitor monitor)
        {
            Makefile    mkfile            = new Makefile();
            ValaProject project           = (ValaProject)entry;
            ValaProjectConfiguration conf = (ValaProjectConfiguration)project.DefaultConfiguration;

            StringBuilder files = new StringBuilder();

            foreach (ProjectFile t in project.Files)
            {
                if (BuildAction.Compile == t.BuildAction)
                {
                    files.Append("\\\n\t" + FileService.AbsoluteToRelativePath(project.BaseDirectory, t.FilePath));
                }
            }

            string dir = ctx.DeployContext.GetResolvedPath(TargetDirectory.ProgramFiles, FileService.AbsoluteToRelativePath(conf.OutputDirectory, ctx.TargetSolution.BaseDirectory));

            dir = dir.Replace("@prefix@", "$(prefix)");
            dir = dir.Replace("@PACKAGE@", "$(PACKAGE)");

            TemplateEngine templateEngine = new TemplateEngine();

            templateEngine.Variables ["TOP_SRCDIR"]  = FileService.AbsoluteToRelativePath(project.BaseDirectory, ctx.TargetSolution.BaseDirectory);
            templateEngine.Variables ["FILES"]       = files.ToString();
            templateEngine.Variables ["BUILD_DIR"]   = ".";
            templateEngine.Variables ["INSTALL_DIR"] = "$(DESTDIR)" + dir;
            templateEngine.Variables ["ALL_TARGET"]  = string.Format("all-{0}", conf.Name);
            templateEngine.Variables ["VFLAGS"]      = string.Format("{0} {1}", ValaCompiler.GetCompilerFlags(conf), ValaCompiler.GeneratePkgCompilerArgs(project.Packages));
            templateEngine.Variables ["VTARGET"]     = conf.CompiledOutputName;

            StringWriter sw = new StringWriter();

            string mt;

            if (ctx.MakefileType == MakefileType.AutotoolsMakefile)
            {
                mt = "Makefile.am.template";
            }
            else
            {
                mt = "Makefile.template";
            }

            using (Stream stream = GetType().Assembly.GetManifestResourceStream(mt)) {
                StreamReader reader = new StreamReader(stream);

                templateEngine.Process(reader, sw);
                reader.Close();
            }

            mkfile.Append(sw.ToString());

            return(mkfile);
        }
Esempio n. 4
0
        public static i32 Main(String[] args)
        {
            // Default argument values.
            // NB: these are strings ONLY, conversion to appropriate types is done ad hoc.
            var dic = new Dictionary <String, String> {
                ["target"]          = null,
                ["filename"]        = "makefile.xml",
                ["redirect"]        = "false",
                ["cancel-on-error"] = "true",
                ["var-str"]         = ""
            };

            if (args.Length == 1 && args[0].Equals("love"))
            {
                Program.WriteLine("Not war");
            }
            Program.ParseArguments(args, dic);

            String filename = dic["filename"];

            if (!File.Exists(filename))
            {
                return(Program.ExitMessage(1, "ERROR - file not found: {0}", filename));
            }
            String target = dic["target"];

            // Prepare XBOSS for Makefile type and its dependencies.
            Array <Node <String> > .RegisterType();

            NamedCollection.RegisterType();
            Makefile.RegisterType();

            // Parse the file
            Document d    = Document.FromFile(filename);
            var      file = (Makefile)d.Root;

            file.AddVariables(Program.ToNamedCollection(dic["var-str"]));

            if (String.IsNullOrWhiteSpace(target))
            {
                target = file.DefaultTarget;
                Program.WriteLine($"No target specified; defaulting to {target}");
            }             // if

            if (!file.Commands.ContainsKey(target))
            {
                return(Program.ExitMessage(2, "ERROR - command not found: {0}", target));
            }
            Program.CacheDirectory = Program.FindCacheDirectory();
            bool redirect = dic["redirect"].Equals("true");

            //bool cancel_on_error = dic["cancel-on-error"].Equals("true");

            (ProcessStartInfo, bool)[] res = file.MakeCommands(target);
Esempio n. 5
0
            public static void RegisterType()
            {
                Command.RegisterType();
                if (Makefile.TypeRegistered)
                {
                    return;
                }

                TreeBuilder.RegisterType(typeof(Makefile), Makefile.PublicTypeName, (XElement el, Node_base Parent, Document owner) => {
                    IEnumerable <XElement> Children = el.Elements();
                    var ret = new Makefile(el.Name.ToString(), Parent, owner);
                    foreach (XElement c in Children)
                    {
                        String Name = c.Name.ToString();
                        if (Name.Equals("variables"))
                        {
                            ret.m_Variables = (NamedCollection)TreeBuilder.InvokeParser(c, Parent, owner);
                        }
                        else if (Name.Equals("commands"))
                        {
                            ret.Commands = (NamedCollection)TreeBuilder.InvokeParser(c, Parent, owner);
                        }
                    }                     // foreach

                    IEnumerable <XAttribute> Attributes = el.Attributes();
                    foreach (XAttribute a in Attributes)
                    {
                        String Name = a.Name.ToString();
                        if (Name.Equals("DefaultTarget"))
                        {
                            ret.DefaultTarget = a.Value;
                        }
                    }                     // foreach

                    return(ret);
                }, (Node_base N, i32 lvl, StringBuilderEx sb) => {
                    TreeBuilder.CheckChildCount(N, 0, 0);
                    ((Makefile)N).ToXML(lvl, sb);
                });

                Makefile.TypeRegistered = true;
            }
Esempio n. 6
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;
        }
Esempio n. 7
0
 public void convertToLink(Makefile mkfile, Component cp)
 {
     MakefileUtil.ParseLinkFlags(mkfile, words, cp);
 }
Esempio n. 8
0
 public void convertToLink(Makefile mkfile, Component cp)
 {
     MakefileUtil.ParseLinkFlags(mkfile, words, cp);
 }
Esempio n. 9
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;
        }
Esempio n. 10
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;
        }
        private static Model CopyMakeModel(Model sourceModel)
        {
            var targetModel = new Model();

            var makefile = (Makefile)sourceModel.RootElements[0];

            var newMakefile = new Makefile
            {
                ID      = makefile.ID,
                Name    = makefile.Name,
                Comment = new Comment()
                {
                    ID   = makefile.Comment.ID,
                    Text = makefile.Comment.Text
                }
            };

            foreach (var element in makefile.Elements)
            {
                if (element is Rule)
                {
                    var rule = element as Rule;

                    var newRule = new Rule
                    {
                        ID   = rule.ID,
                        Name = rule.Name
                    };

                    foreach (var shellLine in rule.ShellLines)
                    {
                        var newShellLine = new ShellLine
                        {
                            ID      = shellLine.ID,
                            Display = shellLine.Display,
                            Command = shellLine.Command
                        };

                        newRule.ShellLines.Add(newShellLine);
                    }

                    foreach (var dependency in rule.Dependencies)
                    {
                        if (dependency is FileDep)
                        {
                            var fileDep = dependency as FileDep;

                            var newFileDep = new FileDep
                            {
                                ID   = fileDep.ID,
                                Name = fileDep.Name
                            };

                            newRule.Dependencies.Add(newFileDep);
                        }
                    }

                    newMakefile.Elements.Add(newRule);
                }
                else if (element is Macro)
                {
                    var macro = element as Macro;

                    var newMacro = new Macro
                    {
                        ID    = macro.ID,
                        Name  = macro.Name,
                        Value = macro.Value
                    };

                    newMakefile.Elements.Add(newMacro);
                }
            }

            targetModel.RootElements.Add(newMakefile);
            return(targetModel);
        }
Esempio n. 12
0
        public static Model GenerateMake(int numberOfElements)
        {
            var rand  = new Random();
            var rules = new List <Rule>();

            int idCounter = 0;

            var model = new Model();

            var makefile = new Makefile
            {
                ID   = idCounter.ToString(),
                Name = "makefile name"
            };

            model.RootElements.Add(makefile);
            idCounter++;

            var comment = new Comment
            {
                ID   = idCounter.ToString(),
                Text = "comment text" + idCounter
            };

            makefile.Comment = comment;
            idCounter++;

            //~10% macros
            for (int i = 0; i < (numberOfElements / 10); i++)
            {
                var macro = new Macro
                {
                    ID    = idCounter.ToString(),
                    Name  = "macro name" + idCounter,
                    Value = "macro value" + idCounter
                };
                idCounter++;

                makefile.Elements.Add(macro);
            }

            //~25% rules
            for (int i = 0; i < (numberOfElements / 4); i++)
            {
                var rule = new Rule
                {
                    ID   = idCounter.ToString(),
                    Name = "RuleName" + idCounter
                };
                idCounter++;

                rules.Add(rule);
                makefile.Elements.Add(rule);

                var dependencyFileDep = new FileDep
                {
                    ID   = idCounter.ToString(),
                    Name = "fileName" + idCounter
                };
                rule.Dependencies.Add(dependencyFileDep);
                idCounter++;

                var shellLine = new ShellLine
                {
                    ID      = idCounter.ToString(),
                    Command = "command shell line " + idCounter
                };
                var dice = rand.NextDouble();
                shellLine.Display = dice > 0.5;
                rule.ShellLines.Add(shellLine);
                idCounter++;
            }

            for (int i = idCounter; i < numberOfElements; i++)
            {
                var ruleNumber = rand.Next(rules.Count - 1);

                var dice = rand.NextDouble();
                if (dice < 0.5)
                {
                    var shellLine = new ShellLine
                    {
                        ID      = idCounter.ToString(),
                        Command = "command shell line " + idCounter
                    };
                    var displayDice = rand.NextDouble();
                    shellLine.Display = dice > 0.5;
                    rules[ruleNumber].ShellLines.Add(shellLine);
                    idCounter++;
                }
                else
                {
                    var dependencyFileDep = new FileDep
                    {
                        ID   = idCounter.ToString(),
                        Name = "fileName" + idCounter
                    };
                    rules[ruleNumber].Dependencies.Add(dependencyFileDep);
                    idCounter++;
                }
            }

            return(model);
        }
Esempio n. 13
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;
        }
Esempio n. 14
-1
        /*
         * 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;
        }
Esempio n. 15
-1
        /*
         * 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;
        }
Esempio n. 16
-1
        /*
         * 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;
        }
Esempio n. 17
-1
        /*
         * 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;
        }