Commit cef9fc82 authored by Rusty Russell's avatar Rusty Russell

tools/create-ccan-tree: fix nested modules with -a

The cp -a would copy nested submodules, and worse, if that submodule
was copied later it would end up duplicated in a subdir,
eg. "ccan/tal/str/str/".

Using modfiles handles this properly, and also uses git to filter
out ignored files & other junk.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 25ea9a3d
...@@ -15,7 +15,6 @@ EOF ...@@ -15,7 +15,6 @@ EOF
} }
# parse options, setting the following flags # parse options, setting the following flags
copy_all=
build_type= build_type=
opts=$(getopt -o ab: --long copy-all,build-type: -n $progname -- "$@") opts=$(getopt -o ab: --long copy-all,build-type: -n $progname -- "$@")
...@@ -27,12 +26,13 @@ then ...@@ -27,12 +26,13 @@ then
fi fi
eval set -- "$opts" eval set -- "$opts"
MODFILES_ARGS="--no-tests --no-other"
while : while :
do do
case "$1" in case "$1" in
-a|--copy-all) -a|--copy-all)
copy_all=1 MODFILES_ARGS=""
shift shift
;; ;;
-b|--build-type) -b|--build-type)
...@@ -85,11 +85,13 @@ tmpdir="$(mktemp -d)" ...@@ -85,11 +85,13 @@ tmpdir="$(mktemp -d)"
# We'll need the ccan_depends tool, but also a clean source tree. Build # We'll need the ccan_depends tool, but also a clean source tree. Build
# tools/ccan_depends, and store it in $tmpdir for later use # tools/ccan_depends, and store it in $tmpdir for later use
echo "Building ccan_depends" echo "Building ccan_depends, modfiles"
ccan_depends="$tmpdir/ccan_depends" ccan_depends="$tmpdir/ccan_depends"
make -s -C "$srcdir" tools/ccan_depends modfiles="$tmpdir/modfiles"
make -s -C "$srcdir" tools/ccan_depends tools/modfiles
[ $? -eq 0 ] || exit 1 [ $? -eq 0 ] || exit 1
cp "$srcdir/tools/ccan_depends" "$ccan_depends" cp "$srcdir/tools/ccan_depends" "$ccan_depends"
cp "$srcdir/tools/modfiles" "$modfiles"
echo "Cleaning source tree" echo "Cleaning source tree"
make -s -C "$srcdir" clean make -s -C "$srcdir" clean
...@@ -103,18 +105,14 @@ copy_ccan_module() { ...@@ -103,18 +105,14 @@ copy_ccan_module() {
module_srcdir="$srcdir/$module_dir" module_srcdir="$srcdir/$module_dir"
module_destdir="$tmpdir/$module_dir" module_destdir="$tmpdir/$module_dir"
if [ -n "$copy_all" ] mkdir -p "$module_destdir"
then # Copy license
# bulk copy license="$module_srcdir/LICENSE"
mkdir -p "$(dirname "$module_destdir")" [ -e "$license" ] && cp -a "$license" "$module_destdir"
cp -a "$module_srcdir" "$module_destdir" for f in $("$modfiles" $MODULES_ARGS --no-license --git-only "$module_dir"); do
else mkdir -p $(dirname "$module_destdir"/"$f")
mkdir -p "$module_destdir" cp "$module_srcdir"/$f "$module_destdir"/$f
# only copy sources & license done
license="$module_srcdir/LICENSE"
cp -a "$module_srcdir"/*.[ch] "$module_destdir"
[ -e "$license" ] && cp -a "$license" "$module_destdir"
fi
} }
# generate list of directories to copy # generate list of directories to copy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment