1 | #!/usr/bin/env kmk_ash
|
---|
2 | # $Id: tstIEMAImplData.sh 94412 2022-03-31 11:26:27Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Shell script for massaging a data file to stub missing instructions.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2022 Oracle Corporation
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | # General Public License (GPL) as published by the Free Software
|
---|
14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | #
|
---|
18 |
|
---|
19 | # Get parameters.
|
---|
20 | CP="$1"
|
---|
21 | MV="$2"
|
---|
22 | SED="$3"
|
---|
23 | APPEND="$4"
|
---|
24 | OUTDIR="$5"
|
---|
25 | SRCDIR="$6"
|
---|
26 | FILE="$7"
|
---|
27 |
|
---|
28 | # Globals.
|
---|
29 | set -e
|
---|
30 | LC_ALL=C
|
---|
31 | export LC_ALL
|
---|
32 | SRCFILE="${SRCDIR}/tstIEMAImplData${FILE}.cpp"
|
---|
33 | OUTFILE="${OUTDIR}/tstIEMAImplData${FILE}.cpp"
|
---|
34 |
|
---|
35 | # Copy the file and deal with empty file.
|
---|
36 | if test -f "${SRCFILE}"; then
|
---|
37 | "${CP}" -f -- "${SRCFILE}" "${OUTFILE}.tmp"
|
---|
38 | else
|
---|
39 | "${APPEND}" -t "${OUTFILE}.tmp"
|
---|
40 | fi
|
---|
41 | if ! test -s "${OUTFILE}.tmp"; then
|
---|
42 | echo '#include "tstIEMAImpl.h"' >> "${OUTFILE}.tmp"
|
---|
43 | fi
|
---|
44 | "${APPEND}" "${OUTFILE}.tmp" ""
|
---|
45 |
|
---|
46 | # Stub empty test arrays.
|
---|
47 | "${SED}" -n -e 's/\r//' \
|
---|
48 | -e 's/TSTIEM_DECLARE_TEST_ARRAY[(]'"${FILE}"', *\([^,]*\), *\([^ ][^ ]*\) *[)];/\1\n\2/p' \
|
---|
49 | "${SRCDIR}/tstIEMAImpl.h" \
|
---|
50 | --output-binary="${OUTFILE}.tmp2"
|
---|
51 |
|
---|
52 | while IFS= read -r a_Type && IFS= read -r a_Instr;
|
---|
53 | do
|
---|
54 | if "${SED}" -n -e "/ const g_cTests_${a_Instr} /q1" "${OUTFILE}.tmp"; then
|
---|
55 | "${APPEND}" "${OUTFILE}.tmp" "TSTIEM_DEFINE_EMPTY_TEST_ARRAY(${a_Type}, ${a_Instr});"
|
---|
56 | fi
|
---|
57 | done < "${OUTFILE}.tmp2"
|
---|
58 |
|
---|
59 | # Put the file into place, removing the tmp2 file in the process (avoid needing RM).
|
---|
60 | "${MV}" -f -- "${OUTFILE}.tmp" "${OUTFILE}.tmp2"
|
---|
61 | "${MV}" -f -- "${OUTFILE}.tmp2" "${OUTFILE}"
|
---|
62 |
|
---|