From: Chris Koeritz Date: Sat, 7 Apr 2012 18:56:11 +0000 (-0400) Subject: updated filename with hopefully close to right cygwin and msys path munging, couldn... X-Git-Tag: 2.140.90~1438 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=7694650f42a2ceb801896662dbd531097fc11758;p=feisty_meow.git updated filename with hopefully close to right cygwin and msys path munging, couldn't test quite completely on linux due to default slashes, so windows vm testing is next. also cleaned up some logging in clam, and made it consider a failure of RUN_TARGETS as build failure, plus now test projects for c++ will clean themselves after success, such that they will always run even if they had run successfully previously. otherwise we were seeing changed libraries with bugs not get caught by their tests, since the tests had built their own binaries successfully and then not bothered with anything else (despite having made the run_targets target into a phony target. some frustrating incorrectness in there somewhere.). --- diff --git a/nucleus/library/filesystem/filename.cpp b/nucleus/library/filesystem/filename.cpp index 6c87f99d..1ab0c0d4 100644 --- a/nucleus/library/filesystem/filename.cpp +++ b/nucleus/library/filesystem/filename.cpp @@ -189,28 +189,32 @@ void filename::canonicalize() + astring(DEFAULT_SEPARATOR, 1)); // must be at least as long as the string we're looking for, plus a drive letter afterwards. if ( (length() > CYGDRIVE_PATH.length() + 1) && begins(CYGDRIVE_PATH) ) { - zap(0, CYGDRIVE_PATH.length() + 1); // whack the cygdrive portion plus two slashes. + zap(0, CYGDRIVE_PATH.length() - 1); // whack the cygdrive portion plus two slashes. insert(1, ":"); // add a colon after the imputed drive letter. +LOG(astring("turned cygdrive string into: ") + *this); } // now we convert msys... - if ( (length() >= 2) && (get(0) == DEFAULT_SEPARATOR) && textual::parser_bits::is_alpha(get(1)) ) { + if ( (length() >= 2) && (get(0) == DEFAULT_SEPARATOR) + && textual::parser_bits::is_alpha(get(1)) ) { // we seem reasonably sure now that this is a windows path hiding in msys format, but // the next character needs to be a slash (if there is a next character) for it to be // the windows drive form. otherwise it could be /tmp, which would obviously not be // intended as a windows path. - if ( (length() < 3) || (get(2) == DEFAULT_SEPARATOR) ) { + if ( (length() == 2) || (get(2) == DEFAULT_SEPARATOR) ) { // cool, this should be interpretable as an msys path, except for those wacky types - // that use top-level single character directory names. we cannot help that, because - // we *know* msys is a choice used in other code a lot. -//hmmm: future revision: see if the file or directory '/x' actually exists on current drive? yuck. + // of folks that might use a top-level single character directory name. we cannot + // help them, because we have made a design decision to support msys-style paths. + // note that this would only affect someone if they were referring to their directory on + // the current windows partition (c:, d:, etc.) without providing the drive letter, + // if they had that single character directory name (e.g., c:\x, d:\q, etc.) and even + // then only on the near defunct windows platform. zap(0, 0); // take off initial slash. insert(1, ":"); // add the obligatory colon. +LOG(astring("turned msys string into: ") + *this); } } #endif -LOG(astring("ha ha turned string into: ") + *this); - // we don't crop the last separator if the name's too small. for msdos // names, that would be chopping a slash off the c:\ style name. if (length() > 3) { diff --git a/nucleus/library/tests_filesystem/test_filename.cpp b/nucleus/library/tests_filesystem/test_filename.cpp index 8f08de45..20c64292 100644 --- a/nucleus/library/tests_filesystem/test_filename.cpp +++ b/nucleus/library/tests_filesystem/test_filename.cpp @@ -218,6 +218,48 @@ int test_filename::execute() ASSERT_TRUE(test2.unpack(packed), GROUP + "unpack 1 failed"); ASSERT_EQUAL(test2, test1, GROUP + "packed contents differ, 1 failed"); } +#ifdef __WIN32__ + { + // eighth test group is only for windows side. +//hmmm: might be nice to get the build machine launching this on a windows vm. + astring GROUP = "eighth: cygwin and msys paths"; + filename test1("/cygdrive/q/marbles"); + ASSERT_EQUAL(test1, astring("q:\\marbles"), GROUP + "test 1 failed"); + filename test2("/cygdrive/r"); + ASSERT_EQUAL(test2, astring("r:\\"), GROUP + "test 2 failed"); + filename test3("/cygdrive/r/"); + ASSERT_EQUAL(test3, astring("r:\\"), GROUP + "test 3 failed"); + filename test4("/cygdrive//"); + ASSERT_EQUAL(test4, astring("\\cygdrive"), GROUP + "test 4 failed"); + filename test5("/cygdrive/"); + ASSERT_EQUAL(test5, astring("\\cygdrive"), GROUP + "test 5 failed"); + filename test6("/cygdrive"); + ASSERT_EQUAL(test6, astring("\\cygdrive"), GROUP + "test 6 failed"); + filename test7("/klaunspendle"); + ASSERT_EQUAL(test7, astring("\\klaunspendle"), GROUP + "test 7 failed"); + filename test8("z:/klaunspendle"); + ASSERT_EQUAL(test8, astring("z:\\klaunspendle"), GROUP + "test 8 failed"); + + filename test10("/q/borkage"); + ASSERT_EQUAL(test10, astring("q:\\borkage"), GROUP + "test 10 failed"); + filename test11("/q/r"); + ASSERT_EQUAL(test11, astring("q:\\r"), GROUP + "test 11 failed"); + filename test12("/q/r/"); + ASSERT_EQUAL(test12, astring("q:\\r"), GROUP + "test 12 failed"); + filename test13("/q/r/x"); + ASSERT_EQUAL(test13, astring("q:\\r\\x"), GROUP + "test 13 failed"); + filename test14("/r/"); + ASSERT_EQUAL(test14, astring("r:\\"), GROUP + "test 14 failed"); + filename test15("/r"); + ASSERT_EQUAL(test15, astring("r:"), GROUP + "test 15 failed"); + filename test16("/"); + ASSERT_EQUAL(test16, astring("\\"), GROUP + "test 16 failed"); + filename test17("r/"); + ASSERT_EQUAL(test17, astring("r\\"), GROUP + "test 17 failed"); + filename test18("/kr/soop"); + ASSERT_EQUAL(test18, astring("\\kr\\soop"), GROUP + "test 18 failed"); + } +#endif return final_report(); } diff --git a/scripts/clam/badness_catcher.sh b/scripts/clam/badness_catcher.sh index 9872891b..e9b19f29 100755 --- a/scripts/clam/badness_catcher.sh +++ b/scripts/clam/badness_catcher.sh @@ -1,13 +1,22 @@ #!/bin/bash # badness_catcher: runs the command line passed in and catches error conditions. + #echo args are: $* -eval $* -ERR=$? # get exit status. +eval "$@" + +# get exit status. +ERR=$? + if [ $ERR -eq 0 ]; then exit; fi # exit if no error. -# print a complaint if there was an error. + +# print a complaint since there was an error. echo -echo "Error in project \"$PROJECT\"!" -echo " command=\"$*\"." +echo "=======================" echo +echo "Error in project: \"$PROJECT\"" +echo " command was: $*" +echo +echo "=======================" source $CLAM_DIR/exit_make.sh exit $ERR + diff --git a/scripts/clam/cpp/rules.def b/scripts/clam/cpp/rules.def index 02d3010c..ffb66602 100644 --- a/scripts/clam/cpp/rules.def +++ b/scripts/clam/cpp/rules.def @@ -15,10 +15,13 @@ # This section manipulates variable values to prepare them for their use # in the standard CLAM support. -# Modify the output directory for executable files if we're building a -# test project. +# special actions for projects that are tests. ifneq "$(findstring test, $(TYPE))" "" -### EXECUTABLE_DIR = $(TARGETS_DIR)/tests/$(PROJECT) + # add the clean task at the end, so that we will always rebuild the tests + # and run them again. +#hmmm: this is a kludge to make sure we always run the tests. there has got +# to be a better way. + LAST_TARGETS += clean endif # see if they have got the clean flag set. if so, we will not build anything. @@ -379,7 +382,7 @@ endif %.bad: @echo There is a problem with the makefile in the SOURCE variable. - @echo The offending item is $@. + @echo The offending item is: $@ $(HIDESH)$(CLAM_DIR)/exit_make.sh ## faked debug object. @@ -392,7 +395,7 @@ endif # recreate dependencies for static applications. %.gendeps: %.cpp @echo "Generating Static Deps: $*.cpp" - $(HIDESH)$(CLAM_DIR)/cpp/buildor_gen_deps.sh "$*.cpp" + $(CATCHER)$(CLAM_DIR)/cpp/buildor_gen_deps.sh "$*.cpp" ############################################################################ @@ -403,7 +406,7 @@ endif $(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.cpp ifeq "$(NO_COMPILE)" "" ifneq "$(COMPILER)" "VISUAL_CPP" - @echo Compiling [$(shell basename $@)]. + @echo Compiling [$(shell basename $@)] $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi' $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@ else @@ -420,7 +423,7 @@ endif $(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.c ifeq "$(NO_COMPILE)" "" ifneq "$(COMPILER)" "VISUAL_CPP" - @echo Compiling [$@]. + @echo Compiling [$@] $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi' $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@ else @@ -437,14 +440,14 @@ endif ifeq "$(OP_SYSTEM)" "WIN32" $(OBJECT_DIR)/%.res: %.rc $(PARAMETER_FILE) ifeq "$(NO_COMPILE)" "" - @echo Resource [$@]. + @echo Resource [$@] $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi' $(CATCHER)$(RC) -r $(DEFINITIONS:%=-D%) $(HEADER_SEARCH_PATH:%=-i%) -fo $@ $< endif $(OBJECT_DIR)/%.resources: %.resx $(PARAMETER_FILE) ifeq "$(NO_COMPILE)" "" - @echo Resource [$@]. + @echo Resource [$@] $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi' $(VCS_ROOT)/../SDK/v1.1/bin/resgen $< $@ endif @@ -452,7 +455,7 @@ else #non-win32 # this platform probably does not use rc files. $(OBJECT_DIR)/%.res: %.rc ifeq "$(NO_COMPILE)" "" - @echo Bogus resource [$@]. + @echo Bogus resource [$@] @echo >$@ endif endif #win32 @@ -466,7 +469,7 @@ endif ifeq "$(NO_COMPILE)" "" $(STATIC_LIBRARY_DIR)/%.library: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE) - $(HIDER)echo Static [$@]. + $(HIDER)echo Static [$@] @echo $@ >$(DIRTY_FILE) ifeq "$(COMPILER)" "VISUAL_CPP" $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi' @@ -499,7 +502,7 @@ ifeq "$(NO_COMPILE)" "" $(DYNAMIC_LIBRARY_DIR)/%.dll: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(PARAMETER_FILE) #hmmm: use the res objects variable to rebuild res files as needed. ###$(RES_OBJECTS) - $(HIDER)echo Dynamic [$@]. + $(HIDER)echo Dynamic [$@] @echo $@ >$(DIRTY_FILE) ifeq "$(COMPILER)" "VISUAL_CPP" $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi' @@ -524,7 +527,7 @@ endif ifeq "$(NO_COMPILE)" "" $(DYNAMIC_LIBRARY_DIR)/%.so: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE) ifeq "$(COMPILER:%_LINUX=LINUX)" "LINUX" - $(HIDER)echo Shared [$@]. + $(HIDER)echo Shared [$@] @echo $@ >$(DIRTY_FILE) $(CATCHER)$(LINK_TOOL) $(LINKER_OUTPUT_FLAG)$@ $(LOAD_FLAG_PREFIX) -shared -Wl,-soname,$*.so $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(HIDER)rm -f $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING) @@ -543,7 +546,7 @@ $(EXECUTABLE_DIR)/%.exe: ifeq "$(NO_COMPILE)" "" $(EXECUTABLE_DIR)/%.exe: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(PARAMETER_FILE) - $(HIDER)echo Application [$@]. + $(HIDER)echo Application [$@] @echo $@ >$(DIRTY_FILE) ifeq "$(COMPILER)" "VISUAL_CPP" $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi' @@ -569,7 +572,7 @@ $(EXECUTABLE_DIR)/%: ifeq "$(NO_COMPILE)" "" $(EXECUTABLE_DIR)/%: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE) - $(HIDER)echo Application [$@]. + $(HIDER)echo Application [$@] @echo $@ >$(DIRTY_FILE) $(CATCHER)$(LINK_TOOL) $(EXE_FLAGS) $(LOAD_FLAG_PREFIX) $< $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@ #hmmm: experimental item below. @@ -587,13 +590,13 @@ endif ifeq "$(NO_COMPILE)" "" $(EXECUTABLE_DIR)/%.elf: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE) - $(HIDER)echo Application [$@]. + $(HIDER)echo Application [$@] @echo $@ >$(DIRTY_FILE) $(CATCHER)$(LINK_TOOL) $(MAP) $(LOAD_FLAG_PREFIX) $< $(LINKER_COMMAND_FILE) $(STARTUP_OBJECT_FILE) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@ #$(^:force_rebuild=) - @echo Hex [$(EXECUTABLE_DIR)/$*.out]. + @echo Hex [$(EXECUTABLE_DIR)/$*.out] $(CATCHER)$(DDUMP_TOOL) $(DDUMP_OPTIONS) $@ -o$(EXECUTABLE_DIR)/$*.out - @echo Binary [$(EXECUTABLE_DIR)/$*.bin]. + @echo Binary [$(EXECUTABLE_DIR)/$*.bin] $(CATCHER)$(DDUMP_TOOL) $(DDUMP_BIN_OPTIONS) $@ -o$(EXECUTABLE_DIR)/$*.bin endif #no_compile @@ -687,7 +690,7 @@ else $(DEPS_FILE): $(VERSION_RC_ROOT)_version.rc endif endif - @echo Dependencies [$(shell basename $@)]. + @echo Dependencies [$(shell basename $@)] -$(HIDESH)$(CLAM_DIR)/cpp/preconditions.sh @touch $@ # @echo dep adds: $(DEPENDENCY_ADDITIONS) diff --git a/scripts/clam/cpp/variables.def b/scripts/clam/cpp/variables.def index 41030be7..72a16136 100644 --- a/scripts/clam/cpp/variables.def +++ b/scripts/clam/cpp/variables.def @@ -226,7 +226,6 @@ export OBJECT_DIR = $(OUTPUT_PATH) export EXECUTABLE_DIR = $(TARGETS_DIR) export DYNAMIC_LIBRARY_DIR = $(TARGETS_DIR) export STATIC_LIBRARY_DIR = $(TARGETS_DIR) -#export TESTS_DIR = $(TARGETS_DIR)/tests # "HEADER_SEARCH_PATH" is where the class interface files are to be found. #HEADER_SEARCH_PATH = diff --git a/scripts/clam/rules.def b/scripts/clam/rules.def index 2b506ab8..1a526236 100644 --- a/scripts/clam/rules.def +++ b/scripts/clam/rules.def @@ -29,7 +29,7 @@ endif # This rule halts make for some supposedly devastating reason. More # information should be printed out by the cause of the halt. %.halt: - @echo CLAM execution halted, the cause being $@... + @echo CLAM execution halted, the cause being: $@ $(HIDESH)$(CLAM_DIR)/exit_make.sh # Provides a time-stamp in the make log. @@ -50,7 +50,9 @@ if [ -d $* ]; then \ else \ echo Skipping missing directory [$*]; \ fi' -#used to include message for first case: echo "Entering directory [$*]"; + +# always run the targets. if they don't exist, that's an error. +.PHONY: run_targets # "all" is the first target to execute in any makefile. we capture it and # use it to produce the requested actions. @@ -63,7 +65,7 @@ if [ ! -d "$(CLAM_TMP)" ]; then \ mkdir "$(CLAM_TMP)"; \ fi' ifeq "$(QUIET)" "" - $(HIDER)echo Project $(PROJECT) [$(shell basename $(shell dirname $(shell pwd) ) )/$(shell basename $(shell pwd) )] v. $(major).$(minor).$(revision).$(build). + $(HIDER)echo Project $(PROJECT) [$(shell basename $(shell dirname $(shell pwd) ) )/$(shell basename $(shell pwd) )] v. $(major).$(minor).$(revision).$(build) endif $(HIDER)rm -f $(FLAG_FILES) @@ -100,11 +102,11 @@ if [ ! -z "$(RUN_TARGETS)" ]; then \ done; \ if [ $$total_exitval -ne 0 ]; then \ echo "FAILURE: errors occurred in RUN_TARGETS."; \ + echo yep >"$(FAILURE_FILE)"; \ + exit 1; \ fi; \ fi; \ fi' -#hmmm: run targets needs to work on a hierarchy. -#hmmm: old idea? exit $$total_exitval; \ # "make_subdirs" travels down each subdirectory and builds using make. make_subdirs: @@ -121,7 +123,6 @@ for i in *; do \ fi \ done; \ exit 0' -##echo Entering $$i now...; # "clean" is a default target that removes object files, libs, executable # files and such that were created by the project. it invokes the makefile @@ -131,7 +132,7 @@ clean: $(HIDER)$(MAKE) --silent CLEAN=t ready_to_clean ready_to_clean: $(OTHER_CLEANS) clean_subdirs - @echo Whacking [$(CLEANUPS)]. + @echo Whacking [$(CLEANUPS)] $(HIDESH) -c '\ echo the other cleans were: $(OTHER_CLEANS); \ echo the clean list is: $(CLEANUPS); \