Skip to content

Commit cc9494f

Browse files
authored
Merge pull request #20 from aperture-data/allow_custom_protobuf_ver_in_aperturedb-cpp
Allow custom protobuf ver in aperturedb-cpp
2 parents 67d48c8 + 475e062 commit cc9494f

File tree

9 files changed

+101
-54
lines changed

9 files changed

+101
-54
lines changed

SConstruct

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,22 @@ else:
4242
OPTFLAGS = "-O3 "
4343

4444
# Enviroment use by all the builds
45-
env = Environment(CXXFLAGS="-std=c++2a " + FFLAGS + OPTFLAGS + WFLAGS)
45+
env = Environment(
46+
# The PATH should contain version-specific tools, such as 'protoc',
47+
# otherwise e.g. '/bin/protoc' would be called and the latter would produce
48+
# *.pb.* of a version different from the one of $PROTOBUF_INCLUDE dir.
49+
ENV = {'PATH' : os.environ['PATH']},
50+
CXXFLAGS="-std=c++2a " + FFLAGS + OPTFLAGS + WFLAGS
51+
)
4652
# env.MergeFlags(GetOption('cflags'))
4753

4854
comm_env = env.Clone()
4955
comm_env.Replace(
5056
CPPPATH = ['include', 'src',
5157
os.getenv('NLOHMANN_JSON_INCLUDE', default='/usr/include'),
52-
os.getenv('GLOG_INCLUDE', default='')],
58+
os.getenv('GLOG_INCLUDE', default=''),
59+
os.getenv('PROTOBUF_INCLUDE', default='')
60+
],
5361
LIBS = [],
5462
LIBPATH = []
5563
)
@@ -58,11 +66,15 @@ comm_env.Replace(
5866
# The rest of the code is supposed to compiled using higher standards.
5967
lenient_env = comm_env.Clone()
6068
lenient_env.Replace(CXXFLAGS = lenient_env['CXXFLAGS'].replace("-Weffc++", ""))
61-
lenient_env.Replace(CXXFLAGS = re.sub("-Warray-bounds[^\s]+", "-Warray-bounds=1", lenient_env['CXXFLAGS']))
69+
lenient_env.Replace(CXXFLAGS = re.sub("-Warray-bounds[^\s]+", "-Warray-bounds=1", lenient_env['CXXFLAGS']))
6270
lenient_env.Replace(CXXFLAGS = re.sub("-Wsuggest-attribute=const", "-Wno-suggest-attribute=const", lenient_env['CXXFLAGS']))
6371
lenient_env.Replace(CXXFLAGS = re.sub("-Wsuggest-final-types", "-Wno-suggest-final-types", lenient_env['CXXFLAGS']))
6472
lenient_env.Replace(CXXFLAGS = re.sub("-Wuseless-cast", "-Wno-useless-cast", lenient_env['CXXFLAGS']))
6573
lenient_env.Replace(CXXFLAGS = re.sub("-Wsuggest-override", "-Wno-suggest-override", lenient_env['CXXFLAGS']))
74+
lenient_env.Replace(CXXFLAGS = re.sub("-Wshadow", "-Wno-shadow", lenient_env['CXXFLAGS']))
75+
lenient_env.Replace(CXXFLAGS = re.sub("-Wredundant-decls", "-Wno-redundant-decls", lenient_env['CXXFLAGS']))
76+
lenient_env.Replace(CXXFLAGS = re.sub("-Wdeprecated-declarations", "-Wno-deprecated-declarations", lenient_env['CXXFLAGS']))
77+
lenient_env.Replace(CXXFLAGS = re.sub("-Wundef", "-Wno-undef", lenient_env['CXXFLAGS']))
6678

6779
comm_cc = [
6880
'src/comm/ConnClient.cc',
@@ -83,10 +95,27 @@ ulib = comm_env.SharedLibrary('lib/comm', comm_cc)
8395
client_env = comm_env.Clone()
8496
client_env.Replace(
8597
CPPPATH = ['include', 'src',
86-
os.getenv('NLOHMANN_JSON_INCLUDE', default='/usr/include')],
98+
os.getenv('NLOHMANN_JSON_INCLUDE', default='/usr/include'),
99+
os.getenv('PROTOBUF_INCLUDE', default='')
100+
],
101+
# This might not be required:
87102
LIBS = ['comm'],
88-
LIBPATH = ['lib/']
89-
)
103+
104+
# Pointing to $XYZ_LIB in LIBPATH and RPATH is a way for the executables
105+
# that will be linked with this lib to ibe able to find the correct
106+
# version of XYZ lib, even if serveral version of XYZ lib exists on the
107+
# system. (And to avoid potential coredumps when a wrong .so is used at
108+
# run-time.) If curious, do
109+
#
110+
# % ldd lib/libaperturedb-client.so | grep protobuf
111+
#
112+
# once the lib is build.
113+
LIBPATH = ['lib/',
114+
os.getenv('PROTOBUF_LIB', default='')
115+
],
116+
)
117+
118+
client_env.Append(RPATH = client_env['LIBPATH'])
90119

91120
compileProtoFiles(client_env)
92121

@@ -108,29 +137,46 @@ CXXFLAGS = env['CXXFLAGS']
108137

109138
# Comm Testing
110139
comm_test_env = Environment(
140+
ENV = {'PATH' : os.environ['PATH']},
111141
CPPPATH = ['include', 'src',
112142
os.getenv('NLOHMANN_JSON_INCLUDE', default='/usr/include'),
113143
os.getenv('PROMETHEUS_CPP_CORE_INCLUDE', default=''),
114144
os.getenv('GLOG_INCLUDE', default=''),
145+
os.getenv('PROTOBUF_INCLUDE', default='')
115146
],
116147
LIBPATH = ['lib',
117148
os.getenv('PROMETHEUS_CPP_LIB', default=''),
118149
os.getenv('GLOG_LIB', default=''),
150+
os.getenv('PROTOBUF_LIB', default='')
119151
],
120152
CXXFLAGS = CXXFLAGS,
121-
LIBS = [
122-
'aperturedb-client',
153+
LIBS = ['aperturedb-client',
154+
'prometheus-cpp-core',
123155
'comm',
124-
'pthread',
125156
'gtest',
126157
'glog',
127-
'prometheus-cpp-core',
158+
'protobuf',
159+
'pthread',
128160
],
129-
RPATH = ['../lib']
130161
)
131162

163+
# Using RPATH causes the linker to record locations of shared libs inside the
164+
# executable, so that we do not need to either (a) copy the libs to standard
165+
# locations or (b) point to them in LD_LIBRARY_PATH. To check if this worked
166+
# correctly, do
167+
#
168+
# % ldd test/comm_test | grep 'not found'
169+
#
170+
# To check for which libs relative paths are used, do
171+
#
172+
# % ldd test/comm_test | grep '=>' | grep -v '=> /'
173+
#
174+
# For an info on RPATH, see the man page for 'ld'.
175+
176+
comm_test_env.Append(RPATH = comm_test_env['LIBPATH'])
177+
132178

133-
comm_test_env.ParseConfig('pkg-config --cflags --libs protobuf')
179+
##comm_test_env.ParseConfig('pkg-config --cflags --libs protobuf')
134180

135181
comm_test_source_files = [
136182
'test/AuthEnabledVDMSServer.cc',

compiler_warnings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"-Wdelete-incomplete",
5656
"-Wdelete-non-virtual-dtor",
5757
#"-Wdeprecated-copy", # N/A
58+
"-Wdeprecated-declarations",
5859
#"-Wdeprecated-copy-dtor", # N/A
5960
"-Wdisabled-optimization",
6061
#"-Wdouble-promotion", # FOR NOW

src/aperturedb/TokenBasedVDMSClient.cc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,7 @@
2929
*/
3030

3131
#include "aperturedb/VDMSClient.h"
32-
33-
#include "util/gcc_util.h" // DISABLE_WARNING
34-
DISABLE_WARNING(effc++)
35-
DISABLE_WARNING(useless-cast)
36-
DISABLE_WARNING(suggest-override)
37-
#include "aperturedb/queryMessage.pb.h"
38-
ENABLE_WARNING(suggest-override)
39-
ENABLE_WARNING(useless-cast)
40-
ENABLE_WARNING(effc++)
41-
32+
#include "aperturedb/queryMessageWrapper.h"
4233
#include "aperturedb/Exception.h"
4334
#include "comm/ConnClient.h"
4435
#include "comm/Connection.h"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#pragma once
2+
3+
#include "util/gcc_util.h" // DISABLE_WARNING
4+
5+
// Cleaning after developers of protobuf 3.9.0:
6+
#ifndef GOOGLE_PROTOBUF_USE_UNALIGNED
7+
#define GOOGLE_PROTOBUF_USE_UNALIGNED 0
8+
#endif
9+
10+
#ifndef GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE
11+
#define GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE 0
12+
#endif
13+
14+
DISABLE_WARNING(effc++)
15+
DISABLE_WARNING(useless-cast)
16+
DISABLE_WARNING(suggest-override)
17+
DISABLE_WARNING(deprecated-declarations)
18+
DISABLE_WARNING(shadow)
19+
DISABLE_WARNING(redundant-decls)
20+
DISABLE_WARNING(deprecated-declarations)
21+
#include "aperturedb/queryMessage.pb.h"
22+
ENABLE_WARNING(deprecated-declarations)
23+
ENABLE_WARNING(redundant-decls)
24+
ENABLE_WARNING(shadow)
25+
ENABLE_WARNING(deprecated-declarations)
26+
ENABLE_WARNING(suggest-override)
27+
ENABLE_WARNING(useless-cast)
28+
ENABLE_WARNING(effc++)

test/AuthEnabledVDMSServer.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@
66

77
#include <nlohmann/json.hpp>
88

9-
#include "util/gcc_util.h" // DISABLE_WARNING
10-
DISABLE_WARNING(effc++)
11-
DISABLE_WARNING(useless-cast)
12-
DISABLE_WARNING(suggest-override)
13-
#include "aperturedb/queryMessage.pb.h"
14-
ENABLE_WARNING(suggest-override)
15-
ENABLE_WARNING(useless-cast)
16-
ENABLE_WARNING(effc++)
17-
9+
#include "aperturedb/queryMessageWrapper.h"
1810
#include "comm/Connection.h"
1911
#include "comm/ConnServer.h"
2012
#include "comm/Exception.h"

test/VDMSServer.cc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,7 @@
33
*/
44

55
#include "VDMSServer.h"
6-
7-
#include "util/gcc_util.h" // DISABLE_WARNING
8-
DISABLE_WARNING(effc++)
9-
DISABLE_WARNING(useless-cast)
10-
DISABLE_WARNING(suggest-override)
11-
#include "aperturedb/queryMessage.pb.h"
12-
ENABLE_WARNING(suggest-override)
13-
ENABLE_WARNING(useless-cast)
14-
ENABLE_WARNING(effc++)
15-
6+
#include "aperturedb/queryMessageWrapper.h"
167
#include "comm/Connection.h"
178
#include "comm/ConnServer.h"
189
#include "comm/Exception.h"

tools/prometheus_ambassador/SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ prom_amb_env.Replace(
1414
os.getenv('PROMETHEUS_CPP_PULL_INCLUDE', default=''),
1515
os.getenv('NLOHMANN_JSON_INCLUDE', default='/usr/include'),
1616
os.getenv('GLOG_INCLUDE', default=''),
17+
os.getenv('PROTOBUF_INCLUDE', default='')
1718
],
1819
LIBPATH = [ '/usr/local/lib/',
1920
os.getenv('AD_COMM_LIB', default='../../lib'),
2021
os.getenv('AD_CLIENT_LIB', default='../../lib'),
2122
os.getenv('PROMETHEUS_CPP_LIB', default=''),
2223
os.getenv('GLOG_INCLUDE', default=''),
24+
os.getenv('PROTOBUF_LIB', default='')
2325
],
2426
LIBS = [ 'comm',
2527
'aperturedb-client',
2628
'prometheus-cpp-core',
2729
'prometheus-cpp-pull',
2830
'glog',
31+
'protobuf',
2932
],
3033
)
3134

tools/prometheus_ambassador/test/ClientCollectorTests.cc

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,11 @@
55
#include <thread>
66

77
#include "gtest/gtest.h"
8-
98
#include "ClientCollector.h"
109
#include "prometheus_ambassador_defines.h"
11-
1210
#include "Barrier.h"
1311
#include "comm/ConnServer.h"
14-
15-
#include "util/gcc_util.h" // DISABLE_WARNING
16-
DISABLE_WARNING(effc++)
17-
DISABLE_WARNING(useless-cast)
18-
DISABLE_WARNING(suggest-override)
19-
#include "aperturedb/queryMessage.pb.h"
20-
ENABLE_WARNING(suggest-override)
21-
ENABLE_WARNING(useless-cast)
22-
ENABLE_WARNING(effc++)
23-
12+
#include "aperturedb/queryMessageWrapper.h"
2413
#include "metrics/JsonWriter.h"
2514

2615
#define SERVER_PORT_INTERCHANGE 43210

tools/send_query/SConstruct

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@ send_query_env.Replace(
1111
os.getenv('AD_CLIENT_INCLUDE', default='../../include'),
1212
os.getenv('NLOHMANN_JSON_INCLUDE', default='/usr/include'),
1313
os.getenv('GLOG_INCLUDE', default=''),
14+
os.getenv('PROTOBUF_INCLUDE', default='')
1415
],
1516
LIBPATH = ['/usr/local/lib/',
1617
os.getenv('AD_COMM_LIB', default='../../lib'),
1718
os.getenv('AD_CLIENT_LIB', default='../../lib'),
1819
os.getenv('GLOG_LIB', default=''),
20+
os.getenv('PROTOBUF_LIB', default='')
21+
],
22+
LIBS = [ 'comm',
23+
'aperturedb-client',
24+
'glog',
25+
'protobuf'
1926
],
20-
LIBS = ['libglog', 'comm', 'aperturedb-client', 'glog'],
2127
)
2228

2329
files = [ 'send_query.cc' ]

0 commit comments

Comments
 (0)