Blob Blame History Raw
From 694241f7905967bf69af3a31265180c00b73e28c Mon Sep 17 00:00:00 2001
From: Michael Cronenworth <mike@cchtml.com>
Date: Fri, 11 Aug 2017 10:08:27 -0500
Subject: [PATCH] build: Detect and allow external tinyxpath library usage

Signed-off-by: Michael Cronenworth <mike@cchtml.com>
---
 CMakeLists.txt                             | 57 +++++++++++++++++++++---------
 removed from Fedora patch hardware/AnnaThermostat.cpp                |  3 +-
 removed from Fedora patch hardware/RAVEn.cpp                         |  3 +-
 removed from Fedora patch hardware/openzwave/control_panel/ozwcp.cpp |  3 +-
 removed from Fedora patch hardware/plugins/PluginManager.cpp         |  3 +-
 removed from Fedora patch hardware/plugins/Plugins.cpp               |  3 +-
 removed from Fedora patch main/LuaCommon.cpp                         |  7 +++-
 removed from Fedora patch main/LuaHandler.cpp                        |  3 +-
 removed from Fedora patch msbuild/domoticz.vcxproj                   |  6 ++--
 9 files changed, 62 insertions(+), 26 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bc231d8f6..334f203a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -371,22 +371,6 @@
 webserver/server.cpp
 webserver/Websockets.cpp
 webserver/WebsocketHandler.cpp
-tinyxpath/action_store.cpp
-tinyxpath/htmlutil.cpp
-tinyxpath/lex_util.cpp
-tinyxpath/node_set.cpp
-tinyxpath/tinystr.cpp
-tinyxpath/tinyxml.cpp
-tinyxpath/tinyxmlerror.cpp
-tinyxpath/tinyxmlparser.cpp
-tinyxpath/tokenlist.cpp
-tinyxpath/xml_util.cpp
-tinyxpath/xpath_expression.cpp
-tinyxpath/xpath_processor.cpp
-tinyxpath/xpath_stream.cpp
-tinyxpath/xpath_stack.cpp
-tinyxpath/xpath_static.cpp
-tinyxpath/xpath_syntax.cpp
 )
 
 add_executable(domoticz ${domoticz_SRCS})
@@ -710,6 +694,47 @@
   ENDIF(LIBUSB_FOUND)
 ENDIF(WITH_LIBUSB)
 
+option(USE_BUILTIN_TINYXPATH "Use builtin tinyxpath library" YES)
+IF(USE_BUILTIN_TINYXPATH)
+  include_directories(tinyxpath)
+  target_sources(
+  domoticz
+  PUBLIC
+  tinyxpath/action_store.cpp
+  tinyxpath/htmlutil.cpp
+  tinyxpath/lex_util.cpp
+  tinyxpath/node_set.cpp
+  tinyxpath/tinystr.cpp
+  tinyxpath/tinyxml.cpp
+  tinyxpath/tinyxmlerror.cpp
+  tinyxpath/tinyxmlparser.cpp
+  tinyxpath/tokenlist.cpp
+  tinyxpath/xml_util.cpp
+  tinyxpath/xpath_expression.cpp
+  tinyxpath/xpath_processor.cpp
+  tinyxpath/xpath_stream.cpp
+  tinyxpath/xpath_stack.cpp
+  tinyxpath/xpath_static.cpp
+  tinyxpath/xpath_syntax.cpp
+  )
+else()
+  pkg_check_modules(TinyXML QUIET tinyxml)
+  IF(TinyXML_FOUND)
+    MESSAGE(STATUS "TinyXML found at: ${TinyXML_LIBRARIES}")
+    IF(EXISTS "/usr/include/tinyxpath/xpath_processor.h")
+      MESSAGE(STATUS "TinyXPath found")
+      target_link_libraries(domoticz ${TinyXML_LIBRARIES})
+      target_link_libraries(domoticz tinyxpath)
+      include_directories(/usr/include/tinyxpath)
+      add_definitions(-DWITH_EXTERNAL_TINYXPATH)
+    else()
+      MESSAGE(FATAL_ERROR "TinyXPath not found but USE_BUILTIN_TINYXPATH=NO")
+    ENDIF()
+  else()
+    MESSAGE(FATAL_ERROR "TinyXML not found but USE_BUILTIN_TINYXPATH=NO")
+  ENDIF(TinyXML_FOUND)
+ENDIF(USE_BUILTIN_TINYXPATH)
+
 #
 # OpenZWave
 # try to find open-zwave, if found, include support
--- a/hardware/openzwave/control_panel/ozwcp.cpp	2020-03-22 09:16:16.000000000 -0500
+++ b/hardware/openzwave/control_panel/ozwcp.cpp	2020-03-24 10:53:04.968630391 -0500
@@ -49,7 +49,7 @@
 #include <sys/stat.h>
 #include <fstream>
 #include <iostream>
-#include "../../../tinyxpath/tinyxml.h"
+#include <tinyxml.h>
 
 //#include "microhttpd.h"
 #include "ozwcp.h"
--- a/hardware/plugins/PluginManager.cpp	2020-03-22 09:16:16.000000000 -0500
+++ b/hardware/plugins/PluginManager.cpp	2020-03-24 13:53:05.305852598 -0500
@@ -21,11 +21,12 @@
 #include "../../main/Logger.h"
 #include "../../main/SQLHelper.h"
 #include "../../main/WebServer.h"
-#include "../../tinyxpath/tinyxml.h"
 #ifdef WIN32
+#       include "../../tinyxpath/tinyxml.h"
 #	include <direct.h>
 #else
 #	include <sys/stat.h>
+#       include <tinyxml.h>
 #endif
 
 #include "DelayedLink.h"
--- a/hardware/AnnaThermostat.cpp	2020-03-22 09:16:16.000000000 -0500
+++ b/hardware/AnnaThermostat.cpp	2020-03-24 10:41:00.530030798 -0500
@@ -9,7 +9,7 @@
 #include "../httpclient/HTTPClient.h"
 #include "../main/mainworker.h"
 
-#include "../tinyxpath/tinyxml.h"
+#include <tinyxml.h>
 
 #define round(a) ( int ) ( a + .5 )
 
--- a/hardware/EcoDevices.cpp	2020-03-22 09:16:16.000000000 -0500
+++ b/hardware/EcoDevices.cpp	2020-03-24 10:47:20.095926641 -0500
@@ -35,11 +35,11 @@
 #include "../main/Logger.h"
 #include "hardwaretypes.h"
 #include "../httpclient/HTTPClient.h"
-#include "../tinyxpath/tinyxml.h"
-#include "../tinyxpath/xpath_static.h"
 #include "../webserver/Base64.h"
 #include "../main/json_helper.h"
 #include <sstream>
+#include <tinyxml.h>
+#include <xpath_static.h>
 
 // Minimum EcoDevises firmware required
 #define MAJOR 1
--- a/hardware/Enever.cpp	2023-07-21 10:23:44.000000000 -0500
+++ b/hardware/Enever.cpp	2023-11-10 13:51:27.603228843 -0600
@@ -9,12 +9,12 @@
 #include "../main/RFXtrx.h"
 #include "../main/SQLHelper.h"
 #include "../notifications/NotificationHelper.h"
-#include "../tinyxpath/tinyxml.h"
 #include "../webserver/Base64.h"
 #include "hardwaretypes.h"
 #include <iostream>
 #define __STDC_FORMAT_MACROS
 #include <inttypes.h>
+#include <tinyxml.h>
 
 //See https://enever.nl/prijzenfeeds
 //We are able to do 5 requests per day, so we need to cache the results!
--- a/hardware/EnphaseAPI.cpp	2023-07-21 10:23:44.000000000 -0500
+++ b/hardware/EnphaseAPI.cpp	2023-11-10 13:53:38.445870705 -0600
@@ -9,10 +9,10 @@
 #include "../main/RFXtrx.h"
 #include "../main/SQLHelper.h"
 #include "../notifications/NotificationHelper.h"
-#include "../tinyxpath/tinyxml.h"
 #include "../webserver/Base64.h"
 #include "hardwaretypes.h"
 #include <iostream>
+#include <tinyxml.h>
 //#define JWT_DISABLE_BASE64
 //#include "../jwt-cpp/jwt.h"
 
--- a/hardware/OnkyoAVTCP.cpp	2018-06-23 09:18:06.000000000 -0500
+++ b/hardware/OnkyoAVTCP.cpp	2018-07-08 14:21:06.884163094 -0500
@@ -3,14 +3,14 @@
 #include "../main/Logger.h"
 #include "../main/Helper.h"
 #include "../main/SQLHelper.h"
-#include <iostream>
 #include "../main/mainworker.h"
 #include "../hardware/hardwaretypes.h"
-#include <json/json.h>
-#include "../tinyxpath/tinyxml.h"
 #include "../main/WebServer.h"
 
+#include <iostream>
+#include <json/json.h>
 #include <sstream>
+#include <tinyxml.h>
 
 #define RETRY_DELAY 30
 
--- a/hardware/RAVEn.cpp	2020-03-22 09:16:16.000000000 -0500
+++ b/hardware/RAVEn.cpp	2020-03-24 12:55:59.616310732 -0500
@@ -5,8 +5,8 @@
 #include "../main/Logger.h"
 #include "../main/mainworker.h"
 #include "../main/RFXtrx.h"
-#include "../tinyxpath/tinyxml.h"
 #include "hardwaretypes.h"
+#include <tinyxml.h>
 
 //Rainforest RAVEn USB ZigBee Smart Meter Adapter
 //https://rainforestautomation.com/rfa-z106-raven/
--- a/hardware/plugins/Plugins.cpp	2022-01-31 02:34:32.000000000 -0600
+++ b/hardware/plguins/Plugins.cpp	2022-03-11 12:00:00.168080154 -0600
@@ -17,10 +17,11 @@
 #include "../../main/Logger.h"
 #include "../../main/SQLHelper.h"
 #include "../../main/mainworker.h"
-#include "../../tinyxpath/tinyxml.h"
 
 #include "../../notifications/NotificationHelper.h"
 
+#include <tinyxml.h>
+
 #define ADD_STRING_TO_DICT(pPlugin, pDict, key, value)                                                                                      \
 	{                                                                                                                                       \
 		PyNewRef	pStr(value);                                                                               \