Squashed 'third_party/flatbuffers/' content from commit acc9990ab
Change-Id: I48550d40d78fea996ebe74e9723a5d1f910de491
git-subtree-dir: third_party/flatbuffers
git-subtree-split: acc9990abd2206491480291b0f85f925110102ea
diff --git a/.travis/build-and-run-docker-test-containers.sh b/.travis/build-and-run-docker-test-containers.sh
new file mode 100755
index 0000000..e6039bf
--- /dev/null
+++ b/.travis/build-and-run-docker-test-containers.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# Copyright 2018 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+set -e
+
+# build flatc on debian once to speed up the test loop below
+docker build -t build_flatc_debian_stretch -f tests/docker/Dockerfile.testing.build_flatc_debian_stretch .
+BUILD_CONTAINER_ID=$(docker create --read-only build_flatc_debian_stretch)
+docker cp ${BUILD_CONTAINER_ID}:/code/flatc flatc_debian_stretch
+
+for f in $(ls tests/docker/languages | sort)
+do
+ # docker pull sometimes fails for unknown reasons, probably travisci-related. this retries the pull we need a few times.
+ REQUIRED_BASE_IMAGE=$(cat tests/docker/languages/${f} | head -n 1 | awk ' { print $2 } ')
+
+ set +e
+ n=0
+ until [ $n -ge 5 ]
+ do
+ docker pull $REQUIRED_BASE_IMAGE && break
+ n=$[$n+1]
+ sleep 1
+ done
+ set -e
+
+ docker build -t $(echo ${f} | cut -f 3- -d .) -f tests/docker/languages/${f} .
+ echo "TEST OK: ${f}"
+done
diff --git a/.travis/check-generate-code.sh b/.travis/check-generate-code.sh
new file mode 100755
index 0000000..37d81bb
--- /dev/null
+++ b/.travis/check-generate-code.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# Copyright 2018 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+set -e
+
+cd tests
+./generate_code.sh
+cd ..
+
+# TODO: Linux and macos builds produce differences here for some reason.
+git checkout HEAD -- tests/monster_test.bfbs
+git checkout HEAD -- tests/arrays_test.bfbs
+
+if ! git diff --quiet; then
+ echo >&2
+ echo "ERROR: ********************************************************" >&2
+ echo "ERROR: The following differences were found after running the" >&2
+ echo "ERROR: tests/generate_code.sh script. Maybe you forgot to run" >&2
+ echo "ERROR: it after making changes in a generator or schema?" >&2
+ echo "ERROR: ********************************************************" >&2
+ echo >&2
+ git diff --binary --exit-code
+fi
diff --git a/.travis/check-sources.sh b/.travis/check-sources.sh
new file mode 100644
index 0000000..3e6dbf1
--- /dev/null
+++ b/.travis/check-sources.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Copyright 2018 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+set -e
+
+if [ -n "$1" ]; then
+ scan_dir="$1"
+else
+ scan_dir="$( pwd )"
+fi
+
+py_checker="$0.py"
+
+echo "scan root directory = '$scan_dir'"
+python3 --version
+# Scan recursively and search all *.cpp and *.h files using regex patterns.
+# Assume that script running from a root of Flatbuffers working dir.
+python3 $py_checker "ascii" "$scan_dir/include" "\.h$"
+python3 $py_checker "ascii" "$scan_dir/src" "\.cpp$"
+python3 $py_checker "ascii" "$scan_dir/tests" "\.h$"
+python3 $py_checker "utf-8" "$scan_dir/tests" "\.cpp$"
diff --git a/.travis/check-sources.sh.py b/.travis/check-sources.sh.py
new file mode 100644
index 0000000..2b001d7
--- /dev/null
+++ b/.travis/check-sources.sh.py
@@ -0,0 +1,35 @@
+import os
+import re
+import sys
+
+def check_encoding(encoding, scan_dir, regex_pattern):
+ fname = None
+ try:
+ assert encoding in ['ascii', 'utf-8'], "unexpected encoding"
+ cmp = re.compile(regex_pattern)
+ for root, dirs, files in os.walk(scan_dir):
+ fname = root
+ cmp_list = [f for f in files if cmp.search(f) is not None]
+ for f in cmp_list:
+ fname = os.path.join(root, f)
+ with open(fname, mode='rb') as test_file:
+ btext = test_file.read()
+ # check encoding
+ btext.decode(encoding=encoding, errors="strict")
+ if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'):
+ raise ValueError("unexpected BOM in file")
+ # check LF line endings
+ LF = btext.count(b'\n')
+ CR = btext.count(b'\r')
+ if CR!=0:
+ raise ValueError("invalid line endings: LF({})/CR({})".format(LF, CR))
+ except Exception as err:
+ print("ERROR with [{}]: {}".format(fname, err))
+ return -1
+ else:
+ return 0
+
+if __name__ == "__main__":
+ # python check-sources.sh.py 'ascii' '.' '.*\.(cpp|h)$'
+ res = check_encoding(sys.argv[1], sys.argv[2], sys.argv[3])
+ sys.exit(0 if res == 0 else -1)
diff --git a/.travis/deploy-python.sh b/.travis/deploy-python.sh
new file mode 100755
index 0000000..4cc0346
--- /dev/null
+++ b/.travis/deploy-python.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+PROD_REPOSITORY="https://upload.pypi.org/legacy/"
+TEST_REPOSITORY="https://test.pypi.org/legacy/"
+
+twine upload \
+ --username "$PYPI_USERNAME" \
+ --password "$PYPI_PASSWORD" \
+ --repository-url "$PROD_REPOSITORY" \
+ "$DIR/../python/dist/"*
+