1#!/bin/bash
2# Stop immediately if any executed command has exit status different from 0.
3set -e
4
5script_name="$(basename "$0")"
6script_dir="$(
7  cd "$(dirname "$0")"
8  echo "${PWD}"
9)"
10
11fatal() {
12  echo "${script_name}: $*" >&2
13  exit 1
14}
15
16usage() {
17  fatal "Usage: ${script_name}"
18}
19
20if [ $# -ne 1 ]; then
21  usage
22  exit 1
23fi
24
25export XEN_TARGET_ARCH
26
27if [ "$1" = "X86_64" ]; then
28  CONFIG_FILE="${script_dir}/xen_x86_config"
29  XEN_TARGET_ARCH=x86_64
30elif [ "$1" = "ARM64" ]; then
31  CONFIG_FILE="${script_dir}/xen_arm_config"
32  XEN_TARGET_ARCH=arm64
33else
34  fatal "Unknown configuration: $1"
35fi
36
37(
38    ./configure
39    cp "${CONFIG_FILE}" xen/.config
40    make clean
41    find . -type f -name "*.safparse" -print -delete
42    cd xen
43    make -f "${script_dir}/Makefile.prepare" prepare
44    # Translate the /* SAF-n-safe */ comments into ECLAIR CBTs
45    scripts/xen-analysis.py --run-eclair --no-build --no-clean
46    # Translate function-properties.json into ECLAIR properties
47    python3 ${script_dir}/propertyparser.py
48)
49