Exemple #1
0
        private bool TryCompileFile(InputFile inputFile, string outputDirectory, IEnumerable<string> includeDirectories, out CompiledObject compiledObject)
        {
            Console.WriteLine("Compiling {0}", inputFile.Path);

            var arguments = "";

            var tool = "";
            switch (inputFile.FileType)
            {
                case InputFileType.CSource:
                    tool = _configSection.CCompilerTool;
                    arguments += _configSection.CFlags + " -c "; // "-Wall -O2 -nostdlib -nostartfiles -ffreestanding -c ";
                    if( _environmentSection.Verbose )
                    {
                        arguments += "-v ";
                    }

                    arguments += string.Join(" ", includeDirectories.Select(t => string.Format("-I {0} ", t)).ToArray());
                    break;
                case InputFileType.AsmSource:
                    if (_environmentSection.Verbose)
                    {
                        arguments += "--verbose ";
                    }
                    tool = _configSection.AssemblerTool;
                    break;
            }

            arguments += string.Format(@"{0} -o {1}.o", inputFile.Path,
                Path.Combine(outputDirectory, inputFile.Filename));

            compiledObject = null;
            if(ExecuteTool(tool, arguments))
            {
                compiledObject = new CompiledObject {Name = inputFile.Filename, Path = outputDirectory};
                return true;
            }

            return false;
        }
        private bool TryCompileFile(string filename, string path, InputFileType fileType, string outputDirectory, IEnumerable<string> includeDirectories, out CompiledObject compiledObject)
        {
            Console.WriteLine("Compiling {0}", path);

            var arguments = "";

            //InputFile file = new InputFile {Path = filePath};

            // figure out tool based on extension
            //var extension = (Path.GetExtension(in) ?? string.Empty).ToLower();
            var tool = "";
            switch (fileType)
            {
                case InputFileType.CSource:
                    tool = _configuration.CCompilerTool;
                    arguments += _configuration.CFlags + " -c "; // "-Wall -O2 -nostdlib -nostartfiles -ffreestanding -c ";
                    if (_configuration.Verbose)
                    {
                        arguments += "-v ";
                    }

                    arguments += string.Join(" ", includeDirectories.Select(t => string.Format("-I {0} ", t)).ToArray());
                    break;
                case InputFileType.AsmSource:
                    if (_configuration.Verbose)
                    {
                        arguments += "--verbose ";
                    }
                    tool = _configuration.AssemblerTool;
                    break;
            }

            arguments += string.Format(@"{0} -o {1}.o", path,
                Path.Combine(outputDirectory, filename));

            compiledObject = null;
            //if (ExecuteTool(tool, arguments))
            //{
            //    compiledObject = new CompiledObject { Name = filename, Path = outputDirectory };
            //    return true;
            //}

            return false;
        }