vxx / vlib / x / executor / tools / check_no_async_dependency.sh
39 lines · 32 sloc · 1.26 KB · e80386b6af8a071a2e13fd654ebcdb2105fb9202
Raw
1#!/usr/bin/env sh
2set -eu
3
4script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
5repo_root=$(CDPATH= cd "$script_dir/../../../.." && pwd)
6cd "$repo_root"
7
8target="vlib/x/executor"
9
10if [ ! -d "$target" ]; then
11 echo "$target does not exist" >&2
12 exit 1
13fi
14
15if find "$target" -type f -name '*.v' -print | xargs grep -n 'import x\.async' >/tmp/xexecutor_async_imports.$$ 2>/dev/null; then
16 echo "x.executor must not import x.async:" >&2
17 cat /tmp/xexecutor_async_imports.$$ >&2
18 rm -f /tmp/xexecutor_async_imports.$$
19 exit 1
20fi
21rm -f /tmp/xexecutor_async_imports.$$
22
23if [ -d "$target/examples" ] && find "$target/examples" -type f -print | xargs grep -n 'x\.async' >/tmp/xexecutor_async_examples.$$ 2>/dev/null; then
24 echo "x.executor examples must not mention or use x.async:" >&2
25 cat /tmp/xexecutor_async_examples.$$ >&2
26 rm -f /tmp/xexecutor_async_examples.$$
27 exit 1
28fi
29rm -f /tmp/xexecutor_async_examples.$$
30
31if find "$target" -type f -name '*.v' | grep -Ei '(^|/)(async|.*bridge.*)\.v$' >/tmp/xexecutor_async_bridge_files.$$ 2>/dev/null; then
32 echo "x.executor must not add async or bridge V files:" >&2
33 cat /tmp/xexecutor_async_bridge_files.$$ >&2
34 rm -f /tmp/xexecutor_async_bridge_files.$$
35 exit 1
36fi
37rm -f /tmp/xexecutor_async_bridge_files.$$
38
39echo "x.executor dependency check passed"
40