Skip to content

Commit

Permalink
Merge pull request xbmc#6243 from Montellese/cmake_addon_download_fix
Browse files Browse the repository at this point in the history
cmake: fix addon tarball download
  • Loading branch information
Montellese committed Jan 22, 2015
2 parents a2a7c9b + 531069e commit c5f67b5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
33 changes: 25 additions & 8 deletions project/cmake/addons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,30 +143,47 @@ foreach(addon ${addons})
# get the URL and revision of the addon
list(LENGTH def deflength)
list(GET def 1 url)
list(GET def 2 revision)

# download and extract all addons
if(deflength GREATER 2)
set(archive_name ${id})

# if there is a 3rd parameter in the file, we consider it a git revision
if(deflength GREATER 2)
list(GET def 2 revision)

# Note: downloading specific revisions via http in the format below is probably github specific
# if we ever use other repositories, this might need adapting
set(url ${url}/archive/${revision}.tar.gz)
set(archive_name ${archive_name}-${revision})
endif()
if(NOT EXISTS ${BUILD_DIR}/download/${id}.tar.gz)
file(DOWNLOAD "${url}" "${BUILD_DIR}/download/${id}.tar.gz" STATUS dlstatus LOG dllog SHOW_PROGRESS)

# download and extract the addon
if(NOT EXISTS ${BUILD_DIR}/download/${archive_name}.tar.gz)
# cleanup any of the previously downloaded archives of this addon
file(GLOB archives "${BUILD_DIR}/download/${id}*.tar.gz")
if(archives)
message(STATUS "Removing old archives of ${id}: ${archives}")
file(REMOVE ${archives})
endif()

# download the addon
file(DOWNLOAD "${url}" "${BUILD_DIR}/download/${archive_name}.tar.gz" STATUS dlstatus LOG dllog SHOW_PROGRESS)
list(GET dlstatus 0 retcode)
if(NOT ${retcode} EQUAL 0)
message(FATAL_ERROR "ERROR downloading ${url} - status: ${dlstatus} log: ${dllog}")
endif()
endif()

# remove any previously extracted version of the addon
if(EXISTS "${BUILD_DIR}/${id}")
file(REMOVE_RECURSE "${BUILD_DIR}/${id}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${BUILD_DIR}/download/${id}.tar.gz

# extract the addon from the archive
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${BUILD_DIR}/download/${archive_name}.tar.gz
WORKING_DIRECTORY ${BUILD_DIR})
file(GLOB extract_dir "${BUILD_DIR}/${id}-${revision}*")
file(GLOB extract_dir "${BUILD_DIR}/${archive_name}*")
if(extract_dir STREQUAL "")
message(FATAL_ERROR "Error extracting ${BUILD_DIR}/download/${id}.tar.gz")
message(FATAL_ERROR "Error extracting ${BUILD_DIR}/download/${archive_name}.tar.gz")
else()
file(RENAME "${extract_dir}" "${BUILD_DIR}/${id}")
endif()
Expand Down
6 changes: 3 additions & 3 deletions project/cmake/scripts/common/handle-depends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ function(add_addon_depends addon searchpath)
endif()

set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DOUTPUT_DIR=${DEPENDS_PATH}
-DOUTPUT_DIR=${OUTPUT_DIR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE}
-DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX}
-DCMAKE_INSTALL_PREFIX=${DEPENDS_PATH}
-DCMAKE_INSTALL_PREFIX=${OUTPUT_DIR}
-DARCH_DEFINES=${ARCH_DEFINES}
-DENABLE_STATIC=1
-DBUILD_SHARED_LIBS=0)
Expand Down Expand Up @@ -82,7 +82,7 @@ function(add_addon_depends addon searchpath)
set(INSTALL_COMMAND INSTALL_COMMAND ${CMAKE_COMMAND}
-DINPUTDIR=${BUILD_DIR}/${id}/src/${id}-build/
-DINPUTFILE=${dir}/install.txt
-DDESTDIR=${DEPENDS_PATH}
-DDESTDIR=${OUTPUT_DIR}
-DENABLE_STATIC=1
"${extraflags}"
-P ${PROJECT_SOURCE_DIR}/install.cmake)
Expand Down

0 comments on commit c5f67b5

Please sign in to comment.