Exemplo n.º 1
0
        public static string CreateDepsCacheString(
            BuildTranslation translation,
            IFileDecider fileDecider)
        {
            //  SortedDictionary is used to canonicalize the output.

            SortedDictionary<string, string> eiVersions = new SortedDictionary<string, string>();
            SortedDictionary<string, string> eoVersions = new SortedDictionary<string, string>();
            SortedDictionary<string, string> iiVersions = new SortedDictionary<string, string>();

            foreach (var filePath in translation.ExplicitInputs) {
                string versionStamp = fileDecider.GetVersionStamp(filePath);
                eiVersions[filePath] = versionStamp;
            }
            foreach (var filePath in translation.ExplicitOutputs) {
                string versionStamp = fileDecider.GetVersionStamp(filePath);
                eoVersions[filePath] = versionStamp;
            }
            foreach (var filePath in translation.ImplicitInputs) {
                string versionStamp = fileDecider.GetVersionStamp(filePath);
                iiVersions[filePath] = versionStamp;
            }

            string translationParameters = translation.GetCacheableTranslationParameters();
            if (translationParameters == null) {
                return null;
            }

            StringBuilder sb = new StringBuilder();
            sb.Append("__ExplicitInputs:\n");
            foreach (var kvp in eiVersions) {
                sb.AppendFormat("\t{0} >> {1}\n", kvp.Key, kvp.Value);
            }
            sb.Append("__ExplicitsOutputs:\n");
            foreach (var kvp in eoVersions) {
                sb.AppendFormat("\t{0} >> {1}\n", kvp.Key, kvp.Value);
            }
            sb.Append("__ImplicitInputs:\n");
            foreach (var kvp in iiVersions) {
                sb.AppendFormat("\t{0} >> {1}\n", kvp.Key, kvp.Value);
            }
            sb.Append("__Params:\n");
            sb.Append(translationParameters);

            string result = sb.ToString();
            return result;
        }
Exemplo n.º 2
0
        /// Create a BuildFile for each output, and set its [generator] BuildNode.
        private bool AddOutputDependencies(BuildTranslation translation, IEnumerable<string> outputs)
        {
            bool result = true;
            foreach (string path in outputs) {
                BuildFile buildFile = CreateOrGetBuildFile(path);

                if (buildFile.BuildNode != null) {
                    Trace.TraceError("Target {0} claims to be generated by more than one Translation:\n\t{1}\n\t{2}\n",
                        buildFile.Path,
                        buildFile.BuildNode.Translation.BuildFileBaseName,
                        translation.BuildFileBaseName);
                    result = false;
                }
                else {
                    buildFile.BuildNode = translation.BuildNode;
                }
            }
            return result;
        }
Exemplo n.º 3
0
        /// Update translation.BuildNode.Dependencies.
        private void AddInputDependencies(BuildTranslation translation, IEnumerable<string> inputs)
        {
            foreach (string input in inputs) {
                BuildFile buildFile = CreateOrGetBuildFile(input);
                buildFile.Consumers.Add(translation.BuildNode);

                if (buildFile.BuildNode != null) {
                    //  Add the BuildNode that generates input to the current node's dependency list.
                    translation.BuildNode.Dependencies.Add(buildFile.BuildNode);
                }
            }
        }
Exemplo n.º 4
0
 /// Add a translation to the BuildGraph.
 /// BuildTranslation's constructor calls this, so that users don't have to.
 internal void Add(BuildTranslation translation)
 {
     m_dependenciesComputed = false;
     m_translations.Add(translation);
 }
Exemplo n.º 5
0
 public BuildNode(BuildTranslation translation)
 {
     Translation = translation;
 }