-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd181ea
commit 4450719
Showing
5 changed files
with
234 additions
and
28 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,97 @@ | ||
#!/usr/bin/env bash | ||
|
||
# pro user tip (because this repository shares the same structure as in libjade); assumes libjade is next to formosa-25519 | ||
# | ||
# ./scripts/releaser/extract-libjade --list-implementations | while read implementation; do ./scripts/releaser/extract-libjade --gen-implementation $implementation ../libjade/$(realpath --relative-to="$(pwd)" $implementation); done | ||
# | ||
|
||
call=$0 | ||
script_dir=$(cd "$(dirname "$0")" ; pwd -P) | ||
top_dir=$(cd "$(dirname "$0")/../../" ; pwd -P) | ||
|
||
print_usage() | ||
{ | ||
echo "usage:" | ||
echo " $ $call --list-implementations" | ||
echo " $ $call --gen-implementation IMPLEMENTATION DIRECTORY" | ||
} | ||
|
||
# if there are no arguments, print usage | ||
if [ $# -eq 0 ]; then | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
# check if --list-implementations | ||
if [ "$1" == "--list-implementations" ]; then | ||
make --no-print-directory -C $top_dir/src print-available-implementations | ||
exit 1 | ||
fi | ||
|
||
# check if --gen-implementation | ||
if [ "$1" == "--gen-implementation" ]; then | ||
# if we are generating an implementation then there should be 3 args | ||
if [ $# -eq 3 ]; then | ||
|
||
# start by realpath them (useful to run make) | ||
implementation=$(realpath $2) | ||
directory=$(realpath $3) | ||
|
||
# test if IMPLEMENTATION directory exists | ||
if [ ! -d "$implementation" ]; then | ||
echo " IMPLEMENTATION: $implementation does not exist." | ||
exit 1; | ||
fi | ||
|
||
# test if libjade DIRECTORY exists | ||
if [ ! -d "$directory" ]; then | ||
echo " DIRECTORY: $directory does not exist." | ||
exit 1; | ||
fi | ||
|
||
relative_implementation=$(realpath --relative-to="$top_dir/src" "$implementation") | ||
make --no-print-directory -C $top_dir/src/ $relative_implementation/preprocess-inplace | ||
|
||
############################################################################# | ||
# copy the preprocessed files | ||
|
||
jazz_files=$(find $implementation -name '*.jazz') | ||
for file in $jazz_files; do | ||
cp $file $directory/ | ||
done | ||
|
||
# setup the Makefile | ||
echo -n "SRCS := " > $directory/Makefile | ||
for file in $jazz_files; do | ||
echo -n $(basename $file) >> $directory/Makefile | ||
done | ||
echo "" >> $directory/Makefile | ||
|
||
# NOTE: the following line will need change (or be deleted) once multi-repo libjade is stable | ||
echo "include ../../../../Makefile.common" >> $directory/Makefile | ||
|
||
# NOTE: the following command will change once there is a PR in libjade to move api.h files out of include/ directories | ||
cp $implementation/include/api.h $directory/include/api.h | ||
|
||
# | ||
############################################################################# | ||
|
||
# restore implementation state | ||
make --no-print-directory -C $top_dir/src/ $relative_implementation/revert-preprocess-inplace | ||
|
||
exit 1; | ||
|
||
else | ||
echo "error: --gen-implementation : number of required arguments 3 : provided $#" | ||
print_usage | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# with 'good' options this should be unreachable, hence, print usage | ||
print_usage | ||
exit 1 | ||
|
||
|
||
|
||
|
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
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
Oops, something went wrong.