xref: /openbmc/linux/scripts/remove-stale-files (revision 1476fee5)
1*1476fee5SMasahiro Yamada#!/bin/sh
2*1476fee5SMasahiro Yamada
3*1476fee5SMasahiro Yamadaset -e
4*1476fee5SMasahiro Yamada
5*1476fee5SMasahiro Yamada# When you move, remove or rename generated files, you probably also update
6*1476fee5SMasahiro Yamada# .gitignore and cleaning rules in the Makefile. This is the right thing
7*1476fee5SMasahiro Yamada# to do. However, people usually do 'git pull', 'git bisect', etc. without
8*1476fee5SMasahiro Yamada# running 'make clean'. Then, the stale generated files are left over, often
9*1476fee5SMasahiro Yamada# causing build issues.
10*1476fee5SMasahiro Yamada#
11*1476fee5SMasahiro Yamada# Also, 'git status' shows such stale build artifacts as untracked files.
12*1476fee5SMasahiro Yamada# What is worse, some people send a wrong patch to get them back to .gitignore
13*1476fee5SMasahiro Yamada# without checking the commit history.
14*1476fee5SMasahiro Yamada#
15*1476fee5SMasahiro Yamada# So, when you (re)move generated files, please move the cleaning rules from
16*1476fee5SMasahiro Yamada# the Makefile to this script. This is run before Kbuild starts building
17*1476fee5SMasahiro Yamada# anything, so people will not be annoyed by such garbage files.
18*1476fee5SMasahiro Yamada#
19*1476fee5SMasahiro Yamada# This script is not intended to grow endlessly. Rather, it is a temporary scrap
20*1476fee5SMasahiro Yamada# yard. Stale files stay in this file for a while (for some release cycles?),
21*1476fee5SMasahiro Yamada# then will be really dead and removed from the code base entirely.
22*1476fee5SMasahiro Yamada
23*1476fee5SMasahiro Yamada# These were previously generated source files. When you are building the kernel
24*1476fee5SMasahiro Yamada# with O=, make sure to remove the stale files in the output tree. Otherwise,
25*1476fee5SMasahiro Yamada# the build system wrongly compiles the stale ones.
26*1476fee5SMasahiro Yamadaif [ -n "${building_out_of_srctree}" ]; then
27*1476fee5SMasahiro Yamada	for f in fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
28*1476fee5SMasahiro Yamada	do
29*1476fee5SMasahiro Yamada		rm -f arch/arm/boot/compressed/${f}
30*1476fee5SMasahiro Yamada	done
31*1476fee5SMasahiro Yamadafi
32