Skip to content

Commit c28011f

Browse files
committed
Add 2 versions of library with c++98 and c++11 abi
1 parent ceb4681 commit c28011f

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ m4/ltversion.m4
5252
m4/lt~obsolete.m4
5353
missing
5454
source/Makefile.in
55-
55+
test-driver

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ build/Makefile: configure
5252

5353
cpp: build/Makefile
5454
cd build && \
55-
$(MAKE)
55+
$(MAKE) check
5656

5757
cpp-install: cpp
5858
cd build && \
@@ -77,7 +77,8 @@ cpp-clean:
7777
m4/ltversion.m4 \
7878
m4/lt~obsolete.m4 \
7979
missing \
80-
source/Makefile.in
80+
source/Makefile.in \
81+
test-driver
8182

8283
################################################################################
8384

source/Makefile.am

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
lib_LTLIBRARIES =
77
noinst_PROGRAMS =
8+
check_PROGRAMS =
89

910
################################################################################
1011
# Global flags
@@ -34,9 +35,14 @@ AM_CXXFLAGS = \
3435
################################################################################
3536
# AdafruitBBIO library
3637
################################################################################
37-
lib_LTLIBRARIES += libadafruit-bbio.la
38+
# libadafruit-bbio1 - c++11 ABI
39+
# libadafruit-bbio0 - c++98 ABI
3840

39-
libadafruit_bbio_la_SOURCES = \
41+
lib_LTLIBRARIES += \
42+
libadafruit-bbio1.la \
43+
libadafruit-bbio0.la
44+
45+
LIBSOURCES = \
4046
c_adc.c \
4147
c_pinmux.c \
4248
c_pwm.c \
@@ -47,19 +53,45 @@ libadafruit_bbio_la_SOURCES = \
4753
library/gpio.cpp \
4854
library/pwm.cpp
4955

50-
libadafruit_bbio_la_LDFLAGS = $(AM_LDFLAGS) -shared
56+
libadafruit_bbio1_la_SOURCES = $(LIBSOURCES)
57+
libadafruit_bbio0_la_SOURCES = $(LIBSOURCES)
58+
59+
libadafruit_bbio1_la_CXXFLAGS = $(AM_CXXFLAGS) -D_GLIBCXX_USE_CXX11_ABI=1
60+
libadafruit_bbio0_la_CXXFLAGS = $(AM_CXXFLAGS) -D_GLIBCXX_USE_CXX11_ABI=0
61+
62+
libadafruit_bbio1_la_LDFLAGS = $(AM_LDFLAGS) -shared
63+
libadafruit_bbio0_la_LDFLAGS = $(AM_LDFLAGS) -shared
5164

5265
################################################################################
5366
# Examples
5467
################################################################################
5568
noinst_PROGRAMS += examples/cpp/pwm
5669

5770
examples_cpp_pwm_SOURCES = examples/cpp/pwm.cpp
58-
examples_cpp_pwm_LDADD = libadafruit-bbio.la
71+
examples_cpp_pwm_LDADD = libadafruit-bbio1.la
5972
examples_cpp_pwm_LDFLAGS = $(AM_LDFLAGS) -lpthread -static
6073

6174
noinst_PROGRAMS += examples/cpp/gpio
6275

6376
examples_cpp_gpio_SOURCES = examples/cpp/gpio.cpp
64-
examples_cpp_gpio_LDADD = libadafruit-bbio.la
77+
examples_cpp_gpio_LDADD = libadafruit-bbio1.la
6578
examples_cpp_gpio_LDFLAGS = $(AM_LDFLAGS) -lpthread -static
79+
80+
################################################################################
81+
# Tests
82+
################################################################################
83+
TESTS = $(check_PROGRAMS)
84+
85+
check_PROGRAMS += test/cpp/abi-old
86+
87+
test_cpp_abi_old_SOURCES = test/cpp/abi.cpp
88+
test_cpp_abi_old_CXXFLAGS = $(AM_CXXFLAGS) -pthread -D_GLIBCXX_USE_CXX11_ABI=0
89+
test_cpp_abi_old_LDADD = libadafruit-bbio0.la
90+
test_cpp_abi_old_LDFLAGS = $(AM_LDFLAGS) -lpthread -static
91+
92+
check_PROGRAMS += test/cpp/abi-new
93+
94+
test_cpp_abi_new_SOURCES = test/cpp/abi.cpp
95+
test_cpp_abi_new_CXXFLAGS = $(AM_CXXFLAGS) -pthread -D_GLIBCXX_USE_CXX11_ABI=1
96+
test_cpp_abi_new_LDADD = libadafruit-bbio1.la
97+
test_cpp_abi_new_LDFLAGS = $(AM_LDFLAGS) -lpthread -static

source/test/cpp/abi.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright (c) 2017 Adafruit
3+
Copyright (c) 2017 Nikolay Semenov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
of the Software, and to permit persons to whom the Software is furnished to do
10+
so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
*/
23+
24+
#include "adafruit/bbio.h"
25+
26+
int main(int /*argc*/, char** /*argv*/)
27+
{
28+
adafruit::bbio::init({LOG_DEBUG, nullptr, LOG_PERROR});
29+
return 0;
30+
}

0 commit comments

Comments
 (0)