Skip to content

Commit 3699581

Browse files
Garret Fickanhnguyen-cpi
Garret Fick
authored andcommitted
Successful build on Windows (VOLTTRON#13)
* Successful build on Windows * Only set visibilify flag when not running MSVC * Automatically patch imasteroperations if required
1 parent 5bcd824 commit 3699581

File tree

230 files changed

+2595
-491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+2595
-491
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.patch text eol=lf

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,8 @@ ENV/
100100

101101
# mypy
102102
.mypy_cache/
103-
*.pytest_cache/
103+
*.pytest_cache/
104+
105+
# VisualStudio and VisualStudio Code project settings
106+
.vscode/
107+
.vs/

CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ option(PROFILE "Builds the libraries with profiling support (gcc only)" OFF)
2828
set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS})
2929

3030
set(STATICLIBS ON)
31-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
31+
32+
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
33+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
34+
endif()
3235

3336
add_subdirectory(deps/pybind11)
3437
add_subdirectory(deps/dnp3)
@@ -41,7 +44,7 @@ include_directories(deps/dnp3/cpp/libs/src)
4144
include_directories(deps/dnp3/deps/asio/asio/include)
4245
add_definitions(-DASIO_STANDALONE)
4346

44-
pybind11_add_module(pydnp3 MODULE src/pydnp3.cpp)
47+
pybind11_add_module(pydnp3 MODULE src/pydnp3.cpp src/pydnp3asiodnp3.cpp src/pydnp3asiopal.cpp src/pydnp3opendnp3.cpp src/pydnp3openpal.cpp)
4548
target_link_libraries(pydnp3 PRIVATE asiopal asiodnp3 openpal opendnp3)
4649

4750

imasteroperations.patch

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/cpp/libs/include/asiodnp3/IMasterOperations.h b/cpp/libs/include/asiodnp3/IMasterOperations.h
2+
index f056323e4..75cad0273 100644
3+
--- a/cpp/libs/include/asiodnp3/IMasterOperations.h
4+
+++ b/cpp/libs/include/asiodnp3/IMasterOperations.h
5+
@@ -40,6 +40,7 @@
6+
7+
#include <vector>
8+
#include <memory>
9+
+#include <string>
10+
11+
namespace asiodnp3
12+
{

setup.py

+8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ def build_extension(self, ext):
5555
self.distribution.get_version())
5656
if not os.path.exists(self.build_temp):
5757
os.makedirs(self.build_temp)
58+
59+
setup_path = os.path.dirname(os.path.abspath(__file__))
60+
if not "<string>" in open(os.path.join(setup_path, 'deps', 'dnp3', 'cpp', 'libs', 'include', 'asiodnp3', 'IMasterOperations.h')).read():
61+
dnp3_path = os.path.join(setup_path, 'deps', 'dnp3')
62+
patch_path = os.path.join(setup_path, 'imasteroperations.patch')
63+
64+
subprocess.check_call(['git', 'apply', patch_path], cwd=dnp3_path)
65+
5866
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
5967
subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
6068

src/AllHeaders.h

-252
This file was deleted.

src/asiodnp3/AllHeaders.h

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* -*- coding: utf-8 -*- {{{
3+
* vim: set fenc=utf-8 ft=python sw=4 ts=4 sts=4 et:
4+
*
5+
* Copyright 2018, Kisensum.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
* Neither Kisensum, nor any of its employees, nor any jurisdiction or
20+
* organization that has cooperated in the development of these materials,
21+
* makes any warranty, express or implied, or assumes any legal liability
22+
* or responsibility for the accuracy, completeness, or usefulness or any
23+
* information, apparatus, product, software, or process disclosed, or
24+
* represents that its use would not infringe privately owned rights.
25+
* Reference herein to any specific commercial product, process, or service
26+
* by trade name, trademark, manufacturer, or otherwise does not necessarily
27+
* constitute or imply its endorsement, recommendation, or favoring by Kisensum.
28+
* }}}
29+
*/
30+
31+
#ifndef PYDNP3_ASIODNP3_ALLHEADERS_H
32+
#define PYDNP3_ASIODNP3_ALLHEADERS_H
33+
34+
// For this compilation unit, include the header file
35+
// related to asiodnp3
36+
#define PYDNP3_ASIODNP3
37+
38+
// ---------- ASIODNP3 HEADERS ----------
39+
#include "ConsoleLogger.h"
40+
#include "DatabaseConfig.h"
41+
#include "DefaultListenCallbacks.h"
42+
#include "DefaultMasterApplication.h"
43+
#include "DNP3Manager.h"
44+
#include "ErrorCodes.h"
45+
#include "IChannel.h"
46+
#include "IChannelListener.h"
47+
#include "IListenCallbacks.h"
48+
#include "IMaster.h"
49+
#include "IMasterOperations.h"
50+
#include "IMasterScan.h"
51+
#include "IMasterSession.h"
52+
#include "IOutstation.h"
53+
#include "ISessionAcceptor.h"
54+
#include "IStack.h"
55+
#include "MasterStackConfig.h"
56+
#include "MasterTCPServer.h"
57+
#include "OutstationStackConfig.h"
58+
#include "PrintingChannelListener.h"
59+
#include "PrintingCommandCallback.h"
60+
#include "PrintingSOEHandler.h"
61+
#include "UpdateBuilder.h"
62+
#include "Updates.h"
63+
#include "X509Info.h"
64+
65+
#endif

0 commit comments

Comments
 (0)