CMake/Utilities/Scripts/regenerate-lexers.bash
Joerg Bornemann f8c505d4b3 Add a parser for GCC-style depfiles
Introduce the function cmReadGccDepfile that parses a GCC-style depfile
and returns its content. The implementation uses a lexer that is
modeled after the re2c implementation in Ninja.

The sample files of the autotest have been created with gcc 8.3.0.

This depfile reader is to be used by the Autogen facility to make use
of the depfiles that are generated by Qt's meta object compiler.
2020-01-28 11:16:11 -05:00

55 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
forced=1
if [[ "${1}" = "make" ]]; then
forced=0
fi
pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null
for lexer in \
CommandArgument \
CTestResourceGroups \
DependsJava \
Expr \
Fortran \
GccDepfile
do
cxx_file=cm${lexer}Lexer.cxx
h_file=cm${lexer}Lexer.h
in_file=cm${lexer}Lexer.in.l
if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then
echo "Generating Lexer ${lexer}"
flex --nounistd -DFLEXINT_H --noline --header-file=${h_file} -o${cxx_file} ${in_file}
sed -i 's/\s*$//' ${h_file} ${cxx_file} # remove trailing whitespaces
sed -i '${/^$/d;}' ${h_file} ${cxx_file} # remove blank line at the end
sed -i '1i#include "cmStandardLexer.h"' ${cxx_file} # add cmStandardLexer.h include
else
echo "Skipped generating Lexer ${lexer}"
fi
done
# these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header
for lexer in ListFile
do
c_file=cm${lexer}Lexer.c
in_file=cm${lexer}Lexer.in.l
if [[ (${in_file} -nt ${c_file}) || (${forced} -gt 0) ]]; then
echo "Generating Lexer ${lexer}"
flex --nounistd -DFLEXINT_H --noline -o${c_file} ${in_file}
sed -i 's/\s*$//' ${c_file} # remove trailing whitespaces
sed -i '${/^$/d;}' ${c_file} # remove blank line at the end
sed -i '1i#include "cmStandardLexer.h"' ${c_file} # add cmStandardLexer.h include
else
echo "Skipped generating Lexer ${lexer}"
fi
done
popd > /dev/null