Example #1
0
        void GenerateCache(string path, string filename)
        {
            int    error;
            string executeMessage = ConsoleTools.Execute(inputCompilerLine, out error);

            if (error == 0)
            {
                Console.WriteLine(executeMessage);
                File.Copy(outputFile, path + filename + "bin.cache", true);
                File.WriteAllText(path + filename + ".cache", executeMessage);
            }
            else
            {
                ConsoleTools.Error(executeMessage, error);
            }
        }
Example #2
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);
            }
        }