Пример #1
0
        private void UpdateIncludeCacheItem(string include)
        {
            string curFileDir = Path.GetDirectoryName(GetFilePath());
            string path       = null;
            bool   needUpdate = true;

            if (_includeCache.ContainsKey(include) &&
                File.Exists(_includeCache[include].FileName))
            {
                path       = _includeCache[include].FileName;
                needUpdate =
                    (File.GetLastWriteTime(path) != _includeCache[include].TimeStamp);
            }
            else
            {
                path = Path.Combine(curFileDir, include + ".cmake");
                if (!File.Exists(path))
                {
                    path = Path.Combine(CMakePath.FindCMakeModules(),
                                        include + ".cmake");
                    if (!File.Exists(path))
                    {
                        path = null;
                    }
                }
            }
            if (path != null && needUpdate)
            {
                try
                {
                    string[] includeLines = File.ReadAllLines(path);
                    bool     rootRef      = _includeCache.ContainsKey(include) &&
                                            _includeCache[include].RootRef;
                    _includeCache[include] = new IncludeCacheEntry()
                    {
                        FileName     = path,
                        TimeStamp    = File.GetLastWriteTime(path),
                        RootRef      = rootRef,
                        Variables    = CMakeParsing.ParseForVariables(includeLines),
                        EnvVariables = CMakeParsing.ParseForEnvVariables(
                            includeLines),
                        CacheVariables = CMakeParsing.ParseForCacheVariables(
                            includeLines),
                        Functions = CMakeParsing.ParseForFunctionNames(includeLines,
                                                                       false),
                        Macros = CMakeParsing.ParseForFunctionNames(includeLines,
                                                                    true),
                        Dependencies = CMakeParsing.ParseForIncludes(includeLines)
                    };
                    foreach (string dependency in _includeCache[include].Dependencies)
                    {
                        UpdateIncludeCacheItem(dependency);
                    }
                }
                catch (IOException)
                {
                    // Just ignore any errors.
                }
            }
        }
Пример #2
0
        private void UpdateUsageStatus(string include)
        {
            IncludeCacheEntry entry = _includeCache[include];

            if (!entry.Used)
            {
                entry.Used = true;
                foreach (string dependency in entry.Dependencies)
                {
                    UpdateUsageStatus(dependency);
                }
            }
        }
Пример #3
0
 private void UpdateIncludeCacheItem(string include)
 {
     string curFileDir = Path.GetDirectoryName(GetFilePath());
     string path = null;
     bool needUpdate = true;
     if (_includeCache.ContainsKey(include) &&
         File.Exists(_includeCache[include].FileName))
     {
         path = _includeCache[include].FileName;
         needUpdate =
             (File.GetLastWriteTime(path) != _includeCache[include].TimeStamp);
     }
     else
     {
         path = Path.Combine(curFileDir, include + ".cmake");
         if (!File.Exists(path))
         {
             path = Path.Combine(CMakePath.FindCMakeModules(),
                 include + ".cmake");
             if (!File.Exists(path))
             {
                 path = null;
             }
         }
     }
     if (path != null && needUpdate)
     {
         try
         {
             string[] includeLines = File.ReadAllLines(path);
             bool rootRef = _includeCache.ContainsKey(include) &&
                 _includeCache[include].RootRef;
             _includeCache[include] = new IncludeCacheEntry()
             {
                 FileName = path,
                 TimeStamp = File.GetLastWriteTime(path),
                 RootRef = rootRef,
                 Variables = CMakeParsing.ParseForVariables(includeLines),
                 EnvVariables = CMakeParsing.ParseForEnvVariables(
                     includeLines),
                 CacheVariables = CMakeParsing.ParseForCacheVariables(
                     includeLines),
                 Functions = CMakeParsing.ParseForFunctionNames(includeLines,
                     false),
                 Macros = CMakeParsing.ParseForFunctionNames(includeLines,
                     true),
                 Dependencies = CMakeParsing.ParseForIncludes(includeLines)
             };
             foreach (string dependency in _includeCache[include].Dependencies)
             {
                 UpdateIncludeCacheItem(dependency);
             }
         }
         catch (IOException)
         {
             // Just ignore any errors.
         }
     }
 }