Changeset 82149f4


Ignore:
Timestamp:
2023-03-04T19:59:09Z (14 months ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
50d0a72
Parents:
709f41f
git-author:
Petr Vaněk <arkamar@…> (04-03-23 19:59:09)
git-committer:
GitHub <noreply@…> (04-03-23 19:59:09)
Message:

Fixes related to external-json-parser (#165)

  • configure: append conditionally json-parser to pc file

json-parser needs to be appended to Requires section of pkg-config file
when bitlbee is configured to use external-json-parser. This change is
needed for external plugins like bitlbee-steam.

  • Makefile: do not install json.h when system json-parser is used

install-dev target should not install bundled json.h when bitlbee is
configured to use external-json-parser.

  • Use correct json.h header file with respect to external_json_parser value

The preprocessor must include correct json.h header file with respect to
external_json_parser value, otherwise function prototypes and other
definitions do not need to correspond with object used for linking.

The state before this commit is that local version lib/json.h is used
always for compilation and external_json_parser variable controls if
local lib/json.o or global libjsonparser.so will be linked.

In order to fix this problem, #include directives in lib/json_util.h and
lib/oauth2.c were changed from "json.h" to <json.h> and preprocessor -I
flags were moved after conditional json-parser flags, which is enough
for solving the issue. Additionally, USE_EXTERNAL_JSON_PARSER macro is
exported when external-json-parser is used and it is used in lib/json.h
to trigger an error message, which should prevent similar mistakes in
future.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r709f41f r82149f4  
    1111# Program variables
    1212objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_cap.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS) auth.o $(AUTH_OBJS) unix.o conf.o log.o
    13 headers = $(wildcard $(_SRCDIR_)*.h $(_SRCDIR_)lib/*.h $(_SRCDIR_)protocols/*.h)
     13allheaders = $(wildcard $(_SRCDIR_)*.h $(_SRCDIR_)lib/*.h $(_SRCDIR_)protocols/*.h)
     14ifeq ($(EXTERNAL_JSON_PARSER),1)
     15headers = $(filter-out $(_SRCDIR_)lib/json.h,$(allheaders))
     16else
     17headers = $(allheaders)
     18endif
    1419subdirs = lib protocols
    1520
  • configure

    r709f41f r82149f4  
    330330
    331331echo "CFLAGS=$CFLAGS $CPPFLAGS" >> Makefile.settings
    332 echo CFLAGS+=-I"${srcdir}" -I"${srcdir}"/lib -I"${srcdir}"/protocols -I. >> Makefile.settings
    333332
    334333echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
     
    421420    # shellcheck disable=SC2129
    422421    echo "CFLAGS+=$(pkg-config --cflags json-parser)" >> Makefile.settings
     422    echo "CFLAGS+=-DUSE_EXTERNAL_JSON_PARSER" >> Makefile.settings
    423423    echo "LDFLAGS_BITLBEE+=$(pkg-config --libs json-parser)" >> Makefile.settings
    424424    echo "LDFLAGS_TESTS+=$(pkg-config --libs json-parser)" >> Makefile.settings
    425425fi
    426426
     427echo CFLAGS+=-I"${srcdir}" -I"${srcdir}"/lib -I"${srcdir}"/protocols -I. >> Makefile.settings
    427428
    428429detect_gnutls()
     
    868869esac
    869870
     871pkgconfigrequires='glib-2.0'
     872if [ "$external_json_parser" = '1' ]; then
     873        pkgconfigrequires="$pkgconfigrequires json-parser"
     874fi
     875
    870876cat <<EOF >bitlbee.pc
    871877prefix=$prefix
     
    877883Name: bitlbee
    878884Description: IRC to IM gateway
    879 Requires: glib-2.0
     885Requires: $pkgconfigrequires
    880886Version: $BITLBEE_VERSION
    881887Libs: $pkgconfiglibs
  • lib/json.h

    r709f41f r82149f4  
    2929 */
    3030
     31#ifdef USE_EXTERNAL_JSON_PARSER
     32#error Bitlbee was configured to use system json-parser, this header file should not be used.
     33#endif
     34
    3135#ifndef _JSON_H
    3236#define _JSON_H
  • lib/json_util.h

    r709f41f r82149f4  
    2222****************************************************************************/
    2323
    24 #include "json.h"
     24#include <json.h>
    2525
    2626#define JSON_O_FOREACH(o, k, v) \
  • lib/oauth2.c

    r709f41f r82149f4  
    4242#include "oauth2.h"
    4343#include "oauth.h"
    44 #include "json.h"
     44#include <json.h>
    4545#include "json_util.h"
    4646#include "url.h"
Note: See TracChangeset for help on using the changeset viewer.