lava commented on a change in pull request #327: Updated glog to 0.3.5 and then
to 0.4.0, added microseconds to LogSink::send().
URL: https://github.com/apache/mesos/pull/327#discussion_r268572596
##########
File path: src/python/native_common/ext_modules.py.in
##########
@@ -71,75 +94,101 @@ def _create_module(module_name):
os.path.join(abs_top_builddir, libprocess, '.libs', 'libprocess.a')
]
+ def cond_add_extra_objects(true_subst, false_subst, bundled, system):
+ """
+ Depending on the provided results of substitution by the configure
+ script, add either bundled or system ones to EXTRA_OBJECTS.
+ If adding bundled objects, check their existence
+ and fail if they are missing.
+ """
+ use_bundled = _get_ac_subst_bool(true_subst, false_subst)
+ if isinstance(bundled, basestring):
+ bundled = [bundled]
+ if isinstance(system, basestring):
+ system = system
+ if use_bundled:
+ for obj in bundled:
+ if not os.path.exists(obj):
+ raise RuntimeError("{} does not exist.".format(obj))
+ EXTRA_OBJECTS.extend(bundled)
+ else:
+ EXTRA_OBJECTS.extend(system)
# For leveldb, we need to check for the presence of libleveldb.a, since
# it is possible to disable leveldb inside mesos.
- libglog = os.path.join(abs_top_builddir, glog, '.libs', 'libglog.a')
libleveldb = os.path.join(abs_top_builddir, leveldb, 'out-static',
'libleveldb.a')
- libzookeeper = os.path.join(
- abs_top_builddir, zookeeper, '.libs', 'libzookeeper_mt.a')
- libprotobuf = os.path.join(
- abs_top_builddir, protobuf, 'src', '.libs', 'libprotobuf.a')
-
- if os.path.exists(libleveldb):
- EXTRA_OBJECTS.append(libleveldb)
- else:
- EXTRA_OBJECTS.append('-lleveldb')
-
- if os.path.exists(libzookeeper):
- EXTRA_OBJECTS.append(libzookeeper)
- else:
- EXTRA_OBJECTS.append('-lzookeeper_mt')
-
- if os.path.exists(libglog):
- EXTRA_OBJECTS.append(libglog)
- else:
- EXTRA_OBJECTS.append('-lglog')
-
- if os.path.exists(libprotobuf):
- EXTRA_OBJECTS.append(libprotobuf)
- else:
- EXTRA_OBJECTS.append('-lprotobuf')
+ cond_add_extra_objects(
+ "@WITH_BUNDLED_LEVELDB_TRUE@",
+ "@WITH_BUNDLED_LEVELDB_FALSE@",
+ libleveldb,
+ '-lleveldb'
+ )
+ cond_add_extra_objects(
+ "@WITH_BUNDLED_ZOOKEEPER_TRUE@",
+ "@WITH_BUNDLED_ZOOKEEPER_FALSE@",
+ os.path.join(abs_top_builddir, zookeeper, '.libs',
'libzookeeper_mt.a'),
+ '-lzookeeper_mt'
+ )
+ cond_add_extra_objects(
+ "@WITH_BUNDLED_GLOG_TRUE@",
+ "@WITH_BUNDLED_GLOG_FALSE@",
+ os.path.join(abs_top_builddir, glog, '.libs', 'libglog.a'),
+ '-lglog'
+ )
+ cond_add_extra_objects(
Review comment:
I agree that this replication deserves a helper function with proper
validation, but I'm not sure that hiding the manipulation of a global variable
in a function is a good idea, so at least `EXTRA_OBJECTS` should be a parameter.
Another idea is to use the autoconf substition variables directly to comment
out the irrelevant sections of the source (but tbh I'm not sure if this is
really an improvement):
```
@WITH_BUNDLED_GLOG_TRUE@with_bundled_glog = True
@WITH_BUNDLED_GLOG_FALSE@with bundled_glog = False
if with_bundled_glog
EXTRA_OBJECTS.append_if_file_exists(libglog)
else:
EXTRA_OBJECTS.append('-lglog')
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services