Exemple #1
0
        public void Export(string FileName)
        {
            if (Builder == null)
            {
                Generate();
            }

            File.WriteAllText(FileName, Builder.ToString(), Encoding.UTF8);

            if (UseExternalMakefile)
            {
                File.WriteAllText($"{Project.Binary}.Tools.Makefile", ExternalBuilder.ToString());
            }
        }
Exemple #2
0
        void AppendHeaders()
        {
            var now = DateTime.Now.ToLocalTime();

            if (UseExternalMakefile)
            {
                ExternalBuilder.AppendLine($"# This file was generated automatically on {now.ToShortDateString()} {now.ToShortTimeString()}");
                ExternalBuilder.AppendLine($"# Tools configuration for project {Project.Name}");
            }

            // Header
            Builder.AppendLine($"# This file was generated automatically on {now.ToShortDateString()} {now.ToShortTimeString()}");
            Builder.AppendLine($"# Builder: {Program.AppVersion}");
            Builder.AppendLine($"# Project: {Project.Name}");
            Builder.AppendLine($"# Target board: {Project.Board.Name}");
            Builder.AppendLine($"# Processor: {Project.Board.Processor.Name}");
            Builder.AppendLine($"# Framework: {Project.Framework.Name}");
        }
Exemple #3
0
        void AppendDataFiles(SourceDescriptor desc)
        {
            var d = desc.DataFiles;

            if (d != null)
            {
                var DirName = Catalog.ResolvePath(Path.Combine("gen", desc.Name));
                ExternalBuilder.AppendLine($"CFLAGS += -I{DirName}");
                if (!Directory.Exists(DirName))
                {
                    Directory.CreateDirectory(DirName);
                }

                foreach (var df in d)
                {
                    string FilePath = Path.Combine(DirName, df.Name);
                    var    hg       = new HeaderGenerator(df);
                    hg.Export(FilePath);
                }
            }
        }
Exemple #4
0
        public void Generate()
        {
            if (Blocks.Count == 0)
            {
                AddBuilder <ToolsetBlock>();
                AddBuilder <FrameworkBlock>();
                AddBuilder <DriverBlock>();
                AddBuilder <ExternalSourcesBlock>();
            }

            Builder         = new StringBuilder();
            ExternalBuilder = UseExternalMakefile ? new StringBuilder() : Builder;

            AppendHeaders();

            if (UseExternalMakefile)
            {
                Builder.AppendLine();
                Builder.AppendLine($"include {Project.Binary}.Tools.Makefile");
            }

            AppendVariables();
            AppendSourceFiles(Project);
            Blocks.ForEach(block => block.Process(this));
            AppendIncludes(Project);

            AppendDefinitions();

            ExternalBuilder.AppendLine();
            ExternalBuilder.AppendLine("# Automatically generated files");
            AppendDataFiles(Project);
            AppendDataFiles(Project.Framework);

            AppendLibraries();
            AppendRules();
        }