Skip to content

Commit

Permalink
c-parser: handle sed backup files uniformly in mkrelease
Browse files Browse the repository at this point in the history
mkrelease was trying to distinguish BSD and GNU sed command line
options, but was using shell substitution incorrectly. Instead, use
backup files for both versions, and then manually remove the backup file
afterwards.

Signed-off-by: Gerwin Klein <[email protected]>
  • Loading branch information
lsf37 committed Oct 10, 2024
1 parent 6122e24 commit 4f1563a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/c-parser/mkrelease
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
set -e

case $(uname) in
Darwin* ) TAR=gtar ; SEDIOPT="-i ''" ;;
* ) TAR=tar ; SEDIOPT=-i ;;
Darwin* ) TAR=gtar ;;
* ) TAR=tar ;;
esac


Expand Down Expand Up @@ -145,18 +145,20 @@ echo "Hacking Makefile to remove ROOT generation."
if ! grep -q '^testfiles/\$(L4V_ARCH)/ROOT' "$outputdir/src/c-parser/Makefile"; then
die "failed to process c-parser/Makefile"
fi
sed $SEDIOPT \
sed -i .bak \
-e '/^testfiles\/\$(L4V_ARCH)\/ROOT/,/CParserTest/d' \
-e '/^all_tests_\$(L4V_ARCH)\.thy/,/CParser/d' \
"$outputdir/src/c-parser/Makefile"
rm -f "$outputdir/src/c-parser/Makefile.bak"

echo "Hacking Makefile to change root dir."
if ! grep -q '^L4V_ROOT_DIR = ' "$outputdir/src/c-parser/Makefile"; then
die "failed to process c-parser/Makefile"
fi
sed $SEDIOPT \
sed -i .bak \
-e 's/^L4V_ROOT_DIR = .*$/L4V_ROOT_DIR = ../' \
"$outputdir/src/c-parser/Makefile"
rm -f "$outputdir/src/c-parser/Makefile.bak"

echo "Generating standalone-parser/table.ML"
pushd "$TOPLEVEL_DIR/tools/c-parser" > /dev/null
Expand All @@ -177,7 +179,7 @@ popd > /dev/null
echo "Making PDF of ctranslation file."
cd "$outputdir/src/c-parser/doc"
make ctranslation.pdf > /dev/null
/bin/rm ctranslation.{log,aux,blg,bbl,toc}
/bin/rm -f ctranslation.{log,aux,blg,bbl,toc}
mv ctranslation.pdf "$outputdir/doc"

popd > /dev/null
Expand Down

0 comments on commit 4f1563a

Please sign in to comment.