diff options
-rw-r--r-- | Modules/BundleUtilities.cmake | 64 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 8 | ||||
-rw-r--r-- | Source/CTest/cmCTestGIT.cxx | 86 | ||||
-rw-r--r-- | Source/CTest/cmCTestGIT.h | 3 | ||||
-rw-r--r-- | Source/kwsys/kwsysDateStamp.cmake | 4 | ||||
-rw-r--r-- | Tests/CTestUpdateGIT.cmake.in | 5 |
6 files changed, 161 insertions, 9 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index d9c41f4..4d3baf8 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -13,6 +13,7 @@ # set_bundle_key_values # get_bundle_keys # copy_resolved_item_into_bundle +# copy_resolved_framework_into_bundle # fixup_bundle_item # fixup_bundle # copy_and_fixup_bundle @@ -433,6 +434,59 @@ function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item) endfunction(copy_resolved_item_into_bundle) +# copy_resolved_framework_into_bundle +# +# Copy a resolved framework into the bundle if necessary. Copy is not necessary +# if the resolved_item is "the same as" the resolved_embedded_item. +# +# By default, BU_COPY_FULL_FRAMEWORK_CONTENTS is not set. If you want full +# frameworks embedded in your bundles, set BU_COPY_FULL_FRAMEWORK_CONTENTS to +# ON before calling fixup_bundle. By default, +# copy_resolved_framework_into_bundle copies the framework dylib itself plus +# any framework Resources. +# +function(copy_resolved_framework_into_bundle resolved_item resolved_embedded_item) + if(WIN32) + # ignore case on Windows + string(TOLOWER "${resolved_item}" resolved_item_compare) + string(TOLOWER "${resolved_embedded_item}" resolved_embedded_item_compare) + else() + set(resolved_item_compare "${resolved_item}") + set(resolved_embedded_item_compare "${resolved_embedded_item}") + endif() + + if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}") + message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...") + else() + if(BU_COPY_FULL_FRAMEWORK_CONTENTS) + # Full Framework (everything): + get_filename_component(resolved_dir "${resolved_item}" PATH) + get_filename_component(resolved_dir "${resolved_dir}/../.." ABSOLUTE) + get_filename_component(resolved_embedded_dir "${resolved_embedded_item}" PATH) + get_filename_component(resolved_embedded_dir "${resolved_embedded_dir}/../.." ABSOLUTE) + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_dir}' '${resolved_embedded_dir}'") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_dir}" "${resolved_embedded_dir}") + else() + # Framework lib itself: + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}") + + # Plus Resources, if they exist: + string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Resources" resolved_resources "${resolved_item}") + string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Resources" resolved_embedded_resources "${resolved_embedded_item}") + if(EXISTS "${resolved_resources}") + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_resources}' '${resolved_embedded_resources}'") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_resources}" "${resolved_embedded_resources}") + endif() + endif() + endif() + + if(UNIX AND NOT APPLE) + file(RPATH_REMOVE FILE "${resolved_embedded_item}") + endif(UNIX AND NOT APPLE) +endfunction(copy_resolved_framework_into_bundle) + + # fixup_bundle_item # # Get the direct/non-system prerequisites of the resolved embedded item. For each @@ -528,8 +582,14 @@ function(fixup_bundle app libs dirs) endif(show_status) if(${${key}_COPYFLAG}) - copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}" - "${${key}_RESOLVED_EMBEDDED_ITEM}") + set(item "${${key}_ITEM}") + if(item MATCHES "[^/]+\\.framework/") + copy_resolved_framework_into_bundle("${${key}_RESOLVED_ITEM}" + "${${key}_RESOLVED_EMBEDDED_ITEM}") + else() + copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}" + "${${key}_RESOLVED_EMBEDDED_ITEM}") + endif() endif(${${key}_COPYFLAG}) endforeach(key) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index b74f207..b4359c8 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -563,8 +563,9 @@ function(_ep_get_build_command name step cmd_var) if(cfg_cmd_id STREQUAL "cmake") # CMake project. Select build command based on generator. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) - if("${cmake_generator}" MATCHES "Make" AND - "${cmake_generator}" STREQUAL "${CMAKE_GENERATOR}") + if("${CMAKE_GENERATOR}" MATCHES "Make" AND + ("${cmake_generator}" STREQUAL "${CMAKE_GENERATOR}" OR + NOT cmake_generator)) # The project uses the same Makefile generator. Use recursive make. set(cmd "$(MAKE)") if(step STREQUAL "INSTALL") @@ -593,7 +594,8 @@ function(_ep_get_build_command name step cmd_var) endif() else() # if(cfg_cmd_id STREQUAL "configure") # Non-CMake project. Guess "make" and "make install" and "make test". - set(cmd "make") + # But use "$(MAKE)" to get recursive parallel make. + set(cmd "$(MAKE)") if(step STREQUAL "INSTALL") set(args install) endif() diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index a49c852..a6f10ec 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -85,6 +85,75 @@ void cmCTestGIT::NoteNewRevision() } //---------------------------------------------------------------------------- +std::string cmCTestGIT::FindGitDir() +{ + std::string git_dir; + + // Run "git rev-parse --git-dir" to locate the real .git directory. + const char* git = this->CommandLineTool.c_str(); + char const* git_rev_parse[] = {git, "rev-parse", "--git-dir", 0}; + std::string git_dir_line; + OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line); + OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); + if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err)) + { + git_dir = git_dir_line; + } + if(git_dir.empty()) + { + git_dir = ".git"; + } + + // Git reports a relative path only when the .git directory is in + // the current directory. + if(git_dir[0] == '.') + { + git_dir = this->SourceDirectory + "/" + git_dir; + } +#if defined(_WIN32) && !defined(__CYGWIN__) + else if(git_dir[0] == '/') + { + // Cygwin Git reports a full path that Cygwin understands, but we + // are a Windows application. Run "cygpath" to get Windows path. + std::string cygpath_exe = cmSystemTools::GetFilenamePath(git); + cygpath_exe += "/cygpath.exe"; + if(cmSystemTools::FileExists(cygpath_exe.c_str())) + { + char const* cygpath[] = {cygpath_exe.c_str(), "-w", git_dir.c_str(), 0}; + OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line); + OutputLogger cygpath_err(this->Log, "cygpath-err> "); + if(this->RunChild(cygpath, &cygpath_out, &cygpath_err)) + { + git_dir = git_dir_line; + } + } + } +#endif + return git_dir; +} + +//---------------------------------------------------------------------------- +std::string cmCTestGIT::FindTopDir() +{ + std::string top_dir = this->SourceDirectory; + + // Run "git rev-parse --show-cdup" to locate the top of the tree. + const char* git = this->CommandLineTool.c_str(); + char const* git_rev_parse[] = {git, "rev-parse", "--show-cdup", 0}; + std::string cdup; + OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup); + OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); + if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) && + !cdup.empty()) + { + top_dir += "/"; + top_dir += cdup; + top_dir = cmSystemTools::CollapseFullPath(top_dir.c_str()); + } + return top_dir; +} + +//---------------------------------------------------------------------------- bool cmCTestGIT::UpdateByFetchAndReset() { const char* git = this->CommandLineTool.c_str(); @@ -121,11 +190,17 @@ bool cmCTestGIT::UpdateByFetchAndReset() // Identify the merge head that would be used by "git pull". std::string sha1; { - std::string fetch_head = this->SourceDirectory + "/.git/FETCH_HEAD"; + std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD"; std::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary); + if(!fin) + { + this->Log << "Unable to open " << fetch_head << "\n"; + return false; + } std::string line; while(sha1.empty() && cmSystemTools::GetLineFromStream(fin, line)) { + this->Log << "FETCH_HEAD> " << line << "\n"; if(line.find("\tnot-for-merge\t") == line.npos) { std::string::size_type pos = line.find('\t'); @@ -135,6 +210,11 @@ bool cmCTestGIT::UpdateByFetchAndReset() } } } + if(sha1.empty()) + { + this->Log << "FETCH_HEAD has no upstream branch candidate!\n"; + return false; + } } // Reset the local branch to point at that tracked from upstream. @@ -181,11 +261,13 @@ bool cmCTestGIT::UpdateImpl() return false; } + std::string top_dir = this->FindTopDir(); const char* git = this->CommandLineTool.c_str(); char const* git_submodule[] = {git, "submodule", "update", 0}; OutputLogger submodule_out(this->Log, "submodule-out> "); OutputLogger submodule_err(this->Log, "submodule-err> "); - return this->RunChild(git_submodule, &submodule_out, &submodule_err); + return this->RunChild(git_submodule, &submodule_out, &submodule_err, + top_dir.c_str()); } //---------------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h index d8681fe..1765340 100644 --- a/Source/CTest/cmCTestGIT.h +++ b/Source/CTest/cmCTestGIT.h @@ -32,6 +32,9 @@ private: virtual void NoteNewRevision(); virtual bool UpdateImpl(); + std::string FindGitDir(); + std::string FindTopDir(); + bool UpdateByFetchAndReset(); bool UpdateByCustom(std::string const& custom); bool UpdateInternal(); diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 0c4430a..d226eea 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2010) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 07) +SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 27) +SET(KWSYS_DATE_STAMP_DAY 03) diff --git a/Tests/CTestUpdateGIT.cmake.in b/Tests/CTestUpdateGIT.cmake.in index f672a52..793b987 100644 --- a/Tests/CTestUpdateGIT.cmake.in +++ b/Tests/CTestUpdateGIT.cmake.in @@ -275,6 +275,11 @@ execute_process( WORKING_DIRECTORY \"${TOP}\" COMMAND \"${GIT}\" clone \"${REPO}\" dash-source ) + +# Test .git file. +file(RENAME \"${TOP}/dash-source/.git\" \"${TOP}/dash-source/repo.git\") +file(WRITE \"${TOP}/dash-source/.git\" \"gitdir: repo.git\n\") + execute_process( WORKING_DIRECTORY \"${TOP}/dash-source\" COMMAND \"${GIT}\" reset --hard ${revision1} |