check_versions.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : version checks                                                    *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *  Purpose:                                                                   *
00007 *                                                                             *
00008 *    Ensures that all the libraries have a version stamp and that they match  *
00009 *  the version we expect.                                                     *
00010 *                                                                             *
00011 *******************************************************************************
00012 * Copyright (c) 2002-$now By Author.  This program is free software; you can  *
00013 * redistribute it and/or modify it under the terms of the GNU General Public  *
00014 * License as published by the Free Software Foundation; either version 2 of   *
00015 * the License or (at your option) any later version.  This is online at:      *
00016 *     http://www.fsf.org/copyleft/gpl.html                                    *
00017 * Please send any updates to: fred@gruntose.com                               *
00018 \*****************************************************************************/
00019 
00020 #include <basis/portable.h>
00021 #include <basis/string_array.h>
00022 #include <basis/version_checker.h>
00023 #include <basis/version_record.h>
00024 #include <loggers/console_logger.h>
00025 #include <opsystem/directory.h>
00026 #include <loggers/file_logger.h>
00027 #include <data_struct/static_memory_gremlin.h>
00028 
00029 #include <__build_version.h>
00030 
00031 HOOPLE_STARTUP_CODE;
00032 
00033 #undef LOG
00034 #define LOG(s) program_wide_logger().log(s)
00035 
00036 static bool failure = false;
00037 static string_array badness_list;
00038 
00039 #define complain(where) { \
00040   LOG(istring("the file ") +  where + " failed the version check."); \
00041   badness_list += where; \
00042   failure = true; \
00043 }
00044 
00045 int main(int formal(argc), char *formal(argv)[])
00046 {
00047   SET_DEFAULT_COMBO_LOGGER;
00048   // get our main repository directory for the source.
00049   istring repodir = portable::env_string("REPOSITORY_DIR");
00050 
00051   // find all the dlls.
00052 #ifdef __WIN32__
00053   directory dlldir(repodir + "/dll", "*.dll");
00054 #else
00055   directory dlldir(repodir + "/dll", "*.so");
00056 #endif
00057   string_array dll_files = dlldir.files();
00058 
00059   // find all the exes.
00060 #ifdef __WIN32__
00061   directory exedir(repodir + "/exe", "*.exe");
00062 #else
00063   directory exedir(repodir + "/exe", "*");
00064 #endif
00065   string_array exe_files = exedir.files();
00066 
00067   // set our path to include the dll and exe directories.
00068   istring path = dlldir.path() + ";" + exedir.path() + ";"
00069       + portable::env_string("PATH");
00070   portable::set_environ("PATH", path);
00071 //LOG(istring("path is now: ") + portable::env_string("PATH"));
00072 
00073   // calculate the proper version.
00074   version good_version(__build_FILE_VERSION);
00075   LOG(istring("this is build ") + good_version.flex_text_form());
00076 
00077   for (int i = 0; i < dll_files.length(); i++) {
00078     const istring &current = dll_files[i];
00079     version found = version_checker::get_version(current);
00080     if (good_version != found)
00081       complain(current);
00082   }
00083   for (int i = 0; i < exe_files.length(); i++) {
00084     const istring &current = exe_files[i];
00085     // skip any obvious non-executable products.
00086     if ( (current == "manifest.txt") || (current == "paths.ini")
00087         || (current == "shutdown_list.dat") ) continue;
00088     version found = version_checker::get_version(current);
00089     if (good_version != found) {
00090       complain(current);
00091     }
00092   }
00093 
00094   istring lib_type = "release";
00095 #ifdef _DEBUG
00096   lib_type = "debug";
00097 #endif
00098   LOG(istring("finished checking ") + lib_type + " versions.");
00099   if (failure) {
00100     LOG("one or more version checks failed!  this is the full set:");
00101     LOG(badness_list.text_form());
00102   } else {
00103     LOG("all attempted version checks succeeded.");
00104   }
00105 
00106   return !!failure;
00107 }
00108 
00109 #ifdef __BUILD_STATIC_APPLICATION__
00110   // static dependencies found by buildor_gen_deps.sh:
00111   #include <basis/array.cpp>
00112   #include <basis/byte_array.cpp>
00113   #include <basis/callstack_tracker.cpp>
00114   #include <basis/chaos.cpp>
00115   #include <basis/convert_utf.cpp>
00116   #include <basis/definitions.cpp>
00117   #include <basis/earth_time.cpp>
00118   #include <basis/guards.cpp>
00119   #include <basis/istring.cpp>
00120   #include <basis/log_base.cpp>
00121   #include <basis/memory_checker.cpp>
00122   #include <basis/mutex.cpp>
00123   #include <basis/object_base.cpp>
00124   #include <basis/outcome.cpp>
00125   #include <basis/packable.cpp>
00126   #include <basis/portable.cpp>
00127   #include <basis/sequence.cpp>
00128   #include <basis/set.cpp>
00129   #include <basis/utility.cpp>
00130   #include <basis/version_checker.cpp>
00131   #include <basis/version_record.cpp>
00132   #include <data_struct/amorph.cpp>
00133   #include <data_struct/bit_vector.cpp>
00134   #include <data_struct/byte_hasher.cpp>
00135   #include <data_struct/configurator.cpp>
00136   #include <data_struct/hash_table.cpp>
00137   #include <data_struct/pointer_hash.cpp>
00138   #include <data_struct/stack.cpp>
00139   #include <data_struct/static_memory_gremlin.cpp>
00140   #include <data_struct/string_hash.cpp>
00141   #include <data_struct/string_hasher.cpp>
00142   #include <data_struct/string_table.cpp>
00143   #include <data_struct/symbol_table.cpp>
00144   #include <data_struct/table_configurator.cpp>
00145   #include <loggers/console_logger.cpp>
00146   #include <loggers/file_logger.cpp>
00147   #include <loggers/locked_logger.cpp>
00148   #include <loggers/null_logger.cpp>
00149   #include <loggers/program_wide_logger.cpp>
00150   #include <opsystem/byte_filer.cpp>
00151   #include <opsystem/command_line.cpp>
00152   #include <opsystem/critical_events.cpp>
00153   #include <opsystem/directory.cpp>
00154   #include <opsystem/filename.cpp>
00155   #include <opsystem/ini_config.cpp>
00156   #include <opsystem/ini_parser.cpp>
00157   #include <opsystem/path_configuration.cpp>
00158   #include <opsystem/rendezvous.cpp>
00159   #include <textual/byte_format.cpp>
00160   #include <textual/parser_bits.cpp>
00161   #include <textual/string_manipulation.cpp>
00162   #include <textual/tokenizer.cpp>
00163 #endif // __BUILD_STATIC_APPLICATION__
00164 

Generated on Thu Nov 20 04:29:15 2008 for HOOPLE Libraries by  doxygen 1.5.1