1 | #!/usr/bin/env kmk_ash
|
---|
2 | # $Id: tstIEMAImplData.sh 96407 2022-08-22 17:43:14Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Shell script for massaging a data file to stub missing instructions.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2022 Oracle and/or its affiliates.
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox base platform packages, as
|
---|
11 | # available from https://www.virtualbox.org.
|
---|
12 | #
|
---|
13 | # This program is free software; you can redistribute it and/or
|
---|
14 | # modify it under the terms of the GNU General Public License
|
---|
15 | # as published by the Free Software Foundation, in version 3 of the
|
---|
16 | # License.
|
---|
17 | #
|
---|
18 | # This program is distributed in the hope that it will be useful, but
|
---|
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | # General Public License for more details.
|
---|
22 | #
|
---|
23 | # You should have received a copy of the GNU General Public License
|
---|
24 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | #
|
---|
26 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | #
|
---|
28 |
|
---|
29 | # Get parameters.
|
---|
30 | CP="$1"
|
---|
31 | MV="$2"
|
---|
32 | SED="$3"
|
---|
33 | APPEND="$4"
|
---|
34 | OUTDIR="$5"
|
---|
35 | SRCDIR="$6"
|
---|
36 | FILE="$7"
|
---|
37 |
|
---|
38 | # Globals.
|
---|
39 | set -e
|
---|
40 | LC_ALL=C
|
---|
41 | export LC_ALL
|
---|
42 | SRCFILE="${SRCDIR}/tstIEMAImplData${FILE}.cpp"
|
---|
43 | OUTFILE="${OUTDIR}/tstIEMAImplData${FILE}.cpp"
|
---|
44 |
|
---|
45 | # Copy the file and deal with empty file.
|
---|
46 | if test -f "${SRCFILE}"; then
|
---|
47 | "${CP}" -f -- "${SRCFILE}" "${OUTFILE}.tmp"
|
---|
48 | else
|
---|
49 | "${APPEND}" -t "${OUTFILE}.tmp"
|
---|
50 | fi
|
---|
51 | if ! test -s "${OUTFILE}.tmp"; then
|
---|
52 | echo '#include "tstIEMAImpl.h"' >> "${OUTFILE}.tmp"
|
---|
53 | fi
|
---|
54 | "${APPEND}" "${OUTFILE}.tmp" ""
|
---|
55 |
|
---|
56 | # Stub empty test arrays.
|
---|
57 | "${SED}" -n -e 's/\r//' \
|
---|
58 | -e 's/TSTIEM_DECLARE_TEST_ARRAY[(]'"${FILE}"', *\([^,]*\), *\([^ ][^ ]*\) *[)];/\1\n\2/p' \
|
---|
59 | "${SRCDIR}/tstIEMAImpl.h" \
|
---|
60 | --output-binary="${OUTFILE}.tmp2"
|
---|
61 |
|
---|
62 | while IFS= read -r a_Type && IFS= read -r a_Instr;
|
---|
63 | do
|
---|
64 | if "${SED}" -n -e "/ const g_cTests_${a_Instr} /q1" "${OUTFILE}.tmp"; then
|
---|
65 | "${APPEND}" "${OUTFILE}.tmp" "TSTIEM_DEFINE_EMPTY_TEST_ARRAY(${a_Type}, ${a_Instr});"
|
---|
66 | fi
|
---|
67 | done < "${OUTFILE}.tmp2"
|
---|
68 |
|
---|
69 | # Put the file into place, removing the tmp2 file in the process (avoid needing RM).
|
---|
70 | "${MV}" -f -- "${OUTFILE}.tmp" "${OUTFILE}.tmp2"
|
---|
71 | "${MV}" -f -- "${OUTFILE}.tmp2" "${OUTFILE}"
|
---|
72 |
|
---|