-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tools] add source_desp_cp.sh: add a script to extract cpp and hpp fr…
…om a target
- Loading branch information
1 parent
5cb922f
commit 677fa96
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
set -o pipefail | ||
|
||
if [[ "${DEBUG:-0}" = '1' ]]; then | ||
set -x | ||
fi | ||
|
||
dest=redemption_source | ||
|
||
if (( $# == 0 )) || [[ "$1" = '-h' || "$1" = '--help' ]]; then | ||
echo "Copy .cpp and .hpp in '$dest' from a bjam target | ||
$0 targets... | ||
Ex: $0 libscytale" 2>&1 | ||
exit | ||
fi | ||
|
||
# extract hpp/cpp | ||
typeset -A dirset sources | ||
while read l ; do | ||
if [[ $l =~ ^[a-zA-Z0-9_/]+'.o: '(.*) ]]; then | ||
for f in ${BASH_REMATCH[1]}; do | ||
# check duplicate | ||
if [[ ! -v sources[$f] ]]; then | ||
sources[$f]=1 | ||
dirset[${f%/*}]+="$f " | ||
fi | ||
done | ||
fi | ||
done < <(bjam "$@" cxxflags='-MM -MF -' -a ||:) | ||
|
||
rm -r $dest | ||
|
||
# create new arbo | ||
dirs=("${!dirset[@]}") | ||
for i in "${!dirs[@]}"; do | ||
dirs[$i]=$dest/${dirs[$i]} | ||
done | ||
mkdir -p ${dirs[@]} | ||
|
||
# copy files | ||
for dir in "${!dirset[@]}"; do | ||
cp ${dirset[$dir]} $dest/$dir | ||
done |