File: generate-thin-binding.sh

package info (click to toggle)
dbusada 0.6.3-2.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 748 kB
  • sloc: ada: 5,892; ansic: 98; makefile: 81; sh: 47
file content (59 lines) | stat: -rwxr-xr-x 1,983 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
set -Ceuvx

# This script once generated the current thin binding.
# Since then, the way GCC generates Ada sources and the dbus header
# may have changed, so running it again will most probably produce a
# different binding, requiring manual changes in the Ada code.
# It is provided to document the process in order to make next update
# or regeneration easier.

# Some files appear unused, but this actually depends on the
# architecture, so removing them is a risk for little benefit.

# If an argument is provided, it is used as the g++ executable.

thindir=thin
dbus_lib=dbus-1
dbus_includes="`pkg-config --cflags-only-I $dbus_lib | sed s/-I//g`"
dbus_h=`find $dbus_includes -name dbus.h`
CXX=${1:-g++-10}

if ! mkdir $thindir; then
    echo "The $thindir/ subdirectory exists, and may contain manual changes."
    echo "Please confirm by deleting or renaming it."
    exit 1
fi
cd $thindir

# This command line actually compiles nothing, so CPPFLAGS CXXFLAGS
# probably have no other effect than silencing the Build Log Hardening
# Checker in Debian.
$CXX --dump-ada-spec $dbus_h `pkg-config --cflags $dbus_lib` $CPPFLAGS $CXXFLAGS

# Remove arch, path or version dependent prefixes.
for i in *dbus_dbus_*; do
    mv $i `echo $i | sed 's/.*dbus_dbus_/dbus_/'`
done
sed -i 's/[a-z0-9_]*dbus_dbus_/dbus_/g' *

# Remove arch or version dependent paths from comments.
# (for reproducible builds and readability)
sed -i 's|  -- /usr/.*/|  -- |' *

# Fix a warning about unused entities.
sed -i '/^with Interfaces\.C; use Interfaces\.C;$/d' \
    dbus_h.ads \
    dbus_memory_h.ads \
    dbus_pending_call_h.ads \
    dbus_shared_h.ads \
    dbus_syntax_h.ads \
    stdarg_h.ads

# On arm64 armel armhf,
# a reference to stdarg_h.Class_va_list is generated without stdarg_h.
# dbusada does not need this reference, remove it.
sed -i \
    -e '/^with stdarg_h;$/d' \
    -e '/^   function dbus_message_\(append\|get\)_args_valist$/{:l;N;/\n$/d;bl}' \
    dbus_message_h.ads