Elliot Berman | 90d9243 | 2020-09-28 07:26:37 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Usage: |
| 4 | # build/config.sh <config editor> <make options>* |
| 5 | # |
| 6 | # Example: |
| 7 | # build/config.sh menuconfig|config|nconfig|... (default to menuconfig) |
| 8 | # |
| 9 | # Runs a configuration editor inside kernel/build environment. |
| 10 | # |
| 11 | # In addition to the environment variables considered in build/build.sh, the |
| 12 | # the following can be defined: |
| 13 | # |
| 14 | # FRAGMENT_CONFIG |
| 15 | # If set, the FRAGMENT_CONFIG file (absolute or relative to ROOT_DIR) is |
| 16 | # updated with the options selected by the config editor. |
| 17 | # |
| 18 | # Note: When editing a FRAGMENT_CONFIG, config.sh is intentionally |
| 19 | # unintelligent about removing "redundant" configuration options. That is, |
| 20 | # setting CONFIG_ARM_SMMU=m using config.sh, then unsetting it would |
| 21 | # result in a fragment config with CONFIG_ARM_SMMU explicitly unset. |
| 22 | # This behavior is desired since it is unknown whether the base |
| 23 | # configuration without the fragment would have CONFIG_ARM_SMMU (un)set. |
| 24 | # If desire is to let the base configuration properly control a CONFIG_ |
| 25 | # option, then remove the line from FRAGMENT_CONFIG |
| 26 | |
Yifan Hong | 872d69c | 2022-01-07 17:09:25 -0800 | [diff] [blame] | 27 | export ROOT_DIR=$($(dirname $(readlink -f $0))/gettop.sh) |
Elliot Berman | 90d9243 | 2020-09-28 07:26:37 -0700 | [diff] [blame] | 28 | |
| 29 | # Disable hermetic toolchain for ncurses |
| 30 | # TODO: Support hermetic toolchain with ncurses menuconfig, xconfig |
| 31 | HERMETIC_TOOLCHAIN=0 |
| 32 | |
| 33 | set -e |
| 34 | set -a |
| 35 | source "${ROOT_DIR}/build/_setup_env.sh" |
| 36 | set -a |
| 37 | |
Elliot Berman | 1d67ceb | 2021-02-12 17:17:07 -0800 | [diff] [blame] | 38 | # Disable mixed build |
| 39 | GKI_BUILD_CONFIG= |
| 40 | |
Elliot Berman | 90d9243 | 2020-09-28 07:26:37 -0700 | [diff] [blame] | 41 | menucommand="${1:-menuconfig}" |
| 42 | MAKE_ARGS="${@:2}" |
| 43 | |
| 44 | if [[ "${menucommand}" =~ "*config" ]]; then |
| 45 | MAKE_ARGS="$*" |
| 46 | menucommand="menuconfig" |
| 47 | fi |
| 48 | |
Yifan Hong | e357f28 | 2022-10-25 09:41:28 -0700 | [diff] [blame] | 49 | ( |
| 50 | [[ "$KLEAF_SUPPRESS_BUILD_SH_DEPRECATION_WARNING" == "1" ]] && exit 0 || true |
| 51 | echo "Inferring equivalent Bazel command..." |
| 52 | bazel_command_code=0 |
| 53 | eq_bazel_command=$( |
| 54 | ${ROOT_DIR}/build/kernel/kleaf/convert_to_bazel.sh --config $menucommand # error messages goes to stderr |
| 55 | ) || bazel_command_code=$? |
| 56 | echo "*****************************************************************************" >&2 |
| 57 | echo "* WARNING: build.sh is deprecated for this branch. Please migrate to Bazel. " >&2 |
| 58 | echo "* See build/kernel/kleaf/README.md " >&2 |
| 59 | if [[ $bazel_command_code -eq 0 ]]; then |
| 60 | echo "* Possibly equivalent Bazel command: " >&2 |
| 61 | echo "*" >&2 |
| 62 | echo "* \$ $eq_bazel_command" >&2 |
| 63 | echo "*" >&2 |
| 64 | else |
| 65 | echo "WARNING: Unable to infer an equivalent Bazel command. " >&2 |
| 66 | fi |
| 67 | echo "* To suppress this warning, set KLEAF_SUPPRESS_BUILD_SH_DEPRECATION_WARNING=1" >&2 |
| 68 | echo "*****************************************************************************" >&2 |
| 69 | echo >&2 |
| 70 | ) |
| 71 | |
| 72 | # Suppress deprecation warning for the last build.sh invocation |
| 73 | export KLEAF_SUPPRESS_BUILD_SH_DEPRECATION_WARNING=1 |
| 74 | |
Elliot Berman | 90d9243 | 2020-09-28 07:26:37 -0700 | [diff] [blame] | 75 | # let all the POST_DEFCONFIG_CMDS run since they may clean up loose files, then exit |
| 76 | append_cmd POST_DEFCONFIG_CMDS "exit" |
| 77 | # menuconfig should go first. If POST_DEFCONFIG_CMDS modifies the .config, then we probably don't |
| 78 | # want those changes to end up in the resulting saved defconfig |
| 79 | POST_DEFCONFIG_CMDS="menuconfig ${menucommand} && ${POST_DEFCONFIG_CMDS}" |
| 80 | |
| 81 | ${ROOT_DIR}/build/build.sh ${MAKE_ARGS} |