Skip to content

Commit

Permalink
Merge pull request #10 from cxw42/dev
Browse files Browse the repository at this point in the history
Add templates; add tests, code-coverage checks
  • Loading branch information
cxw42 authored Sep 8, 2020
2 parents def0870 + 5838247 commit 87e053e
Show file tree
Hide file tree
Showing 48 changed files with 1,995 additions and 137 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ pfft
*.idb
*.pdb

# Coverage
*.gcda
*.gcno
/*coverage.info
/*coverage/

# Kernel Module Compile Results
*.mod*
*.cmd
Expand All @@ -63,6 +69,7 @@ dkms.conf

# autotools
/aclocal.m4
/aminclude_static.am
/autom4te.cache/
/build-aux/
conf*.dir/
Expand Down
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ addons:
- valadoc
- graphviz-dev
- help2man
- lcov
- autotools-dev
- libpango1.0-dev
- libsnapd-glib-dev
Expand All @@ -28,11 +29,19 @@ before_script:

script:
- ./configure --disable-dependency-tracking
# The dependency tracking doesn't work on Travis for some reason ---
# The dependency tracking doesn't work on Travis for some reason ---
# e.g, https://travis-ci.org/github/cxw42/pfft/builds/718187356
- make V=1
- make test V=1

after_failure:
- find . -name pfft-logging.h -exec sh -c 'echo "$0" ; cat "$0"' {} ';'
- ls -alR
- find . -name Makefile -exec sh -c 'echo "$0" ; cat "$0"' {} ';'

after_success:
- |
make -j maintainer-clean ; ./bootstrap && \
./configure --disable-dependency-tracking --enable-code-coverage USER_VALAFLAGS='-g' CFLAGS='-g -O0' && \
make -j4 check-code-coverage && \
bash <(curl -s https://codecov.io/bash) ; : -f pfft-coverage.info
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Install Vala:

Install development dependencies for pfft:

$ sudo apt install -y libpango1.0-dev libgee-0.8-dev libgstreamer1.0-dev autotools-dev uncrustify perl
$ sudo apt install -y libpango1.0-dev libgee-0.8-dev libgstreamer1.0-dev autotools-dev uncrustify perl lcov

Initialize submodules:

Expand All @@ -64,6 +64,13 @@ Note: `libpango1.0-dev` pulls in Pango, Cairo, and pangocairo.
In GLib 2.62+, the default output format is TAP. Therefore, you can do
`make build-tests && prove`.

### Checking code coverage

./configure --enable-code-coverage && make -j4 check-code-coverage

This will print a summary to the console. For the full report, open
`pfft-<VERSION>-coverage/index.html` in a Web browser.

### Making a release

$ make distcheck
Expand Down Expand Up @@ -93,6 +100,13 @@ Before submitting a PR, please run `make prep`. This will:
be left in the tree. To remove the generated C files,
`make maintainer-clean`.

### Design decisions

- Decisions about the exact appearance of an item should be made as late
as possible. For example, in the `pango-markup` writer (the default),
headers and footers are set in smaller type by the writer, not the upstream
code that feeds markup to the writer.

## Thanks

- <https://github.com/stefantalpalaru/vala-skeleton-autotools>
Expand Down
29 changes: 28 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dnl === Basic setup =======================================================
AC_INIT([pfft markdown-to-PDF converter], [0.0.1], [], [pfft], [https://github.com/cxw42/pfft])
AC_INIT([pfft markdown-to-PDF converter], [0.0.2], [], [pfft], [https://github.com/cxw42/pfft])
AC_PREREQ([2.65])
AC_COPYRIGHT([Copyright (C) 2020 Christopher White])
AC_CONFIG_SRCDIR([rules.mk]) dnl make sure the srcdir is correctly specified
Expand All @@ -24,6 +24,33 @@ AC_ARG_VAR([USER_VALAFLAGS], [extra options for valac(1)])

AC_PROG_RANLIB

dnl === Code coverage =====================================================

dnl For some reason, the coverage data is referring to src/.../glib-2.0.vapi.
dnl Inject code to strip that from the .info file so genhtml can succeed.
dnl This is all very ugly. For example, the variables in this section are
dnl hardwired for use in a Makefile, since they assume Makefile syntax
dnl (embedded in sh(1) escaping).

AC_CHECK_PROG([GENHTMLREAL], [genhtml], [genhtml])

GENHTMLHACK="\$(GENHTMLREAL)"
AC_CHECK_PROG([GENHTML], [genhtml], [\$(GENHTMLHACK)])

AX_AM_MACROS_STATIC
AX_CODE_COVERAGE

AM_COND_IF(
[CODE_COVERAGE_ENABLED],
[ dnl then
AC_SUBST([GENHTMLHACK], ['dnl
perl -n -i -e '"'"'print unless m{\b(?:src|t)/?.*?/glib-2.0.vapi}..m{^end_of_record}'"'"' "$(CODE_COVERAGE_OUTPUT_FILE)" ; dnl
LANG=C $(GENHTMLREAL) dnl
'])
]
)


dnl === Sanity checks =====================================================

AC_MSG_CHECKING([for local md4c])
Expand Down
32 changes: 32 additions & 0 deletions m4/ax_ac_append_to_file.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_ac_append_to_file.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_AC_APPEND_TO_FILE([FILE],[DATA])
#
# DESCRIPTION
#
# Appends the specified data to the specified Autoconf is run. If you want
# to append to a file when configure is run use AX_APPEND_TO_FILE instead.
#
# LICENSE
#
# Copyright (c) 2009 Allan Caffee <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 10

AC_DEFUN([AX_AC_APPEND_TO_FILE],[
AC_REQUIRE([AX_FILE_ESCAPES])
m4_esyscmd(
AX_FILE_ESCAPES
[
printf "%s" "$2" >> "$1"
])
])
32 changes: 32 additions & 0 deletions m4/ax_ac_print_to_file.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_ac_print_to_file.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_AC_PRINT_TO_FILE([FILE],[DATA])
#
# DESCRIPTION
#
# Writes the specified data to the specified file when Autoconf is run. If
# you want to print to a file when configure is run use AX_PRINT_TO_FILE
# instead.
#
# LICENSE
#
# Copyright (c) 2009 Allan Caffee <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 10

AC_DEFUN([AX_AC_PRINT_TO_FILE],[
m4_esyscmd(
AC_REQUIRE([AX_FILE_ESCAPES])
[
printf "%s" "$2" > "$1"
])
])
28 changes: 28 additions & 0 deletions m4/ax_add_am_macro_static.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_add_am_macro_static.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_ADD_AM_MACRO_STATIC([RULE])
#
# DESCRIPTION
#
# Adds the specified rule to $AMINCLUDE.
#
# LICENSE
#
# Copyright (c) 2009 Tom Howard <[email protected]>
# Copyright (c) 2009 Allan Caffee <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 8

AC_DEFUN([AX_ADD_AM_MACRO_STATIC],[
AC_REQUIRE([AX_AM_MACROS_STATIC])
AX_AC_APPEND_TO_FILE(AMINCLUDE_STATIC,[$1])
])
38 changes: 38 additions & 0 deletions m4/ax_am_macros_static.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_am_macros_static.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_AM_MACROS_STATIC
#
# DESCRIPTION
#
# Adds support for macros that create Automake rules. You must manually
# add the following line
#
# include $(top_srcdir)/aminclude_static.am
#
# to your Makefile.am files.
#
# LICENSE
#
# Copyright (c) 2009 Tom Howard <[email protected]>
# Copyright (c) 2009 Allan Caffee <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 11

AC_DEFUN([AMINCLUDE_STATIC],[aminclude_static.am])

AC_DEFUN([AX_AM_MACROS_STATIC],
[
AX_AC_PRINT_TO_FILE(AMINCLUDE_STATIC,[
# ]AMINCLUDE_STATIC[ generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on ]m4_esyscmd([LC_ALL=C date])[
])
])
95 changes: 95 additions & 0 deletions m4/ax_check_gnu_make.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_GNU_MAKE([run-if-true],[run-if-false])
#
# DESCRIPTION
#
# This macro searches for a GNU version of make. If a match is found:
#
# * The makefile variable `ifGNUmake' is set to the empty string, otherwise
# it is set to "#". This is useful for including a special features in a
# Makefile, which cannot be handled by other versions of make.
# * The makefile variable `ifnGNUmake' is set to #, otherwise
# it is set to the empty string. This is useful for including a special
# features in a Makefile, which can be handled
# by other versions of make or to specify else like clause.
# * The variable `_cv_gnu_make_command` is set to the command to invoke
# GNU make if it exists, the empty string otherwise.
# * The variable `ax_cv_gnu_make_command` is set to the command to invoke
# GNU make by copying `_cv_gnu_make_command`, otherwise it is unset.
# * If GNU Make is found, its version is extracted from the output of
# `make --version` as the last field of a record of space-separated
# columns and saved into the variable `ax_check_gnu_make_version`.
# * Additionally if GNU Make is found, run shell code run-if-true
# else run shell code run-if-false.
#
# Here is an example of its use:
#
# Makefile.in might contain:
#
# # A failsafe way of putting a dependency rule into a makefile
# $(DEPEND):
# $(CC) -MM $(srcdir)/*.c > $(DEPEND)
#
# @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
# @ifGNUmake@ include $(DEPEND)
# @ifGNUmake@ else
# fallback code
# @ifGNUmake@ endif
#
# Then configure.in would normally contain:
#
# AX_CHECK_GNU_MAKE()
# AC_OUTPUT(Makefile)
#
# Then perhaps to cause gnu make to override any other make, we could do
# something like this (note that GNU make always looks for GNUmakefile
# first):
#
# if ! test x$_cv_gnu_make_command = x ; then
# mv Makefile GNUmakefile
# echo .DEFAULT: > Makefile ;
# echo \ $_cv_gnu_make_command \$@ >> Makefile;
# fi
#
# Then, if any (well almost any) other make is called, and GNU make also
# exists, then the other make wraps the GNU make.
#
# LICENSE
#
# Copyright (c) 2008 John Darrington <[email protected]>
# Copyright (c) 2015 Enrico M. Crisostomo <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 12

AC_DEFUN([AX_CHECK_GNU_MAKE],dnl
[AC_PROG_AWK
AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl
_cv_gnu_make_command="" ;
dnl Search all the common names for GNU make
for a in "$MAKE" make gmake gnumake ; do
if test -z "$a" ; then continue ; fi ;
if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
_cv_gnu_make_command=$a ;
AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make")
ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }')
break ;
fi
done ;])
dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])])
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifnGNUmake], [""])], [AS_VAR_SET([ifnGNUmake], ["#"])])
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])])
AS_VAR_IF([_cv_gnu_make_command], [""],[$2],[$1])
AC_SUBST([ifGNUmake])
AC_SUBST([ifnGNUmake])
])
Loading

0 comments on commit 87e053e

Please sign in to comment.