| # Copyright 2024 Google LLC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| SCRIPT_ROOT=$(dirname $(readlink -f "$0")) | |
| SCRIPT_ROOT=${SCRIPT_ROOT%cos} | |
| . "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1 | |
| # Script must be run inside the chroot. | |
| restart_in_chroot_if_needed "$@" | |
| DEFINE_string kernel_tree "" \ | |
| "In-chroot path to the kernel tree to sync configs in." | |
| # Parse command line. | |
| FLAGS "$@" || exit 1 | |
| eval set -- "${FLAGS_ARGV}" | |
| switch_to_strict_mode | |
| sync_config() { | |
| local -r config=$1 | |
| local -r arch=$2 | |
| local tuple | |
| case "${arch}" in | |
| x86_64) | |
| tuple=x86_64-cros-linux-gnu | |
| ;; | |
| arm64) | |
| tuple=aarch64-cros-linux-gnu | |
| ;; | |
| *) | |
| error "Unknown arch ${arch}" | |
| return 1 | |
| ;; | |
| esac | |
| local build_dir | |
| build_dir="$(mktemp -d)" | |
| cp "${config}" "${build_dir}/.config" | |
| make -C "${FLAGS_kernel_tree}" O="${build_dir}" ARCH="${arch}" \ | |
| CC="${tuple}-clang" LD="${tuple}-ld.lld" CROSS_COMPILE="${tuple}-" \ | |
| olddefconfig | |
| cp "${build_dir}/.config" "${config}" | |
| rm -rf "${build_dir}" | |
| } | |
| main() { | |
| if [[ -z "${FLAGS_kernel_tree}" ]]; then | |
| error "Please provide a --kernel_tree value" | |
| return 1 | |
| fi | |
| update_chroot | |
| sync_config "${FLAGS_kernel_tree}/arch/x86/configs/lakitu_defconfig" x86_64 | |
| sync_config "${FLAGS_kernel_tree}/arch/x86/configs/lakitu_dump_defconfig" x86_64 | |
| sync_config "${FLAGS_kernel_tree}/arch/arm64/configs/lakitu_defconfig" arm64 | |
| sync_config "${FLAGS_kernel_tree}/arch/arm64/configs/lakitu_dump_defconfig" arm64 | |
| } | |
| main "$@" |