From: Chris Koeritz Date: Sun, 29 May 2022 01:45:34 +0000 (-0400) Subject: updates lurching towards functionality X-Git-Tag: 2.140.136^2~58 X-Git-Url: https://feistymeow.org/gitweb/?p=feisty_meow.git;a=commitdiff_plain;h=0f0df8de389914b66cf70759575eef0b8261c797 updates lurching towards functionality first attempt at virtual unix root is not going to work out due to interdependencies introduced between configuration and filesystem or vice-versa. i warned about them in a comment, and they unfortunately became true. we need to pull the virtual unix root up to a new level, hoist it into a config file that we can generate at build time and not depend on a lot of file ops. --- diff --git a/nucleus/library/configuration/application_configuration.cpp b/nucleus/library/configuration/application_configuration.cpp index 51df2a82..c8cc179f 100644 --- a/nucleus/library/configuration/application_configuration.cpp +++ b/nucleus/library/configuration/application_configuration.cpp @@ -298,6 +298,10 @@ const astring &application_configuration::DEFAULT_VIRTUAL_UNIX_ROOT() ////////////// +// static storage for virtual unix root, if used. +SAFE_STATIC(astring, static_root_holder, ) + +// we don't expect it to change during runtime, right? that would be fubar. astring application_configuration::get_virtual_unix_root() { #ifdef __UNIX__ @@ -305,6 +309,11 @@ astring application_configuration::get_virtual_unix_root() return "/"; #endif #ifdef __WIN32__ + // see if we already cached the root. it shouldn't change during runtime. + if (static_root_holder().length()) { + return static_root_holder(); + } + /* read the path out of the config file, which should have been set during the build process if this is really windows. @@ -312,7 +321,11 @@ astring application_configuration::get_virtual_unix_root() astring virtual_root = read_item(WINDOZE_VIRTUAL_ROOT_NAME()); if (!virtual_root) { // if it has no length, we didn't get our setting! we'll limp along with a guess. - return DEFAULT_VIRTUAL_UNIX_ROOT; + // also don't cache the failure value. maybe it will wake up later! + return DEFAULT_VIRTUAL_UNIX_ROOT(); + } else { + static_root_holder() = virtual_root; + return static_root_holder(); } #endif diff --git a/nucleus/library/configuration/ini_configurator.cpp b/nucleus/library/configuration/ini_configurator.cpp index c5b2edf6..7ca4ba1b 100644 --- a/nucleus/library/configuration/ini_configurator.cpp +++ b/nucleus/library/configuration/ini_configurator.cpp @@ -30,6 +30,8 @@ #include #include +#include + #undef LOG #define LOG(to_print) printf("%s::%s: %s\n", static_class_name(), func, astring(to_print).s()) @@ -57,7 +59,9 @@ ini_configurator::ini_configurator(const astring &ini_filename, _where(where), _add_spaces(false) { + FUNCDEF("constructor"); name(ini_filename); // set name properly. +LOG(astring("calculated ini name as: '") + _ini_name->raw() + "'"); } ini_configurator::~ini_configurator() diff --git a/nucleus/library/filesystem/filename.cpp b/nucleus/library/filesystem/filename.cpp index ba72084e..d12d9e7e 100644 --- a/nucleus/library/filesystem/filename.cpp +++ b/nucleus/library/filesystem/filename.cpp @@ -19,6 +19,17 @@ #include #include +#include +/* + hmmm: note that we are relying on forward declared code here. + the canonical ordering for feisty's nucleus has the filesystem code come before + the configuration code, because the configuratin library uses filesystem features. + not sure i want to resolve this bizarritude at this time, but it points to the + need for a virtual interface at lower level than either filesystem or configuration + libraries, so we can emplace the need for the virtual unix root as a low-level + dependency to be implemented later. + */ + #include #include @@ -42,13 +53,13 @@ class status_info : public stat namespace filesystem { -#if defined(__WIN32__) || defined(__VMS__) - const char DEFAULT_SEPARATOR = '\\'; -#elif defined(__UNIX__) +//#if defined(__WIN32__) || defined(__VMS__) +// const char DEFAULT_SEPARATOR = '\\'; +//#elif defined(__UNIX__) const char DEFAULT_SEPARATOR = '/'; -#else - #error "We have no idea what the default path separator is." -#endif +//#else +// #error "We have no idea what the default path separator is." +//#endif const char *NO_PARENT_DEFAULT = "."; // used when no directory name can be popped off. @@ -207,6 +218,7 @@ void filename::canonicalize() } else { //LOG(astring("path didn't match so left as: ") + *this); } + // now we convert msys... if ( (length() >= 2) && (get(0) == DEFAULT_SEPARATOR) && textual::parser_bits::is_alpha(get(1)) ) { @@ -228,19 +240,39 @@ void filename::canonicalize() } } - // if no specialized path specifications were seen, and we have a unix style path - // here, then there will be trouble when we pass that to windows. -//if first character is a slash, and second char is alphanumeric, then we check... -//can we find a cygwin root dir stored in our config stuff? -// maybe in the build version file? ugh, yuck. -// what about in generated files, created at build time? --> yes, nice option. -// -//hmmm: we need the capability to re-create the config file that tells us -// where cyg root is, but how can we, aside from guessing at where to find -// cygwin (c:/cygwin c:/cygwin64 etc). -// -//hmmm: + // if we still have a unix style path here on windows, then there will be + // trouble when we pass that to the OS. we are not using any cygwin or + // other virtualization libraries directly, so we can't rely on those to + // fix the path. but if we built under something like cygwin, we should + // have stored the real dos-style location of the virtual unix root. we + // will use that to replace the root '/' and this should fix most of that + // style of path. + bool inject_root = false; // assume we don't need to do anything. + +LOG(astring("before root injection: ") + raw()); + + // condition here just checks if the path is only the root. + if ( (length() == 1) && separator(get(0)) ) { inject_root = true; } + +if (inject_root) LOG("decided to inject root since path is '/'."); + + // condition is looking for first character being a slash, and second char as alphanumeric or dash or underscore. + // we will currently fail detecting freaky paths that don't start off with alphanumeric or one of that small set of special chars. + if ( (length() >= 2) + && separator(get(0)) + && ( textual::parser_bits::is_alphanumeric(get(1)) || ('-' == get(1)) || ('_' == get(1)) ) ) { + inject_root = true; +if (inject_root) LOG(astring("decided to inject root since path is compatible: ") + *this); + } + +LOG(astring("after second phase root injection: ") + *this); + if (inject_root) { + // inject the actual path to the unix root in front, if we know it. + // if we don't know it, then a default path that's unlikely to work is idiotically plugged in. + insert(0, configuration::application_configuration::get_virtual_unix_root()); +LOG(astring("turned cygdrive path string into: ") + *this); + } #endif // we don't crop the last separator if the name's too small. for msdos diff --git a/nucleus/makefile b/nucleus/makefile index 65b0bbd0..9a2fd10b 100644 --- a/nucleus/makefile +++ b/nucleus/makefile @@ -41,12 +41,12 @@ if [ $$? -ne 0 ]; then \ echo build failure while copying paths initialization file.; \ exit 1; \ fi; \ -bash $(BUILD_SCRIPTS_PATH)/wrapdoze.sh $(CLAM_BINARIES)/value_tagger$(EXE_END) $(PRODUCTION_STORE)/codescan.ini; \ +$(CLAM_BINARIES)/value_tagger$(EXE_END) $(PRODUCTION_STORE)/codescan.ini; \ if [ $$? -ne 0 ]; then \ echo build failure during value tagging.; \ exit 1; \ fi; \ -bash $(BUILD_SCRIPTS_PATH)/wrapdoze.sh $(CLAM_BINARIES)/write_build_config$(EXE_END); \ +$(CLAM_BINARIES)/write_build_config$(EXE_END); \ if [ $$? -ne 0 ]; then \ echo build failure while writing config.; \ exit 1; \ diff --git a/scripts/generator/produce_feisty_meow.sh b/scripts/generator/produce_feisty_meow.sh index efdb78ac..7466031b 100644 --- a/scripts/generator/produce_feisty_meow.sh +++ b/scripts/generator/produce_feisty_meow.sh @@ -69,7 +69,7 @@ function prepare_binaries_dir() whichable cygpath if [ $? -eq 0 ]; then # found cygpath, so run it now to get the dossy path of the root ('/' folder). - found_root=$(cygpath -w -m /) + found_root="$(cygpath -w -m /)" if [ $? -ne 0 ]; then echo "Failure to find virtual Unix root folder with cygpath." exit 1322 @@ -79,7 +79,7 @@ echo "found root as '$found_root'" found_root=$(echo $found_root | tr '\\' '/') echo "processed root is now: '$found_root'" # edit the entry in place to correct the default path. - sed -i -e "s/VirtualUnixRoot=.*/VirtualUnixRoot=$found_root/" "$CLAM_BINARIES/paths.ini" + sed -i -e "s%VirtualUnixRoot=.*%VirtualUnixRoot=$found_root%" "$CLAM_BINARIES/paths.ini" echo "paths file now has:" cat "$CLAM_BINARIES/paths.ini" fi @@ -198,14 +198,6 @@ if [ -z "$SAVE_BINARIES" ]; then done fi -# make the clam shell scripts executable. -#hmmm: why? this should no longer be needed. -# and even if it's needed, the perms should be stored in the repo. -#chmod 755 "$CLAM_SCRIPTS"/*.sh -#chmod 755 "$CLAM_SCRIPTS"/cpp/*.sh -#chmod 755 "$CLAM_SCRIPTS"/csharp/*.sh -#chmod 755 "$FEISTY_MEOW_SCRIPTS/generator/wrapdoze.sh" - # rebuild the dependency tool. needed by everything, pretty much, but # since it's from the xfree project, it doesn't need any of our libraries. if [ ! -f "$CLAM_BINARIES/makedep$EXE_ENDING" ]; then diff --git a/scripts/generator/wrapdoze.sh b/scripts/generator/wrapdoze.sh deleted file mode 100644 index b368a6cf..00000000 --- a/scripts/generator/wrapdoze.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash - -eval "$@" - -exit $? - - -#old below, we hope. - - -source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" - -#hmmm: make this support multiple vars as parameters. -# replaces a specific environment variable with a dos approved equivalent. -function dossify_environment_variable() -{ - local var="$1"; shift - -#cygpath doesn't handle multiple path variables properly and otherwise operates only on one path element. -## new_value="$(cygpath -p -d ${!var})" -## eval "export $var=\"$new_value\"" -##echo "hey now the var is '${!var}'" - - old_value="${!var}" -#echo "var is '$var' and old value is '$old_value'" - if [[ ! "$old_value" =~ \/cygdrive\/ ]]; then -#echo didnt have a cygdrive in it: $old_value - return 0 -#hmmm: want this to continue in multi parm version. - fi - - # replace single back-slashes with double ones. - local new_value="$(unix_to_dos_path "${old_value}")" - - # remove any quote characters in the value. - new_value="${new_value//\"/}" - - eval "export $var=\"$new_value\"" - echo "new value established: $var='${!var}'" -} - -# for a windows build, this will replace any forward slashes -# and other cygwin notation with the appropriate dos style paths. -function dossify_and_run_commands() -{ - if [ "$OS" != "Windows_NT" ]; then - # for non windows, just run the commands straight up. - eval "${@}" - return $? - fi - - # force all slashes to be dossy. -# export SERIOUS_SLASH_TREATMENT=true - - dossify_environment_variable INCLUDE - - declare -a darc_commands=() - - for i in "$@"; do - if [[ "$i" =~ ^-[a-zA-z][/\"].* ]]; then - flag="${i:0:2}" - filename="$(unix_to_dos_path ${i:2})" -#echo "first two chars are $flag" -#echo "last after that are $filename" - recombined="$flag$filename" -#echo combined flag and file is $recombined - darc_commands+=("$recombined") - elif [[ "$i" =~ ^-libpath:.* ]]; then - flag="-libpath:" - filename="$(unix_to_dos_path ${i:9})" -#echo "libflag flag is $flag" -#echo "name after that is $filename" - recombined="$flag$filename" -#echo combined flag and file is $recombined - darc_commands+=("$recombined") - else - darc_commands+=($(unix_to_dos_path $i)) - fi - done - - declare -a real_commands=() - for i in "${darc_commands[@]}"; do - real_commands+=($(echo $i | sed -e 's/\//\\/g')) - done - - if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then - echo commands are now: - for i in "${real_commands[@]}"; do - echo -n "$i " - done - echo - fi - -# this nonsense is only necessary because cygwin is screwing up our carefully constructed -# command line. it can't seem to leave the dos style paths alone in some cases, and insists -# on changing their form to use forward slashes, which breaks the windows compiler. -# this is NOT what cygwin is supposed to be doing, according to their documentation that -# claims all styles of paths are supported. and of course this worked fine in msys. - - # now actually run the chewed command. - -# old approach, not working since cygwin is hosing us on some paths. -#cmd /c "${real_commands[@]}" - -#new approach that creates a cmd file. - cmdfile="$(mktemp $CLAM_TMP/build_cmds.XXXXXX)" - echo "${real_commands[@]}" >"$cmdfile" -#echo "**** cmd file is $cmdfile" - cmd /c $(cat "$cmdfile") - retval=$? - # leave the file for inspection if there was an error. - if [ $retval -eq 0 ]; then - \rm "$cmdfile" - fi - return $retval -} - -dossify_and_run_commands "$@" -