33 using namespace basis;
59 #define LOG(to_print) CLASS_EMERGENCY_LOG(program_wide_logger::get(), to_print)
77 static bool _initted =
false;
80 _hidden +=
"OPTIMIZE";
81 _hidden +=
"STRICT_WARNINGS";
87 #define ADD_COMMENT_RETURN(sym, val) { \
88 *_end_matter += astring(" ") + sym + " = " + val + "\n"; \
89 return common::OKAY; \
101 accumulator +=
" #ifndef ";
102 accumulator += symbol;
104 accumulator +=
" #define ";
105 accumulator += symbol;
106 accumulator +=
" \"";
107 accumulator += value;
108 accumulator +=
"\"\n";
109 accumulator +=
" #endif\n";
121 { _ver->
set_component(version::REVISION, value);
return true; }
152 if (symbol_in[0] ==
'[')
157 astring *the_accumulator = &cfg_accumulator;
159 the_accumulator = &ver_accumulator;
169 FUNCDEF(
"output_definition_macro");
172 t.
parse(embedded_value);
187 bool write_header =
true;
189 if (check_header.
good()) {
192 if (
read < 1)
LOG(
"why is existing header contentless?");
194 astring found(astring::UNTERMINATED, (
char *)file_contents.
observe(),
198 if (found == new_contents) {
199 write_header =
false;
209 if (!build_header.
good()) {
211 "build header file in ") + build_header.
name());
214 build_header.
write(new_contents);
216 + build_header.
name());
232 astring repodir = environment::get(
"FEISTY_MEOW_APEX");
236 if (!repodir) repodir =
"l:";
239 repodir = environment::get(
"HOME") +
"/hoople";
244 astring parmfile = environment::get(
"BUILD_PARAMETER_FILE");
245 if (parmfile.
t()) fname = parmfile;
246 else fname = repodir +
"/build.ini";
251 astring versions_directory = environment::get(
"FEISTY_MEOW_GENERATED_STORE");
253 versions_directory +=
"/versions";
254 if (!
filename(versions_directory).good()) {
256 astring(
"failed to locate the library folder storing the generated files."));
262 astring cfg_header_filename = versions_directory +
"/__build_configuration.h";
263 astring ver_header_filename = versions_directory +
"/__build_version.h";
269 "build configuration file for reading at ") + ini.
name());
279 cfg_accumulator +=
"\
280 #ifndef BUILD_SYSTEM_CONFIGURATION\n\
281 #define BUILD_SYSTEM_CONFIGURATION\n\n\
282 // This file provides all of the code flags which were used when this build\n\
283 // was generated. Some of the items in the build configuration have been\n\
284 // stripped out because they are not used.\n\n";
285 ver_accumulator +=
"\
286 #ifndef BUILD_VERSION_CONFIGURATION\n\
287 #define BUILD_VERSION_CONFIGURATION\n\n\
288 // This file provides the version macros for this particular build.\n\n";
295 if (!chars)
continue;
303 value = t.
table()[0];
307 while ( (symbol[symbol.
end()] ==
'+') || (symbol[symbol.
end()] ==
':') ) {
312 if (symbol[0] ==
'#')
continue;
314 if (!symbol)
continue;
334 ver_accumulator +=
"\n";
335 ver_accumulator +=
" // calculated macros are dropped in here.\n\n";
341 ver_accumulator +=
" #define __build_SYSTEM_VERSION \"";
343 ver_accumulator +=
"\"\n\n";
346 ver_accumulator +=
" #define __build_FILE_VERSION_COMMAS ";
348 ver_accumulator +=
"\n";
350 ver_accumulator +=
" #define __build_FILE_VERSION \"";
352 ver_accumulator +=
"\"\n";
358 ver_accumulator +=
" #define __build_PRODUCT_VERSION_COMMAS ";
360 ver_accumulator +=
"\n";
362 ver_accumulator +=
" #define __build_PRODUCT_VERSION \"";
363 ver_accumulator += _ver->
flex_text_form(version::DOTS, version::MINOR);
364 ver_accumulator +=
"\"\n";
367 cfg_accumulator +=
"\n";
368 cfg_accumulator +=
"/*\n";
369 cfg_accumulator +=
"These settings were not used:\n";
370 cfg_accumulator += *_end_matter;
371 cfg_accumulator +=
"*/\n";
372 cfg_accumulator +=
"\n";
373 cfg_accumulator +=
"#endif /* outer guard */\n\n";
376 ver_accumulator +=
"\n";
377 ver_accumulator +=
"#endif /* outer guard */\n\n";
380 LOG(
astring(
"failed writing output file ") + cfg_header_filename);
383 LOG(
astring(
"failed writing output file ") + ver_header_filename);
391 #ifdef __BUILD_STATIC_APPLICATION__
The application_shell is a base object for console programs.
const contents * observe() const
Returns a pointer to the underlying C array of data.
Provides a dynamically resizable ASCII character string.
bool t() const
t() is a shortcut for the string being "true", as in non-empty.
virtual void zap(int start, int end)
Deletes the characters between "start" and "end" inclusively.
void strip_spaces(how_to_strip way=FROM_BOTH_SIDES)
removes excess space characters from string's beginning, end or both.
bool equal_to(const char *that) const
returns true if "that" is equal to this.
int end() const
returns the index of the last (non-null) character in the string.
bool compare(const astring &to_compare, int start_first, int start_second, int count, bool case_sensitive) const
Compares "this" string with "to_compare".
bool contains(const astring &to_find) const
Returns true if "to_find" is contained in this string or false if not.
A very common template for a dynamic array of bytes.
Outcomes describe the state of completion for an operation.
Manages a bank of textual definitions of variables.
const structures::string_table & table() const
provides a constant peek at the string_table holding the values.
int symbols() const
returns the number of entries in the variable_tokenizer.
bool parse(const basis::astring &to_tokenize)
parses the string using our established sentinel characters.
Provides file managment services using the standard I/O support.
int getline(basis::abyte *buffer, int desired_size)
reads a line of text (terminated by a return) into the "buffer".
int write(const basis::abyte *buffer, int buffer_size)
writes "buffer_size" bytes into the file from "buffer".
const basis::astring & name() const
returns the file name that the object is operating on.
int read(basis::abyte *buffer, int buffer_size)
reads "buffer_size" bytes from the file into "buffer".
bool eof()
returns true if the cursor is at (or after) the end of the file.
bool good()
returns true if the file seems to be in the appropriate desired state.
Provides operations commonly needed on file names.
A simple object that wraps a templated set of strings.
const basis::astring & name(int index) const
returns the name held at the "index".
Holds a file's version identifier.
void set_component(int index, const basis::astring &to_set)
sets the component at "index" to "to_set".
basis::astring flex_text_form(version_style style=DOTS, int including=-1) const
returns a textual form of the version number.
const structures::string_set & exclusions()
returns the set of symbols that we will not include in the header.
bool write_output_file(const basis::astring &filename, const basis::astring &contents)
writes "contents" to "filename" if it differs from current contents.
basis::outcome output_macro(const basis::astring &symbol, const basis::astring &value, basis::astring &accumulator)
sends a macro definition for "symbol" with "value" to "accumulator".
basis::outcome output_definition_macro(const basis::astring &embedded_value, basis::astring &accumulator)
parses a 'name=value' pair out of "embedded_value" and writes a macro.
bool check_nesting(const basis::astring &to_check)
if "to_check" is a make conditional, the nesting level is adjusted.
basis::outcome output_decorated_macro(const basis::astring &symbol, const basis::astring &value, basis::astring &cfg_accumulator, basis::astring &ver_accumulator)
produces a new macro by adding a uniquifying string to "symbol".
int execute()
performs the main action of creating our build configuration header.
bool process_version_parts(const basis::astring &symbol, const basis::astring &value)
checks on "symbol" to see if it's a version component. stores if so.
#define SETUP_CONSOLE_LOGGER
< a macro that retasks the program-wide logger as a console_logger.
#define continuable_error(c, f, i)
#define non_continuable_error(c, f, i)
an extra piece of information used, if available, in bounds_halt below.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
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.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
const int KILOBYTE
Number of bytes in a kilobyte.
A platform independent way to obtain the timestamp of a file.
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.
#define static_class_name()
Aids in achievement of platform independence.
const char * EXPORT_STATEMENT
a tag we see on variables to be inherited by subshells
const int MAX_HEADER_FILE
an excessively long allowance for the maximum generated header size.
const char * DEFINITIONS_STATEMENT
the tag we see in the config file for directly compatible macros.
const char * IFNEQ_STATEMENT
const char * ENDIF_STATEMENT
const int MAX_LINE_SIZE
we should never see an ini line longer than this.
#define ADD_COMMENT_RETURN(sym, val)
const char * IFEQ_STATEMENT