]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/seastar/cooking.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / cooking.sh
index a8f3aba1f72b62bbdf7263ceaf9240848aec40cf..eb028c09e258ec3eedf8e29eb7b9836d3aa3af47 100755 (executable)
@@ -17,7 +17,7 @@
 #
 
 #
-# This is cmake-cooking v0.8.1
+# This is cmake-cooking v0.10.0
 # The home of cmake-cooking is https://github.com/hakuch/CMakeCooking
 #
 
@@ -30,7 +30,7 @@ source_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 initial_wd=$(pwd)
 memory_file="${initial_wd}/.cooking_memory"
 
-recipe=""
+recipe="${source_dir}/cooking_recipe.cmake"
 declare -a excluded_ingredients
 declare -a included_ingredients
 build_dir="${initial_wd}/build"
@@ -60,9 +60,12 @@ where OPTIONS are:
 -t BUILD_TYPE (=${build_type})
 -g GENERATOR (=${generator})
 -s VAR=VALUE
+-f EXPORT_DIR
 -l
 -h
 
+By default, cmake-cooking reads a file called `cooking_recipe.cmake`.
+
 If neither [-i] nor [-e] are specified with a recipe ([-r]), then all ingredients of the recipe
 will be fetched and built.
 
@@ -77,8 +80,11 @@ Option details:
 
 -r RECIPE
 
-    Prepare the named recipe. Recipes are stored in 'recipe/RECIPE.cmake'.
-    If no recipe is indicated, then configure the build without any ingredients.
+    Instead of reading the recipe in a file called `cooking_recipe.cmake`, follow the recipe
+    in the named file.
+
+    If the recipe file is a relative path, it is interpretted relative to the source directory
+    of the project.
 
 -e INGREDIENT
 
@@ -133,6 +139,17 @@ Option details:
 
    Set an environmental variable 'VAR' to the value 'VALUE' during the invocation of CMake.
 
+-f EXPORT_DIR
+
+   If provided, and the project is successfully configured, then the tree of installed ingredients
+   is exported to this directory (the actual files: not symbolic links).
+
+   This option requires rsync.
+
+   This may be useful for preparing continuous integration environments, but it is not
+   recommended for distribution or release purposes (since this would be counter
+   to the goal of cmake-cooking).
+
 -l
 
     Only list available ingredients for a given recipe, and don't do anything else.
@@ -153,7 +170,7 @@ yell_include_exclude_mutually_exclusive() {
     echo "Cooking: [-e] and [-i] are mutually exclusive options!" >&2
 }
 
-while getopts "ar:e:i:d:p:t:g:s:lhx" arg; do
+while getopts "ar:e:i:d:p:t:g:s:f:lhx" arg; do
     case "${arg}" in
         a)
             if [ ! -f "${memory_file}" ]; then
@@ -164,7 +181,13 @@ while getopts "ar:e:i:d:p:t:g:s:lhx" arg; do
             source "${memory_file}"
             run_previous && exit 0
             ;;
-        r) recipe=${OPTARG} ;;
+        r)
+            if [[ "${OPTARG}" = /* ]]; then
+                recipe=${OPTARG}
+            else
+                recipe="${source_dir}/${OPTARG}"
+            fi
+            ;;
         e)
             if [[ ${#included_ingredients[@]} -ne 0 ]]; then
                 yell_include_exclude_mutually_exclusive
@@ -186,6 +209,7 @@ while getopts "ar:e:i:d:p:t:g:s:lhx" arg; do
         t) build_type=${OPTARG} ;;
         g) generator=${OPTARG} ;;
         s) parse_assignment "${OPTARG}" ;;
+        f) export_dir=$(realpath "${OPTARG}") ;;
         l) list_only="1" ;;
         h) usage; exit 0 ;;
         x) nested="1" ;;
@@ -196,7 +220,6 @@ done
 shift $((OPTIND - 1))
 
 cooking_dir="${build_dir}/_cooking"
-cmake_dir="${source_dir}/cmake"
 cache_file="${build_dir}/CMakeCache.txt"
 ingredients_ready_file="${cooking_dir}/ready.txt"
 
@@ -204,9 +227,9 @@ if [ -z "${ingredients_dir}" ]; then
     ingredients_dir="${cooking_dir}/installed"
 fi
 
-mkdir -p "${cmake_dir}"
+mkdir -p "${build_dir}"
 
-cat <<'EOF' > "${cmake_dir}/Cooking.cmake"
+cat <<'EOF' > "${build_dir}/Cooking.cmake"
 #
 # Copyright 2018 Jesse Haber-Kucharsky
 #
@@ -224,7 +247,7 @@ cat <<'EOF' > "${cmake_dir}/Cooking.cmake"
 #
 
 #
-# This file was generated by cmake-cooking v0.8.1
+# This file was generated by cmake-cooking v0.10.0
 # The home of cmake-cooking is https://github.com/hakuch/CMakeCooking
 #
 
@@ -313,7 +336,7 @@ macro (project name)
         DEPENDS ${_cooking_local_synchronize_marker_file})
 
       list (APPEND CMAKE_PREFIX_PATH ${Cooking_INGREDIENTS_DIR})
-      include ("recipe/${Cooking_RECIPE}.cmake")
+      include (${Cooking_RECIPE})
 
       if (NOT EXISTS ${_cooking_ready_marker_file})
         return ()
@@ -416,10 +439,16 @@ function (_cooking_define_listing_targets)
     ${CMAKE_COMMAND} -E touch ${Cooking_INGREDIENTS_DIR}/.cooking_ingredient_${pa_NAME})
 
   if (pa_RECIPE)
+    if (pa_RECIPE STREQUAL <DEFAULT>)
+      set (recipe_args "")
+    else ()
+      set (recipe_args -r ${pa_RECIPE})
+    endif ()
+
     list (INSERT commands 0
       COMMAND
       ${pa_SOURCE_DIR}/cooking.sh
-      -r ${pa_RECIPE}
+      ${recipe_args}
       -p ${Cooking_INGREDIENTS_DIR}
       -g ${CMAKE_GENERATOR}
       -x
@@ -545,6 +574,12 @@ function (_cooking_populate_ep_configure_command)
     ${ARGN})
 
   if (pa_RECIPE)
+    if (pa_RECIPE STREQUAL <DEFAULT>)
+      set (recipe_args "")
+    else ()
+      set (recipe_args -r ${pa_RECIPE})
+    endif ()
+
     _cooking_prepare_restrictions_arguments (
       IS_EXCLUDING ${pa_IS_EXCLUDING}
       IS_INCLUDING ${pa_IS_INCLUDING}
@@ -554,7 +589,7 @@ function (_cooking_populate_ep_configure_command)
     set (value
       CONFIGURE_COMMAND
       <SOURCE_DIR>/cooking.sh
-      -r ${pa_RECIPE}
+      ${recipe_args}
       -d <BINARY_DIR>
       -p ${Cooking_INGREDIENTS_DIR}
       -g ${CMAKE_GENERATOR}
@@ -787,6 +822,17 @@ cmake_cooking_args=(
     "-DCooking_RECIPE=${recipe}"
 )
 
+#
+# Remove any `Cooking.cmake` file from the source directory. We now generate this file in the build directory, and old
+# copies will cause conflicts.
+#
+
+old_cooking_file="${source_dir}/cmake/Cooking.cmake"
+
+if [ -f "${old_cooking_file}" ]; then
+    grep 'This file was generated by cmake-cooking' "${old_cooking_file}" > /dev/null && rm "${old_cooking_file}"
+fi
+
 #
 # Clean-up from a previous run.
 #
@@ -810,9 +856,7 @@ mkdir -p "${ingredients_dir}"
 #
 
 if [ -n "${recipe}" ]; then
-    recipe_file="${source_dir}/recipe/${recipe}.cmake"
-
-    if [ ! -f "${recipe_file}" ]; then
+    if [ ! -f "${recipe}" ]; then
         echo "Cooking: The '${recipe}' recipe does not exist!" >&2
         exit 1
     fi
@@ -840,7 +884,6 @@ fi
 # Configure and build ingredients.
 #
 
-mkdir -p "${build_dir}"
 mkdir -p "${cooking_dir}"/stow
 touch "${cooking_dir}"/stow/.stow
 cd "${build_dir}"
@@ -856,37 +899,49 @@ if [ -n "${list_only}" ]; then
 fi
 
 ${CMAKE} -DCMAKE_BUILD_TYPE="${build_type}" "${cmake_cooking_args[@]}" -G "${generator}" "${source_dir}" "${@}"
-${CMAKE} --build . --target _cooking_ingredients_ready -- "${build_args[@]}"
 
-#
-# Report what we've done (if we're not nested).
-#
+if [ -n "${recipe}" ]; then
+    ${CMAKE} --build . --target _cooking_ingredients_ready -- "${build_args[@]}"
+
+    #
+    # Report what we've done (if we're not nested).
+    #
+
+    if [ -z "${nested}" ]; then
+        ingredients=($(find "${ingredients_dir}" -name '.cooking_ingredient_*' -printf '%f\n' | sed -r 's/\.cooking_ingredient_(.+)/\1/'))
 
-if [ -z "${nested}" ]; then
-    ingredients=($(find "${ingredients_dir}" -name '.cooking_ingredient_*' -printf '%f\n' | sed -r 's/\.cooking_ingredient_(.+)/\1/'))
+        if [ -z "${list_only}" ]; then
+            printf "\nCooking: Installed the following ingredients:\n"
+        else
+            printf "\nCooking: The following ingredients are necessary for this recipe:\n"
+        fi
 
-    if [ -z "${list_only}" ]; then
-        printf "\nCooking: Installed the following ingredients:\n"
-    else
-        printf "\nCooking: The following ingredients are necessary for this recipe:\n"
+        for ingredient in "${ingredients[@]}"; do
+            echo "  - ${ingredient}"
+        done
+
+        printf '\n'
     fi
 
-    for ingredient in "${ingredients[@]}"; do
-        echo "  - ${ingredient}"
-    done
+    if [ -n "${list_only}" ]; then
+        exit 0
+    fi
 
-    printf '\n'
-fi
+    #
+    # Configure the project, expecting all requirements satisfied.
+    #
 
-if [ -n "${list_only}" ]; then
-    exit 0
-fi
+    ${CMAKE} -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON "${@}" .
 
-#
-# Configure the project, expecting all requirements satisfied.
-#
+    #
+    # Optionally export the installed files.
+    #
 
-${CMAKE} -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON "${@}" .
+    if [ -n "${export_dir}" ]; then
+        rsync "${ingredients_dir}/" "${export_dir}" -a --copy-links
+        printf "\nCooking: Exported ingredients to ${export_dir}\n"
+    fi
+fi
 
 #
 # Save invocation information.