add cdtbcd, cbcdtd, and addg6s
[power-instruction-analyzer.git] / libre-soc-install.sh
1 #!/bin/bash
2 set -e
3
4 function fail()
5 {
6 echo "error: $@" >&2
7 exit 1
8 }
9
10 if [[ "$VIRTUAL_ENV" == "" ]]; then
11 user=( "--user" )
12 else
13 user=()
14 fi
15 cargo_version="$(cargo --version)" || fail "can't find cargo, install it from https://rustup.rs/"
16 [[ "$cargo_version" =~ ^'cargo 1.'([0-9]+)'.'[0-9]+' ' ]] || fail "can't parse cargo's version string"
17 (( "${BASH_REMATCH[1]}" >= 53 )) || fail 'your rust version is not recent enough, update your rust version using `rustup update`'
18 python3 -m pip install "${user[@]}" 'maturin>=0.11,<0.12'
19 if [[ "$VIRTUAL_ENV" == "" ]]; then
20 scripts="$(python3 -m sysconfig | sed 's@^\tuserbase = "\([^"]\+\)"$@\1/bin@p; d')"
21 else
22 scripts="$(python3 -m sysconfig | sed 's/^\tscripts = "\([^"]\+\)"$/\1/p; d')"
23 fi
24 echo "$scripts"
25 [[ -d "$scripts" ]] || fail "can't find python's \`scripts\` directory"
26 rm -f target/wheels/power_instruction_analyzer-*.whl
27 "$scripts"/maturin build --compatibility linux --cargo-extra-args=--features=python-extension -i python3 --release --no-sdist
28 python3 -m pip install --force "${user[@]}" target/wheels/power_instruction_analyzer-*.whl