コード例 #1
0
ファイル: Compiler.cs プロジェクト: rgiot/phactory
        public bool Compile(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            if (fileInfo == null)
            {
                return(false);
            }

            if (!IsResourceSupported(resource))
            {
                return(false);
            }

            List <String> resourceFilenames = new List <String>();
            List <String> paddingFilenames  = new List <String>();
            List <int>    address           = new List <int>();

            Document.Document document = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);
            if (document == null)
            {
                return(false);
            }

            document.Expand();

            foreach (Document.File file in document.Files)
            {
                PhactoryHost.Database.Resource iResource = Host.GetResource(file.ResourceID);
                if (iResource == null)
                {
                    Host.Log("Unknown resource identifier : " + file.ResourceID);
                    return(false);
                }

                FileInfo iFileInfo = Host.GetFileInfo(iResource);

                resourceFilenames.Add(iFileInfo.FullName);
                paddingFilenames.Add(file.Pad256 ? "true" : "false");
                address.Add((file.SetAddress == false)?0:file.Address);
            }

            var compiler = new Phactory.Modules.BigFile.Compiler.BigFileCompiler();

            string resourceRelativePathNoExt = resource.RelativePath;

            resourceRelativePathNoExt = resourceRelativePathNoExt.Replace(".cpcbigfile", "");

            App.Controller.View.AppDoEvents();

            string baseFilename   = Host.MakeFullPath(resourceRelativePathNoExt);
            string headerFilename = Host.MakeFullPath(resourceRelativePathNoExt + ".H");

            if (!compiler.Compile(baseFilename, headerFilename, resourceFilenames, paddingFilenames, address, document.TruncateFiles, document.FilesInBank, document.BaseAddress))
            {
                return(false);
            }

            return(true);
        }