Skip to content

Commit

Permalink
Clean up Jansson source tree, document changes made
Browse files Browse the repository at this point in the history
* Update jansson_private_config.h to accurately reflect the presence or
  absence of certain compiler features and headers
* Mark one function as unused to prevent a compilation warning
* Disable one warning on GCC
* Validate that all imported C files are used in the build
* Remove unused Jansson build files, preserve LICENSE
* Document these changes in WEBDIS-CHANGES.md and link from README.md
  • Loading branch information
nicolasff committed Oct 20, 2023
1 parent fe9301d commit d979d6a
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 291 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ LDFLAGS ?= -levent -pthread
# Pass preprocessor macros to the compile invocation
CFLAGS += $(CPPFLAGS)

# disable format-truncation warnings for Jansson on GCC (from Jansson PR #489)
ifeq ($(shell cc -v 2>&1 | grep -cw 'gcc version'),1)
CFLAGS +=-Wno-format-truncation
endif

# check for MessagePack
MSGPACK_LIB=$(shell ls /usr/lib/libmsgpack.so 2>/dev/null)
ifneq ($(strip $(MSGPACK_LIB)),)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

# About Webdis

A very simple web server providing an HTTP interface to Redis. It uses [hiredis](https://github.com/antirez/hiredis), [jansson](https://github.com/akheron/jansson), [libevent](https://monkey.org/~provos/libevent/), and [http-parser](https://github.com/ry/http-parser/).
A very simple web server providing an HTTP interface to Redis. It embeds [hiredis](https://github.com/antirez/hiredis), [jansson](https://github.com/akheron/jansson) (with some [local changes](./src/jansson/WEBDIS-CHANGES.md)), and [http-parser](https://github.com/ry/http-parser/). It also depends on [libevent](https://monkey.org/~provos/libevent/), to be installed separately.

Webdis depends on libevent-dev. You can install it on Ubuntu by typing `sudo apt-get install libevent-dev` or on macOS by typing `brew install libevent`.
# Build and run from source

To build Webdis with support for encrypted connections to Redis, see [Building Webdis with SSL support](#building-webdis-with-ssl-support).
Building Webdis requires the libevent development package. You can install it on Ubuntu by typing `sudo apt-get install libevent-dev` or on macOS by typing `brew install libevent`.

# Build and run from source
To build Webdis with support for encrypted connections to Redis, see [Building Webdis with SSL support](#building-webdis-with-ssl-support).

```sh
$ make clean all
Expand Down
12 changes: 0 additions & 12 deletions src/jansson/Makefile.am

This file was deleted.

32 changes: 32 additions & 0 deletions src/jansson/WEBDIS-CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Webdis changes to Jansson

Webdis imports Jansson by including its source code under `src/jansson`. This document lists the changes made to Jansson files, mostly made to accommodate the requirements of the Webdis build process.

Webdis currently imports Jansson version 2.14.

## Includes and compiler builtins

Added checks for various headers and compiler builtins. For example, `endian.h` is not available on macOS, although `machine/endian.h` is.

## Unused code

Marked `buf_to_uint32` as unused.

## Unused source files

To validate that all the C files imported are used in the build, we can compare the list of files in the Jansson source directory with the object files listed in the Webdis Makefile.

The following `diff` command should not show any output:

```sh
diff -u <(grep ^JANSSON_OBJ Makefile | head -1 | cut -f 2- -d = | tr ' ' '\n' | sed -Ee 's/\.o$/.c/g' | sort)\
<(find src/jansson/src -name '*.c' | sort)
```

## Unused build files

Autotool build files can be removed, namely:
- `configure.ac`
- `jansson.pc.in`
- `Makefile.am` (2 copies)
- `jansson_config.h.in`
181 changes: 0 additions & 181 deletions src/jansson/configure.ac

This file was deleted.

10 changes: 0 additions & 10 deletions src/jansson/jansson.pc.in

This file was deleted.

30 changes: 0 additions & 30 deletions src/jansson/src/Makefile.am

This file was deleted.

1 change: 1 addition & 0 deletions src/jansson/src/hashtable_seed.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include "jansson.h"

__attribute__ ((unused))
static uint32_t buf_to_uint32(char *data) {
size_t i;
uint32_t result = 0;
Expand Down
51 changes: 0 additions & 51 deletions src/jansson/src/jansson_config.h.in

This file was deleted.

Loading

0 comments on commit d979d6a

Please sign in to comment.