File: check-emscripten-enums.sh

package info (click to toggle)
libheif 1.15.1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,080 kB
  • sloc: cpp: 37,383; sh: 5,186; python: 3,032; ansic: 454; makefile: 406; javascript: 249
file content (74 lines) | stat: -rwxr-xr-x 2,247 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -e
#
# HEIF codec.
# Copyright (c) 2018 struktur AG, Joachim Bauch <bauch@struktur.de>
#
# This file is part of libheif.
#
# libheif is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# libheif is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with libheif.  If not, see <http://www.gnu.org/licenses/>.
#

DEFINE_TYPES="
    heif_error_
    heif_suberror_
    heif_compression_
    heif_chroma_
    heif_colorspace_
    heif_channel_
    "

API_DEFINES=""
for type in $DEFINE_TYPES; do
    DEFINES=$(grep "^[ \t]*$type" libheif/heif.h | sed 's|[[:space:]]*\([^ \t=]*\)[[:space:]]*=.*|\1|g')
    if [ -z "$API_DEFINES" ]; then
        API_DEFINES="$DEFINES"
    else
        API_DEFINES="$API_DEFINES
$DEFINES"
    fi
    ALIASES=$(grep "^[ \t]*#define $type" libheif/heif.h | sed 's|[[:space:]]*#define \([^ \t]*\)[[:space:]]*.*|\1|g')
    if [ ! -z "$ALIASES" ]; then
        API_DEFINES="$API_DEFINES
$ALIASES"
    fi
done
API_DEFINES=$(echo "$API_DEFINES" | sort)

EMSCRIPTEN_DEFINES=""
for type in $DEFINE_TYPES; do
    DEFINES=$(grep "\.value(\"$type" libheif/heif_emscripten.h | sed 's|[^\"]*\"\(.*\)\".*|\1|g')
    if [ -z "$EMSCRIPTEN_DEFINES" ]; then
        EMSCRIPTEN_DEFINES="$DEFINES"
    else
        EMSCRIPTEN_DEFINES="$EMSCRIPTEN_DEFINES
$DEFINES"
    fi
done
EMSCRIPTEN_DEFINES=$(echo "$EMSCRIPTEN_DEFINES" | sort)

set +e
CHANGES=$(diff -u <(echo "$API_DEFINES") <(echo "$EMSCRIPTEN_DEFINES"))
set -e
if [ -z "$CHANGES" ]; then
    echo "All defines from heif.h are present in heif_emscripten.h"
    exit 0
fi

echo "Differences found between enum defines in heif.h and heif_emscripten.h."
echo "Lines prefixed with '+' are only in heif_emscripten.h, resulting in"
echo "compile errors. Lines prefixed with '-' are missing in heif_emscripten.h"
echo
echo "$CHANGES"
exit 1