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  XEN_TARGET_ARCH=x86_64
29elif [ "$1" = "ARM64" ]; then
30  XEN_TARGET_ARCH=arm64
31else
32  fatal "Unknown configuration: $1"
33fi
34
35(
36    make -C xen defconfig
37    if [[ -n "${EXTRA_XEN_CONFIG}" ]]; then
38        echo "${EXTRA_XEN_CONFIG}" >> xen/.config
39    fi
40
41    ./configure
42    make -C xen clean
43    find . -type f -name "*.safparse" -print -delete
44    "${script_dir}/build.sh" "$1"
45    # Generate additional configuration files
46    "${script_dir}/ECLAIR/generate_ecl.sh"
47    make -C xen clean
48    cd xen
49    make -f "${script_dir}/Makefile.prepare" prepare
50    # Translate the /* SAF-n-safe */ comments into ECLAIR CBTs
51    scripts/xen-analysis.py --run-eclair --no-build --no-clean
52    # Translate function-properties.json into ECLAIR properties
53    python3 "${script_dir}/propertyparser.py"
54)
55