| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | |
| 5 | usage() { |
| 6 | cat <<'EOF' |
| 7 | Usage: scripts/bootstrap-linked-armfortas.sh /path/to/armfortas [output-dir] |
| 8 | |
| 9 | Generate a local bencch workspace that links against an external armfortas |
| 10 | checkout for linked capture. |
| 11 | |
| 12 | Examples: |
| 13 | scripts/bootstrap-linked-armfortas.sh ../armfortas |
| 14 | scripts/bootstrap-linked-armfortas.sh /abs/path/to/armfortas .bencch-local |
| 15 | EOF |
| 16 | } |
| 17 | |
| 18 | if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then |
| 19 | usage |
| 20 | exit 0 |
| 21 | fi |
| 22 | |
| 23 | if [[ $# -lt 1 || $# -gt 2 ]]; then |
| 24 | usage >&2 |
| 25 | exit 1 |
| 26 | fi |
| 27 | |
| 28 | script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 29 | repo_root="$(cd "${script_dir}/.." && pwd)" |
| 30 | armfortas_root="${1}" |
| 31 | output_dir="${2:-${repo_root}/.bencch-local}" |
| 32 | |
| 33 | if [[ ! -d "${armfortas_root}" ]]; then |
| 34 | echo "armfortas checkout does not exist: ${armfortas_root}" >&2 |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | armfortas_root="$(cd "${armfortas_root}" && pwd)" |
| 39 | output_dir="$(mkdir -p "${output_dir}" && cd "${output_dir}" && pwd)" |
| 40 | |
| 41 | if [[ ! -f "${armfortas_root}/Cargo.toml" ]]; then |
| 42 | echo "armfortas checkout is missing Cargo.toml: ${armfortas_root}" >&2 |
| 43 | exit 1 |
| 44 | fi |
| 45 | |
| 46 | if [[ ! -d "${armfortas_root}/src" ]]; then |
| 47 | echo "armfortas checkout is missing src/: ${armfortas_root}" >&2 |
| 48 | exit 1 |
| 49 | fi |
| 50 | |
| 51 | mkdir -p "${output_dir}/bench" |
| 52 | |
| 53 | cat > "${output_dir}/Cargo.toml" <<EOF |
| 54 | # Generated by scripts/bootstrap-linked-armfortas.sh |
| 55 | [workspace] |
| 56 | members = ["bench"] |
| 57 | default-members = ["bench"] |
| 58 | resolver = "2" |
| 59 | EOF |
| 60 | |
| 61 | cat > "${output_dir}/bench/Cargo.toml" <<EOF |
| 62 | # Generated by scripts/bootstrap-linked-armfortas.sh |
| 63 | [package] |
| 64 | name = "afs-tests" |
| 65 | version = "0.1.0" |
| 66 | edition = "2021" |
| 67 | description = "Structured generic compiler bench runner" |
| 68 | build = "../../bench/build.rs" |
| 69 | |
| 70 | [features] |
| 71 | default = ["linked-armfortas"] |
| 72 | linked-armfortas = [] |
| 73 | |
| 74 | [lib] |
| 75 | path = "../../bench/src/lib.rs" |
| 76 | |
| 77 | [[bin]] |
| 78 | name = "afs-tests" |
| 79 | path = "../../bench/src/main.rs" |
| 80 | |
| 81 | [[bin]] |
| 82 | name = "bencch" |
| 83 | path = "../../bench/src/bin/bencch.rs" |
| 84 | |
| 85 | [dependencies] |
| 86 | bencch-core = { path = "../../bench-core" } |
| 87 | armfortas = { path = "${armfortas_root}" } |
| 88 | EOF |
| 89 | |
| 90 | cat > "${output_dir}/README.md" <<EOF |
| 91 | # Generated local workspace |
| 92 | |
| 93 | This directory is generated by scripts/bootstrap-linked-armfortas.sh. |
| 94 | |
| 95 | armfortas checkout: ${armfortas_root} |
| 96 | |
| 97 | Use it with: |
| 98 | |
| 99 | cargo run --manifest-path "${output_dir}/Cargo.toml" -p afs-tests --bin bencch -- doctor |
| 100 | EOF |
| 101 | |
| 102 | echo "Generated local workspace at ${output_dir}" |
| 103 | echo "Linked armfortas checkout: ${armfortas_root}" |
| 104 | echo |
| 105 | echo "Next step:" |
| 106 | echo " cargo run --manifest-path \"${output_dir}/Cargo.toml\" -p afs-tests --bin bencch -- doctor" |