Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
a86e6ae9b0 | |||
2afdc3aada | |||
d3e158a717 | |||
1f93c2c86a | |||
7826c03ebc | |||
b75fc10cea | |||
2e529e785a | |||
b5d49ab82e | |||
35e6a0c428 | |||
45918377c7 | |||
a0cbdcb4c0 | |||
de0a1ee8e3 | |||
ab9afb258f | |||
25d63a2e48 | |||
92ca340c67 | |||
a2662cb960 | |||
e00a6acbd3 | |||
375ef49946 | |||
a79124b8d5 | |||
1d3ae53c60 | |||
a79535107d | |||
a5f07547c0 | |||
2bcac1eb7c | |||
dc06c4db9d | |||
b44a81085a | |||
965b125eb8 | |||
67e0f4b38f | |||
df68815cb5 | |||
f29338bf63 | |||
d185479478 | |||
414e1bc8df |
27
.github/workflows/deforaos-c-ci_ubuntu-latest.yml
vendored
Normal file
27
.github/workflows/deforaos-c-ci_ubuntu-latest.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
name: DeforaOS C CI (ubuntu-latest)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: bootstrap libSystem
|
||||||
|
run: git clone https://github.com/DeforaOS/libSystem.git libSystem && for dir in include data src; do (cd libSystem/$dir && make PREFIX="$HOME/opt/DeforaOS" install); done
|
||||||
|
- name: bootstrap configure
|
||||||
|
run: git clone https://github.com/DeforaOS/configure.git configure && (cd configure/src && PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make PREFIX="$HOME/opt/DeforaOS" install)
|
||||||
|
- name: configure
|
||||||
|
run: $HOME/opt/DeforaOS/bin/configure -p "$HOME/opt/DeforaOS"
|
||||||
|
- name: make
|
||||||
|
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared"
|
||||||
|
- name: make tests
|
||||||
|
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared" tests
|
||||||
|
- name: make distcheck
|
||||||
|
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared" distcheck
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,5 +5,6 @@ Makefile
|
||||||
*.so
|
*.so
|
||||||
*.so.*
|
*.so.*
|
||||||
*.so.*.*
|
*.so.*.*
|
||||||
|
/config.ent
|
||||||
/config.h
|
/config.h
|
||||||
/config.sh
|
/config.sh
|
||||||
|
|
44
README.md
Normal file
44
README.md
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
DeforaOS CPP
|
||||||
|
============
|
||||||
|
|
||||||
|
About CPP
|
||||||
|
---------
|
||||||
|
|
||||||
|
CPP is a macro preprocessor for the C programming language. It provides the
|
||||||
|
ability for the inclusion of header files, macro expansions, conditional
|
||||||
|
compilation, and line control.
|
||||||
|
|
||||||
|
CPP depends on the DeforaOS libSystem library (version 0.4.3 or above),
|
||||||
|
which is found on the website for the DeforaOS Project:
|
||||||
|
<https://www.defora.org/>.
|
||||||
|
|
||||||
|
|
||||||
|
Compiling CPP
|
||||||
|
-------------
|
||||||
|
|
||||||
|
CPP depends on the following components:
|
||||||
|
|
||||||
|
* DeforaOS libSystem
|
||||||
|
* An implementation of `make`
|
||||||
|
* GTK-Doc for the API documentation
|
||||||
|
|
||||||
|
With GCC, this should then be enough to compile and install CPP:
|
||||||
|
|
||||||
|
$ make install
|
||||||
|
|
||||||
|
To install CPP in a dedicated directory, like `/path/to/CPP`:
|
||||||
|
|
||||||
|
$ make PREFIX="/path/to/CPP" install
|
||||||
|
|
||||||
|
Distributing CPP
|
||||||
|
----------------
|
||||||
|
|
||||||
|
DeforaOS CPP is subject to the terms of the GNU LGPL license (version 3).
|
||||||
|
Please see the `COPYING` file for more information.
|
||||||
|
|
||||||
|
Known issues
|
||||||
|
------------
|
||||||
|
|
||||||
|
* The cpp(1) binary may conflict with the system's own version.
|
||||||
|
* Macro expansions are not fully supported yet.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#$Id$
|
#$Id$
|
||||||
#Copyright (c) 2011-2015 Pierre Pronchery <khorben@defora.org>
|
#Copyright (c) 2011-2022 Pierre Pronchery <khorben@defora.org>
|
||||||
#
|
#
|
||||||
#Redistribution and use in source and binary forms, with or without
|
#Redistribution and use in source and binary forms, with or without
|
||||||
#modification, are permitted provided that the following conditions are met:
|
#modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -25,19 +25,116 @@
|
||||||
|
|
||||||
|
|
||||||
#variables
|
#variables
|
||||||
|
CONFIGSH="${0%/pkgconfig.sh}/../config.sh"
|
||||||
PREFIX="/usr/local"
|
PREFIX="/usr/local"
|
||||||
[ -f "../config.sh" ] && . "../config.sh"
|
|
||||||
DEBUG="_debug"
|
|
||||||
DEVNULL="/dev/null"
|
DEVNULL="/dev/null"
|
||||||
PROGNAME="pkgconfig.sh"
|
PROGNAME="pkgconfig.sh"
|
||||||
#executables
|
#executables
|
||||||
INSTALL="install -m 0644"
|
DEBUG="_debug"
|
||||||
|
INSTALL="install"
|
||||||
MKDIR="mkdir -m 0755 -p"
|
MKDIR="mkdir -m 0755 -p"
|
||||||
RM="rm -f"
|
RM="rm -f"
|
||||||
SED="sed"
|
SED="sed"
|
||||||
|
|
||||||
|
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||||
|
|
||||||
|
|
||||||
#functions
|
#functions
|
||||||
|
#pkgconfig
|
||||||
|
_pkgconfig()
|
||||||
|
{
|
||||||
|
#check the variables
|
||||||
|
if [ -z "$PACKAGE" ]; then
|
||||||
|
_error "The PACKAGE variable needs to be set"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
_error "The VERSION variable needs to be set"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
[ -z "$BINDIR" ] && BINDIR="$PREFIX/bin"
|
||||||
|
[ -z "$DATADIR" ] && DATADIR="$PREFIX/share"
|
||||||
|
[ -z "$INCLUDEDIR" ] && INCLUDEDIR="$PREFIX/include"
|
||||||
|
[ -z "$LIBDIR" ] && LIBDIR="$PREFIX/lib"
|
||||||
|
[ -z "$LIBEXECDIR" ] && LIBEXECDIR="$PREFIX/libexec"
|
||||||
|
[ -z "$MANDIR" ] && MANDIR="$DATADIR/man"
|
||||||
|
[ -z "$SBINDIR" ] && SBINDIR="$PREFIX/sbin"
|
||||||
|
if [ -z "$SYSCONFDIR" ]; then
|
||||||
|
SYSCONFDIR="$PREFIX/etc"
|
||||||
|
[ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc"
|
||||||
|
fi
|
||||||
|
PKGCONFIG="$PREFIX/lib/pkgconfig"
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
target="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
#clean
|
||||||
|
[ "$clean" -ne 0 ] && continue
|
||||||
|
|
||||||
|
#uninstall
|
||||||
|
if [ "$uninstall" -eq 1 ]; then
|
||||||
|
$DEBUG $RM -- "$PKGCONFIG/$target" || return 2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
#install
|
||||||
|
if [ "$install" -eq 1 ]; then
|
||||||
|
source="${target#$OBJDIR}"
|
||||||
|
$DEBUG $MKDIR -- "$PKGCONFIG" || return 2
|
||||||
|
mode="-m 0644"
|
||||||
|
basename="$source"
|
||||||
|
if [ "${source##*/}" != "$source" ]; then
|
||||||
|
basename="${source##*/}"
|
||||||
|
fi
|
||||||
|
$DEBUG $INSTALL $mode "$target" "$PKGCONFIG/$basename" \
|
||||||
|
|| return 2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
#portability
|
||||||
|
RPATH=
|
||||||
|
if [ "$PREFIX" != "/usr" ]; then
|
||||||
|
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
|
||||||
|
case $(uname -s) in
|
||||||
|
"Darwin")
|
||||||
|
RPATH="-Wl,-rpath,\${libdir}"
|
||||||
|
;;
|
||||||
|
"SunOS")
|
||||||
|
RPATH="-Wl,-R\${libdir}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
#create
|
||||||
|
source="${target#$OBJDIR}"
|
||||||
|
source="${source}.in"
|
||||||
|
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") \
|
||||||
|
|| return 2
|
||||||
|
$DEBUG $SED -e "s;@VENDOR@;$VENDOR;g" \
|
||||||
|
-e "s;@PACKAGE@;$PACKAGE;g" \
|
||||||
|
-e "s;@VERSION@;$VERSION;g" \
|
||||||
|
-e "s;@PREFIX@;$PREFIX;g" \
|
||||||
|
-e "s;@BINDIR@;$BINDIR;g" \
|
||||||
|
-e "s;@DATADIR@;$DATADIR;g" \
|
||||||
|
-e "s;@INCLUDEDIR@;$INCLUDEDIR;g" \
|
||||||
|
-e "s;@LIBDIR@;$LIBDIR;g" \
|
||||||
|
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
|
||||||
|
-e "s;@MANDIR@;$MANDIR;g" \
|
||||||
|
-e "s;@PWD@;$PWD;g" \
|
||||||
|
-e "s;@RPATH@;$RPATH;g" \
|
||||||
|
-e "s;@SBINDIR@;$SBINDIR;g" \
|
||||||
|
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
|
||||||
|
-- "$source" > "$target"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
$RM -- "$target" 2> "$DEVNULL"
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#debug
|
#debug
|
||||||
_debug()
|
_debug()
|
||||||
{
|
{
|
||||||
|
@ -66,7 +163,7 @@ _usage()
|
||||||
clean=0
|
clean=0
|
||||||
install=0
|
install=0
|
||||||
uninstall=0
|
uninstall=0
|
||||||
while getopts "ciuP:" name; do
|
while getopts "ciuO:P:" name; do
|
||||||
case $name in
|
case $name in
|
||||||
c)
|
c)
|
||||||
clean=1
|
clean=1
|
||||||
|
@ -79,6 +176,9 @@ while getopts "ciuP:" name; do
|
||||||
install=0
|
install=0
|
||||||
uninstall=1
|
uninstall=1
|
||||||
;;
|
;;
|
||||||
|
O)
|
||||||
|
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||||
|
;;
|
||||||
P)
|
P)
|
||||||
PREFIX="$OPTARG"
|
PREFIX="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
@ -89,72 +189,10 @@ while getopts "ciuP:" name; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
_usage
|
_usage
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#check the variables
|
|
||||||
if [ -z "$PACKAGE" ]; then
|
|
||||||
_error "The PACKAGE variable needs to be set"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
if [ -z "$VERSION" ]; then
|
|
||||||
_error "The VERSION variable needs to be set"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
PKGCONFIG="$PREFIX/lib/pkgconfig"
|
|
||||||
exec 3>&1
|
exec 3>&1
|
||||||
while [ $# -gt 0 ]; do
|
_pkgconfig "$@"
|
||||||
target="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
#clean
|
|
||||||
[ "$clean" -ne 0 ] && continue
|
|
||||||
|
|
||||||
#uninstall
|
|
||||||
if [ "$uninstall" -eq 1 ]; then
|
|
||||||
$DEBUG $RM -- "$PKGCONFIG/$target" || exit 2
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
#install
|
|
||||||
if [ "$install" -eq 1 ]; then
|
|
||||||
source="${target#$OBJDIR}"
|
|
||||||
$DEBUG $MKDIR -- "$PKGCONFIG" || exit 2
|
|
||||||
basename="$source"
|
|
||||||
if [ "${source##*/}" != "$source" ]; then
|
|
||||||
basename="${source##*/}"
|
|
||||||
fi
|
|
||||||
$DEBUG $INSTALL "$target" "$PKGCONFIG/$basename"|| exit 2
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
#portability
|
|
||||||
RPATH=
|
|
||||||
if [ "$PREFIX" != "/usr" ]; then
|
|
||||||
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
|
|
||||||
case $(uname -s) in
|
|
||||||
Darwin)
|
|
||||||
RPATH="-Wl,-rpath,\${libdir}"
|
|
||||||
;;
|
|
||||||
SunOS)
|
|
||||||
RPATH="-Wl,-R\${libdir}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
#create
|
|
||||||
source="${target#$OBJDIR}"
|
|
||||||
source="${source}.in"
|
|
||||||
$DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;" \
|
|
||||||
-e "s;@VERSION@;$VERSION;" \
|
|
||||||
-e "s;@PREFIX@;$PREFIX;" \
|
|
||||||
-e "s;@RPATH@;$RPATH;" \
|
|
||||||
-- "$source" > "$target"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
$DEBUG $RM -- "$target"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
5
doc/.gitignore
vendored
Normal file
5
doc/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/gtkdoc/html
|
||||||
|
/gtkdoc/html.stamp
|
||||||
|
/gtkdoc/CPP.types
|
||||||
|
/gtkdoc/tmpl.stamp
|
||||||
|
/gtkdoc/xml.stamp
|
154
doc/gtkdoc.sh
154
doc/gtkdoc.sh
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#$Id$
|
#$Id$
|
||||||
#Copyright (c) 2012-2015 Pierre Pronchery <khorben@defora.org>
|
#Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org>
|
||||||
#
|
#
|
||||||
#Redistribution and use in source and binary forms, with or without
|
#Redistribution and use in source and binary forms, with or without
|
||||||
#modification, are permitted provided that the following conditions are met:
|
#modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
|
|
||||||
#variables
|
#variables
|
||||||
|
CONFIGSH="${0%/gtkdoc.sh}/../config.sh"
|
||||||
PREFIX="/usr/local"
|
PREFIX="/usr/local"
|
||||||
PROGNAME="gtkdoc.sh"
|
PROGNAME="gtkdoc.sh"
|
||||||
#executables
|
#executables
|
||||||
|
@ -38,9 +39,10 @@ GTKDOC_SCAN="gtkdoc-scan"
|
||||||
INSTALL="install -m 0644"
|
INSTALL="install -m 0644"
|
||||||
MKDIR="mkdir -m 0755 -p"
|
MKDIR="mkdir -m 0755 -p"
|
||||||
RM="rm -f"
|
RM="rm -f"
|
||||||
|
RMDIR="rmdir"
|
||||||
TOUCH="touch"
|
TOUCH="touch"
|
||||||
|
|
||||||
[ -f "../config.sh" ] && . "../config.sh"
|
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||||
|
|
||||||
|
|
||||||
#functions
|
#functions
|
||||||
|
@ -60,6 +62,77 @@ _error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#gtkdoc_fixxref
|
||||||
|
_gtkdoc_fixxref()
|
||||||
|
{
|
||||||
|
module="$1"
|
||||||
|
moduledir="$2"
|
||||||
|
htmldir="$3"
|
||||||
|
outputdir="$4"
|
||||||
|
|
||||||
|
(cd "$outputdir" &&
|
||||||
|
$DEBUG $GTKDOC_FIXXREF \
|
||||||
|
--module="$module" \
|
||||||
|
--module-dir="$moduledir" \
|
||||||
|
--html-dir="$htmldir") || exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#gtkdoc_mkdb
|
||||||
|
_gtkdoc_mkdb()
|
||||||
|
{
|
||||||
|
module="$1"
|
||||||
|
sourcedir="$2"
|
||||||
|
outputdir="$3"
|
||||||
|
|
||||||
|
(cd "$sourcedir" &&
|
||||||
|
$DEBUG $GTKDOC_MKDB --module="$module" \
|
||||||
|
--output-dir="$outputdir" \
|
||||||
|
--output-format="xml" --tmpl-dir="tmpl")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#gtkdoc_mkhtml
|
||||||
|
_gtkdoc_mkhtml()
|
||||||
|
{
|
||||||
|
module="$1"
|
||||||
|
path="$2"
|
||||||
|
driver="$3"
|
||||||
|
outputdir="$4"
|
||||||
|
|
||||||
|
(cd "$outputdir" &&
|
||||||
|
$DEBUG $GTKDOC_MKHTML --path "$path" "$module" "$driver")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#gtkdoc_mktmpl
|
||||||
|
_gtkdoc_mktmpl()
|
||||||
|
{
|
||||||
|
module="$1"
|
||||||
|
sourcedir="$2"
|
||||||
|
outputdir="$3"
|
||||||
|
|
||||||
|
(cd "$sourcedir" &&
|
||||||
|
$DEBUG $GTKDOC_MKTMPL --module="$module" \
|
||||||
|
--output-dir="$outputdir")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#gtkdoc_scan
|
||||||
|
_gtkdoc_scan()
|
||||||
|
{
|
||||||
|
module="$1"
|
||||||
|
sourcedir="$2"
|
||||||
|
outputdir="$3"
|
||||||
|
|
||||||
|
(cd ".." &&
|
||||||
|
$DEBUG $GTKDOC_SCAN --module="$module" \
|
||||||
|
--source-dir="$sourcedir" \
|
||||||
|
--output-dir="$outputdir")
|
||||||
|
# --rebuild-types
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#usage
|
#usage
|
||||||
_usage()
|
_usage()
|
||||||
{
|
{
|
||||||
|
@ -72,7 +145,7 @@ _usage()
|
||||||
clean=0
|
clean=0
|
||||||
install=0
|
install=0
|
||||||
uninstall=0
|
uninstall=0
|
||||||
while getopts "ciuP:" name; do
|
while getopts "ciO:uP:" name; do
|
||||||
case "$name" in
|
case "$name" in
|
||||||
c)
|
c)
|
||||||
clean=1
|
clean=1
|
||||||
|
@ -81,6 +154,9 @@ while getopts "ciuP:" name; do
|
||||||
uninstall=0
|
uninstall=0
|
||||||
install=1
|
install=1
|
||||||
;;
|
;;
|
||||||
|
O)
|
||||||
|
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||||
|
;;
|
||||||
u)
|
u)
|
||||||
install=0
|
install=0
|
||||||
uninstall=1
|
uninstall=1
|
||||||
|
@ -95,7 +171,7 @@ while getopts "ciuP:" name; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
_usage
|
_usage
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
@ -126,23 +202,28 @@ while [ $# -gt 0 ]; do
|
||||||
file="${i##*/}"
|
file="${i##*/}"
|
||||||
$DEBUG $RM -- "$instdir/$MODULE/$file" || exit 2
|
$DEBUG $RM -- "$instdir/$MODULE/$file" || exit 2
|
||||||
done
|
done
|
||||||
|
if [ -d "$instdir/$MODULE" ]; then
|
||||||
|
$DEBUG $RMDIR -- "$instdir/$MODULE" || exit 2
|
||||||
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#create
|
#create
|
||||||
case "$target" in
|
case "$target" in
|
||||||
gtkdoc/html.stamp)
|
gtkdoc/html.stamp)
|
||||||
driver="../$MODULE-docs.xml"
|
|
||||||
if [ -n "$OBJDIR" ]; then
|
|
||||||
driver="gtkdoc/$MODULE-docs.xml"
|
|
||||||
$DEBUG $CP -- "$driver" "${OBJDIR}gtkdoc" \
|
|
||||||
|| exit 2
|
|
||||||
fi
|
|
||||||
output="${OBJDIR}gtkdoc/html"
|
output="${OBJDIR}gtkdoc/html"
|
||||||
$DEBUG $MKDIR -- "$output" || exit 2
|
$DEBUG $MKDIR -- "$output" || exit 2
|
||||||
(cd "$output" &&
|
driver="$MODULE-docs.xml"
|
||||||
$DEBUG $GTKDOC_MKHTML "$MODULE" \
|
oldpath="$PWD"
|
||||||
"${OBJDIR}$driver")
|
[ -n "$OBJDIR" ] && for file in \
|
||||||
|
"gtkdoc/$driver" \
|
||||||
|
"gtkdoc/xml/gtkdocentities.ent"; do
|
||||||
|
[ -f "$file" ] || continue
|
||||||
|
$DEBUG $CP -- "$file" \
|
||||||
|
"${OBJDIR}$file" || exit 2
|
||||||
|
done
|
||||||
|
_gtkdoc_mkhtml "$MODULE" "${oldpath%/*}" "../$driver" \
|
||||||
|
"$output"
|
||||||
#detect when gtk-doc is not available
|
#detect when gtk-doc is not available
|
||||||
res=$?
|
res=$?
|
||||||
if [ $res -eq 127 ]; then
|
if [ $res -eq 127 ]; then
|
||||||
|
@ -153,24 +234,7 @@ while [ $# -gt 0 ]; do
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
output="${OBJDIR}gtkdoc"
|
output="${OBJDIR}gtkdoc"
|
||||||
(cd "$output" &&
|
_gtkdoc_fixxref "$MODULE" "html" "$instdir" "$output"
|
||||||
$DEBUG $GTKDOC_FIXXREF \
|
|
||||||
--module="$MODULE" \
|
|
||||||
--module-dir="html" \
|
|
||||||
--html-dir="$instdir") || exit 2
|
|
||||||
;;
|
|
||||||
gtkdoc/sgml.stamp)
|
|
||||||
output="xml"
|
|
||||||
if [ -n "$OBJDIR" ]; then
|
|
||||||
output="${OBJDIR}gtkdoc/xml"
|
|
||||||
$DEBUG $MKDIR -- "$output" || exit 2
|
|
||||||
fi
|
|
||||||
(cd "${OBJDIR}gtkdoc" &&
|
|
||||||
$DEBUG $GTKDOC_MKDB \
|
|
||||||
--module="$MODULE" \
|
|
||||||
--output-dir="$output" \
|
|
||||||
--output-format="xml" \
|
|
||||||
--tmpl-dir="tmpl")
|
|
||||||
;;
|
;;
|
||||||
gtkdoc/tmpl.stamp)
|
gtkdoc/tmpl.stamp)
|
||||||
output="tmpl"
|
output="tmpl"
|
||||||
|
@ -178,22 +242,28 @@ while [ $# -gt 0 ]; do
|
||||||
output="${OBJDIR}gtkdoc/tmpl"
|
output="${OBJDIR}gtkdoc/tmpl"
|
||||||
$DEBUG $MKDIR -- "$output" || exit 2
|
$DEBUG $MKDIR -- "$output" || exit 2
|
||||||
fi
|
fi
|
||||||
(cd "${OBJDIR}gtkdoc" &&
|
_gtkdoc_mktmpl "$MODULE" "${OBJDIR}gtkdoc" "$output"
|
||||||
$DEBUG $GTKDOC_MKTMPL \
|
;;
|
||||||
--module="$MODULE" \
|
gtkdoc/xml.stamp)
|
||||||
--output-dir="$output")
|
output="xml"
|
||||||
|
if [ -n "$OBJDIR" ]; then
|
||||||
|
output="${OBJDIR}gtkdoc"
|
||||||
|
sections="gtkdoc/$MODULE-sections.txt"
|
||||||
|
$DEBUG $MKDIR -- "$output/xml" || exit 2
|
||||||
|
$DEBUG $CP -- "$sections" "$output" \
|
||||||
|
|| exit 2
|
||||||
|
_gtkdoc_scan "$MODULE" "include" "$output"
|
||||||
|
output="${OBJDIR}gtkdoc/xml"
|
||||||
|
fi
|
||||||
|
_gtkdoc_mkdb "$MODULE" "${OBJDIR}gtkdoc" "$output"
|
||||||
;;
|
;;
|
||||||
gtkdoc/*.types)
|
gtkdoc/*.types)
|
||||||
output="doc/gtkdoc" || exit 2
|
output="$PWD/gtkdoc" || exit 2
|
||||||
if [ -n "$OBJDIR" ]; then
|
if [ -n "$OBJDIR" ]; then
|
||||||
output="${OBJDIR}gtkdoc"
|
output="${OBJDIR}gtkdoc"
|
||||||
$DEBUG $MKDIR -- "$output" || exit 2
|
$DEBUG $MKDIR -- "$output" || exit 2
|
||||||
fi
|
fi
|
||||||
(cd ".." &&
|
_gtkdoc_scan "$MODULE" "include" "$output"
|
||||||
$DEBUG $GTKDOC_SCAN \
|
|
||||||
--module="$MODULE" \
|
|
||||||
--source-dir="include" \
|
|
||||||
--output-dir="$output")
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_error "$target: Unknown type"
|
_error "$target: Unknown type"
|
||||||
|
@ -205,7 +275,7 @@ while [ $# -gt 0 ]; do
|
||||||
_error "$target: Could not create documentation"
|
_error "$target: Could not create documentation"
|
||||||
install=0
|
install=0
|
||||||
fi
|
fi
|
||||||
$TOUCH "$target"
|
$TOUCH "${OBJDIR}$target"
|
||||||
|
|
||||||
#install
|
#install
|
||||||
if [ "$install" -eq 1 ]; then
|
if [ "$install" -eq 1 ]; then
|
||||||
|
|
|
@ -3,25 +3,32 @@
|
||||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
|
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
|
||||||
[
|
[
|
||||||
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
|
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
|
||||||
<!ENTITY server "www.defora.org/doc/gtk-doc/html">
|
<!ENTITY % gtkdocentities SYSTEM "xml/gtkdocentities.ent">
|
||||||
<!ENTITY title "DeforaOS CPP">
|
%gtkdocentities;
|
||||||
<!ENTITY version "0.0.1">
|
<!ENTITY % configentities SYSTEM "config.ent">
|
||||||
|
%configentities;
|
||||||
]>
|
]>
|
||||||
<book id="index">
|
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
|
||||||
<bookinfo>
|
<bookinfo>
|
||||||
<title>CPP Reference Manual</title>
|
<title>&vendor; &package; &title;</title>
|
||||||
<releaseinfo>
|
<releaseinfo>
|
||||||
for CPP &version;.
|
for &vendor; &package; &version;.
|
||||||
The latest version of this documentation can be found on-line at
|
The latest version of this documentation can be found on-line at
|
||||||
<ulink role="online-location" url="http://&server;/CPP/index.html">http://&server;/CPP/</ulink>.
|
<ulink role="online-location" url="https://&server;/&package;/">https://&server;/&package;/</ulink>.
|
||||||
</releaseinfo>
|
</releaseinfo>
|
||||||
</bookinfo>
|
</bookinfo>
|
||||||
|
|
||||||
<chapter>
|
<chapter>
|
||||||
<title>&title;</title>
|
<title>&vendor; &package;</title>
|
||||||
<xi:include href="xml/CPP.xml"/>
|
<xi:include href="xml/CPP.xml"/>
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
||||||
|
<!-- enable this when you use gobject types
|
||||||
|
<chapter id="object-tree">
|
||||||
|
<title>Object Hierarchy</title>
|
||||||
|
<xi:include href="xml/tree_index.sgml"/>
|
||||||
|
</chapter>
|
||||||
|
-->
|
||||||
<index id="api-index-full">
|
<index id="api-index-full">
|
||||||
<title>API Index</title>
|
<title>API Index</title>
|
||||||
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
||||||
|
@ -30,6 +37,7 @@
|
||||||
<title>Index of deprecated API</title>
|
<title>Index of deprecated API</title>
|
||||||
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
|
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
|
||||||
</index>
|
</index>
|
||||||
|
<!-- enable this when you use gobject introspection annotations
|
||||||
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
|
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
|
||||||
|
-->
|
||||||
</book>
|
</book>
|
||||||
|
|
21
doc/gtkdoc/CPP-sections.txt
Normal file
21
doc/gtkdoc/CPP-sections.txt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<SECTION>
|
||||||
|
<FILE>CPP</FILE>
|
||||||
|
CPP_CODE_COUNT
|
||||||
|
CPP_CODE_LAST
|
||||||
|
CPP_CODE_META_FIRST
|
||||||
|
CPP_CODE_META_LAST
|
||||||
|
Cpp
|
||||||
|
CppCode
|
||||||
|
CppFilter
|
||||||
|
CppOption
|
||||||
|
cpp_define_add
|
||||||
|
cpp_define_get
|
||||||
|
cpp_define_remove
|
||||||
|
cpp_delete
|
||||||
|
cpp_get_filename
|
||||||
|
cpp_new
|
||||||
|
cpp_new_string
|
||||||
|
cpp_path_add
|
||||||
|
cpp_scan
|
||||||
|
</SECTION>
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
subdirs=tmpl
|
subdirs=tmpl
|
||||||
dist=Makefile,CPP-docs.xml
|
dist=Makefile,CPP-docs.xml,CPP-sections.txt,xml/gtkdocentities.ent
|
||||||
|
|
2
doc/gtkdoc/xml/gtkdocentities.ent
Normal file
2
doc/gtkdoc/xml/gtkdocentities.ent
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<!ENTITY server "www.defora.org/doc/gtk-doc/html">
|
||||||
|
<!ENTITY title "Reference Manual">
|
|
@ -1,23 +1,25 @@
|
||||||
subdirs=gtkdoc
|
subdirs=gtkdoc
|
||||||
targets=gtkdoc/CPP.types,gtkdoc/tmpl.stamp,gtkdoc/sgml.stamp,gtkdoc/html.stamp
|
targets=gtkdoc/CPP.types,gtkdoc/html.stamp,gtkdoc/tmpl.stamp,gtkdoc/xml.stamp
|
||||||
dist=Makefile,gtkdoc.sh
|
dist=Makefile,gtkdoc.sh
|
||||||
|
|
||||||
|
#targets
|
||||||
[gtkdoc/CPP.types]
|
[gtkdoc/CPP.types]
|
||||||
type=script
|
type=script
|
||||||
script=./gtkdoc.sh
|
script=./gtkdoc.sh
|
||||||
|
depends=gtkdoc.sh
|
||||||
[gtkdoc/tmpl.stamp]
|
|
||||||
type=script
|
|
||||||
script=./gtkdoc.sh
|
|
||||||
depends=$(OBJDIR)gtkdoc/CPP.types,gtkdoc/tmpl/cpp.sgml
|
|
||||||
|
|
||||||
[gtkdoc/sgml.stamp]
|
|
||||||
type=script
|
|
||||||
script=./gtkdoc.sh
|
|
||||||
depends=$(OBJDIR)gtkdoc/tmpl.stamp
|
|
||||||
|
|
||||||
[gtkdoc/html.stamp]
|
[gtkdoc/html.stamp]
|
||||||
type=script
|
type=script
|
||||||
script=./gtkdoc.sh
|
script=./gtkdoc.sh
|
||||||
depends=gtkdoc/CPP-docs.xml,$(OBJDIR)gtkdoc/sgml.stamp
|
depends=gtkdoc/CPP-docs.xml,$(OBJDIR)gtkdoc/xml.stamp,gtkdoc/xml/gtkdocentities.ent,gtkdoc.sh,../config.ent,../config.sh
|
||||||
install=
|
install=
|
||||||
|
|
||||||
|
[gtkdoc/tmpl.stamp]
|
||||||
|
type=script
|
||||||
|
script=./gtkdoc.sh
|
||||||
|
depends=$(OBJDIR)gtkdoc/CPP.types,gtkdoc.sh,../config.sh
|
||||||
|
|
||||||
|
[gtkdoc/xml.stamp]
|
||||||
|
type=script
|
||||||
|
script=./gtkdoc.sh
|
||||||
|
depends=$(OBJDIR)gtkdoc/tmpl.stamp,gtkdoc.sh
|
||||||
|
|
30
project.conf
30
project.conf
|
@ -1,6 +1,30 @@
|
||||||
package=CPP
|
package=CPP
|
||||||
version=0.0.3
|
version=0.0.6
|
||||||
config=h,sh
|
vendor=Devel
|
||||||
|
config=ent,h,sh
|
||||||
|
|
||||||
subdirs=data,doc,include,src,tests
|
subdirs=data,doc,include,src,tests
|
||||||
dist=Makefile,COPYING,config.h,config.sh
|
targets=tests
|
||||||
|
dist=Makefile,COPYING,README.md,config.ent,config.h,config.sh
|
||||||
|
|
||||||
|
#modes
|
||||||
|
[mode::debug]
|
||||||
|
title=Debug
|
||||||
|
|
||||||
|
[mode::release]
|
||||||
|
title=Release
|
||||||
|
|
||||||
|
#targets
|
||||||
|
[tests]
|
||||||
|
type=command
|
||||||
|
command=cd tests && (if [ -n "$(OBJDIR)" ]; then $(MAKE) OBJDIR="$(OBJDIR)tests/" "$(OBJDIR)tests/clint.log" "$(OBJDIR)tests/distcheck.log" "$(OBJDIR)tests/fixme.log"; else $(MAKE) clint.log distcheck.log fixme.log; fi)
|
||||||
|
depends=all
|
||||||
|
enabled=0
|
||||||
|
phony=1
|
||||||
|
|
||||||
|
#dist
|
||||||
|
[COPYING]
|
||||||
|
install=$(PREFIX)/share/doc/$(PACKAGE)
|
||||||
|
|
||||||
|
[README.md]
|
||||||
|
install=$(PREFIX)/share/doc/$(PACKAGE)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2006-2015 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2006-2022 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Devel cpp */
|
/* This file is part of DeforaOS Devel cpp */
|
||||||
/* This program is free software: you can redistribute it and/or modify
|
/* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
@ -75,7 +75,7 @@ Cpp * cpp_new(CppPrefs * prefs)
|
||||||
/* cpp_new_string */
|
/* cpp_new_string */
|
||||||
Cpp * cpp_new_string(CppPrefs * prefs, char const * string)
|
Cpp * cpp_new_string(CppPrefs * prefs, char const * string)
|
||||||
{
|
{
|
||||||
/* FIXME really implement (and refactor) */
|
/* FIXME really implement */
|
||||||
Cpp * cpp;
|
Cpp * cpp;
|
||||||
String * p;
|
String * p;
|
||||||
int r = 0;
|
int r = 0;
|
|
@ -850,6 +850,7 @@ static int _cpp_callback_unknown(Parser * parser, Token * token, int c,
|
||||||
CppParser * cppparser_new(Cpp * cpp, CppParser * parent, char const * filename,
|
CppParser * cppparser_new(Cpp * cpp, CppParser * parent, char const * filename,
|
||||||
int filters)
|
int filters)
|
||||||
{
|
{
|
||||||
|
/* FIXME factor code */
|
||||||
CppParser * cp;
|
CppParser * cp;
|
||||||
|
|
||||||
if((cp = object_new(sizeof(*cp))) == NULL)
|
if((cp = object_new(sizeof(*cp))) == NULL)
|
||||||
|
@ -905,7 +906,6 @@ CppParser * cppparser_new(Cpp * cpp, CppParser * parent, char const * filename,
|
||||||
CppParser * cppparser_new_string(Cpp * cpp, CppParser * parent,
|
CppParser * cppparser_new_string(Cpp * cpp, CppParser * parent,
|
||||||
char const * string, int filters)
|
char const * string, int filters)
|
||||||
{
|
{
|
||||||
/* FIXME refactor */
|
|
||||||
CppParser * cp;
|
CppParser * cp;
|
||||||
|
|
||||||
if((cp = object_new(sizeof(*cp))) == NULL)
|
if((cp = object_new(sizeof(*cp))) == NULL)
|
31
src/lib/project.conf
Normal file
31
src/lib/project.conf
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
targets=libcpp
|
||||||
|
cppflags_force=-I../../include
|
||||||
|
cppflags=
|
||||||
|
cflags_force=`pkg-config --cflags libSystem` -fPIC
|
||||||
|
cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||||
|
ldflags_force=`pkg-config --libs libSystem`
|
||||||
|
ldflags=
|
||||||
|
dist=Makefile,common.h,parser.h
|
||||||
|
|
||||||
|
#modes
|
||||||
|
[mode::debug]
|
||||||
|
|
||||||
|
[mode::release]
|
||||||
|
cppflags_force=-I../../include -DNDEBUG
|
||||||
|
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||||
|
|
||||||
|
#targets
|
||||||
|
[libcpp]
|
||||||
|
type=library
|
||||||
|
sources=cpp.c,parser.c,scanner.c
|
||||||
|
install=$(LIBDIR)
|
||||||
|
|
||||||
|
#sources
|
||||||
|
[cpp.c]
|
||||||
|
depends=common.h,../../include/CPP.h
|
||||||
|
|
||||||
|
[parser.c]
|
||||||
|
depends=parser.h,../../include/CPP.h
|
||||||
|
|
||||||
|
[scanner.c]
|
||||||
|
depends=common.h,../../include/CPP.h
|
24
src/main.c
24
src/main.c
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2007-2013 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2007-2022 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Devel cpp */
|
/* This file is part of DeforaOS Devel cpp */
|
||||||
/* This program is free software: you can redistribute it and/or modify
|
/* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,6 +24,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "CPP.h"
|
#include "CPP.h"
|
||||||
|
|
||||||
|
#ifndef PROGNAME_CPP
|
||||||
|
# define PROGNAME_CPP "cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* cpp */
|
/* cpp */
|
||||||
/* private */
|
/* private */
|
||||||
|
@ -62,13 +66,13 @@ static int _cpp(Prefs * prefs, int filec, char * filev[])
|
||||||
if(prefs->outfile == NULL)
|
if(prefs->outfile == NULL)
|
||||||
fp = stdout;
|
fp = stdout;
|
||||||
else if((fp = fopen(prefs->outfile, "w")) == NULL)
|
else if((fp = fopen(prefs->outfile, "w")) == NULL)
|
||||||
return error_set_print("cpp", 1, "%s: %s", prefs->outfile,
|
return error_set_print(PROGNAME_CPP, 1, "%s: %s",
|
||||||
strerror(errno));
|
prefs->outfile, strerror(errno));
|
||||||
for(i = 0; i < filec; i++)
|
for(i = 0; i < filec; i++)
|
||||||
ret |= _cpp_do(prefs, fp, filev[i]);
|
ret |= _cpp_do(prefs, fp, filev[i]);
|
||||||
if(fclose(fp) != 0)
|
if(fclose(fp) != 0)
|
||||||
return error_set_print("cpp", 1, "%s: %s", prefs->outfile,
|
return error_set_print(PROGNAME_CPP, 1, "%s: %s",
|
||||||
strerror(errno));
|
prefs->outfile, strerror(errno));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +147,7 @@ static void _do_print_token(FILE * fp, Token * token)
|
||||||
/* cpp_error */
|
/* cpp_error */
|
||||||
static int _cpp_error(void)
|
static int _cpp_error(void)
|
||||||
{
|
{
|
||||||
return error_print("cpp");
|
return error_print(PROGNAME_CPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,7 +155,7 @@ static int _cpp_error(void)
|
||||||
/* FIXME -E prints metadata? */
|
/* FIXME -E prints metadata? */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: cpp [-D name[=value]]...[-I directory][-o file][-t][-U name]... input...\n"
|
fputs("Usage: " PROGNAME_CPP " [-D name[=value]]...[-I directory][-o file][-t][-U name]... input...\n"
|
||||||
" -D Add a substitution\n"
|
" -D Add a substitution\n"
|
||||||
" -I Add a directory to the search path\n"
|
" -I Add a directory to the search path\n"
|
||||||
" -o Write output to a file\n"
|
" -o Write output to a file\n"
|
||||||
|
@ -218,7 +222,7 @@ static int _main_add_define(Prefs * prefs, char * define)
|
||||||
value = strtok(define, "=");
|
value = strtok(define, "=");
|
||||||
if((p = realloc(prefs->defines, sizeof(*p) * (prefs->defines_cnt + 1)))
|
if((p = realloc(prefs->defines, sizeof(*p) * (prefs->defines_cnt + 1)))
|
||||||
== NULL)
|
== NULL)
|
||||||
return error_set_print("cpp", 1, "%s", strerror(errno));
|
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
|
||||||
prefs->defines = p;
|
prefs->defines = p;
|
||||||
prefs->defines[prefs->defines_cnt++] = define;
|
prefs->defines[prefs->defines_cnt++] = define;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -230,7 +234,7 @@ static int _main_add_path(Prefs * prefs, char const * path)
|
||||||
|
|
||||||
if((p = realloc(prefs->paths, sizeof(*p) * (prefs->paths_cnt + 1)))
|
if((p = realloc(prefs->paths, sizeof(*p) * (prefs->paths_cnt + 1)))
|
||||||
== NULL)
|
== NULL)
|
||||||
return error_set_print("cpp", 1, "%s", strerror(errno));
|
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
|
||||||
prefs->paths = p;
|
prefs->paths = p;
|
||||||
prefs->paths[prefs->paths_cnt++] = path;
|
prefs->paths[prefs->paths_cnt++] = path;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -244,7 +248,7 @@ static int _main_add_undefine(Prefs * prefs, char const * undefine)
|
||||||
return 1;
|
return 1;
|
||||||
if((p = realloc(prefs->undefines, sizeof(*p)
|
if((p = realloc(prefs->undefines, sizeof(*p)
|
||||||
* (prefs->undefines_cnt + 1))) == NULL)
|
* (prefs->undefines_cnt + 1))) == NULL)
|
||||||
return error_set_print("cpp", 1, "%s", strerror(errno));
|
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
|
||||||
prefs->undefines = p;
|
prefs->undefines = p;
|
||||||
prefs->undefines[prefs->undefines_cnt++] = undefine;
|
prefs->undefines[prefs->undefines_cnt++] = undefine;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,34 +1,30 @@
|
||||||
targets=libcpp,cpp
|
subdirs=lib
|
||||||
|
targets=cpp
|
||||||
cppflags_force=-I ../include
|
cppflags_force=-I ../include
|
||||||
cppflags=
|
cppflags=
|
||||||
cflags_force=`pkg-config --cflags libSystem`
|
cflags_force=`pkg-config --cflags libSystem` -fPIE
|
||||||
cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector-all
|
cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||||
ldflags_force=`pkg-config --libs libSystem`
|
ldflags_force=`pkg-config --libs libSystem`
|
||||||
ldflags=
|
ldflags=-pie -Wl,-z,relro -Wl,-z,now
|
||||||
dist=Makefile,common.h,parser.h
|
dist=Makefile
|
||||||
|
|
||||||
[libcpp]
|
#modes
|
||||||
type=library
|
[mode::debug]
|
||||||
sources=cpp.c,parser.c,scanner.c
|
|
||||||
cflags=-fPIC
|
|
||||||
install=$(LIBDIR)
|
|
||||||
|
|
||||||
[cpp.c]
|
[mode::release]
|
||||||
depends=common.h,../include/CPP.h
|
cppflags_force=-I ../include -DNDEBUG
|
||||||
|
cflags=-W -Wall -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||||
[parser.c]
|
|
||||||
depends=parser.h,../include/CPP.h
|
|
||||||
|
|
||||||
[scanner.c]
|
|
||||||
depends=common.h,../include/CPP.h
|
|
||||||
|
|
||||||
|
#targets
|
||||||
[cpp]
|
[cpp]
|
||||||
type=binary
|
type=binary
|
||||||
sources=main.c
|
sources=main.c
|
||||||
depends=$(OBJDIR)libcpp.so
|
#XXX should really use this (race condition with "make -k")
|
||||||
cflags=-fPIE
|
depends=$(OBJDIR)lib/libcpp$(SOEXT)
|
||||||
ldflags=-L$(OBJDIR). -L$(LIBDIR) -Wl,-rpath,$(LIBDIR) -lcpp
|
depends=$(OBJDIR)lib/libcpp.a
|
||||||
|
ldflags=-L$(OBJDIR)lib -L$(LIBDIR) -Wl,-rpath,$(LIBDIR) -lcpp
|
||||||
install=$(BINDIR)
|
install=$(BINDIR)
|
||||||
|
|
||||||
|
#sources
|
||||||
[main.c]
|
[main.c]
|
||||||
depends=../include/CPP.h
|
depends=../include/CPP.h
|
||||||
|
|
3
tests/.gitignore
vendored
Normal file
3
tests/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
/clint.log
|
||||||
|
/distcheck.log
|
||||||
|
/fixme.log
|
192
tests/clint.sh
Executable file
192
tests/clint.sh
Executable file
|
@ -0,0 +1,192 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#$Id$
|
||||||
|
#Copyright (c) 2016-2021 Pierre Pronchery <khorben@defora.org>
|
||||||
|
#
|
||||||
|
#Redistribution and use in source and binary forms, with or without
|
||||||
|
#modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#variables
|
||||||
|
CONFIGSH="${0%/clint.sh}/../config.sh"
|
||||||
|
CFLAGS=
|
||||||
|
CPPFLAGS=
|
||||||
|
PROGNAME="clint.sh"
|
||||||
|
PROJECTCONF="../project.conf"
|
||||||
|
#executables
|
||||||
|
DATE="date"
|
||||||
|
DEBUG="_debug"
|
||||||
|
ECHO="/bin/echo"
|
||||||
|
FIND="find"
|
||||||
|
GREP="grep"
|
||||||
|
LINT="lint -g"
|
||||||
|
MKDIR="mkdir -p"
|
||||||
|
SORT="sort -n"
|
||||||
|
TR="tr"
|
||||||
|
|
||||||
|
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||||
|
|
||||||
|
|
||||||
|
#functions
|
||||||
|
#clint
|
||||||
|
_clint()
|
||||||
|
{
|
||||||
|
res=0
|
||||||
|
subdirs=
|
||||||
|
|
||||||
|
$DATE
|
||||||
|
while read line; do
|
||||||
|
case "$line" in
|
||||||
|
"["*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"subdirs="*)
|
||||||
|
subdirs=${line#subdirs=}
|
||||||
|
subdirs=$(echo "$subdirs" | $TR ',' ' ')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done < "$PROJECTCONF"
|
||||||
|
if [ ! -n "$subdirs" ]; then
|
||||||
|
_error "Could not locate directories to analyze"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
for subdir in $subdirs; do
|
||||||
|
[ -d "../$subdir" ] || continue
|
||||||
|
while read filename; do
|
||||||
|
[ -n "$filename" ] || continue
|
||||||
|
r=0
|
||||||
|
case "$filename" in
|
||||||
|
*.c)
|
||||||
|
echo
|
||||||
|
_clint_lint "$filename" || r=$?
|
||||||
|
_clint_rtrim "$filename"|| r=$?
|
||||||
|
;;
|
||||||
|
*.h)
|
||||||
|
echo
|
||||||
|
echo "$filename:"
|
||||||
|
_clint_rtrim "$filename"|| r=$?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ $r -eq 0 ]; then
|
||||||
|
echo " OK"
|
||||||
|
echo "$PROGNAME: $filename: OK" 1>&2
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
echo "$PROGNAME: $filename: FAIL" 1>&2
|
||||||
|
res=2
|
||||||
|
fi
|
||||||
|
done << EOF
|
||||||
|
$($FIND "../$subdir" -type f | $SORT)
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
return $res
|
||||||
|
}
|
||||||
|
|
||||||
|
_clint_lint()
|
||||||
|
{(
|
||||||
|
filename="$1"
|
||||||
|
|
||||||
|
$ECHO -n "${filename%/*}/"
|
||||||
|
$DEBUG $LINT $CPPFLAGS $CFLAGS "$filename" 2>&1
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -eq 127 ]; then
|
||||||
|
#XXX ignore errors when $LINT is not available
|
||||||
|
ret=0
|
||||||
|
fi
|
||||||
|
return $ret
|
||||||
|
)}
|
||||||
|
|
||||||
|
_clint_rtrim()
|
||||||
|
{
|
||||||
|
filename="$1"
|
||||||
|
regex="[ ]\\+\$"
|
||||||
|
|
||||||
|
$DEBUG $GREP -vq "$regex" "$filename" 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#debug
|
||||||
|
_debug()
|
||||||
|
{
|
||||||
|
echo "$@" 1>&3
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#error
|
||||||
|
_error()
|
||||||
|
{
|
||||||
|
echo "$PROGNAME: $@" 1>&2
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#usage
|
||||||
|
_usage()
|
||||||
|
{
|
||||||
|
echo "Usage: $PROGNAME [-c] target..." 1>&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#main
|
||||||
|
clean=0
|
||||||
|
while getopts "cO:P:" name; do
|
||||||
|
case "$name" in
|
||||||
|
c)
|
||||||
|
clean=1
|
||||||
|
;;
|
||||||
|
O)
|
||||||
|
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||||
|
;;
|
||||||
|
P)
|
||||||
|
CPPFLAGS="$CPPFLAGS -I$OPTARG/include"
|
||||||
|
;;
|
||||||
|
?)
|
||||||
|
_usage
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
_usage
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
#clean
|
||||||
|
[ $clean -ne 0 ] && exit 0
|
||||||
|
|
||||||
|
exec 3>&1
|
||||||
|
ret=0
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
target="$1"
|
||||||
|
dirname="${target%/*}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
|
||||||
|
$MKDIR -- "$dirname" || ret=$?
|
||||||
|
fi
|
||||||
|
_clint > "$target" || ret=$?
|
||||||
|
done
|
||||||
|
exit $ret
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#$Id$
|
#$Id$
|
||||||
#Copyright (c) 2013-2014 Pierre Pronchery <khorben@defora.org>
|
#Copyright (c) 2013-2022 Pierre Pronchery <khorben@defora.org>
|
||||||
#
|
#
|
||||||
#Redistribution and use in source and binary forms, with or without
|
#Redistribution and use in source and binary forms, with or without
|
||||||
#modification, are permitted provided that the following conditions are met:
|
#modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -27,8 +27,7 @@
|
||||||
#variables
|
#variables
|
||||||
PROGNAME="cpp.sh"
|
PROGNAME="cpp.sh"
|
||||||
#executables
|
#executables
|
||||||
CPP="../src/cpp"
|
CPP="$OBJDIR../src/cpp"
|
||||||
[ -n "$OBJDIR" ] && CPP="${OBJDIR}../src/cpp"
|
|
||||||
|
|
||||||
|
|
||||||
#functions
|
#functions
|
||||||
|
@ -64,14 +63,14 @@ fi
|
||||||
if [ $# -eq 1 -a -n "$output" ]; then
|
if [ $# -eq 1 -a -n "$output" ]; then
|
||||||
target="$1"
|
target="$1"
|
||||||
|
|
||||||
LD_LIBRARY_PATH="../src" $CPP "$target" > "$output"
|
LD_LIBRARY_PATH="$OBJDIR../src/lib" $CPP "$target" > "$output"
|
||||||
elif [ $# -ge 1 -a -z "$output" ]; then
|
elif [ $# -ge 1 -a -z "$output" ]; then
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
target="$1"
|
target="$1"
|
||||||
output="${target%.cpp}.o"
|
output="${target%.cpp}.o"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
LD_LIBRARY_PATH="../src" $CPP "$target" > "$output"
|
LD_LIBRARY_PATH="$OBJDIR../src/lib" $CPP "$target" > "$output"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
_usage
|
_usage
|
||||||
|
|
102
tests/distcheck.sh
Executable file
102
tests/distcheck.sh
Executable file
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#$Id$
|
||||||
|
#Copyright (c) 2020 Pierre Pronchery <khorben@defora.org>
|
||||||
|
#
|
||||||
|
#Redistribution and use in source and binary forms, with or without
|
||||||
|
#modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#variables
|
||||||
|
CONFIGSH="${0%/distcheck.sh}/../config.sh"
|
||||||
|
CFLAGS=
|
||||||
|
LDFLAGS=
|
||||||
|
PROGNAME="distcheck.sh"
|
||||||
|
TARGET="tests.log"
|
||||||
|
#executables
|
||||||
|
DATE="date"
|
||||||
|
[ -n "$MAKE" ] || MAKE="make"
|
||||||
|
MKDIR="mkdir -p"
|
||||||
|
MKTEMP="mktemp"
|
||||||
|
RM="rm -f"
|
||||||
|
|
||||||
|
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||||
|
|
||||||
|
|
||||||
|
#distcheck
|
||||||
|
_distcheck()
|
||||||
|
{
|
||||||
|
(cd .. && $MAKE distcheck)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#date
|
||||||
|
_date()
|
||||||
|
{
|
||||||
|
if [ -n "$SOURCE_DATE_EPOCH" ]; then
|
||||||
|
TZ=UTC $DATE -d "@$SOURCE_DATE_EPOCH" '+%a %b %d %T %Z %Y'
|
||||||
|
else
|
||||||
|
$DATE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#usage
|
||||||
|
_usage()
|
||||||
|
{
|
||||||
|
echo "Usage: $PROGNAME [-c] target..." 1>&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#main
|
||||||
|
clean=0
|
||||||
|
while getopts "cO:P:" name; do
|
||||||
|
case "$name" in
|
||||||
|
c)
|
||||||
|
clean=1
|
||||||
|
;;
|
||||||
|
O)
|
||||||
|
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||||
|
;;
|
||||||
|
P)
|
||||||
|
#XXX ignored
|
||||||
|
;;
|
||||||
|
?)
|
||||||
|
_usage
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
_usage
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ $# -ne 0 ]; do
|
||||||
|
target="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
[ "$clean" -eq 0 ] || break
|
||||||
|
|
||||||
|
(_date; echo; _distcheck) > "$target" || exit 2
|
||||||
|
done
|
||||||
|
exit 0
|
261
tests/fixme.sh
Executable file
261
tests/fixme.sh
Executable file
|
@ -0,0 +1,261 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#$Id$
|
||||||
|
#Copyright (c) 2017-2022 Pierre Pronchery <khorben@defora.org>
|
||||||
|
#
|
||||||
|
#Redistribution and use in source and binary forms, with or without
|
||||||
|
#modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#variables
|
||||||
|
CONFIGSH="${0%/fixme.sh}/../config.sh"
|
||||||
|
PROGNAME="fixme.sh"
|
||||||
|
PROJECTCONF="../project.conf"
|
||||||
|
REGEXP_ERROR="FIXME"
|
||||||
|
REGEXP_WARNING="\\(TODO\|XXX\\)"
|
||||||
|
#executables
|
||||||
|
DATE="date"
|
||||||
|
DEBUG="_debug"
|
||||||
|
FIND="find"
|
||||||
|
GREP="grep"
|
||||||
|
HEAD="head"
|
||||||
|
MKDIR="mkdir -p"
|
||||||
|
SORT="sort -n"
|
||||||
|
TR="tr"
|
||||||
|
|
||||||
|
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||||
|
|
||||||
|
|
||||||
|
#functions
|
||||||
|
#fixme
|
||||||
|
_fixme()
|
||||||
|
{
|
||||||
|
res=0
|
||||||
|
subdirs=
|
||||||
|
|
||||||
|
$DATE
|
||||||
|
echo
|
||||||
|
while read line; do
|
||||||
|
case "$line" in
|
||||||
|
"["*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"subdirs="*)
|
||||||
|
subdirs=${line#subdirs=}
|
||||||
|
subdirs=$(echo "$subdirs" | $TR ',' ' ')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done < "$PROJECTCONF"
|
||||||
|
if [ ! -n "$subdirs" ]; then
|
||||||
|
_error "Could not locate directories to analyze"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
for subdir in $subdirs; do
|
||||||
|
[ -d "../$subdir" ] || continue
|
||||||
|
for filename in $($FIND "../$subdir" -type f | $SORT); do
|
||||||
|
callback=$(_fixme_callback "$filename")
|
||||||
|
[ -n "$callback" ] || continue
|
||||||
|
($callback "$filename") 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "$PROGNAME: $filename: FAIL" 1>&2
|
||||||
|
res=2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
return $res
|
||||||
|
}
|
||||||
|
|
||||||
|
_fixme_callback()
|
||||||
|
{
|
||||||
|
filename="$1"
|
||||||
|
ext=${filename##*/}
|
||||||
|
ext=${ext%.in}
|
||||||
|
ext=${ext##*.}
|
||||||
|
callback=
|
||||||
|
|
||||||
|
case "$ext" in
|
||||||
|
asm|S)
|
||||||
|
echo "_fixme_callback_asm"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
c|cc|cpp|cxx|go|h|js|v)
|
||||||
|
echo "_fixme_callback_c"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
conf|sh)
|
||||||
|
echo "_fixme_callback_sh"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
py)
|
||||||
|
echo "_fixme_callback_python"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
htm|html|xml|xsl)
|
||||||
|
echo "_fixme_callback_xml"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case $($HEAD -n 1 "$filename") in
|
||||||
|
"#!/bin/sh"*|"#! /bin/sh"*|\
|
||||||
|
"#!/usr/bin/env bash"*|"#! /usr/bin/env bash"*)
|
||||||
|
echo "_fixme_callback_sh"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
"#!/usr/bin/env python"*|"#! /usr/bin/env python"*)
|
||||||
|
echo "_fixme_callback_python"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
"<!DOCTYPE"*|"<!doctype"*|"<HTML"*|"<html"*|"<?xml"*)
|
||||||
|
echo "_fixme_callback_xml"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
|
||||||
|
_fixme_callback_asm()
|
||||||
|
{
|
||||||
|
res=0
|
||||||
|
filename="$1"
|
||||||
|
|
||||||
|
#warnings
|
||||||
|
$GREP -nH "/\\*.*$REGEXP_WARNING" "$filename"
|
||||||
|
#failures
|
||||||
|
$GREP -nH "/\\*.*$REGEXP_ERROR" "$filename" && res=2
|
||||||
|
return $res
|
||||||
|
}
|
||||||
|
|
||||||
|
_fixme_callback_c()
|
||||||
|
{
|
||||||
|
res=0
|
||||||
|
filename="$1"
|
||||||
|
|
||||||
|
#warnings
|
||||||
|
$GREP -nH "/\\(/\\|\\*\\).*$REGEXP_WARNING" "$filename"
|
||||||
|
#failures
|
||||||
|
$GREP -nH "/\\(/\\|\\*\\).*$REGEXP_ERROR" "$filename" && res=2
|
||||||
|
return $res
|
||||||
|
}
|
||||||
|
|
||||||
|
_fixme_callback_python()
|
||||||
|
{
|
||||||
|
res=0
|
||||||
|
filename="$1"
|
||||||
|
comment="#"
|
||||||
|
|
||||||
|
#warnings
|
||||||
|
$GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
|
||||||
|
#failures
|
||||||
|
$GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
|
||||||
|
return $res
|
||||||
|
}
|
||||||
|
|
||||||
|
_fixme_callback_sh()
|
||||||
|
{
|
||||||
|
res=0
|
||||||
|
filename="$1"
|
||||||
|
comment="#"
|
||||||
|
|
||||||
|
#warnings
|
||||||
|
$GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
|
||||||
|
#failures
|
||||||
|
$GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
|
||||||
|
return $res
|
||||||
|
}
|
||||||
|
|
||||||
|
_fixme_callback_xml()
|
||||||
|
{
|
||||||
|
res=0
|
||||||
|
filename="$1"
|
||||||
|
|
||||||
|
#XXX limited to a single line
|
||||||
|
#warnings
|
||||||
|
$GREP -nH "<!--.*$REGEXP_WARNING" "$filename"
|
||||||
|
#failures
|
||||||
|
$GREP -nH "<!--.*$REGEXP_ERROR" "$filename" && res=2
|
||||||
|
return $res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#debug
|
||||||
|
_debug()
|
||||||
|
{
|
||||||
|
echo "$@" 1>&3
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#error
|
||||||
|
_error()
|
||||||
|
{
|
||||||
|
echo "$PROGNAME: $@" 1>&2
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#usage
|
||||||
|
_usage()
|
||||||
|
{
|
||||||
|
echo "Usage: $PROGNAME [-c] target..." 1>&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#main
|
||||||
|
clean=0
|
||||||
|
while getopts "cO:P:" name; do
|
||||||
|
case "$name" in
|
||||||
|
c)
|
||||||
|
clean=1
|
||||||
|
;;
|
||||||
|
O)
|
||||||
|
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||||
|
;;
|
||||||
|
P)
|
||||||
|
#XXX ignored for compatibility
|
||||||
|
;;
|
||||||
|
?)
|
||||||
|
_usage
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
_usage
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
#clean
|
||||||
|
[ $clean -ne 0 ] && exit 0
|
||||||
|
|
||||||
|
exec 3>&1
|
||||||
|
ret=0
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
target="$1"
|
||||||
|
dirname="${target%/*}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
|
||||||
|
$MKDIR -- "$dirname" || ret=$?
|
||||||
|
fi
|
||||||
|
_fixme > "$target" || ret=$?
|
||||||
|
done
|
||||||
|
exit $ret
|
|
@ -1,28 +1,49 @@
|
||||||
targets=define.o,if.o,include.o
|
targets=clint.log,define.o,distcheck.log,fixme.log,if.o,include.o
|
||||||
cxx=./cpp.sh
|
cxx=./cpp.sh
|
||||||
cxxflags=
|
cxxflags=
|
||||||
dist=Makefile,cpp.sh,include-define.cpp
|
dist=Makefile,clint.sh,cpp.sh,distcheck.sh,fixme.sh,include-define.cpp
|
||||||
|
|
||||||
|
#targets
|
||||||
|
[clint.log]
|
||||||
|
type=script
|
||||||
|
script=./clint.sh
|
||||||
|
flags=-O CPPFLAGS="-I../include"
|
||||||
|
depends=clint.sh
|
||||||
|
enabled=0
|
||||||
|
|
||||||
[define.o]
|
[define.o]
|
||||||
type=object
|
type=object
|
||||||
sources=define.cpp
|
sources=define.cpp
|
||||||
depends=../src/cpp
|
depends=../src/cpp
|
||||||
|
|
||||||
[define.cpp]
|
[distcheck.log]
|
||||||
depends=cpp.sh
|
type=script
|
||||||
|
script=./distcheck.sh
|
||||||
|
depends=distcheck.sh
|
||||||
|
enabled=0
|
||||||
|
|
||||||
|
[fixme.log]
|
||||||
|
type=script
|
||||||
|
script=./fixme.sh
|
||||||
|
depends=fixme.sh
|
||||||
|
enabled=0
|
||||||
|
|
||||||
[if.o]
|
[if.o]
|
||||||
type=object
|
type=object
|
||||||
sources=if.cpp
|
sources=if.cpp
|
||||||
depends=../src/cpp
|
depends=../src/cpp
|
||||||
|
|
||||||
[if.cpp]
|
|
||||||
depends=cpp.sh
|
|
||||||
|
|
||||||
[include.o]
|
[include.o]
|
||||||
type=object
|
type=object
|
||||||
sources=include.cpp
|
sources=include.cpp
|
||||||
depends=../src/cpp
|
depends=../src/cpp
|
||||||
|
|
||||||
|
#sources
|
||||||
|
[define.cpp]
|
||||||
|
depends=cpp.sh
|
||||||
|
|
||||||
|
[if.cpp]
|
||||||
|
depends=cpp.sh
|
||||||
|
|
||||||
[include.cpp]
|
[include.cpp]
|
||||||
depends=cpp.sh
|
depends=cpp.sh
|
||||||
|
|
Loading…
Reference in New Issue
Block a user