summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/clang-format-diff.sh28
-rwxr-xr-xscripts/clang-tidy-diff.sh28
-rwxr-xr-xscripts/travis-emcc-tests.sh16
3 files changed, 72 insertions, 0 deletions
diff --git a/scripts/clang-format-diff.sh b/scripts/clang-format-diff.sh
new file mode 100755
index 000000000..2525259e9
--- /dev/null
+++ b/scripts/clang-format-diff.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+set -o errexit
+
+# When we are running on travis and *not* part of a pull request we don't
+# have any upstream branch to compare against.
+if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
+ echo "Skipping since not running on travis PR"
+ exit 0
+fi
+
+if [ -n "$TRAVIS_BRANCH" ]; then
+ BRANCH=$TRAVIS_BRANCH
+else
+ BRANCH=origin/master
+fi
+
+MERGE_BASE=$(git merge-base $BRANCH HEAD)
+FORMAT_MSG=$(git clang-format $MERGE_BASE -q --diff -- src/)
+if [ -n "$FORMAT_MSG" -a "$FORMAT_MSG" != "no modified files to format" ]
+then
+ echo "Please run git clang-format before committing, or apply this diff:"
+ echo
+ # Run git clang-format again, this time without capruting stdout. This way
+ # clang-format format the message nicely and add color.
+ git clang-format $MERGE_BASE -q --diff -- src/
+ exit 1
+fi
diff --git a/scripts/clang-tidy-diff.sh b/scripts/clang-tidy-diff.sh
new file mode 100755
index 000000000..5f3495504
--- /dev/null
+++ b/scripts/clang-tidy-diff.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+set -o errexit
+
+# When we are running on travis and *not* part of a pull request we don't
+# have any upstream branch to compare against.
+if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
+ echo "Skipping since not running on travis PR"
+ exit 0
+fi
+
+if [ -n "$TRAVIS_BRANCH" ]; then
+ BRANCH=$TRAVIS_BRANCH
+else
+ BRANCH=origin/master
+fi
+
+CLANG_DIR=$(dirname $(dirname $(which clang-tidy)))
+CLANG_TIDY_DIFF=$CLANG_DIR/share/clang/clang-tidy-diff.py
+TIDY_MSG=$(git diff -U0 $BRANCH... | $CLANG_TIDY_DIFF -quiet -p1 2> /dev/null)
+if [ -n "$TIDY_MSG" -a "$TIDY_MSG" != "No relevant changes found." ]
+then
+ echo "Please fix clang-tidy errors before committing"
+ echo
+ # Run clang-tidy once again to show the error
+ git diff -U0 $BRANCH... | $CLANG_TIDY_DIFF -quiet -p1 2> /dev/null
+ exit 1
+fi
diff --git a/scripts/travis-emcc-tests.sh b/scripts/travis-emcc-tests.sh
new file mode 100755
index 000000000..ac10118f8
--- /dev/null
+++ b/scripts/travis-emcc-tests.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+set -e
+
+echo "travis-test build:wasm"
+emcmake cmake -DCMAKE_BUILD_TYPE=Release
+emmake make -j4 binaryen_wasm
+echo "travis-test test:wasm"
+python3 -m scripts.test.binaryenjs wasm
+echo "travis-test done:wasm"
+
+echo "travis-test build:js"
+emmake make -j4 binaryen_js
+echo "travis-test test:js"
+python3 -m scripts.test.binaryenjs js
+echo "travis-test done:js"