2017-03-25 21:56:37 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-08-26 11:57:57 +02:00
|
|
|
set -e
|
|
|
|
|
2017-03-25 21:56:37 +01:00
|
|
|
TAG=$(git describe)
|
2019-08-26 11:57:57 +02:00
|
|
|
RE_RELATIVE_INCLUDE='^#include[[:space:]]*"(.*)"'
|
|
|
|
RE_ABSOLUTE_INCLUDE='^#include[[:space:]]*<(ArduinoJson/.*)>'
|
|
|
|
RE_SYSTEM_INCLUDE='^#include[[:space:]]*<(.*)>'
|
2017-03-25 21:56:37 +01:00
|
|
|
RE_EMPTY='^(#pragma[[:space:]]+once)?[[:space:]]*(//.*)?$'
|
2019-09-03 15:11:05 +02:00
|
|
|
SRC_DIRECTORY="$(realpath "$(dirname $0)/../../src")"
|
2019-08-26 11:57:57 +02:00
|
|
|
|
2017-03-25 21:56:37 +01:00
|
|
|
|
|
|
|
declare -A INCLUDED
|
|
|
|
|
|
|
|
process()
|
|
|
|
{
|
|
|
|
local PARENT=$1
|
|
|
|
local FOLDER=$(dirname $1)
|
|
|
|
local SHOW_COMMENT=$2
|
|
|
|
while IFS= read -r LINE; do
|
2019-08-26 11:57:57 +02:00
|
|
|
if [[ $LINE =~ $RE_ABSOLUTE_INCLUDE ]]; then
|
|
|
|
local CHILD=${BASH_REMATCH[1]}
|
|
|
|
local CHILD_PATH
|
|
|
|
CHILD_PATH=$(realpath "$SRC_DIRECTORY/$CHILD")
|
|
|
|
echo "$PARENT -> $CHILD" >&2
|
|
|
|
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
|
|
|
|
INCLUDED[$CHILD_PATH]=true
|
|
|
|
process "$CHILD" false
|
|
|
|
fi
|
|
|
|
elif [[ $LINE =~ $RE_RELATIVE_INCLUDE ]]; then
|
2017-03-25 21:56:37 +01:00
|
|
|
local CHILD=${BASH_REMATCH[1]}
|
|
|
|
pushd "$FOLDER" > /dev/null
|
2019-08-26 11:57:57 +02:00
|
|
|
local CHILD_PATH
|
|
|
|
CHILD_PATH=$(realpath "$CHILD")
|
|
|
|
echo "$PARENT -> $CHILD" >&2
|
|
|
|
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
|
|
|
|
INCLUDED[$CHILD_PATH]=true
|
|
|
|
process "$CHILD" false
|
2017-03-25 21:56:37 +01:00
|
|
|
fi
|
|
|
|
popd > /dev/null
|
2019-08-26 11:57:57 +02:00
|
|
|
elif [[ $LINE =~ $RE_SYSTEM_INCLUDE ]]; then
|
|
|
|
local CHILD=${BASH_REMATCH[1]}
|
|
|
|
echo "$PARENT -> <$CHILD>" >&2
|
|
|
|
if [[ ! ${INCLUDED[$CHILD]} ]]; then
|
|
|
|
echo "#include <$CHILD>"
|
|
|
|
INCLUDED[$CHILD]=true
|
|
|
|
fi
|
2017-03-25 21:56:37 +01:00
|
|
|
elif [[ "${SHOW_COMMENT}" = "true" ]] ; then
|
|
|
|
echo "$LINE"
|
|
|
|
elif [[ ! $LINE =~ $RE_EMPTY ]]; then
|
|
|
|
echo "$LINE"
|
|
|
|
fi
|
|
|
|
done < $PARENT
|
|
|
|
}
|
|
|
|
|
2019-08-26 11:57:57 +02:00
|
|
|
simplify_namespaces() {
|
|
|
|
perl -p0i -e 's|\} // namespace ARDUINOJSON_NAMESPACE\r?\nnamespace ARDUINOJSON_NAMESPACE \{\r?\n||igs' "$1"
|
|
|
|
}
|
|
|
|
|
2017-03-25 21:56:37 +01:00
|
|
|
cd $(dirname $0)/../
|
|
|
|
INCLUDED=()
|
2017-04-20 10:04:40 +02:00
|
|
|
process src/ArduinoJson.h true > ../ArduinoJson-$TAG.h
|
2019-08-26 11:57:57 +02:00
|
|
|
simplify_namespaces ../ArduinoJson-$TAG.h
|
2017-05-02 21:29:45 +02:00
|
|
|
g++ -x c++ -c -o ../smoketest.o - <<END
|
|
|
|
#include "../ArduinoJson-$TAG.h"
|
2019-08-26 11:57:57 +02:00
|
|
|
int main() {
|
|
|
|
StaticJsonDocument<300> doc;
|
|
|
|
deserializeJson(doc, "{}");
|
|
|
|
}
|
2017-05-02 21:29:45 +02:00
|
|
|
END
|
|
|
|
|
2017-03-25 21:56:37 +01:00
|
|
|
INCLUDED=()
|
2017-05-02 21:29:45 +02:00
|
|
|
process src/ArduinoJson.hpp true > ../ArduinoJson-$TAG.hpp
|
2019-08-26 11:57:57 +02:00
|
|
|
simplify_namespaces ../ArduinoJson-$TAG.hpp
|
2017-05-02 21:29:45 +02:00
|
|
|
g++ -x c++ -c -o ../smoketest.o - <<END
|
|
|
|
#include "../ArduinoJson-$TAG.hpp"
|
2019-08-26 11:57:57 +02:00
|
|
|
int main() {
|
|
|
|
ArduinoJson::StaticJsonDocument<300> doc;
|
|
|
|
ArduinoJson::deserializeJson(doc, "{}");
|
|
|
|
}
|
|
|
|
END
|