new home directory
[feisty_meow.git] / nucleus / tools / clam_tools / version_stamper.cpp
1 /*****************************************************************************\
2 *                                                                             *
3 *  Name   : version_stamper                                                   *
4 *  Author : Chris Koeritz                                                     *
5 *                                                                             *
6 *******************************************************************************
7 * Copyright (c) 1995-$now By Author.  This program is free software; you can  *
8 * redistribute it and/or modify it under the terms of the GNU General Public  *
9 * License as published by the Free Software Foundation; either version 2 of   *
10 * the License or (at your option) any later version.  This is online at:      *
11 *     http://www.fsf.org/copyleft/gpl.html                                    *
12 * Please send any updates to: fred@gruntose.com                               *
13 \*****************************************************************************/
14
15 #include <application/application_shell.h>
16 #include <application/command_line.h>
17 #include <application/hoople_main.h>
18 #include <application/windoze_helper.h>
19 #include <loggers/program_wide_logger.h>
20 #include <basis/astring.h>
21 #include <basis/enhance_cpp.h>
22 #include <filesystem/byte_filer.h>
23 #include <filesystem/directory.h>
24 #include <filesystem/filename.h>
25 #include <loggers/console_logger.h>
26 #include <structures/static_memory_gremlin.h>
27 #include <structures/version_record.h>
28 #include <versions/version_ini.h>
29
30 #undef LOG
31 #define LOG(to_print) CLASS_EMERGENCY_LOG(program_wide_logger(), to_print)
32
33 using namespace application;
34 using namespace basis;
35 using namespace filesystem;
36 using namespace loggers;
37 using namespace structures;
38 using namespace versions;
39
40 //! This class creates resource information for applications and libraries to be version stamped.
41 /*!
42   This creates a resource (.rc) file and a C++ header (.h) file when given the directory where
43   a version information file (version.ini) resides.  It creates the files in that directory.
44 */
45
46 class version_stamper : public application_shell
47 {
48 public:
49   version_stamper();
50   ~version_stamper();
51
52   DEFINE_CLASS_NAME("version_stamper");
53
54   int execute();
55     // performs the main action of creating resource and code files.
56 };
57
58 //////////////
59
60 version_stamper::version_stamper() : application_shell()
61 {
62 }
63
64 version_stamper::~version_stamper() {}
65
66 int version_stamper::execute()
67 {
68   FUNCDEF("execute");
69   SETUP_CONSOLE_LOGGER;  // override the file_logger from app_shell.
70   if (application::_global_argc < 2) {
71     log(astring("The directory where the 'version.ini' file is located\n"
72         "must be specified as the first parameter of this program.  Another\n"
73         "version file may optionally be specified as the second parameter of\n"
74         "the program; the version contained in this file will be used to set\n"
75         "the version of the file specified in the first parameter.\n"
76         "Additionally, if the environment variable 'DEBUG' exists, then the\n"
77         "generated RC file will be marked as a debug build.  Otherwise it is\n"
78         "marked as a release build.  Note that the CLAM system automatically\n"
79         "sets this for you.\n\n"), ALWAYS_PRINT);
80     return 1;
81   }
82
83   astring path_name = application::_global_argv[1];
84   astring source_version_file;  // blank by default.
85   if (application::_global_argc > 2)
86     source_version_file = application::_global_argv[2];
87   bool ret = version_ini::one_stop_version_stamp(path_name, source_version_file, true);
88   if (!ret) return 1;  // failure.
89   return 0;  // success.
90 }
91
92 HOOPLE_MAIN(version_stamper, )
93
94 #ifdef __BUILD_STATIC_APPLICATION__
95   // static dependencies found by buildor_gen_deps.sh:
96   #include <application/application_shell.cpp>
97   #include <application/command_line.cpp>
98   #include <application/windoze_helper.cpp>
99   #include <basis/astring.cpp>
100   #include <basis/common_outcomes.cpp>
101   #include <basis/environment.cpp>
102   #include <basis/guards.cpp>
103   #include <basis/mutex.cpp>
104   #include <basis/utf_conversion.cpp>
105   #include <configuration/application_configuration.cpp>
106   #include <configuration/configurator.cpp>
107   #include <configuration/ini_configurator.cpp>
108   #include <configuration/ini_parser.cpp>
109   #include <configuration/table_configurator.cpp>
110   #include <configuration/variable_tokenizer.cpp>
111   #include <filesystem/byte_filer.cpp>
112   #include <filesystem/directory.cpp>
113   #include <filesystem/filename.cpp>
114   #include <loggers/combo_logger.cpp>
115   #include <loggers/console_logger.cpp>
116   #include <loggers/critical_events.cpp>
117   #include <loggers/file_logger.cpp>
118   #include <loggers/program_wide_logger.cpp>
119   #include <structures/bit_vector.cpp>
120   #include <structures/checksums.cpp>
121   #include <structures/object_packers.cpp>
122   #include <structures/static_memory_gremlin.cpp>
123   #include <structures/string_hasher.cpp>
124   #include <structures/string_table.cpp>
125   #include <structures/version_record.cpp>
126   #include <textual/byte_formatter.cpp>
127   #include <textual/parser_bits.cpp>
128   #include <textual/string_manipulation.cpp>
129   #include <timely/earth_time.cpp>
130   #include <timely/time_stamp.cpp>
131   #include <versions/version_ini.cpp>
132 #endif // __BUILD_STATIC_APPLICATION__
133