kheaders: optimize header copy for in-tree builds
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 8 Oct 2019 12:05:54 +0000 (21:05 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 11 Nov 2019 11:10:01 +0000 (20:10 +0900)
This script copies headers by the cpio command twice; first from
srctree, and then from objtree. However, when we building in-tree,
we know the srctree and the objtree are the same. That is, all the
headers copied by the first cpio are overwritten by the second one.

Skip the first cpio when we are building in-tree.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
kernel/gen_kheaders.sh

index 6ff86e62787f591f755d354593f46f2c54fc7278..0f7752dd93a696064c81a1d5f502e5b98028db1d 100755 (executable)
@@ -56,14 +56,16 @@ fi
 rm -rf $cpio_dir
 mkdir $cpio_dir
 
-pushd $srctree > /dev/null
-for f in $dir_list;
-       do find "$f" -name "*.h";
-done | cpio --quiet -pd $cpio_dir
-popd > /dev/null
+if [ "$building_out_of_srctree" ]; then
+       pushd $srctree > /dev/null
+       for f in $dir_list
+               do find "$f" -name "*.h";
+       done | cpio --quiet -pd $cpio_dir
+       popd > /dev/null
+fi
 
-# The second CPIO can complain if files already exist which can
-# happen with out of tree builds. Just silence CPIO for now.
+# The second CPIO can complain if files already exist which can happen with out
+# of tree builds having stale headers in srctree. Just silence CPIO for now.
 for f in $dir_list;
        do find "$f" -name "*.h";
 done | cpio --quiet -pd $cpio_dir >/dev/null 2>&1