Skip to content

Commit e3a479e

Browse files
FreeBSD build fixes + CI (#1026)
* BSD linkage fix proposal * Touch up the Makefile to fix BSD builds Fixes #984 * Add a build in FreeBSD to GitHub Actions Lots of people use hiredis in FreeBSD so this should reduce some pain moving forward. Co-authored-by: David Carlier <devnexen@gmail.com>
1 parent da5a4ff commit e3a479e

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.github/workflows/build.yml

+23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on: [push, pull_request]
33

44
jobs:
55
ubuntu:
6+
name: Ubuntu
67
runs-on: ubuntu-latest
78
steps:
89
- name: Checkout code
@@ -40,6 +41,7 @@ jobs:
4041
# run: $GITHUB_WORKSPACE/test.sh
4142

4243
centos7:
44+
name: CentOS 7
4345
runs-on: ubuntu-latest
4446
container: centos:7
4547
steps:
@@ -79,6 +81,7 @@ jobs:
7981
run: $GITHUB_WORKSPACE/test.sh
8082

8183
centos8:
84+
name: CentOS 8
8285
runs-on: ubuntu-latest
8386
container: centos:8
8487
steps:
@@ -118,7 +121,26 @@ jobs:
118121
TEST_PREFIX: valgrind --error-exitcode=99 --track-origins=yes --leak-check=full
119122
run: $GITHUB_WORKSPACE/test.sh
120123

124+
freebsd:
125+
runs-on: macos-10.15
126+
name: FreeBSD
127+
steps:
128+
- name: Checkout code
129+
uses: actions/checkout@v2
130+
with:
131+
repository: ${{ env.GITHUB_REPOSITORY }}
132+
ref: ${{ env.GITHUB_HEAD_REF }}
133+
134+
- name: Build in FreeBSD
135+
uses: vmactions/freebsd-vm@v0.1.5
136+
with:
137+
prepare: pkg install -y gmake cmake
138+
run: |
139+
mkdir build && cd build && cmake .. && make && cd ..
140+
gmake
141+
121142
macos:
143+
name: macOS
122144
runs-on: macos-latest
123145
steps:
124146
- name: Checkout code
@@ -140,6 +162,7 @@ jobs:
140162
run: $GITHUB_WORKSPACE/test.sh
141163

142164
windows:
165+
name: Windows
143166
runs-on: windows-latest
144167
steps:
145168
- name: Checkout code

CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ SET_TARGET_PROPERTIES(hiredis_static
5959
IF(WIN32 OR MINGW)
6060
TARGET_LINK_LIBRARIES(hiredis PUBLIC ws2_32 crypt32)
6161
TARGET_LINK_LIBRARIES(hiredis_static PUBLIC ws2_32 crypt32)
62+
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
63+
TARGET_LINK_LIBRARIES(hiredis PUBLIC m)
64+
TARGET_LINK_LIBRARIES(hiredis_static PUBLIC m)
6265
ENDIF()
6366

6467
TARGET_INCLUDE_DIRECTORIES(hiredis PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

Makefile

+11-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ else
9292
SSL_LDFLAGS+=-L$(OPENSSL_PREFIX)/lib -lssl -lcrypto
9393
endif
9494

95+
ifeq ($(uname_S),FreeBSD)
96+
LDFLAGS+=-lm
97+
IS_GCC=$(shell sh -c '$(CC) --version 2>/dev/null |egrep -i -c "gcc"')
98+
ifeq ($(IS_GCC),1)
99+
REAL_CFLAGS+=-pedantic
100+
endif
101+
else
102+
REAL_CFLAGS+=-pedantic
103+
endif
104+
95105
ifeq ($(uname_S),SunOS)
96106
IS_SUN_CC=$(shell sh -c '$(CC) -V 2>&1 |egrep -i -c "sun|studio"')
97107
ifeq ($(IS_SUN_CC),1)
@@ -231,7 +241,7 @@ check: hiredis-test
231241
TEST_SSL=$(USE_SSL) ./test.sh
232242

233243
.c.o:
234-
$(CC) -std=c99 -pedantic -c $(REAL_CFLAGS) $<
244+
$(CC) -std=c99 -c $(REAL_CFLAGS) $<
235245

236246
clean:
237247
rm -rf $(DYLIBNAME) $(STLIBNAME) $(SSL_DYLIBNAME) $(SSL_STLIBNAME) $(TESTS) $(PKGCONFNAME) examples/hiredis-example* *.o *.gcda *.gcno *.gcov

0 commit comments

Comments
 (0)