/// <summary>
        /// Reads data for this dependency cache from disk
        /// </summary>
        private void Read()
        {
            try
            {
                using (BinaryArchiveReader Reader = new BinaryArchiveReader(Location))
                {
                    int Version = Reader.ReadInt();
                    if (Version != CurrentVersion)
                    {
                        Log.TraceLog("Unable to read dependency cache from {0}; version {1} vs current {2}", Location, Version, CurrentVersion);
                        return;
                    }

                    int Count = Reader.ReadInt();
                    for (int Idx = 0; Idx < Count; Idx++)
                    {
                        FileItem File = Reader.ReadFileItem();
                        DependencyFileToInfo[File] = DependencyInfo.Read(Reader);
                    }
                }
            }
            catch (Exception Ex)
            {
                Log.TraceWarning("Unable to read {0}. See log for additional information.", Location);
                Log.TraceLog("{0}", ExceptionUtils.FormatExceptionDetails(Ex));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read from binary archive
        /// </summary>
        public bool ReadDocument(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    int major, minor;
                    archive.Read3dmChunkVersion(out major, out minor);
                    if (major == MAJOR && minor == MINOR)
                    {
                        var count = archive.ReadInt();
                        for (var i = 0; i < count; i++)
                        {
                            var data = new SampleCsSimpleDocumentData();
                            if (data.Read(archive))
                            {
                                Add(data);
                            }
                        }
                        rc = archive.ReadErrorOccured;
                    }
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor. Reads a makefile from disk.
 /// </summary>
 /// <param name="Reader">The archive to read from</param>
 public TargetMakefile(BinaryArchiveReader Reader)
 {
     CreateTimeUtc                = new DateTime(Reader.ReadLong(), DateTimeKind.Utc);
     ToolchainInfo                = Reader.ReadString();
     ExternalMetadata             = Reader.ReadString();
     ReceiptFile                  = Reader.ReadFileReference();
     ProjectIntermediateDirectory = Reader.ReadDirectoryReference();
     TargetType              = (TargetType)Reader.ReadInt();
     bDeployAfterCompile     = Reader.ReadBool();
     bHasProjectScriptPlugin = Reader.ReadBool();
     AdditionalArguments     = Reader.ReadArray(() => Reader.ReadString());
     PreBuildScripts         = Reader.ReadArray(() => Reader.ReadFileReference());
     Actions = Reader.ReadList(() => new Action(Reader));
     EnvironmentVariables    = Reader.ReadList(() => Tuple.Create(Reader.ReadString(), Reader.ReadString()));
     OutputItems             = Reader.ReadList(() => Reader.ReadFileItem());
     ModuleNameToOutputItems = Reader.ReadDictionary(() => Reader.ReadString(), () => Reader.ReadArray(() => Reader.ReadFileItem()), StringComparer.OrdinalIgnoreCase);
     HotReloadModuleNames    = Reader.ReadHashSet(() => Reader.ReadString(), StringComparer.OrdinalIgnoreCase);
     DirectoryToSourceFiles  = Reader.ReadDictionary(() => Reader.ReadDirectoryItem(), () => Reader.ReadArray(() => Reader.ReadFileItem()));
     WorkingSet = Reader.ReadHashSet(() => Reader.ReadFileItem());
     CandidatesForWorkingSet = Reader.ReadHashSet(() => Reader.ReadFileItem());
     UObjectModules          = Reader.ReadList(() => new UHTModuleInfo(Reader));
     UObjectModuleHeaders    = Reader.ReadList(() => new UHTModuleHeaderInfo(Reader));
     PluginFiles             = Reader.ReadHashSet(() => Reader.ReadFileItem());
     AdditionalDependencies  = Reader.ReadHashSet(() => Reader.ReadFileItem());
 }
        /// <summary>
        /// Read from binary archive
        /// </summary>
        public bool ReadDocument(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    archive.Read3dmChunkVersion(out var major, out var minor);
                    if (major == MAJOR && minor == MINOR)
                    {
                        var count = archive.ReadInt();
                        for (var i = 0; i < count; i++)
                        {
                            var key  = archive.ReadString();
                            var data = new ModelEntity();
                            if (data.ReadArchive(archive))
                            {
                                this.Add(key, data);
                            }
                        }
                        rc = archive.ReadErrorOccured;
                    }
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Construct a key from an archive
 /// </summary>
 /// <param name="Reader">Archive to read from</param>
 public ConfigDependencyKey(BinaryArchiveReader Reader)
 {
     Type        = (ConfigHierarchyType)Reader.ReadInt();
     ProjectDir  = Reader.ReadDirectoryReference();
     Platform    = Reader.ReadUnrealTargetPlatform();
     SectionName = Reader.ReadString();
     KeyName     = Reader.ReadString();
 }
        /// <summary>
        /// Reads data for this dependency cache from disk
        /// </summary>
        private void Read()
        {
            try
            {
                using (BinaryArchiveReader Reader = new BinaryArchiveReader(Location))
                {
                    int Version = Reader.ReadInt();
                    if (Version != CurrentVersion)
                    {
                        Log.TraceLog("Unable to read dependency cache from {0}; version {1} vs current {2}", Location, Version, CurrentVersion);
                        return;
                    }

                    int FileToFirstIncludeCount = Reader.ReadInt();
                    for (int Idx = 0; Idx < FileToFirstIncludeCount; Idx++)
                    {
                        FileItem File = Reader.ReadCompactFileItem();

                        IncludeInfo IncludeInfo = new IncludeInfo();
                        IncludeInfo.LastWriteTimeUtc = Reader.ReadLong();
                        IncludeInfo.IncludeText      = Reader.ReadString();

                        FileToIncludeInfo[File] = IncludeInfo;
                    }

                    int FileToMarkupFlagCount = Reader.ReadInt();
                    for (int Idx = 0; Idx < FileToMarkupFlagCount; Idx++)
                    {
                        FileItem File = Reader.ReadCompactFileItem();

                        ReflectionInfo ReflectionInfo = new ReflectionInfo();
                        ReflectionInfo.LastWriteTimeUtc = Reader.ReadLong();
                        ReflectionInfo.bContainsMarkup  = Reader.ReadBool();

                        FileToReflectionInfo[File] = ReflectionInfo;
                    }
                }
            }
            catch (Exception Ex)
            {
                Log.TraceWarning("Unable to read {0}. See log for additional information.", Location);
                Log.TraceLog("{0}", ExceptionUtils.FormatExceptionDetails(Ex));
            }
        }
        /// <summary>
        /// Read from binary archive
        /// </summary>
        public bool Read(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    archive.Read3dmChunkVersion(out var major, out var minor);
                    if (major == MAJOR && minor == MINOR)
                    {
                        Value = archive.ReadInt();
                        rc    = archive.ReadErrorOccured;
                    }
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Attempts to load this action history from disk
        /// </summary>
        void Load()
        {
            try
            {
                using (BinaryArchiveReader Reader = new BinaryArchiveReader(Location))
                {
                    int Version = Reader.ReadInt();
                    if (Version != CurrentVersion)
                    {
                        Log.TraceLog("Unable to read action history from {0}; version {1} vs current {2}", Location, Version, CurrentVersion);
                        return;
                    }

                    OutputItemToAttributeHash = new ConcurrentDictionary <FileItem, byte[]>(Reader.ReadDictionary(() => Reader.ReadFileItem(), () => Reader.ReadFixedSizeByteArray(HashLength)));
                }
            }
            catch (Exception Ex)
            {
                Log.TraceWarning("Unable to read {0}. See log for additional information.", Location);
                Log.TraceLog("{0}", ExceptionUtils.FormatExceptionDetails(Ex));
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Loads a makefile  from disk
        /// </summary>
        /// <param name="MakefilePath">Path to the makefile to load</param>
        /// <param name="ProjectFile">Path to the project file</param>
        /// <param name="Platform">Platform for this makefile</param>
        /// <param name="Arguments">Command line arguments for this target</param>
        /// <param name="ReasonNotLoaded">If the function returns null, this string will contain the reason why</param>
        /// <returns>The loaded makefile, or null if it failed for some reason.  On failure, the 'ReasonNotLoaded' variable will contain information about why</returns>
        public static TargetMakefile Load(FileReference MakefilePath, FileReference ProjectFile, UnrealTargetPlatform Platform, string[] Arguments, out string ReasonNotLoaded)
        {
            using (Timeline.ScopeEvent("Checking dependent timestamps"))
            {
                // Check the directory timestamp on the project files directory.  If the user has generated project files more recently than the makefile, then we need to consider the file to be out of date
                FileInfo MakefileInfo = new FileInfo(MakefilePath.FullName);
                if (!MakefileInfo.Exists)
                {
                    // Makefile doesn't even exist, so we won't bother loading it
                    ReasonNotLoaded = "no existing makefile";
                    return(null);
                }

                // Check the build version
                FileInfo BuildVersionFileInfo = new FileInfo(BuildVersion.GetDefaultFileName().FullName);
                if (BuildVersionFileInfo.Exists && MakefileInfo.LastWriteTime.CompareTo(BuildVersionFileInfo.LastWriteTime) < 0)
                {
                    Log.TraceLog("Existing makefile is older than Build.version, ignoring it");
                    ReasonNotLoaded = "Build.version is newer";
                    return(null);
                }

                // @todo ubtmake: This will only work if the directory timestamp actually changes with every single GPF.  Force delete existing files before creating new ones?  Eh... really we probably just want to delete + create a file in that folder
                //			-> UPDATE: Seems to work OK right now though on Windows platform, maybe due to GUID changes
                // @todo ubtmake: Some platforms may not save any files into this folder.  We should delete + generate a "touch" file to force the directory timestamp to be updated (or just check the timestamp file itself.  We could put it ANYWHERE, actually)

                // Installed Build doesn't need to check engine projects for outdatedness
                if (!UnrealBuildTool.IsEngineInstalled())
                {
                    if (DirectoryReference.Exists(ProjectFileGenerator.IntermediateProjectFilesPath))
                    {
                        DateTime EngineProjectFilesLastUpdateTime = new FileInfo(ProjectFileGenerator.ProjectTimestampFile).LastWriteTime;
                        if (MakefileInfo.LastWriteTime.CompareTo(EngineProjectFilesLastUpdateTime) < 0)
                        {
                            // Engine project files are newer than makefile
                            Log.TraceLog("Existing makefile is older than generated engine project files, ignoring it");
                            ReasonNotLoaded = "project files are newer";
                            return(null);
                        }
                    }
                }

                // Check the game project directory too
                if (ProjectFile != null)
                {
                    string   ProjectFilename = ProjectFile.FullName;
                    FileInfo ProjectFileInfo = new FileInfo(ProjectFilename);
                    if (!ProjectFileInfo.Exists || MakefileInfo.LastWriteTime.CompareTo(ProjectFileInfo.LastWriteTime) < 0)
                    {
                        // .uproject file is newer than makefile
                        Log.TraceLog("Makefile is older than .uproject file, ignoring it");
                        ReasonNotLoaded = ".uproject file is newer";
                        return(null);
                    }

                    DirectoryReference MasterProjectRelativePath        = ProjectFile.Directory;
                    string             GameIntermediateProjectFilesPath = Path.Combine(MasterProjectRelativePath.FullName, "Intermediate", "ProjectFiles");
                    if (Directory.Exists(GameIntermediateProjectFilesPath))
                    {
                        DateTime GameProjectFilesLastUpdateTime = new DirectoryInfo(GameIntermediateProjectFilesPath).LastWriteTime;
                        if (MakefileInfo.LastWriteTime.CompareTo(GameProjectFilesLastUpdateTime) < 0)
                        {
                            // Game project files are newer than makefile
                            Log.TraceLog("Makefile is older than generated game project files, ignoring it");
                            ReasonNotLoaded = "game project files are newer";
                            return(null);
                        }
                    }
                }

                // Check to see if UnrealBuildTool.exe was compiled more recently than the makefile
                DateTime UnrealBuildToolTimestamp = new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime;
                if (MakefileInfo.LastWriteTime.CompareTo(UnrealBuildToolTimestamp) < 0)
                {
                    // UnrealBuildTool.exe was compiled more recently than the makefile
                    Log.TraceLog("Makefile is older than UnrealBuildTool.exe, ignoring it");
                    ReasonNotLoaded = "UnrealBuildTool.exe is newer";
                    return(null);
                }

                // Check to see if any BuildConfiguration files have changed since the last build
                List <XmlConfig.InputFile> InputFiles = XmlConfig.FindInputFiles();
                foreach (XmlConfig.InputFile InputFile in InputFiles)
                {
                    FileInfo InputFileInfo = new FileInfo(InputFile.Location.FullName);
                    if (InputFileInfo.LastWriteTime > MakefileInfo.LastWriteTime)
                    {
                        Log.TraceLog("Makefile is older than BuildConfiguration.xml, ignoring it");
                        ReasonNotLoaded = "BuildConfiguration.xml is newer";
                        return(null);
                    }
                }
            }

            TargetMakefile Makefile;

            using (Timeline.ScopeEvent("Loading makefile"))
            {
                try
                {
                    using (BinaryArchiveReader Reader = new BinaryArchiveReader(MakefilePath))
                    {
                        int Version = Reader.ReadInt();
                        if (Version != CurrentVersion)
                        {
                            ReasonNotLoaded = "makefile version does not match";
                            return(null);
                        }
                        Makefile = new TargetMakefile(Reader);
                    }
                }
                catch (Exception Ex)
                {
                    Log.TraceWarning("Failed to read makefile: {0}", Ex.Message);
                    Log.TraceLog("Exception: {0}", Ex.ToString());
                    ReasonNotLoaded = "couldn't read existing makefile";
                    return(null);
                }
            }

            using (Timeline.ScopeEvent("Checking makefile validity"))
            {
                // Check if the arguments are different
                if (!Enumerable.SequenceEqual(Makefile.AdditionalArguments, Arguments))
                {
                    ReasonNotLoaded = "command line arguments changed";
                    return(null);
                }

                // Check if ini files are newer. Ini files contain build settings too.
                DirectoryReference ProjectDirectory = DirectoryReference.FromFile(ProjectFile);
                foreach (ConfigHierarchyType IniType in (ConfigHierarchyType[])Enum.GetValues(typeof(ConfigHierarchyType)))
                {
                    foreach (FileReference IniFilename in ConfigHierarchy.EnumerateConfigFileLocations(IniType, ProjectDirectory, Platform))
                    {
                        FileInfo IniFileInfo = new FileInfo(IniFilename.FullName);
                        if (IniFileInfo.LastWriteTimeUtc > Makefile.CreateTimeUtc)
                        {
                            // Ini files are newer than makefile
                            ReasonNotLoaded = "ini files are newer than makefile";
                            return(null);
                        }
                    }
                }

                // Get the current build metadata from the platform
                string CurrentExternalMetadata = UEBuildPlatform.GetBuildPlatform(Platform).GetExternalBuildMetadata(ProjectFile);
                if (String.Compare(CurrentExternalMetadata, Makefile.ExternalMetadata, StringComparison.Ordinal) != 0)
                {
                    Log.TraceLog("Old metadata:\n", Makefile.ExternalMetadata);
                    Log.TraceLog("New metadata:\n", CurrentExternalMetadata);
                    ReasonNotLoaded = "build metadata has changed";
                    return(null);
                }
            }

            // The makefile is ok
            ReasonNotLoaded = null;
            return(Makefile);
        }