Skip to content

Commit

Permalink
Separate mypaint-config.h and config.h.
Browse files Browse the repository at this point in the history
MyPaint uses some of the constants from `mypaint-config.h` but much of
the generated part from configuration should not be public because it
conflicts with the configuration of other autotooled project.
Split it so that the generated constants are not in the public header.
This means also that config.h cannot be included from any of the other
public headers and the main problem with this was that the macro
MYPAINT_CONFIG_USE_GLIB cannot be used inside a public header anymore.
I slightly reorganized installed files to account for this.
  • Loading branch information
Jehan committed May 30, 2016
1 parent ae76bd4 commit 5e68f90
Show file tree
Hide file tree
Showing 34 changed files with 82 additions and 35 deletions.
14 changes: 4 additions & 10 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ACLOCAL_AMFLAGS = -I m4macros

if WITH_GLIB
libmypaint_glib = glib/mypaint-brush.h
endif

## GObject introspection ##

Expand Down Expand Up @@ -98,6 +100,7 @@ nobase_libmypaint_public_HEADERS = \

LIBMYPAINT_SOURCES = \
brushmodes.c \
config.h \
fifo.c \
helpers.c \
mypaint-mapping.c \
Expand All @@ -116,14 +119,7 @@ LIBMYPAINT_SOURCES = \

libmypaint_la_SOURCES = $(libmypaint_public_HEADERS) $(LIBMYPAINT_SOURCES)

# Force generated source files to be built first.
# Automatic dependency tracking does not always work as expected. See:
# https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html
BUILT_SOURCES = mypaint-config.h
DISTCLEANFILES = mypaint-config.h MyPaint-@LIBMYPAINT_MAJOR_VERSION@.@[email protected]

mypaint-config.h: mypaint-config.h.top config.h mypaint-config.h.bottom
cat $^ >$@
DISTCLEANFILES = MyPaint-@LIBMYPAINT_MAJOR_VERSION@.@[email protected]

EXTRA_DIST = \
brushsettings.json \
Expand All @@ -138,8 +134,6 @@ EXTRA_DIST = \
generate.py \
helpers.h \
libmypaint.c \
mypaint-config.h.bottom \
mypaint-config.h.top \
operationqueue.h \
rng-double.h \
tiled-surface-private.h \
Expand Down
2 changes: 2 additions & 0 deletions brushmodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include <stdint.h>
#include <assert.h>

Expand Down
2 changes: 2 additions & 0 deletions fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

#include <config.h>

#include <stdlib.h>
#include "fifo.h"

Expand Down
2 changes: 2 additions & 0 deletions gegl/mypaint-gegl-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include <stdlib.h>
#include <assert.h>

Expand Down
1 change: 1 addition & 0 deletions gegl/mypaint-gegl-surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

G_BEGIN_DECLS

#include <mypaint-config.h>
#include <glib/mypaint-gegl-glib.h>
#include <mypaint-tiled-surface.h>

Expand Down
3 changes: 0 additions & 3 deletions glib/mypaint-brush.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <mypaint-config.h>

#if MYPAINT_CONFIG_USE_GLIB
#include <glib-object.h>

#define MYPAINT_TYPE_BRUSH (mypaint_brush_get_type ())
Expand All @@ -22,6 +21,4 @@ GType mypaint_fixed_tiled_surface_get_type(void);
#define MYPAINT_VALUE_HOLDS_RECTANGLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), MYPAINT_TYPE_RECTANGLE))
GType mypaint_rectangle_get_type(void);

#endif

#endif // MYPAINTBRUSHGLIB_H
1 change: 1 addition & 0 deletions glib/mypaint-gegl-glib.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <config.h>
#include <mypaint-config.h>

#if MYPAINT_CONFIG_USE_GLIB
Expand Down
4 changes: 0 additions & 4 deletions glib/mypaint-gegl-glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@

#include <mypaint-config.h>

#if MYPAINT_CONFIG_USE_GLIB

#include <glib-object.h>
#define MYPAINT_GEGL_TYPE_TILED_SURFACE (mypaint_gegl_tiled_surface_get_type ())
#define MYPAINT_GEGL_VALUE_HOLDS_TILED_SURFACE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), MYPAINT_GEGL_TYPE_TILED_SURFACE))
GType mypaint_gegl_tiled_surface_get_type(void);

#endif

#endif // MYPAINTGEGLGLIB_H
2 changes: 2 additions & 0 deletions helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef HELPERS_C
#define HELPERS_C

#include <config.h>

#include <assert.h>
#include <stdint.h>
#include <math.h>
Expand Down
2 changes: 2 additions & 0 deletions mypaint-brush-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include "mypaint-brush-settings.h"

#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions mypaint-brush-settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <mypaint-config.h>
#include <mypaint-glib-compat.h>
#include <mypaint-brush-settings-gen.h>

Expand Down
7 changes: 7 additions & 0 deletions mypaint-brush.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>

#if MYPAINT_CONFIG_USE_GLIB
#include <glib.h>
#include <glib/mypaint-brush.h>
#endif

#include "mypaint-brush.h"

#include "mypaint-brush-settings.h"
Expand Down
4 changes: 1 addition & 3 deletions mypaint-brush.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <mypaint-glib-compat.h>
#include <mypaint-config.h>
#include <mypaint-surface.h>
#include <mypaint-brush-settings.h>

G_BEGIN_DECLS

typedef struct MyPaintBrush MyPaintBrush;

#include <glib/mypaint-brush.h>

MyPaintBrush *
mypaint_brush_new(void);

Expand Down
2 changes: 1 addition & 1 deletion mypaint-config.h.top → mypaint-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
#define MYPAINT_MAX_MIPMAP_LEVEL 4
#endif

/* Start generated config */
#endif /* MYPAINTCONFIG_H */
3 changes: 0 additions & 3 deletions mypaint-config.h.bottom

This file was deleted.

6 changes: 6 additions & 0 deletions mypaint-fixed-tiled-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#include <stdio.h>
#include <string.h>

#include <config.h>

#if MYPAINT_CONFIG_USE_GLIB
#include <glib.h>
#endif

#include <mypaint-fixed-tiled-surface.h>


Expand Down
1 change: 1 addition & 0 deletions mypaint-fixed-tiled-surface.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef MYPAINTFIXEDTILEDSURFACE_H
#define MYPAINTFIXEDTILEDSURFACE_H

#include <mypaint-config.h>
#include <mypaint-glib-compat.h>
#include <mypaint-tiled-surface.h>

Expand Down
12 changes: 2 additions & 10 deletions mypaint-glib-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@

#include <mypaint-config.h>

#if MYPAINT_CONFIG_USE_GLIB

#include <glib.h>

#else // not MYPAINT_CONFIG_USE_GLIB

#ifndef __G_LIB_H_
#ifndef __G_LIB_H__

/* From $INCLUDEPATH/glib-2.0/glib/gmacros.h */
#ifdef __cplusplus
Expand All @@ -33,8 +27,6 @@ typedef gint gboolean;
/* From $LIBPATH/glib-2.0/include/glibconfig.h */
typedef unsigned short guint16;

#endif // __G_LIB_H_

#endif // MYPAINT_CONFIG_USE_GLIB
#endif // __G_LIB_H__

#endif // MYPAINTGLIBCOMPAT_H
6 changes: 6 additions & 0 deletions mypaint-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
#ifndef MAPPING_C
#define MAPPING_C

#include <config.h>

#include <stdlib.h>
#include <assert.h>

#if MYPAINT_CONFIG_USE_GLIB
#include <glib.h>
#endif

#include "mypaint-mapping.h"

#include "helpers.h"
Expand Down
1 change: 1 addition & 0 deletions mypaint-mapping.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef MAPPING_H
#define MAPPING_H

#include <mypaint-config.h>
#include <mypaint-glib-compat.h>

G_BEGIN_DECLS
Expand Down
2 changes: 2 additions & 0 deletions mypaint-rectangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include <mypaint-rectangle.h>
#include <stdlib.h>
#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions mypaint-rectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <mypaint-config.h>
#include <mypaint-glib-compat.h>

G_BEGIN_DECLS
Expand Down
2 changes: 2 additions & 0 deletions mypaint-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include <assert.h>

#include "mypaint-surface.h"
Expand Down
2 changes: 1 addition & 1 deletion mypaint-surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <mypaint-glib-compat.h>
#include <mypaint-config.h>
#include <mypaint-rectangle.h>

G_BEGIN_DECLS
Expand Down
3 changes: 3 additions & 0 deletions mypaint-tiled-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -23,6 +25,7 @@
#include <omp.h>
#endif

#include "mypaint-config.h"
#include "mypaint-tiled-surface.h"
#include "tiled-surface-private.h"
#include "helpers.h"
Expand Down
1 change: 1 addition & 0 deletions mypaint.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#include <config.h>
#include <mypaint-config.h>

#ifdef _OPENMP
Expand Down
6 changes: 6 additions & 0 deletions operationqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include <stdlib.h>
#include <assert.h>

#if MYPAINT_CONFIG_USE_GLIB
#include <glib.h>
#else // not MYPAINT_CONFIG_USE_GLIB
#include <mypaint-glib-compat.h>
#endif

#include "operationqueue.h"
#include "fifo.h"

Expand Down
2 changes: 2 additions & 0 deletions rng-double.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* independent generator objects. All changes made to this file are considered
* to be in the public domain. */

#include <config.h>

#include "rng-double.h"

#include <stdlib.h>
Expand Down
7 changes: 7 additions & 0 deletions rng-double.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#ifndef RNGDOUBLE_H
#define RNGDOUBLE_H

#include "mypaint-config.h"

#if MYPAINT_CONFIG_USE_GLIB
#include <glib.h>
#else // not MYPAINT_CONFIG_USE_GLIB
#include <mypaint-glib-compat.h>
#endif


G_BEGIN_DECLS

Expand Down
5 changes: 5 additions & 0 deletions tests/mypaint-benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/

#include "mypaint-benchmark.h"

#if MYPAINT_CONFIG_USE_GLIB
#include <glib.h>
#else // not MYPAINT_CONFIG_USE_GLIB
#include <mypaint-glib-compat.h>
#endif

#include <stdio.h>
#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions tests/test-details.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "mypaint-config.h"

#include <stdlib.h>
#include <stdio.h>
Expand Down
2 changes: 2 additions & 0 deletions tilemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <config.h>

#include <stdlib.h>
#include <assert.h>

Expand Down
4 changes: 4 additions & 0 deletions tilemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#ifndef TILEMAP_H
#define TILEMAP_H

#if MYPAINT_CONFIG_USE_GLIB
#include <glib.h>
#else // not MYPAINT_CONFIG_USE_GLIB
#include <mypaint-glib-compat.h>
#endif

G_BEGIN_DECLS

Expand Down
Loading

0 comments on commit 5e68f90

Please sign in to comment.