copy script/static-checks folder from tf-a-ci-scripts

This is a complete copy of the folder [1], based on working dir
from commit [2]. Some checks DO NOT apply to TF-M project, but we
introduce the code as it is from TF-A project for completeness and
then further commits will remove/change relevant tests.

[1] https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/tree/script/static-checks
[2] https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/commit/?id=a16c8e2b37e2a8446e586f45c3e9b406496ad7b8

Change-Id: I024c30dc59caa6e635fcd43b1a30086231b29bc3
Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
diff --git a/script/static-checks/static-checks-coding-style-line-endings.sh b/script/static-checks/static-checks-coding-style-line-endings.sh
new file mode 100755
index 0000000..5442f7d
--- /dev/null
+++ b/script/static-checks/static-checks-coding-style-line-endings.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# Copyright (c) 2019, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+TEST_CASE="Line endings not valid"
+
+EXIT_VALUE=0
+
+echo "# Check Line Endings"
+
+LOG_FILE=$(mktemp -t common.XXXX)
+
+if [[ "$2" == "patch" ]]; then
+    cd "$1"
+    parent=$(git merge-base HEAD master | head -1)
+    git diff ${parent}..HEAD --no-ext-diff --unified=0 --exit-code -a --no-prefix | grep -E "^\+" | \
+    grep --files-with-matches $'\r$' &> "$LOG_FILE"
+else
+  # For all the source and doc files
+  # We only return the files that contain CRLF
+  find "." -\( \
+      -name '*.S' -or \
+      -name '*.c' -or \
+      -name '*.h' -or \
+      -name '*.i' -or \
+      -name '*.dts' -or \
+      -name '*.dtsi' -or \
+      -name '*.rst' -or \
+      -name 'Makefile' -or \
+      -name '*.mk' \
+  -\) -exec grep --files-with-matches $'\r$' {} \; &> "$LOG_FILE"
+fi
+
+if [[ -s "$LOG_FILE" ]]; then
+    EXIT_VALUE=1
+fi
+
+{ echo; echo "****** $TEST_CASE ******"; echo; } >> "$LOG_TEST_FILENAME"
+
+{ if [[ "$EXIT_VALUE" == 0 ]]; then \
+      echo "Result : SUCCESS"; \
+  else  \
+      echo "Result : FAILURE"; echo; cat "$LOG_FILE"; \
+  fi \
+} | tee -a "$LOG_TEST_FILENAME"
+
+rm "$LOG_FILE"
+
+exit "$EXIT_VALUE"