mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Meta: Error out on find_program errors with CMake less than 3.18
We have seen some cases where the build fails for folks, and they are missing unzip/tar/gzip etc. We can catch some of these in CMake itself, so lets make sure to handle that uniformly across the build system. The REQUIRED flag to `find_program` was only added on in CMake 3.18 and above, so we can't rely on that to actually halt the program execution.
This commit is contained in:
parent
6b5f0d11ce
commit
66e7ac1954
Notes:
sideshowbarker
2024-07-17 17:04:32 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/66e7ac1954 Pull-request: https://github.com/SerenityOS/serenity/pull/13110 Reviewed-by: https://github.com/ADKaster ✅
6 changed files with 31 additions and 10 deletions
|
@ -49,10 +49,7 @@ endif()
|
||||||
|
|
||||||
if (NOT HACKSTUDIO_BUILD)
|
if (NOT HACKSTUDIO_BUILD)
|
||||||
|
|
||||||
# FIXME: With cmake 3.18, we can change unzip/untar steps to use
|
include(check_for_dependencies)
|
||||||
# file( ARCHIVE_EXTRACT) instead
|
|
||||||
find_program(UNZIP unzip REQUIRED)
|
|
||||||
find_program(TAR tar REQUIRED)
|
|
||||||
|
|
||||||
# Host tools, required to generate files for the build
|
# Host tools, required to generate files for the build
|
||||||
find_package(Lagom CONFIG REQUIRED)
|
find_package(Lagom CONFIG REQUIRED)
|
||||||
|
@ -309,7 +306,7 @@ endif()
|
||||||
if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${PCI_IDS_INSTALL_PATH})
|
if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${PCI_IDS_INSTALL_PATH})
|
||||||
message(STATUS "Extracting PCI ID database from ${PCI_IDS_GZ_PATH}...")
|
message(STATUS "Extracting PCI ID database from ${PCI_IDS_GZ_PATH}...")
|
||||||
file(MAKE_DIRECTORY ${CMAKE_INSTALL_DATAROOTDIR})
|
file(MAKE_DIRECTORY ${CMAKE_INSTALL_DATAROOTDIR})
|
||||||
execute_process(COMMAND gzip -d -c "${PCI_IDS_GZ_PATH}" OUTPUT_FILE "${PCI_IDS_INSTALL_PATH}")
|
execute_process(COMMAND "${GZIP_TOOL}" -d -c "${PCI_IDS_GZ_PATH}" OUTPUT_FILE "${PCI_IDS_INSTALL_PATH}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(USB_IDS_FILE usb.ids)
|
set(USB_IDS_FILE usb.ids)
|
||||||
|
@ -325,5 +322,5 @@ endif()
|
||||||
if(EXISTS ${USB_IDS_GZ_PATH} AND NOT EXISTS ${USB_IDS_INSTALL_PATH})
|
if(EXISTS ${USB_IDS_GZ_PATH} AND NOT EXISTS ${USB_IDS_INSTALL_PATH})
|
||||||
message(STATUS "Extracting USB ID database from ${USB_IDS_GZ_PATH}...")
|
message(STATUS "Extracting USB ID database from ${USB_IDS_GZ_PATH}...")
|
||||||
file(MAKE_DIRECTORY ${CMAKE_INSTALL_DATAROOTDIR})
|
file(MAKE_DIRECTORY ${CMAKE_INSTALL_DATAROOTDIR})
|
||||||
execute_process(COMMAND gzip -d -c "${USB_IDS_GZ_PATH}" OUTPUT_FILE "${USB_IDS_INSTALL_PATH}")
|
execute_process(COMMAND "${GZIP_TOOL}" -d -c "${USB_IDS_GZ_PATH}" OUTPUT_FILE "${USB_IDS_INSTALL_PATH}")
|
||||||
endif()
|
endif()
|
||||||
|
|
23
Meta/CMake/check_for_dependencies.cmake
Normal file
23
Meta/CMake/check_for_dependencies.cmake
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#
|
||||||
|
# Check for the dependencies that the Serenity (target) and Lagom (host) builds require.
|
||||||
|
#
|
||||||
|
|
||||||
|
# FIXME: With cmake 3.18, we can change unzip/untar/gzip steps to use
|
||||||
|
# file( ARCHIVE_EXTRACT) instead
|
||||||
|
#
|
||||||
|
# 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()
|
||||||
|
|
||||||
|
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.")
|
||||||
|
endif()
|
|
@ -41,7 +41,7 @@ set(TZDB_ZONE_1970_PATH "${TZDB_PATH}/${TZDB_ZONE_1970_SOURCE}")
|
||||||
function(extract_tzdb_file source path)
|
function(extract_tzdb_file source path)
|
||||||
if(EXISTS "${TZDB_ZIP_PATH}" AND NOT EXISTS "${path}")
|
if(EXISTS "${TZDB_ZIP_PATH}" AND NOT EXISTS "${path}")
|
||||||
message(STATUS "Extracting TZDB ${source} from ${TZDB_ZIP_PATH}...")
|
message(STATUS "Extracting TZDB ${source} from ${TZDB_ZIP_PATH}...")
|
||||||
execute_process(COMMAND tar -C "${TZDB_PATH}" -xf "${TZDB_ZIP_PATH}" "${source}" RESULT_VARIABLE tar_result)
|
execute_process(COMMAND "${TAR_TOOL}" -C "${TZDB_PATH}" -xf "${TZDB_ZIP_PATH}" "${source}" RESULT_VARIABLE tar_result)
|
||||||
if (NOT tar_result EQUAL 0)
|
if (NOT tar_result EQUAL 0)
|
||||||
message(FATAL_ERROR "Failed to unzip ${source} from ${TZDB_ZIP_PATH} with status ${tar_result}")
|
message(FATAL_ERROR "Failed to unzip ${source} from ${TZDB_ZIP_PATH} with status ${tar_result}")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -91,7 +91,7 @@ set(CLDR_UNITS_PATH "${CLDR_PATH}/${CLDR_UNITS_SOURCE}")
|
||||||
function(extract_cldr_file source path)
|
function(extract_cldr_file source path)
|
||||||
if(EXISTS "${CLDR_ZIP_PATH}" AND NOT EXISTS "${path}")
|
if(EXISTS "${CLDR_ZIP_PATH}" AND NOT EXISTS "${path}")
|
||||||
message(STATUS "Extracting CLDR ${source} from ${CLDR_ZIP_PATH}...")
|
message(STATUS "Extracting CLDR ${source} from ${CLDR_ZIP_PATH}...")
|
||||||
execute_process(COMMAND unzip -q "${CLDR_ZIP_PATH}" "${source}/**" -d "${CLDR_PATH}" RESULT_VARIABLE unzip_result)
|
execute_process(COMMAND "${UNZIP_TOOL}" -q "${CLDR_ZIP_PATH}" "${source}/**" -d "${CLDR_PATH}" RESULT_VARIABLE unzip_result)
|
||||||
if (NOT unzip_result EQUAL 0)
|
if (NOT unzip_result EQUAL 0)
|
||||||
message(FATAL_ERROR "Failed to unzip ${source} from ${CLDR_ZIP_PATH} with status ${unzip_result}")
|
message(FATAL_ERROR "Failed to unzip ${source} from ${CLDR_ZIP_PATH} with status ${unzip_result}")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -22,8 +22,8 @@ if(INCLUDE_WASM_SPEC_TESTS)
|
||||||
if(EXISTS ${WASM_SPEC_TEST_GZ_PATH} AND NOT EXISTS ${WASM_SPEC_TEST_PATH})
|
if(EXISTS ${WASM_SPEC_TEST_GZ_PATH} AND NOT EXISTS ${WASM_SPEC_TEST_PATH})
|
||||||
message(STATUS "Extracting the WebAssembly testsuite from ${WASM_SPEC_TEST_GZ_PATH}...")
|
message(STATUS "Extracting the WebAssembly testsuite from ${WASM_SPEC_TEST_GZ_PATH}...")
|
||||||
file(MAKE_DIRECTORY ${WASM_SPEC_TEST_PATH})
|
file(MAKE_DIRECTORY ${WASM_SPEC_TEST_PATH})
|
||||||
execute_process(COMMAND gzip -k -d ${WASM_SPEC_TEST_GZ_PATH})
|
execute_process(COMMAND "${GZIP_TOOL}" -k -d ${WASM_SPEC_TEST_GZ_PATH})
|
||||||
execute_process(COMMAND tar -xf ${WASM_SPEC_TEST_TAR_PATH})
|
execute_process(COMMAND "${TAR_TOOL}" -xf ${WASM_SPEC_TEST_TAR_PATH})
|
||||||
execute_process(COMMAND rm ${WASM_SPEC_TEST_TAR_PATH})
|
execute_process(COMMAND rm ${WASM_SPEC_TEST_TAR_PATH})
|
||||||
file(GLOB WASM_TESTS "${CMAKE_BINARY_DIR}/testsuite-main/*.wast")
|
file(GLOB WASM_TESTS "${CMAKE_BINARY_DIR}/testsuite-main/*.wast")
|
||||||
foreach(PATH ${WASM_TESTS})
|
foreach(PATH ${WASM_TESTS})
|
||||||
|
|
|
@ -32,6 +32,7 @@ if(NOT COMMAND serenity_option)
|
||||||
endmacro()
|
endmacro()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(check_for_dependencies)
|
||||||
include(lagom_options)
|
include(lagom_options)
|
||||||
|
|
||||||
if(ENABLE_ALL_THE_DEBUG_MACROS)
|
if(ENABLE_ALL_THE_DEBUG_MACROS)
|
||||||
|
|
Loading…
Reference in a new issue