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
# autopkgtest check: Build a program against libkeymancore-dev to verify that the
# headers and pkg-config file are included and installed correctly.
# cf https://github.com/keymanapp/keyman/issues/7490
set -e
WORKDIR=$(mktemp -d)
# shellcheck disable=SC2064
trap "rm -rf ${WORKDIR}" 0 INT QUIT ABRT PIPE TERM
cd "${WORKDIR}"
#
# Test all include files are available
cat <<EOF > keymantest.c
#include <keyman/keyman_core_api.h>
km_core_actions* a;
EOF
# shellcheck disable=SC2046 disable=SC2312
gcc -c keymantest.c $(pkg-config --cflags --libs keyman_core)
echo "build 1: OK"
#
# Test pkg-config file - include without path
cat <<EOF > keymantest.c
#include <keyman_core_api.h>
km_core_actions* a;
EOF
# shellcheck disable=SC2046 disable=SC2312
gcc -c keymantest.c $(pkg-config --cflags --libs keyman_core)
echo "build 2: OK"
#
# Test dynamic linking
cat <<EOF > keymantest.c
#include <keyman/keyman_core_api.h>
int main(int argc, char *argv[]) {
km_core_option_item opts[] = {KM_CORE_OPTIONS_END};
km_core_keyboard *kb = NULL;
km_core_state *state = NULL;
km_core_keyboard_load_from_blob(NULL, NULL, 0, &kb);
km_core_state_create(kb, opts, &state);
km_core_actions const *a = km_core_state_get_actions(state);
}
EOF
# shellcheck disable=SC2046 disable=SC2312
g++ keymantest.c $(pkg-config --cflags --libs keyman_core)
echo "build 3: OK"
# It would be nice to test static linking, but that results in a warning
# which causes autopkgtest to report the tests as FAILED. See #10882.
# #
# # Test static linking
# cat <<EOF > keymantest.c
# #include <keyman/keyman_core_api.h>
# int main(int argc, char *argv[]) {
# km_core_option_item opts[] = {KM_CORE_OPTIONS_END};
# km_core_keyboard *kb = NULL;
# km_core_state *state = NULL;
# km_core_keyboard_load_from_blob(NULL, NULL, 0, &kb);
# km_core_state_create(kb, opts, &state);
# km_core_actions const *a = km_core_state_get_actions(state);
# }
# EOF
# # shellcheck disable=SC2046 disable=SC2312
# g++ keymantest.c -static $(pkg-config --cflags --libs keyman_core) \
# $(pkg-config --cflags --libs icu-uc) $(pkg-config --cflags --libs icu-i18n)
# echo "build 4: OK"
|