Blame view
scripts/adjust_autoksyms.sh
2.16 KB
23121ca2b kbuild: create/ad... |
1 |
#!/bin/sh |
d2912cb15 treewide: Replace... |
2 |
# SPDX-License-Identifier: GPL-2.0-only |
23121ca2b kbuild: create/ad... |
3 |
|
cd195bc47 kbuild: split adj... |
4 |
# Script to update include/generated/autoksyms.h and dependency files |
23121ca2b kbuild: create/ad... |
5 6 7 8 |
# # Copyright: (C) 2016 Linaro Limited # Created by: Nicolas Pitre, January 2016 # |
23121ca2b kbuild: create/ad... |
9 |
|
cd195bc47 kbuild: split adj... |
10 |
# Update the include/generated/autoksyms.h file. |
23121ca2b kbuild: create/ad... |
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# # For each symbol being added or removed, the corresponding dependency # file's timestamp is updated to force a rebuild of the affected source # file. All arguments passed to this script are assumed to be a command # to be exec'd to trigger a rebuild of those files. set -e cur_ksyms_file="include/generated/autoksyms.h" new_ksyms_file="include/generated/autoksyms.h.tmpnew" info() { if [ "$quiet" != "silent_" ]; then printf " %-7s %s " "$1" "$2" fi } info "CHK" "$cur_ksyms_file" # Use "make V=1" to debug this script. case "$KBUILD_VERBOSE" in *1*) set -x ;; esac # We need access to CONFIG_ symbols |
94cf8acc3 kbuild: source in... |
39 |
. include/config/auto.conf |
23121ca2b kbuild: create/ad... |
40 |
|
cd195bc47 kbuild: split adj... |
41 42 |
# Generate a new symbol list file $CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh "$new_ksyms_file" |
23121ca2b kbuild: create/ad... |
43 44 45 46 47 48 49 50 51 |
# Extract changes between old and new list and touch corresponding # dependency files. changed=$( count=0 sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u | sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" | while read sympath; do if [ -z "$sympath" ]; then continue; fi |
fbfa9be99 kbuild: move incl... |
52 |
depfile="include/ksym/${sympath}.h" |
23121ca2b kbuild: create/ad... |
53 54 |
mkdir -p "$(dirname "$depfile")" touch "$depfile" |
825d48758 kbuild: make scri... |
55 56 57 58 59 60 61 |
# Filesystems with coarse time precision may create timestamps # equal to the one from a file that was very recently built and that # needs to be rebuild. Let's guard against that by making sure our # dep files are always newer than the first file we created here. while [ ! "$depfile" -nt "$new_ksyms_file" ]; do touch "$depfile" done |
23121ca2b kbuild: create/ad... |
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
echo $((count += 1)) done | tail -1 ) changed=${changed:-0} if [ $changed -gt 0 ]; then # Replace the old list with tne new one old=$(grep -c "^#define __KSYM_" "$cur_ksyms_file" || true) new=$(grep -c "^#define __KSYM_" "$new_ksyms_file" || true) info "KSYMS" "symbols: before=$old, after=$new, changed=$changed" info "UPD" "$cur_ksyms_file" mv -f "$new_ksyms_file" "$cur_ksyms_file" # Then trigger a rebuild of affected source files exec $@ else rm -f "$new_ksyms_file" fi |