8000 Use absolute instead of relative includes (fixes #1072) · joglosemarduino/ArduinoJson@fcbec6e · GitHub
[go: up one dir, main page]

Skip to content

Commit fcbec6e

Browse files
committed
Use absolute instead of relative includes (fixes bblanchon#1072)
1 parent f5c2582 commit fcbec6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+246
-206
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
ArduinoJson: change log
22
=======================
33

4+
HEAD
5+
----
6+
7+
* Use absolute instead of relative includes (issue #1072)
8+
49
v6.11.5 (2019-08-23)
510
-------
611

scripts/build-single-header.sh

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#!/bin/bash
22

3+
set -e
4+
35
TAG=$(git describe)
4-
RE_INCLUDE='^#include[[:space:]]*["<](.*)[">]'
6+
RE_RELATIVE_INCLUDE='^#include[[:space:]]*"(.*)"'
7+
RE_ABSOLUTE_INCLUDE='^#include[[:space:]]*<(ArduinoJson/.*)>'
8+
RE_SYSTEM_INCLUDE='^#include[[:space:]]*<(.*)>'
59
RE_EMPTY='^(#pragma[[:space:]]+once)?[[:space:]]*(//.*)?$'
10+
SRC_DIRECTORY="$(realpath "$(dirname $0)/../src")"
11+
612

713
declare -A INCLUDED
814

@@ -12,23 +18,33 @@ process()
1218
local FOLDER=$(dirname $1)
1319
local SHOW_COM EED3 MENT=$2
1420
while IFS= read -r LINE; do
15-
if [[ $LINE =~ $RE_INCLUDE ]]; then
21+
if [[ $LINE =~ $RE_ABSOLUTE_INCLUDE ]]; then
22+
local CHILD=${BASH_REMATCH[1]}
23+
local CHILD_PATH
24+
CHILD_PATH=$(realpath "$SRC_DIRECTORY/$CHILD")
25+
echo "$PARENT -> $CHILD" >&2
26+
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
27+
INCLUDED[$CHILD_PATH]=true
28+
process "$CHILD" false
29+
fi
30+
elif [[ $LINE =~ $RE_RELATIVE_INCLUDE ]]; then
1631
local CHILD=${BASH_REMATCH[1]}
1732
pushd "$FOLDER" > /dev/null
18-
if [[ -e $CHILD ]]; then
19-
local CHILD_PATH=$(realpath $CHILD)
20-
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
21-
#echo "// $PARENT -> $CHILD"
22-
INCLUDED[$CHILD_PATH]=true
23-
process "$CHILD" false
24-
fi
25-
else
26-
if [[ ! ${INCLUDED[$CHILD]} ]]; then
27-
echo "$LINE"
28-
INCLUDED[$CHILD]=true
29-
fi
33+
local CHILD_PATH
34+
CHILD_PATH=$(realpath "$CHILD")
35+
echo "$PARENT -> $CHILD" >&2
36+
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
37+
INCLUDED[$CHILD_PATH]=true
38+
process "$CHILD" false
3039
fi
3140
popd > /dev/null
41+
elif [[ $LINE =~ $RE_SYSTEM_INCLUDE ]]; then
42+
local CHILD=${BASH_REMATCH[1]}
43+
echo "$PARENT -> <$CHILD>" >&2
44+
if [[ ! ${INCLUDED[$CHILD]} ]]; then
45+
echo "#include <$CHILD>"
46+
INCLUDED[$CHILD]=true
47+
fi
3248
elif [[ "${SHOW_COMMENT}" = "true" ]] ; then
3349
echo "$LINE"
3450
elif [[ ! $LINE =~ $RE_EMPTY ]]; then
@@ -37,17 +53,29 @@ process()
3753
done < $PARENT
3854
}
3955

56+
simplify_namespaces() {
57+
perl -p0i -e 's|\} // namespace ARDUINOJSON_NAMESPACE\r?\nnamespace ARDUINOJSON_NAMESPACE \{\r?\n||igs' "$1"
58+
}
59+
4060
cd $(dirname $0)/../
4161
INCLUDED=()
4262
process src/ArduinoJson.h true > ../ArduinoJson-$TAG.h
63+
simplify_namespaces ../ArduinoJson-$TAG.h
4364
g++ -x c++ -c -o ../smoketest.o - <<END
4465
#include "../ArduinoJson-$TAG.h"
45-
int main() {}
66+
int main() {
67+
StaticJsonDocument<300> doc;
68+
deserializeJson(doc, "{}");
69+
}
4670
END
4771

4872
INCLUDED=()
4973
process src/ArduinoJson.hpp true > ../ArduinoJson-$TAG.hpp
74+
simplify_namespaces ../ArduinoJson-$TAG.hpp
5075
g++ -x c++ -c -o ../smoketest.o - <<END
5176
#include "../ArduinoJson-$TAG.hpp"
52-
int main() {}
53-
END
77+
int main() {
78+
ArduinoJson::StaticJsonDocument<300> doc;
79+
ArduinoJson::deserializeJson(doc, "{}");
80+
}
81+
END

src/ArduinoJson/Array/ArrayFunctions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "../Collection/CollectionData.hpp"
7+
#include <ArduinoJson/Collection/CollectionData.hpp>
88

99
namespace ARDUINOJSON_NAMESPACE {
1010

src/ArduinoJson/Array/ArrayImpl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#pragma once
66

7-
#include "../Object/ObjectRef.hpp"
8-
#include "ArrayRef.hpp"
7+
#include <ArduinoJson/Array/ArrayRef.hpp>
8+
#include <ArduinoJson/Object/ObjectRef.hpp>
99

1010
namespace ARDUINOJSON_NAMESPACE {
1111

src/ArduinoJson/Array/ArrayIterator.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#pragma once
66

7-
#include "../Variant/SlotFunctions.hpp"
8-
#include "../Variant/VariantRef.hpp"
7+
#include <ArduinoJson/Variant/SlotFunctions.hpp>
8+
#include <ArduinoJson/Variant/VariantRef.hpp>
99

1010
namespace ARDUINOJSON_NAMESPACE {
1111

src/ArduinoJson/Array/ArrayRef.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#pragma once
66

7-
#include "../Variant/VariantData.hpp"
8-
#include "ArrayFunctions.hpp"
9-
#include "ArrayIterator.hpp"
7+
#include <ArduinoJson/Array/ArrayFunctions.hpp>
8+
#include <ArduinoJson/Array/ArrayIterator.hpp>
9+
#include <ArduinoJson/Variant/VariantData.hpp>
1010

1111
// Returns the size (in bytes) of an array with n elements.
1212
// Can be very handy to determine the size of a StaticMemoryPool.

src/ArduinoJson/Array/ArrayShortcuts.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#pragma once
66

7-
#include "../Polyfills/attributes.hpp"
8-
#include "../Polyfills/type_traits.hpp"
7+
#include <ArduinoJson/Polyfills/attributes.hpp>
8+
#include <ArduinoJson/Polyfills/type_traits.hpp>
99

1010
namespace ARDUINOJSON_NAMESPACE {
1111
// Forward declarations.

src/ArduinoJson/Array/ElementProxy.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
#pragma once
66

7-
#include "../Configuration.hpp"
8-
#include "../Operators/VariantOperators.hpp"
7+
#include <ArduinoJson/Configuration.hpp>
8+
#include <ArduinoJson/Operators/VariantOperators.hpp>
9+
#include <ArduinoJson/Variant/VariantTo.hpp>
910

1011
#ifdef _MSC_VER
1112
#pragma warning(push)

src/ArduinoJson/Array/Utilities.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "ArrayRef.hpp"
7+
#include <ArduinoJson/Array/ArrayRef.hpp>
88

99
namespace ARDUINOJSON_NAMESPACE {
1010

src/ArduinoJson/Collection/CollectionData.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include <stddef.h> // size_t
8+
79
namespace ARDUINOJSON_NAMESPACE {
810

911
class MemoryPool;

src/ArduinoJson/Collection/CollectionImpl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#pragma once
66

7-
#include "../Variant/VariantData.hpp"
8-
#include "CollectionData.hpp"
7+
#include <ArduinoJson/Collection/CollectionData.hpp>
8+
#include <ArduinoJson/Variant/VariantData.hpp>
99

1010
namespace ARDUINOJSON_NAMESPACE {
1111

src/ArduinoJson/Deserialization/NestingLimit.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "../Configuration.hpp"
7+
#include <ArduinoJson/Configuration.hpp>
88

99
namespace ARDUINOJSON_NAMESPACE {
1010

src/ArduinoJson/Deserialization/deserialize.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
#pragma once
66

7-
#include "../StringStorage/StringStorage.hpp"
8-
#include "ArduinoStreamReader.hpp"
9-
#include "CharPointerReader.hpp"
10-
#include "DeserializationError.hpp"
11-
#include "FlashStringReader.hpp"
12-
#include "IteratorReader.hpp"
13-
#include "NestingLimit.hpp"
14-
#include "StdStreamReader.hpp"
7+
#include <ArduinoJson/Deserialization/ArduinoStreamReader.hpp>
8+
#include <ArduinoJson/Deserialization/CharPointerReader.hpp>
9+
#include <ArduinoJson/Deserialization/DeserializationError.hpp>
10+
#include <ArduinoJson/Deserialization/FlashStringReader.hpp>
11+
#include <ArduinoJson/Deserialization/IteratorReader.hpp>
12+
#include <ArduinoJson/Deserialization/NestingLimit.hpp>
13+
#include <ArduinoJson/Deserialization/StdStreamReader.hpp>
14+
#include <ArduinoJson/StringStorage/StringStorage.hpp>
1515

1616
namespace ARDUINOJSON_NAMESPACE {
1717

src/ArduinoJson/Document/BasicJsonDocument.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "JsonDocument.hpp"
7+
#include <ArduinoJson/Document/JsonDocument.hpp>
88

99
namespace ARDUINOJSON_NAMESPACE {
1010

src/ArduinoJson/Document/DynamicJsonDocument.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "BasicJsonDocument.hpp"
7+
#include <ArduinoJson/Document/BasicJsonDocument.hpp>
88

99
#include <stdlib.h> // malloc, free
1010

src/ArduinoJson/Document/JsonDocument.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
#pragma once
66

7-
#include "../Memory/MemoryPool.hpp"
8-
#include "../Object/ObjectRef.hpp"
9-
#include "../Variant/VariantRef.hpp"
10-
#include "../Variant/VariantTo.hpp"
11-
12-
#include "../Array/ElementProxy.hpp"
13-
#include "../Object/MemberProxy.hpp"
7+
#include <ArduinoJson/Array/ElementProxy.hpp>
8+
#include <ArduinoJson/Memory/MemoryPool.hpp>
9+
#include <ArduinoJson/Object/MemberProxy.hpp>
10+
#include <ArduinoJson/Object/ObjectRef.hpp>
11+
#include <ArduinoJson/Variant/VariantRef.hpp>
12+
#include <ArduinoJson/Variant/VariantTo.hpp>
1413

1514
namespace ARDUINOJSON_NAMESPACE {
1615

src/ArduinoJson/Document/StaticJsonDocument.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "JsonDocument.hpp"
7+
#include <ArduinoJson/Document/JsonDocument.hpp>
88

99
namespace ARDUINOJSON_NAMESPACE {
1010

src/ArduinoJson/Json/JsonDeserializer.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
#pragma once
66

7-
#include "../Deserialization/deserialize.hpp"
8-
#include "../Memory/MemoryPool.hpp"
9-
#include "../Numbers/parseNumber.hpp"
10-
#include "../Polyfills/type_traits.hpp"
11-
#include "../Variant/VariantData.hpp"
12-
#include "EscapeSequence.hpp"
13-
#include "Utf8.hpp"
7+
#include <ArduinoJson/Deserialization/deserialize.hpp>
8+
#include <ArduinoJson/Json/EscapeSequence.hpp>
9+
#include <ArduinoJson/Json/Utf8.hpp>
10+
#include <ArduinoJson/Memory/MemoryPool.hpp>
11+
#include <ArduinoJson/Numbers/parseNumber.hpp>
12+
#include <ArduinoJson/Polyfills/type_traits.hpp>
13+
#include <ArduinoJson/Variant/VariantData.hpp>
1414

1515
namespace ARDUINOJSON_NAMESPACE {
1616

src/ArduinoJson/Json/JsonSerializer.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
#pragma once
66

7-
#include "../Misc/Visitable.hpp"
8-
#include "../Serialization/measure.hpp"
9-
#include "../Serialization/serialize.hpp"< 10000 /span>
10-
#include "TextFormatter.hpp"
7+
#include <ArduinoJson/Json/TextFormatter.hpp>
8+
#include <ArduinoJson/Misc/Visitable.hpp>
9+
#include <ArduinoJson/Serialization/measure.hpp>
10+
#include <ArduinoJson/Serialization/serialize.hpp>
1111

1212
namespace ARDUINOJSON_NAMESPACE {
1313

src/ArduinoJson/Json/PrettyJsonSerializer.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
#pragma once
66

7-
#include "../Configuration.hpp"
8-
#include "../Serialization/measure.hpp"
9-
#include "../Serialization/serialize.hpp"
10-
#include "JsonSerializer.hpp"
7+
#include <ArduinoJson/Configuration.hpp>
8+
#include <ArduinoJson/Json/JsonSerializer.hpp>
9+
#include <ArduinoJson/Serialization/measure.hpp>
10+
#include <ArduinoJson/Serialization/serialize.hpp>
1111

1212
namespace ARDUINOJSON_NAMESPACE {
1313

src/ArduinoJson/Json/TextFormatter.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
#include <stdint.h>
88
#include <string.h> // for strlen
9-
#include "../Numbers/FloatParts.hpp"
10-
#include "../Numbers/Integer.hpp"
11-
#include "../Polyfills/attributes.hpp"
12-
#include "EscapeSequence.hpp"
9+
10+
#include <ArduinoJson/Json/EscapeSequence.hpp>
11+
#include <ArduinoJson/Numbers/FloatParts.hpp>
12+
#include <ArduinoJson/Numbers/Integer.hpp>
13+
#include <ArduinoJson/Polyfills/attributes.hpp>
1314

1415
namespace ARDUINOJSON_NAMESPACE {
1516

src/ArduinoJson/Memory/MemoryPool.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
#pragma once
66

7-
#include "../Polyfills/assert.hpp"
8-
#include "../Polyfills/mpl/max.hpp"
9-
#include "../Variant/VariantSlot.hpp"
10-
#include "Alignment.hpp"
11-
#include "MemoryPool.hpp"
12-
#include "StringSlot.hpp"
7+
#include <ArduinoJson/Memory/Alignment.hpp>
8+
#include <ArduinoJson/Memory/StringSlot.hpp>
9+
#include <ArduinoJson/Polyfills/assert.hpp>
10+
#include <ArduinoJson/Polyfills/mpl/max.hpp>
11+
#include <ArduinoJson/Variant/VariantSlot.hpp>
1312

1413
namespace ARDUINOJSON_NAMESPACE {
1514

src/ArduinoJson/Memory/StringBuilder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "MemoryPool.hpp"
7+
#include <ArduinoJson/Memory/MemoryPool.hpp>
88

99
namespace ARDUINOJSON_NAMESPACE {
1010

src/ArduinoJson/Memory/StringSlot.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#pragma once
66

77
#include <stddef.h> // for size_t
8-
#include "../Configuration.hpp"
8+
9+
#include <ArduinoJson/Configuration.hpp>
910

1011
#define JSON_STRING_SIZE(SIZE) (SIZE)
1112

src/ArduinoJson/Misc/SerializedValue.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "../Strings/StringAdapters.hpp"
7+
#include <ArduinoJson/Strings/StringAdapters.hpp>
88

99
namespace ARDUINOJSON_NAMESPACE {
1010

0 commit comments

Comments
 (0)
0