Exemplo n.º 1
0
        byte[] GenerateInputCache()
        {
            StringBuilder inputConcat = new StringBuilder();

            inputConcat.Append(compilerInfo);
            foreach (var item in compilerArgs)
            {
                inputConcat.Append(item);
            }
            inputConcat.Append(outputFile);
            foreach (var item in inputFiles)
            {
                inputConcat.Append(item);
            }
            foreach (var item in referenceFiles)
            {
                inputConcat.Append(item);
            }
            foreach (var item in moduleFiles)
            {
                inputConcat.Append(item);
            }

            return(MD5Tools.MakeMD5String(inputConcat.ToString()));
        }
Exemplo n.º 2
0
        public static byte[] GenerateFilesCache(List <string> inputF)
        {
            List <byte[]> filesCache = new List <byte[]>();

            foreach (var item in inputF)
            {
                filesCache.Add(MD5Tools.MakeMD5File(item));
            }
            return(MD5Tools.CombineHashes(filesCache));
        }
Exemplo n.º 3
0
        public void Cache()
        {
            int  error        = -1;
            bool showHelp     = false;
            bool doClearCache = false;

            var options = new OptionSet {
                { "c|clear=", "clear cache. Options : =all", n => { if (n == "all")
                                                                    {
                                                                        doClearCache = true;
                                                                    }
                  } },
                { "v|version", "show the current version of the tool.", v => { } },
                { "h|help", "show help message and exit.", h => showHelp = true },
            };
            List <string> extra = new List <string>();

            try
            {
                extra = options.Parse(inputArgs);
            }
            catch (OptionException e)
            {
                ConsoleTools.Error($"CSCache: {e.Message} \n Try `CSCache --help' for more information.", 1);
            }

            if (showHelp)
            {
                LibArgs.ShowHelp(options);
                return;
            }
            if (doClearCache)
            {
                LibArgs.ClearCache(configuration.cacheLocation);
                return;
            }

            if (extra.Count == 1)
            {
                ProcessInputCompiler(extra[0]);
            }
            else
            {
                ConsoleTools.Error("Error reading the compiler and arguments.\nTry `CSCache --help' for more information.", 1);
            }

            foreach (var item in configuration.versionArg)
            {
                compilerInfo = ConsoleTools.Execute(compilerName + " " + item, out error);
                if (error == 0)
                {
                    break;
                }
            }


            if (error == 0)
            {
                byte[] inputCache;
                byte[] filesCache;
                byte[] combinedCache;

                FilesTools.GenerateFullPath(ref inputFiles, ref referenceFiles, ref moduleFiles);

                inputCache    = GenerateInputCache();
                filesCache    = MD5Tools.GenerateFilesCache(inputFiles);
                combinedCache = MD5Tools.CombineHashes(new List <byte[]> {
                    inputCache, filesCache
                });
                CompareCache(combinedCache);
            }
            else
            {
                ConsoleTools.Error("Error getting the version of the compiler. Check the configuration file.", 2);
            }
        }