diff --git a/.travis.yml b/.travis.yml index 17bd5df436..18241adf03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,6 +77,7 @@ matrix: env: - TASK='compile' - CPPUNIT='1.14' + - PROTOBUF='latest' - LIBFTDI='1' - os: osx osx_image: xcode9.3 @@ -84,6 +85,7 @@ matrix: env: - TASK='compile' - CPPUNIT='1.14' + - PROTOBUF='latest' - LIBFTDI='1' - os: linux dist: xenial @@ -236,6 +238,22 @@ matrix: - TASK='compile' - CPPUNIT='1.14' - LIBFTDI='1' + - os: osx + osx_image: xcode9.3 + compiler: clang + env: + - TASK='compile' + - CPPUNIT='1.14' + - LIBFTDI='1' + - PROTOBUF='latest' + - os: osx + osx_image: xcode9.3 + compiler: gcc + env: + - TASK='compile' + - CPPUNIT='1.14' + - LIBFTDI='1' + - PROTOBUF='latest' - os: linux dist: xenial compiler: gcc @@ -286,7 +304,8 @@ before_cache: install: # Match the version of protobuf being installed via apt - - pip install --user protobuf==3.1.0 +  - if [[ "$PROTOBUF" == "latest" ]]; then pip install --user protobuf; fi + - if [[ "$PROTOBUF" != "latest" ]]; then pip install --user protobuf==3.1.0; fi # disable until can be added to all build variants #- pip install --user timeout-decorator # We need to use pip rather than apt on Xenial @@ -303,10 +322,12 @@ before_install: #Fix a broken homebrew python upgrade - see https://github.com/Homebrew/homebrew-core/issues/26358 - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python || true; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then if [ ! -d /usr/local/sbin ]; then sudo mkdir -p /usr/local/sbin && sudo chown -R $(whoami) /usr/local/sbin; fi; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache bison flex protobuf@3.1 liblo libmicrohttpd; fi # ossp-uuid, homebrew/python/numpy and libusb already present + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache bison flex liblo libmicrohttpd; fi # ossp-uuid, homebrew/python/numpy and libusb already present - if [ "$TRAVIS_OS_NAME" == "osx" -a "$LIBFTDI" != "1" ]; then brew install libftdi0; fi # install libftdi0 - if [ "$TRAVIS_OS_NAME" == "osx" -a "$LIBFTDI" == "1" ]; then brew install libftdi; fi # install the latest libftdi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link -f protobuf@3.1; export PKG_CONFIG_PATH=/usr/local/opt/protobuf@3.1/lib/pkgconfig; brew install --build-from-source --ignore-dependencies --env=std protobuf-c; fi # While protobuf is not on the latest release + - if [ "$TRAVIS_OS_NAME" == "osx" -a "$PROTOBUF" == "latest" ]; then brew install protobuf; fi + - if [ "$TRAVIS_OS_NAME" == "osx" -a "$PROTOBUF" != "latest" ]; then brew install protobuf@3.6; fi + - if [ "$TRAVIS_OS_NAME" == "osx" -a "$PROTOBUF" != "latest" ]; then brew link -f protobuf@3.6; export PKG_CONFIG_PATH=/usr/local/opt/protobuf@3.6/lib/pkgconfig; brew install --build-from-source --ignore-dependencies --env=std protobuf-c; fi # When protobuf is not on the latest release - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p ${HOME}/Library/Python/2.7/lib/python/site-packages; echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> ${HOME}/Library/Python/2.7/lib/python/site-packages/homebrew.pth; fi - if [ "$TRAVIS_OS_NAME" == "osx" -a "$CPPUNIT" != "1.14" ]; then brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e6e43cf6a3%5E/Formula/cppunit.rb; fi # install a slightly older cppunit, as latest needs C++11 support - if [ "$TRAVIS_OS_NAME" == "osx" -a "$CPPUNIT" == "1.14" ]; then brew install cppunit; fi # install the latest cppunit, which needs C++11 diff --git a/AUTHORS b/AUTHORS index ae2d58095a..084ff0b696 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,6 +13,7 @@ Contributors: Hakan Lindestaf, Renard plugin Harry F, for the Eurolite USB Pro code Heikki Junnila, bug fixes for the debian packaging files + Jannis Achstetter, compile fixes for newer dependencies Laurent (Renzo), Debian packages, FreeBSD & RDM testing. Lukas Erlinghagen, win32 port. Johan Nilsson, Philips Hue trigger config diff --git a/NEWS b/NEWS index edff8d3c54..872ed2900f 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,8 @@ x/y/2019 ola-0.10.8 Python API * Renamed RESONSE_INVALID_DESTINATION(sic) to RESPONSE_INVALID_DESTINATION in the ArduinoWidget code + * Fix compatibility with ncurses 6 + * Fix compatibility with Protobuf 3.7 and newer (tested with up to 3.11.4) Internal: * diff --git a/config/ola.m4 b/config/ola.m4 index 6080932e9a..d3b8cc8f8e 100644 --- a/config/ola.m4 +++ b/config/ola.m4 @@ -24,9 +24,6 @@ AC_DEFUN([PROTOBUF_SUPPORT], AC_REQUIRE_CPP() PKG_CHECK_MODULES(libprotobuf, [protobuf >= $1]) -PKG_CHECK_MODULES(libprotobuf2, [protobuf < 3.2], [], - [AC_MSG_ERROR([OLA currently requires protobuf < 3.2, see issue 1192])]) - AC_SUBST([libprotobuf_CFLAGS]) AC_ARG_WITH([protoc], diff --git a/configure.ac b/configure.ac index e40372ec7b..f63767f050 100644 --- a/configure.ac +++ b/configure.ac @@ -858,6 +858,9 @@ AS_IF([test "${enable_rdm_tests}" = "yes"], AS_IF([test "x$build_java_libs" = xyes], [PROTOBUF_SUPPORT([2.4.0])], [PROTOBUF_SUPPORT([2.3.0])]) +# Version 3.7 and above of protoc require some additional includes +AC_CHECK_HEADERS([google/protobuf/io/strtod.h google/protobuf/stubs/logging.h \ + google/protobuf/stubs/stl_util.h]) # Doxygen diff --git a/protoc/CppFileGenerator.cpp b/protoc/CppFileGenerator.cpp index 518c17879d..ee93afc144 100644 --- a/protoc/CppFileGenerator.cpp +++ b/protoc/CppFileGenerator.cpp @@ -196,6 +196,8 @@ void FileGenerator::GenerateBuildDescriptors(Printer* printer) { "assigndescriptorsname", GlobalAssignDescriptorsName(m_output_name)); printer->Indent(); + // No longer needed since protobuf 3.7 +#if GOOGLE_PROTOBUF_VERSION < 3007000 // Make sure the file has found its way into the pool. If a descriptor // is requested *during* static init then AddDescriptors() may not have // been called yet, so we call it manually. Note that it's fine if @@ -203,6 +205,7 @@ void FileGenerator::GenerateBuildDescriptors(Printer* printer) { printer->Print( "$adddescriptorsname$();\n", "adddescriptorsname", GlobalAddDescriptorsName(m_file->name())); +#endif // Get the file's descriptor from the pool. printer->Print( @@ -228,6 +231,10 @@ void FileGenerator::GenerateBuildDescriptors(Printer* printer) { // protobuf_AssignDescriptorsOnce(): The first time it is called, calls // AssignDescriptors(). All later times, waits for the first call to // complete and then returns. + + // We need to generate different code, depending on the version + // of protobuf we compile against +#if GOOGLE_PROTOBUF_VERSION < 3007000 printer->Print( "namespace {\n" "\n" @@ -241,6 +248,19 @@ void FileGenerator::GenerateBuildDescriptors(Printer* printer) { "assigndescriptorsname", GlobalAssignDescriptorsName(m_output_name)); printer->Print("} // namespace\n"); +#else + printer->Print( + "namespace {\n" + "\n" + "inline void protobuf_AssignDescriptorsOnce() {\n" + " static ::google::protobuf::internal::once_flag once;\n" + " ::google::protobuf::internal::call_once(once,\n" + " &$assigndescriptorsname$);\n" + "}\n" + "\n", + "assigndescriptorsname", GlobalAssignDescriptorsName(m_output_name)); + printer->Print("} // namespace\n"); +#endif } } diff --git a/protoc/GeneratorHelpers.cpp b/protoc/GeneratorHelpers.cpp index 19609181e4..d0939c4309 100644 --- a/protoc/GeneratorHelpers.cpp +++ b/protoc/GeneratorHelpers.cpp @@ -104,10 +104,13 @@ string FilenameIdentifier(const string& filename) { return result; } +// No longer needed since protobuf 3.7 +#if GOOGLE_PROTOBUF_VERSION < 3007000 // Return the name of the AddDescriptors() function for a given file. string GlobalAddDescriptorsName(const string& filename) { return "protobuf_AddDesc_" + FilenameIdentifier(filename); } +#endif // Return the name of the AssignDescriptors() function for a given file. string GlobalAssignDescriptorsName(const string& filename) { diff --git a/protoc/GeneratorHelpers.h b/protoc/GeneratorHelpers.h index 35efdbb043..2e9d311d0e 100644 --- a/protoc/GeneratorHelpers.h +++ b/protoc/GeneratorHelpers.h @@ -67,8 +67,11 @@ string StripProto(const string& filename); // Convert a file name into a valid identifier. string FilenameIdentifier(const string& filename); +// No longer needed since protobuf 3.7 +#if GOOGLE_PROTOBUF_VERSION < 3007000 // Return the name of the AddDescriptors() function for a given file. string GlobalAddDescriptorsName(const string& filename); +#endif // Return the name of the AssignDescriptors() function for a given file. string GlobalAssignDescriptorsName(const string& filename); diff --git a/protoc/StrUtil.cpp b/protoc/StrUtil.cpp index 85891a6a46..d300b71e86 100644 --- a/protoc/StrUtil.cpp +++ b/protoc/StrUtil.cpp @@ -41,6 +41,21 @@ #include "protoc/StrUtil.h" +#if HAVE_CONFIG_H +#include +#endif // HAVE_CONFIG_H + +// Required for Protobuf 3.7 onwards +#ifdef HAVE_GOOGLE_PROTOBUF_IO_STRTOD_H +#include +#endif // HAVE_GOOGLE_PROTOBUF_IO_STRTOD_H +#ifdef HAVE_GOOGLE_PROTOBUF_STUBS_LOGGING_H +#include +#endif // HAVE_GOOGLE_PROTOBUF_STUBS_LOGGING_H +#ifdef HAVE_GOOGLE_PROTOBUF_STUBS_STL_UTIL_H +#include +#endif // HAVE_GOOGLE_PROTOBUF_STUBS_STL_UTIL_H + #ifdef _WIN32 // MSVC has only _snprintf, not snprintf. // diff --git a/python/examples/ola_rdm_get.py b/python/examples/ola_rdm_get.py index 94f34954fc..06a2542592 100755 --- a/python/examples/ola_rdm_get.py +++ b/python/examples/ola_rdm_get.py @@ -183,7 +183,7 @@ def do_subdevice(self, line): return self._sub_device = sub_device - def do_print(self, l): + def do_print(self, line): """Prints the current universe, UID and sub device.""" print(textwrap.dedent("""\ Universe: %d @@ -193,7 +193,7 @@ def do_print(self, l): self._uid, self._sub_device))) - def do_uids(self, l): + def do_uids(self, line): """List the UIDs for this universe.""" self.client.FetchUIDList(self._universe, self._DisplayUids) self.wrapper.Run() @@ -206,12 +206,12 @@ def _DisplayUids(self, state, uids): print(str(uid)) self.wrapper.Stop() - def do_full_discovery(self, l): + def do_full_discovery(self, line): """Run full RDM discovery for this universe.""" self.client.RunRDMDiscovery(self._universe, True, self._DiscoveryDone) self.wrapper.Run() - def do_incremental_discovery(self, l): + def do_incremental_discovery(self, line): """Run incremental RDM discovery for this universe.""" self.client.RunRDMDiscovery(self._universe, False, self._DiscoveryDone) self.wrapper.Run() diff --git a/scripts/enforce_licence.py b/scripts/enforce_licence.py index b9502598d6..2e6699474e 100755 --- a/scripts/enforce_licence.py +++ b/scripts/enforce_licence.py @@ -144,8 +144,8 @@ def TransformCppToJsLicence(licence): lines = licence.split('\n') output = [] output.append('/**') - for l in lines[1:]: - output.append(TransformJsLine(l[2:])) + for line in lines[1:]: + output.append(TransformJsLine(line[2:])) return '\n'.join(output) @@ -162,8 +162,8 @@ def TransformCppToPythonLicence(licence): """Change a C++ licence to Python style""" lines = licence.split('\n') output = [] - for l in lines[1:]: - output.append(TransformPythonLine(l[3:])) + for line in lines[1:]: + output.append(TransformPythonLine(line[3:])) return '\n'.join(output) diff --git a/tools/rdm/TestLogger.py b/tools/rdm/TestLogger.py index d39560f902..e53e6baa71 100644 --- a/tools/rdm/TestLogger.py +++ b/tools/rdm/TestLogger.py @@ -199,7 +199,7 @@ def _FormatData(self, test_data, requested_category, requested_test_state, if include_description: results_log.append(str(test['doc'])) if include_debug: - results_log.extend(str(l) for l in test.get('debug', [])) + results_log.extend(str(s) for s in test.get('debug', [])) results_log.append('') warnings.extend(str(s) for s in test.get('warnings', [])) advisories.extend(str(s) for s in test.get('advisories', []))