Skip to content

Commit a487bb8

Browse files
committed
tests: move the pkgconfig test to a separate script
1 parent 2d88cb9 commit a487bb8

File tree

4 files changed

+85
-20
lines changed

4 files changed

+85
-20
lines changed

project.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ title=Release
1616
#targets
1717
[tests]
1818
type=command
19-
command=cd tests && (if [ -n "$(OBJDIR)" ]; then $(MAKE) OBJDIR="$(OBJDIR)tests/" "$(OBJDIR)tests/clint.log" "$(OBJDIR)tests/fixme.log" "$(OBJDIR)tests/pylint.log" "$(OBJDIR)tests/tests.log"; else $(MAKE) clint.log fixme.log pylint.log tests.log; fi)
19+
command=cd tests && (if [ -n "$(OBJDIR)" ]; then $(MAKE) OBJDIR="$(OBJDIR)tests/" "$(OBJDIR)tests/clint.log" "$(OBJDIR)tests/fixme.log" "$(OBJDIR)tests/pkgconfig.log" "$(OBJDIR)tests/pylint.log" "$(OBJDIR)tests/tests.log"; else $(MAKE) clint.log fixme.log pkgconfig.log pylint.log tests.log; fi)
2020
depends=all
2121
enabled=0
2222
phony=1

tests/pkgconfig.sh

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
#$Id$
3-
#Copyright (c) 2016 Pierre Pronchery <[email protected]>
3+
#Copyright (c) 2016-2025 Pierre Pronchery <[email protected]>
44
#This file is part of DeforaOS Desktop libDesktop
55
#Redistribution and use in source and binary forms, with or without
66
#modification, are permitted provided that the following conditions are met:
@@ -23,35 +23,94 @@
2323
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424

2525

26+
2627
#variables
27-
PACKAGE="libSystem"
28+
CONFIGSH="${0%/pkgconfig.sh}/../config.sh"
2829
PKG_CONFIG_PATH="$OBJDIR../data:$PKG_CONFIG_PATH"
2930
PKG_CONFIG_PATH="${PKG_CONFIG_PATH%:}"
31+
PROGNAME="pkgconfig.sh"
3032
#executables
33+
ECHO="echo"
3134
PKGCONFIG="pkg-config"
35+
UNAME="uname"
36+
[ "$($UNAME -s)" != "Darwin" ] || ECHO="/bin/echo"
37+
38+
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
39+
3240

41+
#functions
42+
#pkgconfig
3343
_pkgconfig()
34-
{
44+
{(
3545
ret=0
46+
47+
_pkgconfig_do "EXISTS:" --exists "$PACKAGE" || return 2
48+
49+
_pkgconfig_do "VERSION:" --modversion "$PACKAGE" || ret=3
50+
_pkgconfig_do "CFLAGS: " --cflags "$PACKAGE" || ret=4
51+
_pkgconfig_do "LIBS: " --libs "$PACKAGE" || ret=5
52+
_pkgconfig_do "PROVIDES:" --print-provides "$PACKAGE" || ret=6
53+
_pkgconfig_do "REQUIRES:" --print-requires "$PACKAGE" || ret=7
54+
return $ret
55+
)}
56+
57+
_pkgconfig_do()
58+
{
3659
caption="$1"
3760
options="$2"
3861
packages="$3"
3962

40-
echo -n "$caption"
41-
output=$(PKG_CONFIG_PATH="$PKG_CONFIG_PATH" $PKGCONFIG $options "$packages")
42-
ret=$?
43-
echo "$output"
44-
return $ret
63+
$ECHO -n "$caption"
64+
PKG_CONFIG_PATH="$PKG_CONFIG_PATH" $PKGCONFIG $options "$packages"
4565
}
4666

47-
_pkgconfig "EXISTS:" --exists "$PACKAGE" || exit 2
4867

49-
ret=0
68+
#usage
69+
_usage()
70+
{
71+
echo "Usage: $PROGNAME [-c] target..." 1>&2
72+
return 1
73+
}
5074

51-
_pkgconfig "VERSION:" --modversion "$PACKAGE" || ret=3
52-
_pkgconfig "CFLAGS: " --cflags "$PACKAGE" || ret=4
53-
_pkgconfig "LIBS: " --libs "$PACKAGE" || ret=5
54-
_pkgconfig "PROVIDES:" --print-provides "$PACKAGE" || ret=6
55-
_pkgconfig "REQUIRES:" --print-requires "$PACKAGE" || ret=7
5675

76+
#main
77+
clean=0
78+
while getopts "cO:P:" name; do
79+
case "$name" in
80+
c)
81+
clean=1
82+
;;
83+
O)
84+
export "${OPTARG%%=*}"="${OPTARG#*=}"
85+
;;
86+
P)
87+
#XXX ignored for compatibility
88+
;;
89+
?)
90+
_usage
91+
exit $?
92+
;;
93+
esac
94+
done
95+
shift $((OPTIND - 1))
96+
if [ $# -lt 1 ]; then
97+
_usage
98+
exit $?
99+
fi
100+
101+
#clean
102+
[ $clean -ne 0 ] && exit 0
103+
104+
exec 3>&1
105+
ret=0
106+
while [ $# -gt 0 ]; do
107+
target="$1"
108+
dirname="${target%/*}"
109+
shift
110+
111+
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
112+
$MKDIR -- "$dirname" || ret=$?
113+
fi
114+
_pkgconfig > "$target" || ret=$?
115+
done
57116
exit $ret

tests/project.conf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
targets=array,buffer,clint.log,config,coverage.log,error,event,fixme.log,includes,parser,pylint.log,string,variable,tests.log
1+
targets=array,buffer,clint.log,config,coverage.log,error,event,fixme.log,includes,parser,pkgconfig.log,pylint.log,string,variable,tests.log
22
cppflags_force=-I ../include
33
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
44
ldflags_force=-L$(OBJDIR)../src -L$(OBJDIR)../src/.libs -Wl,-rpath,$(OBJDIR)../src -lSystem `../tools/platform.sh -O DESTDIR="$(DESTDIR)" -l dl` `../tools/platform.sh -O DESTDIR="$(DESTDIR)" -l m`
@@ -56,6 +56,12 @@ sources=includes.c
5656
type=binary
5757
sources=parser.c
5858

59+
[pkgconfig.log]
60+
type=script
61+
script=./pkgconfig.sh
62+
enabled=0
63+
depends=$(OBJDIR)../data/libSystem.pc,pkgconfig.sh
64+
5965
[pylint.log]
6066
type=script
6167
script=./pylint.sh
@@ -70,7 +76,7 @@ sources=string.c
7076
type=script
7177
script=./tests.sh
7278
enabled=0
73-
depends=$(OBJDIR)array$(EXEEXT),$(OBJDIR)buffer$(EXEEXT),$(OBJDIR)config$(EXEEXT),config.conf,config-noeol.conf,$(OBJDIR)error$(EXEEXT),$(OBJDIR)event$(EXEEXT),$(OBJDIR)includes$(EXEEXT),$(OBJDIR)parser$(EXEEXT),pkgconfig.sh,python.sh,$(OBJDIR)string$(EXEEXT),tests.sh,$(OBJDIR)variable$(EXEEXT),$(OBJDIR)../src/libSystem.a,../src/python/libSystem.c
79+
depends=$(OBJDIR)array$(EXEEXT),$(OBJDIR)buffer$(EXEEXT),$(OBJDIR)config$(EXEEXT),config.conf,config-noeol.conf,$(OBJDIR)error$(EXEEXT),$(OBJDIR)event$(EXEEXT),$(OBJDIR)includes$(EXEEXT),$(OBJDIR)parser$(EXEEXT),python.sh,$(OBJDIR)string$(EXEEXT),tests.sh,$(OBJDIR)variable$(EXEEXT),$(OBJDIR)../src/libSystem.a,../src/python/libSystem.c
7480

7581
[variable]
7682
type=binary

tests/tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ failures=
125125
$PKGCONFIG --exists "python-2.7"
126126
case $? in
127127
127)
128-
failures="pkgconfig.sh python.sh"
128+
failures="python.sh"
129129
;;
130130
0)
131131
if [ -n "$PKG_CONFIG_SYSROOT_DIR" ]; then
132132
#XXX cross-compiling
133-
tests="pkgconfig.sh python.sh"
133+
tests="python.sh"
134134
fi
135135
;;
136136
*)

0 commit comments

Comments
 (0)