mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-24 08:30:21 +00:00
Meta: Use CMake functions to extract files
Newer cmake's have internal functions to un-compress files. These functions will work on pure windows - as well as linux. This eliminates the need to search for external tools (TAR,GZIP,ZIP) - and helps fixing #9866. In order to finally fix #9866 we need to decide to bump the cmake version requirements and remove the checks. If we demand a newer cmake version, we will loose Ubuntu 20.04 as a build target - as it ships with CMake 3.16. For now - we keep compatibility with CMake 3.16 - and only if CMake 3.18 as been found - we use its new functionality.
This commit is contained in:
parent
5ab3fcf710
commit
8b30b69dac
Notes:
sideshowbarker
2024-07-17 07:20:05 +09:00
Author: https://github.com/elcuco Commit: https://github.com/SerenityOS/serenity/commit/8b30b69dac Pull-request: https://github.com/SerenityOS/serenity/pull/15040 Issue: https://github.com/SerenityOS/serenity/issues/9866 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/FireFox317 Reviewed-by: https://github.com/trflynn89
4 changed files with 45 additions and 22 deletions
|
@ -257,7 +257,11 @@ endif()
|
|||
if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH})
|
||||
message(STATUS "Extracting PCI ID database from ${PCI_IDS_GZ_PATH}...")
|
||||
file(MAKE_DIRECTORY "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}")
|
||||
execute_process(COMMAND "${GZIP_TOOL}" -d -c "${PCI_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}")
|
||||
if (CMAKE_VERSION VERSION_LESS 3.18.0)
|
||||
execute_process(COMMAND "${GZIP_TOOL}" -d -c "${PCI_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}")
|
||||
else()
|
||||
file(ARCHIVE_EXTRACT INPUT "${PCI_IDS_GZ_PATH}" DESTINATION "${PCI_IDS_GZ_PATH}" PATTERNS "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(USB_IDS_FILE usb.ids)
|
||||
|
@ -273,5 +277,9 @@ endif()
|
|||
if(EXISTS ${USB_IDS_GZ_PATH} AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH})
|
||||
message(STATUS "Extracting USB ID database from ${USB_IDS_GZ_PATH}...")
|
||||
file(MAKE_DIRECTORY "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}")
|
||||
execute_process(COMMAND "${GZIP_TOOL}" -d -c "${USB_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}")
|
||||
if (CMAKE_VERSION VERSION_LESS 3.18.0)
|
||||
execute_process(COMMAND "${GZIP_TOOL}" -d -c "${USB_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}")
|
||||
else()
|
||||
file(ARCHIVE_EXTRACT INPUT "${PCI_IDS_GZ_PATH}" DESTINATION "${USB_IDS_GZ_PATH}" PATTERNS "${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}")
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -7,17 +7,22 @@
|
|||
#
|
||||
# Additionally we have to emit an error message for each tool,
|
||||
# as REQUIRED only works with cmake 3.18 and above.
|
||||
find_program(UNZIP_TOOL unzip REQUIRED)
|
||||
if (NOT UNZIP_TOOL)
|
||||
message(FATAL_ERROR "Failed to locate unzip on your machine, please install it and re-read the SerenityOS build documentation.")
|
||||
endif()
|
||||
if (CMAKE_VERSION VERSION_LESS 3.18.0)
|
||||
find_program(UNZIP_TOOL unzip REQUIRED)
|
||||
message(STATUS "Found cmake ${CMAKE_VERSION} - testing for external tools to uncompress")
|
||||
if (NOT UNZIP_TOOL)
|
||||
message(FATAL_ERROR "Failed to locate unzip on your machine, please install it and re-read the SerenityOS build documentation.")
|
||||
endif()
|
||||
|
||||
find_program(TAR_TOOL tar REQUIRED)
|
||||
if (NOT TAR_TOOL)
|
||||
message(FATAL_ERROR "Failed to locate tar on your machine, please install it and re-read the SerenityOS build documentation.")
|
||||
endif()
|
||||
find_program(TAR_TOOL tar REQUIRED)
|
||||
if (NOT TAR_TOOL)
|
||||
message(FATAL_ERROR "Failed to locate tar on your machine, please install it and re-read the SerenityOS build documentation.")
|
||||
endif()
|
||||
|
||||
find_program(GZIP_TOOL gzip REQUIRED)
|
||||
if (NOT GZIP_TOOL)
|
||||
message(FATAL_ERROR "Failed to locate gzip on your machine, please install it and re-read the SerenityOS build documentation.")
|
||||
find_program(GZIP_TOOL gzip REQUIRED)
|
||||
if (NOT GZIP_TOOL)
|
||||
message(FATAL_ERROR "Failed to locate gzip on your machine, please install it and re-read the SerenityOS build documentation.")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Found cmake ${CMAKE_VERSION} - using CMake to uncompress")
|
||||
endif()
|
|
@ -40,10 +40,15 @@ set(TZDB_ZONE_1970_PATH "${TZDB_PATH}/${TZDB_ZONE_1970_SOURCE}")
|
|||
|
||||
function(extract_tzdb_file source path)
|
||||
if(EXISTS "${TZDB_ZIP_PATH}" AND NOT EXISTS "${path}")
|
||||
message(STATUS "Extracting TZDB ${source} from ${TZDB_ZIP_PATH}...")
|
||||
execute_process(COMMAND "${TAR_TOOL}" -C "${TZDB_PATH}" -xzf "${TZDB_ZIP_PATH}" "${source}" RESULT_VARIABLE tar_result)
|
||||
if (NOT tar_result EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to unzip ${source} from ${TZDB_ZIP_PATH} with status ${tar_result}")
|
||||
if (CMAKE_VERSION VERSION_LESS 3.18.0)
|
||||
message(STATUS "Extracting using ${TAR_TOOL} file ${source}")
|
||||
execute_process(COMMAND "${TAR_TOOL}" -C "${TZDB_PATH}" -xzf "${TZDB_ZIP_PATH}" "${source}" RESULT_VARIABLE tar_result)
|
||||
if (NOT tar_result EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to unzip ${source} from ${TZDB_ZIP_PATH} with status ${tar_result}")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Extracting using cmake ${source}")
|
||||
file(ARCHIVE_EXTRACT INPUT "${TZDB_ZIP_PATH}" DESTINATION "${TZDB_PATH}" PATTERNS "${source}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
|
@ -224,10 +224,15 @@ endfunction()
|
|||
|
||||
function(extract_path dest_dir zip_path source_path dest_path)
|
||||
if (EXISTS "${zip_path}" AND NOT EXISTS "${dest_path}")
|
||||
message(STATUS "Extracting ${source_path} from ${zip_path}")
|
||||
execute_process(COMMAND "${UNZIP_TOOL}" -q "${zip_path}" "${source_path}" -d "${dest_dir}" RESULT_VARIABLE unzip_result)
|
||||
if (NOT unzip_result EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to unzip ${source_path} from ${zip_path} with status ${unzip_result}")
|
||||
if (CMAKE_VERSION VERSION_LESS 3.18.0)
|
||||
message(STATUS "Extracting using ${UNZIP_TOOL} ${source_path} from ${zip_path}")
|
||||
execute_process(COMMAND "${UNZIP_TOOL}" -q "${zip_path}" "${source_path}" -d "${dest_dir}" RESULT_VARIABLE unzip_result)
|
||||
if (NOT unzip_result EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to unzip ${source_path} from ${zip_path} with status ${unzip_result}")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Extracting using cmake ${source_path}")
|
||||
file(ARCHIVE_EXTRACT INPUT "${zip_path}" DESTINATION "${dest_dir}" PATTERNS "${source_path}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
Loading…
Reference in a new issue