blob: c61a1a8963708e6d332d9fe49bd5d940147ded6d [file] [log] [blame]
Elliot Berman90d92432020-09-28 07:26:37 -07001#!/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 Hong872d69c2022-01-07 17:09:25 -080027export ROOT_DIR=$($(dirname $(readlink -f $0))/gettop.sh)
Elliot Berman90d92432020-09-28 07:26:37 -070028
29# Disable hermetic toolchain for ncurses
30# TODO: Support hermetic toolchain with ncurses menuconfig, xconfig
31HERMETIC_TOOLCHAIN=0
32
33set -e
34set -a
35source "${ROOT_DIR}/build/_setup_env.sh"
36set -a
37
Elliot Berman1d67ceb2021-02-12 17:17:07 -080038# Disable mixed build
39GKI_BUILD_CONFIG=
40
Elliot Berman90d92432020-09-28 07:26:37 -070041menucommand="${1:-menuconfig}"
42MAKE_ARGS="${@:2}"
43
44if [[ "${menucommand}" =~ "*config" ]]; then
45 MAKE_ARGS="$*"
46 menucommand="menuconfig"
47fi
48
Yifan Honge357f282022-10-25 09:41:28 -070049(
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
73export KLEAF_SUPPRESS_BUILD_SH_DEPRECATION_WARNING=1
74
Elliot Berman90d92432020-09-28 07:26:37 -070075# let all the POST_DEFCONFIG_CMDS run since they may clean up loose files, then exit
76append_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
79POST_DEFCONFIG_CMDS="menuconfig ${menucommand} && ${POST_DEFCONFIG_CMDS}"
80
81${ROOT_DIR}/build/build.sh ${MAKE_ARGS}