added in old production bits, only relevant on win32 and only if we build dlls, which
[feisty_meow.git] / production / check_versions / check_versions.cpp
1 /*****************************************************************************\
2 *                                                                             *
3 *  Name   : version checks                                                    *
4 *  Author : Chris Koeritz                                                     *
5 *                                                                             *
6 *  Purpose:                                                                   *
7 *                                                                             *
8 *    Ensures that all the libraries have a version stamp and that they match  *
9 *  the version we expect.                                                     *
10 *                                                                             *
11 *******************************************************************************
12 * Copyright (c) 2002-$now By Author.  This program is free software; you can  *
13 * redistribute it and/or modify it under the terms of the GNU General Public  *
14 * License as published by the Free Software Foundation; either version 2 of   *
15 * the License or (at your option) any later version.  This is online at:      *
16 *     http://www.fsf.org/copyleft/gpl.html                                    *
17 * Please send any updates to: fred@gruntose.com                               *
18 \*****************************************************************************/
19
20 #include <basis/portable.h>
21 #include <basis/string_array.h>
22 #include <basis/version_checker.h>
23 #include <basis/version_record.h>
24 #include <loggers/console_logger.h>
25 #include <opsystem/directory.h>
26 #include <loggers/file_logger.h>
27 #include <data_struct/static_memory_gremlin.h>
28
29 #include <__build_version.h>
30
31 HOOPLE_STARTUP_CODE;
32
33 #undef LOG
34 #define LOG(s) program_wide_logger().log(s)
35
36 static bool failure = false;
37 static string_array badness_list;
38
39 #define complain(where) { \
40   LOG(istring("the file ") +  where + " failed the version check."); \
41   badness_list += where; \
42   failure = true; \
43 }
44
45 int main(int formal(argc), char *formal(argv)[])
46 {
47   SET_DEFAULT_COMBO_LOGGER;
48   // get our main repository directory for the source.
49   istring repodir = portable::env_string("REPOSITORY_DIR");
50
51   // find all the dlls.
52 #ifdef __WIN32__
53   directory dlldir(repodir + "/dll", "*.dll");
54 #else
55   directory dlldir(repodir + "/dll", "*.so");
56 #endif
57   string_array dll_files = dlldir.files();
58
59   // find all the exes.
60 #ifdef __WIN32__
61   directory exedir(repodir + "/exe", "*.exe");
62 #else
63   directory exedir(repodir + "/exe", "*");
64 #endif
65   string_array exe_files = exedir.files();
66
67   // set our path to include the dll and exe directories.
68   istring path = dlldir.path() + ";" + exedir.path() + ";"
69       + portable::env_string("PATH");
70   portable::set_environ("PATH", path);
71 //LOG(istring("path is now: ") + portable::env_string("PATH"));
72
73   // calculate the proper version.
74   version good_version(__build_FILE_VERSION);
75   LOG(istring("this is build ") + good_version.flex_text_form());
76
77   for (int i = 0; i < dll_files.length(); i++) {
78     const istring &current = dll_files[i];
79     version found = version_checker::get_version(current);
80     if (good_version != found)
81       complain(current);
82   }
83   for (int i = 0; i < exe_files.length(); i++) {
84     const istring &current = exe_files[i];
85     // skip any obvious non-executable products.
86     if ( (current == "manifest.txt") || (current == "paths.ini")
87         || (current == "shutdown_list.dat") ) continue;
88     version found = version_checker::get_version(current);
89     if (good_version != found) {
90       complain(current);
91     }
92   }
93
94   istring lib_type = "release";
95 #ifdef _DEBUG
96   lib_type = "debug";
97 #endif
98   LOG(istring("finished checking ") + lib_type + " versions.");
99   if (failure) {
100     LOG("one or more version checks failed!  this is the full set:");
101     LOG(badness_list.text_form());
102   } else {
103     LOG("all attempted version checks succeeded.");
104   }
105
106   return !!failure;
107 }
108
109 #ifdef __BUILD_STATIC_APPLICATION__
110   // static dependencies found by buildor_gen_deps.sh:
111   #include <basis/byte_array.cpp>
112   #include <basis/callstack_tracker.cpp>
113   #include <basis/convert_utf.cpp>
114   #include <basis/definitions.cpp>
115   #include <basis/earth_time.cpp>
116   #include <basis/guards.cpp>
117   #include <basis/istring.cpp>
118   #include <basis/log_base.cpp>
119   #include <basis/memory_checker.cpp>
120   #include <basis/mutex.cpp>
121   #include <basis/object_base.h>
122   #include <basis/outcome.cpp>
123   #include <basis/packable.cpp>
124   #include <basis/portable.cpp>
125   #include <basis/trap_new.addin>
126   #include <basis/untrap_new.addin>
127   #include <basis/utility.cpp>
128   #include <basis/version_checker.cpp>
129   #include <basis/version_record.cpp>
130   #include <data_struct/bit_vector.cpp>
131   #include <data_struct/byte_hasher.cpp>
132   #include <data_struct/configurator.cpp>
133   #include <data_struct/pointer_hash.h>
134   #include <data_struct/stack.h>
135   #include <data_struct/static_memory_gremlin.cpp>
136   #include <data_struct/string_hash.h>
137   #include <data_struct/string_hasher.cpp>
138   #include <data_struct/string_table.cpp>
139   #include <data_struct/symbol_table.h>
140   #include <data_struct/table_configurator.cpp>
141   #include <loggers/console_logger.cpp>
142   #include <loggers/file_logger.cpp>
143   #include <loggers/locked_logger.cpp>
144   #include <loggers/null_logger.cpp>
145   #include <loggers/program_wide_logger.cpp>
146   #include <opsystem/byte_filer.cpp>
147   #include <opsystem/command_line.cpp>
148   #include <opsystem/critical_events.cpp>
149   #include <opsystem/directory.cpp>
150   #include <opsystem/filename.cpp>
151   #include <opsystem/ini_config.cpp>
152   #include <opsystem/ini_parser.cpp>
153   #include <opsystem/path_configuration.cpp>
154   #include <opsystem/rendezvous.cpp>
155   #include <textual/byte_format.cpp>
156   #include <textual/parser_bits.cpp>
157   #include <textual/string_manipulation.cpp>
158   #include <textual/tokenizer.cpp>
159 #endif // __BUILD_STATIC_APPLICATION__
160