Commit 3b2f64d1 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Add a program! Yay!

parent 65ac81b0
Pipeline #66261 passed with stage
in 1 minute and 45 seconds
......@@ -106,6 +106,10 @@ src/liblibtarot.la
src/libtarot.pc
src/parser/check-parser
src/parser/tarot.c
src/program/cmdline.c
src/program/cmdline.h
src/program/tarot
src/program/tarot.6.gz
src/scm/tarot
src/scm/tarot-resource-compiler
src/status/check
......
......@@ -3,7 +3,7 @@ image: tarotbis/build:latest
before_script:
- apt-get update
- apt-get upgrade -y
- apt-get install -y --no-install-recommends texlive-base texlive-latex-base git ca-certificates texlive-fonts-recommended texlive-generic-recommended autoconf automake gettext autopoint libtool texinfo gnulib autoconf-archive gobject-introspection make gcc valac valac-vapi gtk-doc-tools flex bison gperf nettle-dev libgtk-3-dev libgirepository1.0-dev emacs org-mode indent doxygen graphviz lcov dejagnu check libxml2-utils xsltproc wget
- apt-get install -y --no-install-recommends texlive-base texlive-latex-base git ca-certificates texlive-fonts-recommended texlive-generic-recommended autoconf automake gettext autopoint libtool texinfo gnulib autoconf-archive gobject-introspection make gcc valac valac-vapi gtk-doc-tools flex bison gperf nettle-dev libgtk-3-dev libgirepository1.0-dev emacs org-mode indent doxygen graphviz lcov dejagnu check libxml2-utils xsltproc wget gengetopt help2man
stages:
- deploy
......
FROM debian:stable
RUN apt-get update
RUN apt-get install -y --no-install-recommends texlive-base texlive-latex-base git ca-certificates texlive-fonts-recommended texlive-generic-recommended autoconf automake gettext autopoint libtool texinfo gnulib autoconf-archive gobject-introspection make gcc valac valac-vapi gtk-doc-tools flex bison gperf nettle-dev libgtk-3-dev libgirepository1.0-dev emacs org-mode indent doxygen graphviz lcov dejagnu check libxml2-utils xsltproc wget
RUN apt-get install -y --no-install-recommends texlive-base texlive-latex-base git ca-certificates texlive-fonts-recommended texlive-generic-recommended autoconf automake gettext autopoint libtool texinfo gnulib autoconf-archive gobject-introspection make gcc valac valac-vapi gtk-doc-tools flex bison gperf nettle-dev libgtk-3-dev libgirepository1.0-dev emacs org-mode indent doxygen graphviz lcov dejagnu check libxml2-utils xsltproc wget gengetopt help2man
RUN apt-get upgrade -y
MAINTAINER framagit.org/gugurumbe/tarot
\ No newline at end of file
......@@ -18,6 +18,7 @@
SUBDIRS = po
AUTOMAKE_OPTIONS = subdir-objects
mansixdir = $(datadir)/man6
bin_PROGRAMS =
bin_SCRIPTS =
dist_bin_SCRIPTS =
......@@ -30,6 +31,7 @@ pkgconfigdir = $(datadir)/pkgconfig
pkgconfig_DATA =
pkgdatadir = $(datadir)/@PACKAGE@
pkgdata_SCRIPTS =
dist_mansix_DATA =
INDENTED =
SUFFIXES =
dist_noinst_SCRIPTS = \
......@@ -56,7 +58,9 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-silent-rules=yes \
--disable-code-coverage \
--disable-gperf \
--disable-flex
--disable-flex \
--disable-gengetopt \
--disable-help2man
AM_CPPFLAGS = -DLOCALEDIR="\"$(localedir)\"" -I. -I$(srcdir)
AM_CFLAGS =
AM_YFLAGS = -d
......
......@@ -17,7 +17,8 @@ _________________
..... 4.1.1 The git pre-commit hook
..... 4.1.2 The CI/CD pipeline
.. 4.2 Everyone: configure, make and install
5 Let me know
5 Introspection and cross-compilation
6 Let me know
......@@ -135,8 +136,41 @@ http://gugurumbe.frama.io/tarot/tarot-devel.tar.gz
linker flags as instructed at the end of `./configure --help'.
5 Let me know
5 Introspection and cross-compilation
=====================================
This package uses some introspection techniques: /help2man/, and maybe
in the future (distributed) code coverage and GObject introspection.
It means that you will need to run some just-built code in order to
update some distributed files. In case you are cross-compiling the
package, you may not be able to run the built code, so the
introspection will not work. Most of the time, you will not have to
do anything, since the results of the introspection will be up to
date. However, if you patch some specific source files, then the
results of the introspection will need to be re-built.
Here is a way out: if you intend to change the source code,
- configure the program out-of-source for the BUILD system [1];
- configure the program out-of-source for the HOST system;
- patch the source;
- in the BUILD directory, run "make dist", or even "make distcheck";
- in the HOST directory, you can safely compile and DESTDIR install,
since the results of the introspection are now up to date. I'm
generally not using cross-compilation myself so the theory may not
hold in practice. If you still get an error, then please, report a
bug!
6 Let me know
=============
I develop Tarot as a personal hobby. If you find it interesting, or
have bugs to submit, please let me know: `vivien@planete-kraus.eu'
Footnotes
_________
[1] See INSTALL for out-of-source configuration
# Table of Contents
1. [READ ME](#org7a2beec)
2. [About tarot](#org7af94e6)
3. [Project site](#org3f643fb)
4. [Compile this project](#orgdb94484)
1. [Gitlab users: make a source distribution](#org274450d)
1. [The git pre-commit hook](#org34778df)
2. [The CI/CD pipeline](#org9402a70)
2. [Everyone: configure, make and install](#org6e132d9)
5. [Let me know](#org629d015)
1. [READ ME](#org9f06ff3)
2. [About tarot](#org4bf0263)
3. [Project site](#orgc9ca723)
4. [Compile this project](#orga627b20)
1. [Gitlab users: make a source distribution](#org1ec3712)
1. [The git pre-commit hook](#org325403e)
2. [The CI/CD pipeline](#org311ea92)
2. [Everyone: configure, make and install](#org1a24dae)
5. [Introspection and cross-compilation](#orgd6dad60)
6. [Let me know](#orgb6d349a)
<a id="org7a2beec"></a>
<a id="org9f06ff3"></a>
# READ ME
RUN THE CONFIGURE SCRIPT NOT `autogen.sh`. If you don't have a
configure script, see section [4.1](#org274450d).
configure script, see section [4.1](#org1ec3712).
<a id="org7af94e6"></a>
<a id="org4bf0263"></a>
# About tarot
......@@ -30,14 +31,14 @@ Of Tarot*. It aims at providing a game and an artificial
intelligence.
<a id="org3f643fb"></a>
<a id="orgc9ca723"></a>
# Project site
Go check out the [project manual](http://gugurumbe.frama.io/tarot/share/doc/tarot/tarot.html/index.html) and the [project code coverage report](http://gugurumbe.frama.io/tarot/coverage/index.html).
<a id="orgdb94484"></a>
<a id="orga627b20"></a>
# Compile this project
......@@ -49,7 +50,7 @@ some more work. Note that a source distribution is already available
my autotools!).
<a id="org274450d"></a>
<a id="org1ec3712"></a>
## Gitlab users: make a source distribution
......@@ -61,10 +62,10 @@ distribution, such as emacs with a recent enough version of org-mode
is *not* available, or difficult to install, then I advise you to make
a *source* distribution from an easier system or download [the build
from the latest passing commit](http://gugurumbe.frama.io/tarot/tarot-devel.tar.gz), and then use this distribution as
discussed in section [4.2](#org6e132d9).
discussed in section [4.2](#org1a24dae).
<a id="org34778df"></a>
<a id="org325403e"></a>
### The git pre-commit hook
......@@ -88,7 +89,7 @@ the project. And if you disable the hook, then the CI pipeline is
very likely to fail anyways.
<a id="org9402a70"></a>
<a id="org311ea92"></a>
### The CI/CD pipeline
......@@ -104,7 +105,7 @@ Dockerfile and `.gitlab-ci.yml`.
I already have bison, flex and gperf, and emacs, in that category.
<a id="org6e132d9"></a>
<a id="org1a24dae"></a>
## Everyone: configure, make and install
......@@ -120,10 +121,43 @@ a pkg-config configuration. In this case, pass the compiler flags and
linker flags as instructed at the end of `./configure --help`.
<a id="org629d015"></a>
<a id="orgd6dad60"></a>
# Introspection and cross-compilation
This package uses some introspection techniques: *help2man*, and maybe
in the future (distributed) code coverage and GObject introspection.
It means that you will need to run some just-built code in order to
update some distributed files. In case you are cross-compiling the
package, you may not be able to run the built code, so the
introspection will not work. Most of the time, you will not have to
do anything, since the results of the introspection will be up to
date. However, if you patch some specific source files, then the
results of the introspection will need to be re-built.
Here is a way out: if you intend to change the source code,
- configure the program out-of-source for the BUILD system <sup><a id="fnr.1" class="footref" href="#fn.1">1</a></sup>;
- configure the program out-of-source for the HOST system;
- patch the source;
- in the BUILD directory, run "make dist", or even "make distcheck";
- in the HOST directory, you can safely compile and DESTDIR install,
since the results of the introspection are now up to date. I'm
generally not using cross-compilation myself so the theory may not
hold in practice. If you still get an error, then please, report a
bug!
<a id="orgb6d349a"></a>
# Let me know
I develop Tarot as a personal hobby. If you find it interesting, or
have bugs to submit, please let me know: `vivien@planete-kraus.eu`
# Footnotes
<sup><a id="fn.1" href="#fnr.1">1</a></sup> See
INSTALL for out-of-source configuration
......@@ -77,6 +77,29 @@ There are some dependencies, some optional, some are known not to have
a pkg-config configuration. In this case, pass the compiler flags and
linker flags as instructed at the end of ~./configure --help~.
* Introspection and cross-compilation
This package uses some introspection techniques: /help2man/, and maybe
in the future (distributed) code coverage and GObject introspection.
It means that you will need to run some just-built code in order to
update some distributed files. In case you are cross-compiling the
package, you may not be able to run the built code, so the
introspection will not work. Most of the time, you will not have to
do anything, since the results of the introspection will be up to
date. However, if you patch some specific source files, then the
results of the introspection will need to be re-built.
Here is a way out: if you intend to change the source code,
- configure the program out-of-source for the BUILD system [fn::See
INSTALL for out-of-source configuration];
- configure the program out-of-source for the HOST system;
- patch the source;
- in the BUILD directory, run "make dist", or even "make distcheck";
- in the HOST directory, you can safely compile and DESTDIR install,
since the results of the introspection are now up to date. I'm
generally not using cross-compilation myself so the theory may not
hold in practice. If you still get an error, then please, report a
bug!
* Let me know
I develop Tarot as a personal hobby. If you find it interesting, or
have bugs to submit, please let me know: =vivien@planete-kraus.eu=
......@@ -54,6 +54,15 @@ AS_IF([test "x$enable_bison" != "xno"], [
])
])
AM_CONDITIONAL([HAVE_BISON], [test "x$BISON_FOUND" = xyes])
AC_ARG_ENABLE([gengetopt], AS_HELP_STRING([--disable-gengetopt],
[Do not use the gengetopt parser generator]))
AS_IF([test "x$enable_gengetopt" != "xno"], [
AC_PATH_PROG([GENGETOPT], [gengetopt], [no])
AS_IF([test "x$GENGETOPT" != xno], [
GENGETOPT_FOUND="yes"
])
])
AM_CONDITIONAL([HAVE_GENGETOPT], [test "x$GENGETOPT_FOUND" = xyes])
AC_ARG_ENABLE([valgrind], AS_HELP_STRING([--enable-valgrind=yes],
[Run the unit tests under valgrind (slow, incompatible with asan)]))
AS_IF([test "x$enable_valgrind" = "xyes"], [
......@@ -66,6 +75,15 @@ AS_IF([test "x$enable_valgrind" = "xyes"], [
])
])
AM_CONDITIONAL([HAVE_VALGRIND], [test "x$HAVE_VALGRIND" = "xyes"])
AC_ARG_ENABLE([help2man], AS_HELP_STRING([--disable-help2man],
[Do not use the help2man generator for manual pages]))
AS_IF([test "x$enable_help2man" != "xno"], [
AC_PATH_PROG([HELP2MAN], [help2man], [no])
AS_IF([test "x$HELP2MAN" != xno], [
HELP2MAN_FOUND="yes"
])
])
AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN_FOUND" = xyes])
AC_ARG_ENABLE([indent],
AS_HELP_STRING([--disable-indent], [Disable GNU indent]))
AS_IF([test "x$enable_indent" != "xno"],
......@@ -131,6 +149,51 @@ AS_IF([test "x$FOUND" = "xyes"], [
AC_DEFINE([HAVE_LIBUNISTRING], [0], [Some headers or functions of libunistring are not available])
])
AC_MSG_CHECKING([for a way to recover from an unused but set variable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(, [[int set_but_not_used; set_but_not_used = 42;]])
], [
AC_MSG_RESULT([nothing needed])
], [
dnl Comes BEFORE the normal cflags since it will be part of
dnl AM_CFLAGS, which always come before CFLAGS in the compiler
dnl invocation. And it works on GCC.
TESTED_FLAG="-Wno-error=unused-but-set-variable"
NORMAL_CFLAGS="$CFLAGS"
CFLAGS="$TESTED_FLAG $NORMAL_CFLAGS"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(, [[int set_but_not_used; set_but_not_used = 42;]])
], [
AC_MSG_RESULT([$TESTED_FLAG])
], [
AC_MSG_RESULT([none found])
AC_MSG_ERROR([Could not find a way to recover from unused but set variable, please remove -Werror from the compiler flags])
])
NORMAL_CFLAGS="$CFLAGS"
])
AC_SUBST([SUPPRESS_WARNING_UNUSED_BUT_SET_VARIABLE_CFLAGS], [$TESTED_FLAG])
AC_MSG_CHECKING([for a way to recover from an unused function])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[static int not_used (void);]],)
], [
AC_MSG_RESULT([nothing needed])
], [
TESTED_FLAG="-Wno-error=unused-function"
NORMAL_CFLAGS="$CFLAGS"
CFLAGS="$TESTED_FLAG $NORMAL_CFLAGS"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[static int not_used (void);]],)
], [
AC_MSG_RESULT([$TESTED_FLAG])
], [
AC_MSG_RESULT([none found])
AC_MSG_ERROR([Could not find a way to recover from unused but set variable, please remove -Werror from the compiler flags])
])
NORMAL_CFLAGS="$CFLAGS"
])
AC_SUBST([SUPPRESS_WARNING_UNUSED_FUNCTION_CFLAGS], [$TESTED_FLAG])
AC_CONFIG_FILES([
Makefile
po/Makefile.in
......
......@@ -55,9 +55,10 @@ For "they" (please check that with extra care too):
* Texinfo setup :noexport:
#+texinfo_header: @syncodeindex pg cp
* Other macros :noexport:
#+macro: iftexinfo (eval (format "@@texinfo:@c@@ %s\n @@texinfo:%s@@" (replace-regexp-in-string "[ \t\r\n]+" " " "$2") (replace-regexp-in-string "[ \t\r\n]+" " " "$1")))
#+macro: iftexinfo (eval (if (org-export-derived-backend-p 'texinfo org-export-current-backend) "@@texinfo:$1@@" "$2"))
#+macro: math {{{iftexinfo(@math{$1},\($1\))}}}
#+macro: dfn {{{iftexinfo(@dfn{$1},/$1/)}}}
#+macro: command {{{iftexinfo(@command{$1},=$1=)}}}
#+macro: copyright {{{iftexinfo(@copyright{},\copy)}}}
* Copying
:PROPERTIES:
......@@ -586,9 +587,15 @@ A new game can then begin, with the new first player being the
previous second.
* TODO Invoking tarot
#+PINDEX: tarot
#+CINDEX: Invoking @@texinfo:@command{@@tarot@@texinfo:}@@
#+CINDEX: Invoking @command{tarot}
The {{{command(tarot)}}} program accepts a number arguments.
Please fix me.
** General arguments
The {{{command(--help)}}} ({{{command(-h)}}}) prints a brief
description of the options of the program, and exits.
The {{{command(--version)}}} ({{{command(-V)}}}) prints the version
information, and exits.
* GNU Free Documentation License
:PROPERTIES:
......
......@@ -51,3 +51,4 @@ include %reldir%/cards/Makefile.am
include %reldir%/lexer/Makefile.am
include %reldir%/command/Makefile.am
include %reldir%/parser/Makefile.am
include %reldir%/program/Makefile.am
# Makefile.am
#
# Copyright (C) 2018 Vivien Kraus <vivien@planete-kraus.eu>
#
# 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 the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
bin_PROGRAMS += %reldir%/tarot
noinst_LTLIBRARIES += %reldir%/libcmdline.la
dist_mansix_DATA += %reldir%/tarot.6.gz
EXTRA_DIST += \
%reldir%/tarot.gg
%canon_reldir%_libcmdline_la_SOURCES = \
%reldir%/cmdline.c \
%reldir%/cmdline.h
%canon_reldir%_libcmdline_la_CFLAGS = \
$(asan_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
$(AM_CFLAGS) \
$(SUPPRESS_WARNING_UNUSED_BUT_SET_VARIABLE_CFLAGS) \
$(SUPPRESS_WARNING_UNUSED_FUNCTION_CFLAGS)
%canon_reldir%_libcmdline_la_CXXFLAGS = \
$(CODE_COVERAGE_CXXFLAGS) \
$(AM_CXXFLAGS)
%canon_reldir%_libcmdline_la_CPPFLAGS = \
$(CODE_COVERAGE_CPPFLAGS) \
$(AM_CPPFLAGS)
%canon_reldir%_libcmdline_la_LIBADD = \
$(asan_LIBS) \
$(CODE_COVERAGE_LIBS) \
$(AM_LIBS)
%canon_reldir%_tarot_SOURCES = \
%reldir%/main.c
%canon_reldir%_tarot_CFLAGS = \
$(asan_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
$(AM_CFLAGS)
%canon_reldir%_tarot_CXXFLAGS = \
$(CODE_COVERAGE_CXXFLAGS) \
$(AM_CXXFLAGS)
%canon_reldir%_tarot_CPPFLAGS = \
$(CODE_COVERAGE_CPPFLAGS) \
$(AM_CPPFLAGS)
%canon_reldir%_tarot_LDADD = \
%reldir%/libcmdline.la \
src/liblibtarot.la \
$(asan_LIBS) \
$(CODE_COVERAGE_LIBS) \
$(AM_LIBS)
AM_CPPFLAGS += -I $(srcdir)/%reldir% -I %reldir%
INDENTED += \
$(%canon_reldir%_libcmdline_la_SOURCES) \
$(%canon_reldir%_tarot_SOURCES)
if HAVE_GENGETOPT
%reldir%/cmdline.c %reldir%/cmdline.h: %reldir%/tarot.gg
$(AM_V_GEN) (cd $(srcdir)/%reldir% && $(GENGETOPT) < tarot.gg)
else
%reldir%/cmdline.c %reldir%/cmdline.h: %reldir%/tarot.gg
@ >&2 echo "Error: gengetopt is required to update the parser." \
&& >&2 echo "Re-run configure with --enable-gengetopt=yes" \
&& >&2 echo "If you were running \`make distcheck', this is a bug." \
&& exit 1
endif
if HAVE_HELP2MAN
%reldir%/tarot.6.gz: $(%canon_reldir%_tarot_SOURCES) $(%canon_reldir%_libcmdline_la_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) %reldir%/tarot
$(AM_V_GEN) ($(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=execute $(HELP2MAN) %reldir%/tarot \
| GZIP=$(GZIP_ENV) gzip > $(srcdir)/%reldir%/tarot.6.gz) \
|| (>&2 echo "Please refer to README regarding introspection and cross-compilation." \
&& exit 1)
else
%reldir%/tarot.6.gz: $(%canon_reldir%_tarot_SOURCES) $(%canon_reldir%_libcmdline_la_SOURCES)
@ >&2 echo "Error: help2man is required to update the man page." \
&& >&2 echo "Re-run configure with --enable-gengetopt=yes" \
&& exit 1
endif
/**
* file main.c Tarot main loop.
*
* Copyright (C) 2018 Vivien Kraus <vivien@planete-kraus.eu>
*
* 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 the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <tarot.h>
#include "cmdline.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
int
main (int argc, char *argv[])
{
struct gengetopt_args_info args;
int error = 0;
error = cmdline_parser (argc, argv, &args);
if (error == 0 && args.help_given)
{
cmdline_parser_print_help ();
return 0;
}
if (error == 0 && args.version_given)
{
cmdline_parser_print_version ();
}
if (error == 0)
{
printf ("What did you expect?\n");
}
return error;
}
purpose "Play the tarot game."
description "Manage a game of tarot."
versiontext "Copyright (C) 2017, 2018 Vivien Kraus \
<vivien@planete-kraus.eu>\nThis is free software; see the source for \
copying conditions. There is NO warranty; not even for \
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
args ""
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment