From 035b37c2d239d6f28a6834395c2f2a9a5c721b01 Mon Sep 17 00:00:00 2001 From: Stephan Schulz <stephan.schulz-x2q@rub.de> Date: Fri, 22 Jan 2021 16:02:04 +0100 Subject: [PATCH] add preprocess tool to apply definitions (and includes) --- misc/preprocess.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 misc/preprocess.sh diff --git a/misc/preprocess.sh b/misc/preprocess.sh new file mode 100755 index 0000000..1a6c4ce --- /dev/null +++ b/misc/preprocess.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Usage: +# $1: path to include directory +# $2..: additional flags to gcc + +# Either run this script in the include directory, or pass the include +# directory as an additional argument ($1). + +set -euo pipefail + +#set -x + +HEADERS="ALL_CustomExceptions.hpp +ALL_Defines.h +ALL_ForceBased.hpp +ALL_Functions.hpp +ALL_Histogram.hpp +ALL.hpp +ALL_LB.hpp +ALL_Point.hpp +ALL_Staggered.hpp +ALL_Tensor.hpp +ALL_Voronoi.hpp" + +PROCESSED_DIR=`mktemp -d` + +CWD="$1" +shift + + +for f in $HEADERS +do + cat $f | sed -e 's!#\s*include\s*<!// PPIGNORE <!' > "$PROCESSED_DIR/$f" +done + +cd "$PROCESSED_DIR" + +gcc -E -fdirectives-only "$@" -o ALL.ii ALL.hpp + +cat ALL.ii | sed -e 's!// PPIGNORE <!#include <!' > "$CWD/ALL_pp.hpp" + +rm -rf $PROCESSED_DIR -- GitLab