2020-04-27 07:26:45 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Setup directories.
|
|
|
|
td="$(realpath $(dirname $0)/..)"
|
|
|
|
build_dir="$td/build"
|
|
|
|
install_mlir="$td/install-mlir"
|
2020-04-27 08:55:15 +08:00
|
|
|
build_mlir="$td/build-mlir"
|
2020-04-29 11:32:49 +08:00
|
|
|
declare -a extra_opts
|
2020-04-27 07:26:45 +08:00
|
|
|
|
|
|
|
if ! [ -d "$install_mlir/include/mlir" ]; then
|
|
|
|
echo "MLIR install path does not appear valid: $install_mlir"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mkdir -p "$build_dir"
|
|
|
|
|
|
|
|
# Make sure we are using python3.
|
|
|
|
python_exe="$(which python3)"
|
|
|
|
echo "Using python: $python_exe"
|
|
|
|
if [ -z "$python_exe" ]; then
|
|
|
|
echo "Could not find python3"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-05-07 14:25:04 +08:00
|
|
|
# Write a .env file for python tooling.
|
|
|
|
echo "Updating $td/.env file"
|
|
|
|
echo "PYTHONPATH=\"$(realpath "$build_dir/python_native"):$(realpath "$build_dir/python")\"" > "$td/.env"
|
2020-05-09 05:21:43 +08:00
|
|
|
echo "NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=1" >> "$td/.env"
|
2020-05-07 14:25:04 +08:00
|
|
|
|
2020-04-27 07:26:45 +08:00
|
|
|
set -x
|
|
|
|
cmake -GNinja \
|
|
|
|
"-H$td" \
|
|
|
|
"-B$build_dir" \
|
2020-05-01 07:00:00 +08:00
|
|
|
"-DCMAKE_BUILD_TYPE=Debug" \
|
|
|
|
"-DCMAKE_CXX_FLAGS_DEBUG=-g3 -gdwarf-2 -Weverything -Werror" \
|
2020-04-27 07:26:45 +08:00
|
|
|
"-DPYTHON_EXECUTABLE=$python_exe" \
|
|
|
|
"-DMLIR_DIR=$install_mlir/lib/cmake/mlir" \
|
2020-04-27 08:55:15 +08:00
|
|
|
"-DLLVM_EXTERNAL_LIT=$build_mlir/bin/llvm-lit" \
|
2020-05-12 03:58:42 +08:00
|
|
|
"-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE" \
|
2020-04-29 11:32:49 +08:00
|
|
|
"${extra_opts[@]}" \
|
2020-04-27 07:26:45 +08:00
|
|
|
"$@"
|