feisty meow concerns codebase  2.140
version_stamper.cpp
Go to the documentation of this file.
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 
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>
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 
41 
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 
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 < 3) {
71  log(astring(
72 "The directory where the 'version.ini' file is located must be specified as the\n"
73 "first parameter of this program. The second parameter must provide the\n"
74 "storage location where the version header will be written. Another version\n"
75 "file may optionally be specified as the third parameter of the program; the\n"
76 "version contained in this file will be used to set the version of the file\n"
77 "specified in the first parameter.\n"
78 "Additionally, if the environment variable 'DEBUG' exists, then the\n"
79 "generated RC file will be marked as a debug build. Otherwise it is\n"
80 "marked as a release build. Note that the CLAM system automatically\n"
81 "sets this for you.\n\n"), ALWAYS_PRINT);
82  return 1;
83  }
84 
85  astring path_name = application::_global_argv[1];
86  astring storage_name = application::_global_argv[2];
87  astring source_version_file; // blank by default.
89  source_version_file = application::_global_argv[3];
90  bool ret = version_ini::one_stop_version_stamp(path_name, storage_name, source_version_file, true);
91  if (!ret) return 1; // failure.
92  return 0; // success.
93 }
94 
95 HOOPLE_MAIN(version_stamper, )
96 
97 #ifdef __BUILD_STATIC_APPLICATION__
98  // static dependencies found by buildor_gen_deps.sh:
102  #include <basis/astring.cpp>
103  #include <basis/common_outcomes.cpp>
104  #include <basis/environment.cpp>
105  #include <basis/guards.cpp>
106  #include <basis/mutex.cpp>
107  #include <basis/utf_conversion.cpp>
114  #include <filesystem/byte_filer.cpp>
115  #include <filesystem/directory.cpp>
116  #include <filesystem/filename.cpp>
117  #include <loggers/combo_logger.cpp>
118  #include <loggers/console_logger.cpp>
119  #include <loggers/critical_events.cpp>
120  #include <loggers/file_logger.cpp>
122  #include <structures/bit_vector.cpp>
123  #include <structures/checksums.cpp>
127  #include <structures/string_table.cpp>
129  #include <textual/byte_formatter.cpp>
130  #include <textual/parser_bits.cpp>
132  #include <timely/earth_time.cpp>
133  #include <timely/time_stamp.cpp>
134  #include <versions/version_ini.cpp>
135 #endif // __BUILD_STATIC_APPLICATION__
136 
The application_shell is a base object for console programs.
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
#define SETUP_CONSOLE_LOGGER
< a macro that retasks the program-wide logger as a console_logger.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition: enhance_cpp.h:45
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Definition: enhance_cpp.h:57
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Definition: hoople_main.h:61
Implements an application lock to ensure only one is running at once.
char ** _global_argv
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
A platform independent way to obtain the timestamp of a file.
Definition: byte_filer.cpp:37
A logger that sends to the console screen using the standard output device.
A dynamic container class that holds any kind of object via pointers.
Definition: amorph.h:55
Aids in achievement of platform independence.