From 06f650d00686006c7e7cb55ca180bad5f543cbff Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Tue, 21 Nov 2017 00:15:24 +0000 Subject: [PATCH] super tasty version fixes getting the version headers and rc files and such to live under the generated store folder. --- nucleus/library/versions/version_ini.cpp | 37 ++++++++++++------- nucleus/library/versions/version_ini.h | 12 +++--- nucleus/tools/clam_tools/version_stamper.cpp | 29 ++++++++------- .../tools/clam_tools/vsts_version_fixer.cpp | 7 +++- .../tools/clam_tools/write_build_config.cpp | 23 +++++++----- scripts/clam/cpp/rules.def | 5 ++- scripts/clam/cpp/variables.def | 2 +- scripts/opensim/opensim_utils.sh | 2 +- 8 files changed, 71 insertions(+), 46 deletions(-) diff --git a/nucleus/library/versions/version_ini.cpp b/nucleus/library/versions/version_ini.cpp index 6a5519e1..e9fc8b23 100644 --- a/nucleus/library/versions/version_ini.cpp +++ b/nucleus/library/versions/version_ini.cpp @@ -269,8 +269,9 @@ END\n\ #define REPLACE(tag, replacement) \ new_version_entry.replace_all(tag, replacement); \ -bool version_ini::write_rc(const version_record &to_write) +bool version_ini::write_rc(const astring &header_store, const version_record &to_write) { + FUNCDEF("write_rc"); astring new_version_entry(version_rc_template); // $file_ver -> w, x, y, z for version of the file. @@ -320,7 +321,7 @@ bool version_ini::write_rc(const version_record &to_write) astring root_part = "/"; root_part += _ini->load(VERSION_SECTION, ROOT, ""); - astring rc_filename(astring(_path_name->dirname()) + root_part + astring rc_filename(header_store + "/" + root_part + "_version.rc"); filename(rc_filename).chmod(filename::ALLOW_BOTH, filename::USER_RIGHTS); @@ -374,8 +375,9 @@ const astring version_header_template = "\ ////////////// -bool version_ini::write_code(const version_record &to_write) +bool version_ini::write_code(const astring &header_store, const version_record &to_write) { + FUNCDEF("write_code"); astring root_part = _ini->load(VERSION_SECTION, ROOT, ""); astring root = root_part.upper(); // make upper case for naming sake. astring name = _ini->load(VERSION_SECTION, NAME, ""); @@ -409,7 +411,7 @@ bool version_ini::write_code(const version_record &to_write) // $web_address -> the web site for the company. not actually stored. REPLACE("$web_address", to_write.web_address); - astring header_filename(_path_name->dirname().raw() + "/" + root_part + astring header_filename(header_store + "/" + root_part + astring("_version.h")); filename(header_filename).chmod(filename::ALLOW_BOTH, filename::USER_RIGHTS); @@ -447,12 +449,16 @@ bool replace_version_entry(astring &full_string, const astring &look_for, return to_return; } -bool version_ini::write_assembly(const version_record &to_write, +bool version_ini::write_assembly(const astring &header_store, const version_record &to_write, bool do_logging) { FUNCDEF("write_assembly"); - filename just_dir = _path_name->dirname(); -//LOG(astring("dir is set to: ") + just_dir); + filename just_dir = filename(header_store); + //_path_name->dirname(); + +//hmmm: make condit on debug +LOG(astring("dir is set to: ") + just_dir); + directory dir(just_dir); filename to_patch; //LOG(astring("dir has: ") + dir.files().text_form()); @@ -530,8 +536,9 @@ bool version_ini::write_assembly(const version_record &to_write, } bool version_ini::one_stop_version_stamp(const astring &path, - const astring &source_version, bool do_logging) + const astring &header_store, const astring &source_version, bool do_logging) { + FUNCDEF("one_stop_version_stamp"); astring path_name = path; if (path_name.equal_to(".")) path_name = application_configuration::current_directory(); @@ -569,24 +576,26 @@ bool version_ini::one_stop_version_stamp(const astring &path, version_ini verini(path_name); verini.set_record(source.get_record(), false); -// LOG(a_sprintf("The file \"%s\" contains this version information:", -// path_name.s())); -// LOG(verini.get_record().text_form()); +//put this in debug brackets + LOG(a_sprintf("The file \"%s\" contains this version information:", + path_name.s())); + LOG(verini.get_record().text_form()); +//...debug to here - if (!verini.write_rc(verini.get_record())) { + if (!verini.write_rc(header_store, verini.get_record())) { critical_events::alert_message(a_sprintf("Could not write the RC file in \"%s\".", filename(path_name).basename().raw().s())); return false; } - if (verini.library() && !verini.write_code(verini.get_record())) { + if (verini.library() && !verini.write_code(header_store, verini.get_record())) { critical_events::alert_message(astring("Could not write the C++ header file for " "the directory \"") + filename(path_name).basename() + astring("\".\n")); return false; } - if (!verini.write_assembly(verini.get_record(), do_logging)) { + if (!verini.write_assembly(header_store, verini.get_record(), do_logging)) { critical_events::alert_message(astring("Could not write the Assembly info file for " "the directory \"") + filename(path_name).basename() + astring("\".\n")); diff --git a/nucleus/library/versions/version_ini.h b/nucleus/library/versions/version_ini.h index 6838adee..0fe559d2 100644 --- a/nucleus/library/versions/version_ini.h +++ b/nucleus/library/versions/version_ini.h @@ -80,18 +80,18 @@ public: bool ole_auto_registering(); //!< returns true if this version file specifies ole auto registration. - bool write_rc(const structures::version_record &to_write); + bool write_rc(const basis::astring &header_store, const structures::version_record &to_write); //!< writes out the file 'X_version.rc' for the X library or application. /*!< the contents will include the information specified in "to_write", where X is the library name from that record. */ - bool write_code(const structures::version_record &to_write); + bool write_code(const basis::astring &header_store, const structures::version_record &to_write); //!< writes out the header ('X_version.h') with the version information. /*!< this file is needed for other libraries or application to know this project's version number. the users can make sure that the header info agrees with the actual version seen on the file. */ - bool write_assembly(const structures::version_record &to_write, bool do_logging); + bool write_assembly(const basis::astring &header_store, const structures::version_record &to_write, bool do_logging); //!< fixes any assemblies with the info in "to_write". static bool executable(const basis::astring &path_name); @@ -103,9 +103,11 @@ public: //!< specialized version ignores cache and gets version directly from file. static bool one_stop_version_stamp(const basis::astring &path, - const basis::astring &source_version, bool do_logging); + const basis::astring &header_store, const basis::astring &source_version, + bool do_logging); //!< performs version stamping using the ini file in "path". - /*!< "source_version" supplies the name of the main version file where + /*!< the created version files will be written to the "header_store". + "source_version" supplies the name of the main version file where we retrieve the current version numbers. if that is not specified, then only the version header and RC file are created. if "do_logging" is true, then version info will be sent to the program-wide logger. */ diff --git a/nucleus/tools/clam_tools/version_stamper.cpp b/nucleus/tools/clam_tools/version_stamper.cpp index ea90cd41..3313906d 100644 --- a/nucleus/tools/clam_tools/version_stamper.cpp +++ b/nucleus/tools/clam_tools/version_stamper.cpp @@ -67,24 +67,27 @@ int version_stamper::execute() { FUNCDEF("execute"); SETUP_CONSOLE_LOGGER; // override the file_logger from app_shell. - if (application::_global_argc < 2) { - log(astring("The directory where the 'version.ini' file is located\n" - "must be specified as the first parameter of this program. Another\n" - "version file may optionally be specified as the second parameter of\n" - "the program; the version contained in this file will be used to set\n" - "the version of the file specified in the first parameter.\n" - "Additionally, if the environment variable 'DEBUG' exists, then the\n" - "generated RC file will be marked as a debug build. Otherwise it is\n" - "marked as a release build. Note that the CLAM system automatically\n" - "sets this for you.\n\n"), ALWAYS_PRINT); + if (application::_global_argc < 3) { + log(astring( +"The directory where the 'version.ini' file is located must be specified as the\n" +"first parameter of this program. The second parameter must provide the\n" +"storage location where the version header will be written. Another version\n" +"file may optionally be specified as the third parameter of the program; the\n" +"version contained in this file will be used to set the version of the file\n" +"specified in the first parameter.\n" +"Additionally, if the environment variable 'DEBUG' exists, then the\n" +"generated RC file will be marked as a debug build. Otherwise it is\n" +"marked as a release build. Note that the CLAM system automatically\n" +"sets this for you.\n\n"), ALWAYS_PRINT); return 1; } astring path_name = application::_global_argv[1]; + astring storage_name = application::_global_argv[2]; astring source_version_file; // blank by default. - if (application::_global_argc > 2) - source_version_file = application::_global_argv[2]; - bool ret = version_ini::one_stop_version_stamp(path_name, source_version_file, true); + if (application::_global_argc > 3) + source_version_file = application::_global_argv[3]; + bool ret = version_ini::one_stop_version_stamp(path_name, storage_name, source_version_file, true); if (!ret) return 1; // failure. return 0; // success. } diff --git a/nucleus/tools/clam_tools/vsts_version_fixer.cpp b/nucleus/tools/clam_tools/vsts_version_fixer.cpp index bef8fcba..3beb8779 100644 --- a/nucleus/tools/clam_tools/vsts_version_fixer.cpp +++ b/nucleus/tools/clam_tools/vsts_version_fixer.cpp @@ -219,8 +219,13 @@ bool stamping_spider(const directory ¤t) if (current_file.ends("version.ini") && !current_file.iequals("core_version.ini") ) { //LOG(astring("found ver file: ") + current.path() + "/" + current_file); +// + astring versions_directory = environment::get("FEISTY_MEOW_GENERATED_STORE"); + // we keep our version files one level below the top of the generated store. + versions_directory += "/versions"; + version_ini::one_stop_version_stamp(current.path() + "/" + current_file, - global_build_ini, true); + versions_directory, global_build_ini, true); } } return true; diff --git a/nucleus/tools/clam_tools/write_build_config.cpp b/nucleus/tools/clam_tools/write_build_config.cpp index b8bfd80c..b52259e2 100644 --- a/nucleus/tools/clam_tools/write_build_config.cpp +++ b/nucleus/tools/clam_tools/write_build_config.cpp @@ -206,12 +206,15 @@ if (read < 1) LOG("why is existing header contentless?"); if (write_header) { // we actually want to blast out a new file. byte_filer build_header(filename, "wb"); - if (!build_header.good()) - non_continuable_error(static_class_name(), func, astring("failed to create " + if (!build_header.good()) { + continuable_error(static_class_name(), func, astring("could not create " "build header file in ") + build_header.name()); - build_header.write(new_contents); - LOG(astring(static_class_name()) + ": wrote config to " - + build_header.name()); + return false; + } else { + build_header.write(new_contents); + LOG(astring(static_class_name()) + ": wrote config to " + + build_header.name()); + } } else { // nothing has changed. // LOG(astring(static_class_name()) + ": config already up to date in " @@ -245,8 +248,10 @@ int write_build_config::execute() // find our storage area for the build headers. we know a couple build // configurations by now, but this should really be coming out of a config // file instead. - astring genstore_directory = environment::get("FEISTY_MEOW_GENERATED_STORE"); - if (!filename(genstore_directory).good()) { + astring versions_directory = environment::get("FEISTY_MEOW_GENERATED_STORE"); + // we keep our version files one level below the top of the generated store. + versions_directory += "/versions"; + if (!filename(versions_directory).good()) { non_continuable_error(static_class_name(), func, astring("failed to locate the library folder storing the generated files.")); } @@ -254,8 +259,8 @@ int write_build_config::execute() // these are very specific paths, but they really are where we expect to // see the headers. - astring cfg_header_filename = genstore_directory + "/__build_configuration.h"; - astring ver_header_filename = genstore_directory + "/__build_version.h"; + astring cfg_header_filename = versions_directory + "/__build_configuration.h"; + astring ver_header_filename = versions_directory + "/__build_version.h"; // open the ini file for reading. byte_filer ini(fname, "r"); diff --git a/scripts/clam/cpp/rules.def b/scripts/clam/cpp/rules.def index 208728d9..40a72ba4 100644 --- a/scripts/clam/cpp/rules.def +++ b/scripts/clam/cpp/rules.def @@ -678,7 +678,7 @@ ifeq "$(OMIT_VERSIONS)" "" ifneq "$(VERSION_RC_ROOT)" "" # only redo the version resource if it or version.ini is out of date. %_version.rc: version.ini $(PARAMETER_FILE) - $(CATCHER)$(CLAM_BINARIES)/version_stamper$(EXE_END) . $(PARAMETER_FILE) + $(CATCHER)$(CLAM_BINARIES)/version_stamper$(EXE_END) . $(FEISTY_MEOW_GENERATED_STORE)/versions $(PARAMETER_FILE) endif endif @@ -769,10 +769,11 @@ endif # no-deps. ############################################################################ -# examines the required variables and complains if they're missing. +# examines the required variables and complains if they are missing. check_requirements: $(HIDESH) -c 'if [ -z "$(PROJECT)" ]; then echo the PROJECT variable is not defined!; . $(CLAM_SCRIPTS)/exit_make.sh; fi' $(HIDESH) -c 'if [ -z "$(TYPE)" ]; then echo the TYPE variable is not defined!; . $(CLAM_SCRIPTS)/exit_make.sh; fi' + $(HIDESH) -c 'if [ ! -d $(FEISTY_MEOW_GENERATED_STORE)/versions ]; then mkdir $(FEISTY_MEOW_GENERATED_STORE)/versions; fi' ############################################################################ diff --git a/scripts/clam/cpp/variables.def b/scripts/clam/cpp/variables.def index bcf70032..c9210586 100644 --- a/scripts/clam/cpp/variables.def +++ b/scripts/clam/cpp/variables.def @@ -229,7 +229,7 @@ export STATIC_LIBRARY_DIR = $(TARGETS_STORE) # "HEADER_SEARCH_PATH" is where the class interface files are to be found. # we add the generated store folder for the build version file. -HEADER_SEARCH_PATH = $(FEISTY_MEOW_GENERATED_STORE) +HEADER_SEARCH_PATH = $(FEISTY_MEOW_GENERATED_STORE)/versions # "HOOPLE_HEADERS" are locations where the HOOPLE headers can be found. ifeq "$(HOOPLE_HEADERS)" "" diff --git a/scripts/opensim/opensim_utils.sh b/scripts/opensim/opensim_utils.sh index b889f02a..f10d6b95 100644 --- a/scripts/opensim/opensim_utils.sh +++ b/scripts/opensim/opensim_utils.sh @@ -39,7 +39,7 @@ function launch_screen() #hmmm: version check for if we're using old screen? this -L change was a mistake though for the screen project owners on ubuntu. local boguslog=$HOME/screen_junk_$(date_stringer).log #maybe they unbroke it in 17.10? - screen -L$boguslog -S "$screen_name" -d -m nice -n $NICENESS_LEVEL mono "$app_name" + screen -L $boguslog -S "$screen_name" -d -m nice -n $NICENESS_LEVEL mono "$app_name" echo "$(date_stringer ' '): $screen_name started." # only sleep if we are not at the last process that gets started. -- 2.34.1