2020-11-28 00:32:59 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
root_dir=$(dirname "$0")
|
|
|
|
root_dir=$(cd "$root_dir/.." && pwd)
|
|
|
|
if [ ! -f "$root_dir/LICENSE.txt" ]; then
|
|
|
|
echo "Couldn't find the root dir"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
pysrc_dir="$root_dir/src/rust/iced-x86-py"
|
|
|
|
|
|
|
|
if [ "$OSTYPE" = "msys" ]; then
|
|
|
|
is_windows=y
|
|
|
|
else
|
|
|
|
is_windows=n
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$is_windows" = "y" ]; then
|
|
|
|
python=python
|
|
|
|
else
|
|
|
|
python=python3
|
|
|
|
fi
|
|
|
|
full_check=y
|
|
|
|
gen_docs=y
|
|
|
|
sdist_only=n
|
|
|
|
wheel_only=n
|
|
|
|
set_rustflags=y
|
|
|
|
|
|
|
|
new_func() {
|
|
|
|
echo
|
|
|
|
echo "****************************************************************"
|
|
|
|
echo "$1"
|
|
|
|
echo "****************************************************************"
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_sdist() {
|
|
|
|
new_func "Generate sdist"
|
|
|
|
|
|
|
|
curr_dir=$(pwd)
|
|
|
|
cd "$pysrc_dir"
|
|
|
|
|
|
|
|
$python setup.py sdist
|
|
|
|
|
|
|
|
cd "$curr_dir"
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_wheel() {
|
|
|
|
new_func "Generate wheel"
|
|
|
|
|
|
|
|
curr_dir=$(pwd)
|
|
|
|
cd "$pysrc_dir"
|
|
|
|
|
|
|
|
$python setup.py bdist_wheel
|
|
|
|
|
|
|
|
cd "$curr_dir"
|
|
|
|
}
|
|
|
|
|
2020-12-03 23:21:19 +00:00
|
|
|
test_wheel() {
|
|
|
|
new_func "Test wheel"
|
|
|
|
|
|
|
|
curr_dir=$(pwd)
|
|
|
|
cd "$pysrc_dir"
|
|
|
|
|
|
|
|
$python -m pip install iced-x86 --no-index -f dist
|
|
|
|
$python -m pytest --color=yes --code-highlight=yes
|
|
|
|
$python -m pip uninstall -y iced-x86
|
|
|
|
|
|
|
|
cd "$curr_dir"
|
|
|
|
}
|
|
|
|
|
2020-11-28 00:32:59 +00:00
|
|
|
generate_docs() {
|
|
|
|
new_func "Generate docs"
|
|
|
|
|
|
|
|
curr_dir=$(pwd)
|
|
|
|
cd "$pysrc_dir"
|
|
|
|
|
|
|
|
# Depends on generate_wheel output.
|
|
|
|
# It needs to load all modules, so copy the built file to the correct place.
|
|
|
|
# It has a *.{pyd,dylib,so} extension
|
2020-11-28 13:49:13 +00:00
|
|
|
built_file=$(ls build/lib/iced_x86/_iced_x86_py.*.*)
|
2020-11-28 00:32:59 +00:00
|
|
|
if [ ! -f "$built_file" ]; then
|
2020-11-28 13:49:13 +00:00
|
|
|
echo "Couldn't find the built _iced_x86_py.*.* file"
|
2020-11-28 00:32:59 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2020-12-03 23:21:11 +00:00
|
|
|
dest_filename="src/iced_x86/$(basename "$built_file")"
|
2020-11-28 00:32:59 +00:00
|
|
|
cp "$built_file" "$dest_filename"
|
|
|
|
|
2020-12-02 19:34:10 +00:00
|
|
|
echo "Generating HTML files"
|
2020-12-07 16:43:30 +00:00
|
|
|
$python -m sphinx --color -n -W --keep-going -b html docs docs/_build
|
2020-11-28 00:32:59 +00:00
|
|
|
|
2020-12-02 19:34:10 +00:00
|
|
|
echo "Running doc tests"
|
2020-12-07 16:43:30 +00:00
|
|
|
$python -m sphinx --color -n -W --keep-going -b doctest docs docs/_build
|
2020-12-02 19:34:10 +00:00
|
|
|
|
2020-11-28 00:32:59 +00:00
|
|
|
rm "$dest_filename"
|
|
|
|
|
|
|
|
cd "$curr_dir"
|
|
|
|
}
|
|
|
|
|
|
|
|
misc_tests() {
|
2020-12-03 23:21:11 +00:00
|
|
|
new_func "clippy, fmt, pylint, mypy"
|
2020-11-28 00:32:59 +00:00
|
|
|
|
|
|
|
curr_dir=$(pwd)
|
|
|
|
cd "$pysrc_dir"
|
|
|
|
|
2020-11-29 12:07:11 +00:00
|
|
|
echo "==== CLIPPY RELEASE ===="
|
|
|
|
cargo clippy --color always --release
|
|
|
|
|
|
|
|
echo "==== FORMAT CHECK ===="
|
|
|
|
cargo fmt -- --color always --check
|
|
|
|
|
2020-11-28 09:35:33 +00:00
|
|
|
echo "mypy"
|
2020-12-03 23:21:11 +00:00
|
|
|
mypy --strict src/iced_x86
|
2020-11-28 00:32:59 +00:00
|
|
|
|
2020-11-28 09:35:33 +00:00
|
|
|
echo "pylint"
|
2020-11-28 13:49:13 +00:00
|
|
|
# It will fail to load _iced_x86_py since it's not in the correct dir, so disable the error
|
2020-12-03 23:21:11 +00:00
|
|
|
pylint src/iced_x86 -d import-error --rcfile="$pysrc_dir/../pylintrc"
|
2020-11-28 00:32:59 +00:00
|
|
|
|
|
|
|
cd "$curr_dir"
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
--quick-check) full_check=n ;;
|
|
|
|
--sdist-only) sdist_only=y ;;
|
|
|
|
--wheel-only) wheel_only=y ;;
|
|
|
|
--python) shift; python=$1 ;;
|
|
|
|
--no-docs) gen_docs=n ;;
|
|
|
|
--no-set-rustflags) set_rustflags=n ;;
|
|
|
|
*) echo "Unknown arg: $1"; exit 1 ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "=================================================="
|
|
|
|
echo "Python build"
|
|
|
|
echo "=================================================="
|
|
|
|
echo
|
|
|
|
|
|
|
|
if [ "$set_rustflags" = "y" ]; then
|
|
|
|
export RUSTFLAGS="-D warnings"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "rustup show"
|
|
|
|
rustup show
|
|
|
|
echo "cargo version"
|
|
|
|
cargo --version
|
|
|
|
echo "Rust version"
|
|
|
|
rustc --version
|
|
|
|
echo "Python version"
|
|
|
|
$python --version
|
|
|
|
|
|
|
|
if [ "$sdist_only" = "y" ]; then
|
|
|
|
generate_sdist
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
if [ "$wheel_only" = "y" ]; then
|
|
|
|
generate_wheel
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-12-03 23:21:19 +00:00
|
|
|
echo "pytest version"
|
|
|
|
$python -m pytest --version
|
|
|
|
|
2020-11-28 13:49:13 +00:00
|
|
|
if [ "$full_check" = "y" ] && [ "$gen_docs" = "y" ]; then
|
|
|
|
echo "sphinx-build version"
|
|
|
|
sphinx-build --version
|
|
|
|
fi
|
|
|
|
|
2020-11-28 00:32:59 +00:00
|
|
|
generate_sdist
|
|
|
|
generate_wheel
|
2020-12-03 23:21:19 +00:00
|
|
|
test_wheel
|
2020-11-28 00:32:59 +00:00
|
|
|
if [ "$full_check" = "y" ]; then
|
|
|
|
misc_tests
|
|
|
|
if [ "$gen_docs" = "y" ]; then
|
|
|
|
generate_docs
|
|
|
|
fi
|
|
|
|
fi
|