From 68953f798b19bfa60d962b5dc3ddc02fdef2fa04 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Thu, 10 Aug 2023 15:45:59 -0600 Subject: [PATCH] CMake: Add option to disable network downloads altogether This is useful for fully offline builds, and some distribution platforms --- Documentation/AdvancedBuildInstructions.md | 1 + Meta/CMake/common_options.cmake | 1 + Meta/CMake/utils.cmake | 3 +++ 3 files changed, 5 insertions(+) diff --git a/Documentation/AdvancedBuildInstructions.md b/Documentation/AdvancedBuildInstructions.md index ca038813492..521fa49b557 100644 --- a/Documentation/AdvancedBuildInstructions.md +++ b/Documentation/AdvancedBuildInstructions.md @@ -68,6 +68,7 @@ There are some optional features that can be enabled during compilation that are - `BUILD_`: builds the specified component, e.g. `BUILD_HEARTS` (note: must be all caps). Check the components.ini file in your build directory for a list of available components. Make sure to run `ninja clean` and `rm -rf Build/x86_64/Root` after disabling components. These options can be easily configured by using the `ConfigureComponents` utility. See the [Component Configuration](#component-configuration) section below. - `BUILD_EVERYTHING`: builds all optional components, overrides other `BUILD_` flags when enabled - `SERENITY_CACHE_DIR`: sets the location of a shared cache of downloaded files. Should not need to be set unless managing a distribution package. +- `ENABLE_NETWORK_DOWNLOADS`: allows downloading files from the internet during the build. Default on, turning off enables offline builds. For offline builds, the structure of the SERENITY_CACHE_DIR must be set up the way that the build expects. Many parts of the SerenityOS codebase have debug functionality, mostly consisting of additional messages printed to the debug console. This is done via the `_DEBUG` macros, which can be enabled individually at build time. They are listed in [this file](../Meta/CMake/all_the_debug_macros.cmake). diff --git a/Meta/CMake/common_options.cmake b/Meta/CMake/common_options.cmake index 235a7900c3b..7b9c504df0c 100644 --- a/Meta/CMake/common_options.cmake +++ b/Meta/CMake/common_options.cmake @@ -26,3 +26,4 @@ serenity_option(ENABLE_JAKT OFF CACHE BOOL "Enable building jakt files") serenity_option(JAKT_SOURCE_DIR "" CACHE STRING "Pre-existing jakt language source directory") serenity_option(SERENITY_CACHE_DIR "${PROJECT_BINARY_DIR}/../caches" CACHE PATH "Location of shared cache of downloaded files") +serenity_option(ENABLE_NETWORK_DOWNLOADS ON CACHE BOOL "Allow downloads of required files. If OFF, required files must already be present in SERENITY_CACHE_DIR") diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake index b3c52bf7e11..5e08bde1847 100644 --- a/Meta/CMake/utils.cmake +++ b/Meta/CMake/utils.cmake @@ -225,6 +225,9 @@ endfunction() function(download_file_multisource urls path) if (NOT EXISTS "${path}") + if (NOT ENABLE_NETWORK_DOWNLOADS) + message(FATAL_ERROR "${path} does not exist, and unable to download it") + endif() get_filename_component(file "${path}" NAME) foreach(url ${urls})