Commit ff5ce5b1 authored by Akim Demaille's avatar Akim Demaille Committed by Roland Levillain

build-aux: update tools

Import from Vaucanson.

* build-aux/bin/bison++.in: No longer "cd", this produces
more accurate error message locations, which is nice when
compiling under Emacs.
* build-aux/bin/move-if-change: Beware that colordiff
might now hang on stdin.
Signed-off-by: Roland Levillain's avatarRoland Levillain <roland@lrde.epita.fr>
parent cef56452
2012-10-17 Akim Demaille <akim@lrde.epita.fr>
build-aux: update tools
Import from Vaucanson.
* build-aux/bin/bison++.in: No longer "cd", this produces
more accurate error message locations, which is nice when
compiling under Emacs.
* build-aux/bin/move-if-change: Beware that colordiff
might now hang on stdin.
2012-02-22 Roland Levillain <roland@lrde.epita.fr>
Distribute build-aux/bin/fuse-switch.
......
#! /bin/sh
# Exit status.
status=0
# Any tool failure is a failure of the script.
set -e
: ${BISON='@BISON@'}
stderr ()
{
local i
......@@ -46,11 +41,6 @@ EOF
exit 0
}
me=$(basename $0)
fuse_switch='@abs_srcdir@/fuse-switch'
move_if_change='@abs_srcdir@/move-if-change --color'
verbose=false
## ---------------------- ##
## Command line parsing. ##
## ---------------------- ##
......@@ -88,53 +78,10 @@ get_options ()
bisonflags="$@"
}
## ------ ##
## Main. ##
## ------ ##
get_options "$@"
input_base=$(basename "$input")
input_dir=$(dirname "$input")
output_base=$(basename "$output")
output_base_noext=$(echo "$output_base" | sed -e 's/\.[^.]*//')
output_dir=$(dirname "$output")
: ${location_dir=$output_dir}
# The namespace we are in.
# FIXME: We need $srcdir to be able to compute it.
namespace=parse
if $BISON --xml --version >/dev/null 2>&1; then
bisonflags="$bisonflags --xml"
fi
# Alexandre Duret-Lutz also notes that in VPATH-builds $(srcdir) can
# be an absolute path depending on how ./configure is called ...
# In that case
# bison $(srcdir)/parsetiger.yy [...]
# will hard code the path in the maintainer's tree. Hence, do not use
# paths with Bison, chdir there.
# A tmp dir.
tmp=$output_base_noext.dir
rm -rf $tmp
mkdir $tmp
# Compile in this dir.
# Don't use `ln -s' as its semantics of paths sucks.
cp $input $tmp
cd $tmp
set +e
$BISON $bisonflags $input_base -o $output_base
status=$?
set -e
noext ()
{
echo "$1" | sed -e 's/\.[^.]*$//'
}
# fix_bison_output FILE
# ---------------------
......@@ -142,26 +89,34 @@ set -e
fix_bison_output ()
{
local file="$1"
local base
base=$(basename "$file")
local base_noext
base_noext=$(echo "$file" | sed -e 's/\..*//')
perl -pi -e "
# Fix doxygen tags.
s|\Q\\file $base\E\b|\\\\file $namespace/$base|g;
# Fix sync lines for composite paths.
s|(^#line.*)$base_noext|\$1$input_dir/$base_noext|g
if '$input_dir' ne '$output_dir';
perl -pi \
-e "
BEGIN
{
\$location_prefix = '$location_prefix';
\$namespace = '$namespace';
\$output_dir = '$output_dir';
\$tmp = '$tmp';
}" \
-e '
BEGIN
{
($TMP = uc $tmp) =~ s/[^A-Z0-9]+/_/g;
($OUTPUT_DIR = uc $output_dir) =~ s/[^A-Z0-9]+/_/g;
}
# We compiled in a tmp directory, remove references to it.
s{$tmp/}{$output_dir/}g;
s{$TMP}{$OUTPUT_DIR}g;
# In case position.hh and location.hh were moved.
s{include \"(position.hh|location.hh)\"}
{include <$location_prefix\$1>}g
if '$location_prefix' ne '';
if $location_prefix ne "";
# Kill trailing blanks.
s/[ \t]+\$//;
" "$1"
s/[ \t]+$//;
' "$file"
# Fuse the switches of the parser.
case $file in
......@@ -221,7 +176,7 @@ out ()
esac
}
# out FILE
# tmp FILE
# --------
# Return path name of FILE in the tmp directory.
tmp ()
......@@ -243,13 +198,57 @@ install ()
$move_if_change "$(tmp "$1")" "$dest"
}
# Go back to where we were and use relative paths instead of using
# absolute file names. The messages look nicer.
cd ..
## ------ ##
## Main. ##
## ------ ##
# Exit status.
status=0
: ${BISON='@BISON@'}
me=$(basename $0)
fuse_switch='@abs_srcdir@/fuse-switch'
move_if_change='@abs_srcdir@/move-if-change --color'
verbose=false
get_options "$@"
input_base=$(basename "$input")
input_dir=$(dirname "$input")
output_noext=$(noext "$output")
output_base=$(basename "$output")
output_base_noext=$(noext "$output_base")
output_dir=$(dirname "$output")
: ${location_dir=$output_dir}
# The namespace we are in.
# FIXME: We need $srcdir to be able to compute it.
namespace=parse
if $BISON --xml --version >/dev/null 2>&1; then
bisonflags="$bisonflags --xml"
fi
# A tmp dir.
tmp=$output_noext.dir
rm -rf $tmp
mkdir -p $tmp
# Compile in this dir.
# Don't use `ln -s' as its semantics of paths sucks.
set +e
$BISON $bisonflags $input -o $tmp/$output_base
status=$?
set -e
for file in $tmp/*
do
test $file != "$tmp/*" ||
fatal "did not find any file in $tmp"
base=$(basename $file)
base_noext=$(echo "$base" | sed -e 's/\.[^.]*//')
case $status:$base in
(*:$input_base)
# Leave it here.
......
......@@ -32,7 +32,7 @@ do
(-c|--color)
# The Emacs shell and compilation-mode are really bad at
# displaying colors.
if (colordiff --version) >/dev/null 2>&1 \
if (colordiff /dev/null /dev/null) >/dev/null 2>&1 \
&& test -z "$INSIDE_EMACS"; then
diff=colordiff
fi
......
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