You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/07/14 16:30:13 UTC
[plc4x] branch feature/s7-cpp updated: - Added a 'proxy' driver
skeleton which will be using thrift for communication with a plc4x proxy
server. - Fine-tuned the assembly of the thrift cpp library.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/s7-cpp
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/s7-cpp by this push:
new 4625982 - Added a 'proxy' driver skeleton which will be using thrift for communication with a plc4x proxy server. - Fine-tuned the assembly of the thrift cpp library.
4625982 is described below
commit 46259825d2bfb98a91953c4ba7ce49a6f3353452
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sun Jul 14 18:30:00 2019 +0200
- Added a 'proxy' driver skeleton which will be using thrift for communication with a plc4x proxy server.
- Fine-tuned the assembly of the thrift cpp library.
---
plc4cpp/CMakeLists.txt | 2 +
plc4cpp/drivers/CMakeLists.txt | 6 +
plc4cpp/drivers/proxy/CMakeLists.txt | 47 +++++++
.../cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.cpp | 89 +++++++++++++
.../cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.h | 87 +++++++++++++
.../plc4x/cpp/proxy/connection/ProxyConnection.cpp | 59 +++++++++
.../plc4x/cpp/proxy/connection/ProxyConnection.h | 137 +++++++++++++++++++++
.../cpp/org/apache/plc4x/cpp/proxy/dllexports.cpp | 40 ++++++
.../cpp/org/apache/plc4x/cpp/proxy/dllexports.h | 29 +++++
plc4cpp/pom.xml | 98 ++++++++++++++-
tools/thrift/src/assembly/cpp.xml | 17 ++-
11 files changed, 608 insertions(+), 3 deletions(-)
diff --git a/plc4cpp/CMakeLists.txt b/plc4cpp/CMakeLists.txt
index 417e5b7..938bd68 100644
--- a/plc4cpp/CMakeLists.txt
+++ b/plc4cpp/CMakeLists.txt
@@ -25,6 +25,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Save the root directory
set(PLC4CPP_ROOT_DIR ${CMAKE_SOURCE_DIR})
+# Define some user-defined profiles
+set(WITH_PROXIES OFF CACHE BOOL "Enable building Thrift based proxy driver")
# Tell the tooling where to find our Boost installation
set(BOOST_INCLUDEDIR "${PLC4CPP_ROOT_DIR}/target/lib/boost/include")
diff --git a/plc4cpp/drivers/CMakeLists.txt b/plc4cpp/drivers/CMakeLists.txt
index 4c3bf2b..667b6fa 100644
--- a/plc4cpp/drivers/CMakeLists.txt
+++ b/plc4cpp/drivers/CMakeLists.txt
@@ -17,4 +17,10 @@
under the License.
]]
+# Only build the proxy module, if the "with-proxies" profile is enabled.
+message(STATUS "With proxy = ${WITH_PROXIES}")
+if(WITH_PROXIES)
+ add_subdirectory(proxy)
+endif()
+
add_subdirectory(s7)
diff --git a/plc4cpp/drivers/proxy/CMakeLists.txt b/plc4cpp/drivers/proxy/CMakeLists.txt
new file mode 100644
index 0000000..e5c214f
--- /dev/null
+++ b/plc4cpp/drivers/proxy/CMakeLists.txt
@@ -0,0 +1,47 @@
+#[[
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+]]
+
+# Collect all the generated files
+aux_source_directory(../../target/generated-sources/drivers/proxy PROXY_GENERATED_SOURCES)
+
+message(STATUS "Found generated sources: ${PROXY_GENERATED_SOURCES}")
+
+add_library(plc4cpp-driver-proxy SHARED
+ src/main/cpp/org/apache/plc4x/cpp/proxy/dllexports.cpp
+ src/main/cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.cpp
+ src/main/cpp/org/apache/plc4x/cpp/proxy/connection/ProxyConnection.cpp
+ ${PROXY_GENERATED_SOURCES}
+ )
+
+target_include_directories (plc4cpp-driver-proxy PUBLIC ${Boost_INCLUDE_DIRS})
+target_include_directories (plc4cpp-driver-proxy PUBLIC ${PLC4CPP_ROOT_DIR}/target/lib/thrift/include/)
+target_include_directories (plc4cpp-driver-proxy PUBLIC ../../api/src/main/cpp)
+target_include_directories (plc4cpp-driver-proxy PUBLIC ../../protocols/driver-bases/base/src/main/cpp)
+target_include_directories (plc4cpp-driver-proxy PUBLIC ../../protocols/s7/src/main/cpp)
+target_include_directories (plc4cpp-driver-proxy PUBLIC ../../utils/logger/src/main/cpp)
+target_include_directories (plc4cpp-driver-proxy PUBLIC ../../utils/systemconfig/src/main/cpp)
+
+target_link_libraries (plc4cpp-driver-proxy
+ ${Boost_LIBRARIES}
+ ${PLC4CPP_ROOT_DIR}/target/lib/thrift/lib/libparse.a ${PLC4CPP_ROOT_DIR}/target/lib/thrift/lib/libthrift.a ${PLC4CPP_ROOT_DIR}/target/lib/thrift/lib/libthriftz.a ${PLC4CPP_ROOT_DIR}/target/lib/thrift/lib/libtutorialgencpp.a
+ plc4cpp-utils-logger
+ plc4cpp-api
+ plc4cpp-protocols-driver-base-base
+ plc4cpp-utils-systemconfig
+ )
diff --git a/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.cpp b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.cpp
new file mode 100644
index 0000000..3571701
--- /dev/null
+++ b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.cpp
@@ -0,0 +1,89 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+#include "ProxyDriver.h"
+#include "connection/ProxyConnection.h"
+#include <org/apache/plc4x/cpp/api/exceptions/PlcConnectionException.h>
+#include <boost/regex.hpp>
+
+using namespace std;
+using namespace org::apache::plc4x::cpp::api::exceptions;
+
+namespace org
+{
+ namespace apache
+ {
+ namespace plc4x
+ {
+ namespace cpp
+ {
+ namespace proxy
+ {
+ string ProxyDriver::getProtocolCode()
+ {
+ return std::string("proxy");
+ }
+
+
+ string ProxyDriver::getProtocolName() {
+ return "Proxy";
+ }
+
+ PlcConnection* ProxyDriver::connect(std::string url)
+ {
+ boost::regex exFilter(PROXY_URI_PATTERN.c_str());
+ boost::smatch what;
+
+ std::string strHost = "";
+ std::string strParams = "";
+ ProxyConnection* pProxyConnection = NULL;
+
+ try
+ {
+ if (!boost::regex_search(url, what, exFilter))
+ {
+ BOOST_THROW_EXCEPTION(PlcConnectionException("Connection url doesn't match the format 'proxy://{host|ip}'"));
+ }
+
+ strHost = what[1].str(); // Host
+ strParams = what[2].str(); // Params
+
+ // Resolve from Hostname to implements PlcConnection
+ pProxyConnection = new ProxyConnection(strHost, strParams);
+ }
+ catch (exception ex)
+ {
+ BOOST_THROW_EXCEPTION(PlcConnectionException("Error connecting to host", ex));
+ }
+
+ return pProxyConnection;
+ }
+
+
+ PlcConnection* ProxyDriver::connect(std::string url, PlcAuthentication authentication)
+ {
+ BOOST_THROW_EXCEPTION(PlcConnectionException("Proxy connections don't support authentication."));
+ }
+
+
+ }
+ }
+ }
+ }
+}
diff --git a/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.h b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.h
new file mode 100644
index 0000000..355ac49
--- /dev/null
+++ b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/ProxyDriver.h
@@ -0,0 +1,87 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+#ifndef _PROXY_DRIVER
+#define _PROXY_DRIVER
+
+#include <org/apache/plc4x/cpp/spi/PlcDriver.h>
+#include <org/apache/plc4x/cpp/api/authentication/PlcAuthentication.h>
+#include <string>
+
+using namespace org::apache::plc4x::cpp::spi;
+
+namespace org
+{
+ namespace apache
+ {
+ namespace plc4x
+ {
+ namespace cpp
+ {
+ namespace proxy
+ {
+ /**
+ * Interface defining the most basic methods a PLC4X connection should support.
+ * This generally handles the connection establishment itself and the parsing of
+ * field address strings to the platform dependent PlcField instances.
+ */
+ class ProxyDriver : public PlcDriver
+ {
+
+ public:
+ /**
+ * @return code of the implemented protocol. This is usually a lot shorter than the String returned by @seeĀ #getProtocolName().
+ */
+ virtual std::string getProtocolCode();
+
+ /**
+ * @return name of the implemented protocol.
+ */
+ virtual std::string getProtocolName();
+
+ /**
+ * Connects to a PLC using the given plc connection string.
+ * @param url plc connection string.
+ * @return PlcConnection object.
+ * @throws PlcConnectionException an exception if the connection attempt failed.
+ */
+ virtual PlcConnection* connect(std::string url);
+
+ /**
+ * Connects to a PLC using the given plc connection string using given authentication credentials.
+ * @param url plc connection string.
+ * @param authentication authentication credentials.
+ * @return PlcConnection object.
+ * @throws PlcConnectionException an exception if the connection attempt failed.
+ */
+ virtual PlcConnection* connect(std::string url, PlcAuthentication authentication);
+
+ private:
+
+ const std::string PROXY_URI_PATTERN="proxy://(?<host>.*)(?<params>\\?.*)?";
+
+ };
+ }
+ }
+ }
+ }
+}
+
+#endif
+
diff --git a/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/connection/ProxyConnection.cpp b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/connection/ProxyConnection.cpp
new file mode 100644
index 0000000..85355ab
--- /dev/null
+++ b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/connection/ProxyConnection.cpp
@@ -0,0 +1,59 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+#include "ProxyConnection.h"
+#include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
+
+
+namespace org
+{
+ namespace apache
+ {
+ namespace plc4x
+ {
+ namespace cpp
+ {
+ namespace proxy
+ {
+ ProxyConnection::ProxyConnection()
+ {
+ _lCloseDeviceTimeoutMS = CONF.getLong("plc4x.s7connection.close.device,timeout", 1000);
+ };
+
+ ProxyConnection::~ProxyConnection()
+ {
+
+ };
+
+ ProxyConnection::ProxyConnection(std::string strHost, string strParams)
+ {
+ setIPAddress(strHost);
+
+ string strMessage = "Setting up ProxyConnection with: host-name " + strHost;
+ LOG_INFO(strMessage);
+
+ return;
+ }
+
+ }
+ }
+ }
+ }
+}
diff --git a/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/connection/ProxyConnection.h b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/connection/ProxyConnection.h
new file mode 100644
index 0000000..3e43716
--- /dev/null
+++ b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/connection/ProxyConnection.h
@@ -0,0 +1,137 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+#ifndef _PROXY_CONNECTION
+#define _PROXY_CONNECTION
+
+#include <org/apache/plc4x/cpp/api/metadata/PlcConnectionMetadata.h>
+#include <org/apache/plc4x/cpp/api/messages/PlcReadRequest.h>
+#include <org/apache/plc4x/cpp/api/messages/PlcWriteRequest.h>
+#include <org/apache/plc4x/cpp/api/messages/PlcSubscriptionRequest.h>
+#include <org/apache/plc4x/cpp/api/messages/PlcUnsubscriptionRequest.h>
+#include <org/apache/plc4x/cpp/base/connection/BoostConnection.h>
+#include <org/apache/plc4x/cpp/base/connection/ChannelFactory.h>
+#include <org/apache/plc4x/cpp/utils/logger/BLogger.h>
+#include <org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.h>
+
+
+/**
+ * Class implementing the Connection handling for Siemens S7.
+ * The adressing of Values in S7 works as follows:
+ * <p>
+ * For adressing values from Datablocks the following syntax is used:
+ * <pre>
+ * DATA_BLOCKS/{blockNumer}/{byteOffset}
+ * </pre>
+ * <p>
+ * For adressing data from other memory segments like I/O, Markers, ...
+ * <pre>
+ * {memory area}/{byte offset}
+ * or
+ * {memory area}/{byte offset}/{bit offset}
+ * </pre>
+ * where the {bit-offset} is optional.
+ * All Available Memory Areas for this mode are defined in the {@link MemoryArea} enum.
+ */
+
+namespace org
+{
+ namespace apache
+ {
+ namespace plc4x
+ {
+ namespace cpp
+ {
+ namespace proxy
+ {
+
+ using namespace org::apache::plc4x::cpp::api::metadata;
+ using namespace org::apache::plc4x::cpp::api::messages;
+ using namespace org::apache::plc4x::cpp::api;
+ using namespace org::apache::plc4x::cpp::base::connection;
+ using namespace org::apache::plc4x::cpp::utils;
+
+ /**
+ * Interface defining the most basic methods a PLC4X connection should support.
+ * This generally handles the connection establishment itself and the parsing of
+ * field address strings to the platform dependent PlcField instances.
+ */
+ class ProxyConnection : public BoostConnection
+ {
+ public:
+
+ ProxyConnection();
+ ProxyConnection(std::string strHost, string strParams);
+
+ ~ProxyConnection();
+
+ void connect() {};
+
+ /**
+ * Provides connection metadata.
+ */
+ PlcConnectionMetadata* getMetadata() { return NULL; };
+
+ /**
+ * Obtain read request builder.
+ * @throws PlcUnsupportedOperationException if the connection does not support reading
+ * Todo: implement pendant for java Builder pattern
+ */
+ PlcReadRequest::Builder* readRequestBuilder() { return NULL; };
+
+ /**
+ * Obtain write request builder.
+ * @throws PlcUnsupportedOperationException if the connection does not support writing
+ * Todo: implement pendant for java Builder pattern (PlcWriteRequest.Builder)
+ */
+ PlcWriteRequest* writeRequestBuilder() { return NULL; };
+
+ /**
+ * Obtain subscription request builder.
+ * @throws PlcUnsupportedOperationException if the connection does not support subscription
+ * Todo: implement pendant for java Builder pattern (PlcSubscriptionRequest.Builder)
+ */
+ PlcSubscriptionRequest* subscriptionRequestBuilder() { return NULL; };
+
+ /**
+ * Obtain unsubscription request builder.
+ * @throws PlcUnsupportedOperationException if the connection does not support subscription
+ * Todo: implement pendant for java Builder pattern (PlcSubscriptionRequest.Builder)
+
+ */
+ PlcUnsubscriptionRequest* unsubscriptionRequestBuilder() { return NULL; };
+
+ void ping() {};
+
+ bool send(unsigned char* pBytesToSend, int iNumBytesToSend) { return true;};
+
+ void onReceive(const boost::system::error_code& errorCode, std::size_t szRecvBytes) {};
+
+ private:
+
+ SystemConfiguration CONF;
+
+ };
+ }
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/dllexports.cpp b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/dllexports.cpp
new file mode 100644
index 0000000..ad72d07
--- /dev/null
+++ b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/dllexports.cpp
@@ -0,0 +1,40 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+//-------- DllMain.cpp --------//
+#include "dllexports.h"
+#include "ProxyDriver.h"
+#if defined (_WIN32)
+ #include <windows.h>
+#endif
+
+using namespace org::apache::plc4x::cpp::proxy;
+using namespace org::apache::plc4x::cpp::spi;
+
+#if defined (_WIN32)
+int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
+{
+ return 1;
+}
+#endif
+
+extern "C" PlcDriver* _CreatePlcDriverInstance()
+{
+ return new ProxyDriver;
+}
\ No newline at end of file
diff --git a/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/dllexports.h b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/dllexports.h
new file mode 100644
index 0000000..9e8295d
--- /dev/null
+++ b/plc4cpp/drivers/proxy/src/main/cpp/org/apache/plc4x/cpp/proxy/dllexports.h
@@ -0,0 +1,29 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+//-------- DllExports.h --------//
+#ifndef _DLLEXPORTS_H
+#define _DLLEXPORTS_H
+
+#include <org/apache/plc4x/cpp/spi/PlcDriver.h>
+
+extern "C" /*__declspec(dllexport)*/ org::apache::plc4x::cpp::spi::PlcDriver* _CreatePlcDriverInstance();
+
+
+#endif // DLLEXPORTS_H
\ No newline at end of file
diff --git a/plc4cpp/pom.xml b/plc4cpp/pom.xml
index 76c5b82..e9056f9 100644
--- a/plc4cpp/pom.xml
+++ b/plc4cpp/pom.xml
@@ -38,6 +38,10 @@
<sonar.language>c++</sonar.language>
</properties-->
+ <properties>
+ <option.with-proxies>OFF</option.with-proxies>
+ </properties>
+
<!--
Notes:
- It turns out that the default version of CMake the cmake-maven-plugin uses is too
@@ -120,6 +124,42 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>with-proxies</id>
+ <properties>
+ <option.with-proxies>ON</option.with-proxies>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>get-boost</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems combine.children="append">
+ <!-- Get the pre-packaged boost library -->
+ <artifactItem>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-tools-thrift</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <type>zip</type>
+ <classifier>cpp-${os.classifier}</classifier>
+ <outputDirectory>${project.build.directory}/lib/thrift</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<build>
@@ -145,7 +185,9 @@
</executions>
</plugin>
- <!-- Get the pre-packaged boost library -->
+ <!--
+ Get additional stuff we need for the build.
+ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
@@ -158,6 +200,7 @@
</goals>
<configuration>
<artifactItems>
+ <!-- Get the pre-packaged boost library -->
<artifactItem>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-tools-boost</artifactId>
@@ -166,12 +209,60 @@
<classifier>lib-${os.classifier}</classifier>
<outputDirectory>${project.build.directory}/lib/boost</outputDirectory>
</artifactItem>
+ <!-- Unpack the protocol spec for the proxy driver -->
+ <artifactItem>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-protocols-proxy</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/protocol-spec</outputDirectory>
+ </artifactItem>
+ <!-- Unpack the thrift compiler -->
+ <artifactItem>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-tools-thrift</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <type>zip</type>
+ <classifier>compiler-${os.classifier}</classifier>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/thrift-compiler</outputDirectory>
+ <destFileName>${thrift.compiler.executable}</destFileName>
+ </artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
-
+ <!--
+ Generate the code for the Thrift-based interop server
+ -->
+ <plugin>
+ <groupId>org.apache.thrift.tools</groupId>
+ <artifactId>maven-thrift-plugin</artifactId>
+ <version>0.1.11</version>
+ <configuration>
+ <thriftExecutable>${project.build.directory}/thrift-compiler/${thrift.compiler.executable}</thriftExecutable>
+ <thriftSourceRoot>${project.build.directory}/protocol-spec</thriftSourceRoot>
+ <includes>
+ <include>**/interop.thrift</include>
+ </includes>
+ <generator>cpp</generator>
+ <outputDirectory>${project.build.directory}/generated-sources/drivers/proxy</outputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <id>thrift-sources</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!--
+ Do the actual build.
+ -->
<plugin>
<groupId>com.googlecode.cmake-maven-project</groupId>
<artifactId>cmake-maven-plugin</artifactId>
@@ -212,6 +303,9 @@
It defines the version and type of the cmake installation to download.
-->
<classifier>${os.classifier}</classifier>
+ <options>
+ <option>-DWITH_PROXIES:BOOL=${option.with-proxies}</option>
+ </options>
</configuration>
</execution>
<!-- Actually executes the build -->
diff --git a/tools/thrift/src/assembly/cpp.xml b/tools/thrift/src/assembly/cpp.xml
index e076d6f..b59e90a 100644
--- a/tools/thrift/src/assembly/cpp.xml
+++ b/tools/thrift/src/assembly/cpp.xml
@@ -30,12 +30,27 @@
<fileSets>
<fileSet>
+ <directory>${project.build.directory}/thrift-${thrift.version}/lib/cpp/src</directory>
+ <includes>
+ <include>**/*.h</include>
+ <include>**/*.tcc</include>
+ </includes>
+ <outputDirectory>include</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}/build/thrift</directory>
+ <includes>
+ <include>**/*.h</include>
+ </includes>
+ <outputDirectory>include/thrift</outputDirectory>
+ </fileSet>
+ <fileSet>
<directory>${project.build.directory}/build/lib</directory>
<includes>
<include>*.a</include>
<include>*.dylib</include>
</includes>
- <outputDirectory/>
+ <outputDirectory>lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file