Commit 70a438e8 authored by Jeremy Kerr's avatar Jeremy Kerr

tools/create-ccan-tree: replace --exclude-tests with --copy-all option

Rather than explicitly excluding the tests, just copy the source files
by default. Add an option (--copy-all) to include all of the non-source
stuff in each module.
Signed-off-by: default avatarJeremy Kerr <jeremy.kerr@canonical.com>
parent 465655bb
...@@ -7,18 +7,18 @@ usage() { ...@@ -7,18 +7,18 @@ usage() {
Usage: $progname [options] <outdir> <depends>... Usage: $progname [options] <outdir> <depends>...
options: options:
-t, --exclude-tests exclude test/ directories from ccan modules -a, --copy-all copy all files in module tree (not just
sources required for build)
-c, --exclude-configurator exclude configurator. config.h must be -c, --exclude-configurator exclude configurator. config.h must be
supplied by another method (eg, autotools) supplied by another method (eg, autotools)
EOF EOF
} }
# parse options, setting the following flags # parse options, setting the following flags
exclude_tests= copy_all=
exclude_configurator= exclude_configurator=
opts=$(getopt -o tc --long exclude-tests,exclude-configurator -n $progname \ opts=$(getopt -o ac --long copy-all,exclude-configurator -n $progname -- "$@")
-- "$@")
if [ $? != 0 ] if [ $? != 0 ]
then then
...@@ -31,8 +31,8 @@ eval set -- "$opts" ...@@ -31,8 +31,8 @@ eval set -- "$opts"
while : while :
do do
case "$1" in case "$1" in
-t|--exclude-tests) -a|--copy-all)
exclude_tests=1 copy_all=1
shift shift
;; ;;
-c|--exclude-configurator) -c|--exclude-configurator)
...@@ -89,6 +89,25 @@ make -s -C "$srcdir" clean ...@@ -89,6 +89,25 @@ make -s -C "$srcdir" clean
# clean up on error # clean up on error
trap 'rm -rf $tmpdir' EXIT trap 'rm -rf $tmpdir' EXIT
copy_ccan_module() {
module_dir="$1"
module_srcdir="$srcdir/$module_dir"
module_destdir="$tmpdir/$module_dir"
if [ -n "$copy_all" ]
then
# bulk copy
mkdir -p "$(dirname "$module_destdir")"
cp -a "$module_srcdir" "$module_destdir"
else
mkdir -p "$module_destdir"
# only copy sources & license
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
for module in $modules for module in $modules
do do
...@@ -110,15 +129,8 @@ done | ...@@ -110,15 +129,8 @@ done |
sort -u | sort -u |
while read dir while read dir
do do
module_srcdir="$srcdir/$dir"
module_destdir="$tmpdir/$dir"
echo "Adding $dir" echo "Adding $dir"
mkdir -p "$(dirname "$module_destdir")" copy_ccan_module $dir
cp -a "$module_srcdir" "$module_destdir"
if [ -n "$exclude_tests" ]
then
rm -rf "$module_destdir/test"
fi
done done
# we're done with the dependency-tracking, remove the tool from our # we're done with the dependency-tracking, remove the tool from our
......
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