Created
November 30, 2025 17:15
-
-
Save jarkkojs/00d4fb05474d00bd64df51b4b0028a3b to your computer and use it in GitHub Desktop.
bootstrap-linux-clangs.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| CONFIG_SCRIPT="$PWD/scripts/config" | |
| GEN_COMPILE_COMMANDS="$PWD/scripts/clang-tools/gen_compile_commands.py" | |
| config_disable() { | |
| "$CONFIG_SCRIPT" --disable "$1" | |
| } | |
| config_enable() { | |
| "$CONFIG_SCRIPT" --enable "$1" | |
| } | |
| config_refresh() { | |
| "$CONFIG_SCRIPT" --refresh | |
| } | |
| config_state() { | |
| "$CONFIG_SCRIPT" --state "$1" | |
| } | |
| gen_compile_commands() { | |
| "$GEN_COMPILE_COMMANDS" -d .clangd | |
| } | |
| CONFIG=( | |
| "CONFIG_MODULES n" | |
| "CONFIG_64BIT y" | |
| "CONFIG_ACPI y" | |
| "CONFIG_CRYPTO_SHA1 y" | |
| "CONFIG_ENCRYPTED_KEYS y" | |
| "CONFIG_I2C y" | |
| "CONFIG_IMA y" | |
| "CONFIG_KEYS y" | |
| "CONFIG_MULTIUSER y" | |
| "CONFIG_SECURITY y" | |
| "CONFIG_SECURITYFS y" | |
| "CONFIG_SPI y" | |
| "CONFIG_SYSFS y" | |
| "CONFIG_TCG_CRB y" | |
| "CONFIG_TCG_TPM2_HMAC y" | |
| "CONFIG_TCG_TIS y" | |
| "CONFIG_TCG_TIS_I2C y" | |
| "CONFIG_TCG_TIS_SPI y" | |
| "CONFIG_TCG_TPM y" | |
| "CONFIG_TCG_VTPM_PROXY y" | |
| "CONFIG_TRUSTED_KEYS y" | |
| "CONFIG_TTY y" | |
| ) | |
| config_apply() { | |
| local entry opt val | |
| for entry in "${CONFIG[@]}"; do | |
| read -r opt val <<<"$entry" | |
| case "$val" in | |
| y) config_enable "$opt" ;; | |
| n) config_disable "$opt" ;; | |
| *) | |
| echo "unknown $opt $val" >&2 | |
| return 1 | |
| ;; | |
| esac | |
| done | |
| } | |
| config_verify() { | |
| local entry opt expected actual rc=0 | |
| for entry in "${CONFIG[@]}"; do | |
| read -r opt expected <<<"$entry" | |
| actual="$(config_state "$opt")" | |
| if [[ "$actual" == "undef" ]]; then | |
| echo "$opt is undefined" >&2 | |
| exit 1 | |
| fi | |
| if [[ "$actual" != "$expected" ]]; then | |
| echo "$opt $actual != $expected" >&2 | |
| exit 1 | |
| fi | |
| done | |
| } | |
| make O=.clangd tinyconfig | |
| cd .clangd | |
| config_apply | |
| config_refresh | |
| config_verify | |
| cd .. | |
| make O=.clangd -j "$(nproc)" | |
| gen_compile_commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment