From b9a1934879ecb280a79a406da0ce654fc8628db6 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Tue, 4 Sep 2018 11:53:53 -0400 Subject: [PATCH 1/3] Making epanet exports opt in --- CMakeLists.txt | 1 + include/epanet2.h | 20 +++++++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0fbce6..88ae5f6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ target_include_directories(epanet PUBLIC ${PROJECT_SOURCE_DIR}/include) # create export lib so we can link against dll using Visual Studio +add_definitions(-DWITH_GENX) include(GenerateExportHeader) GENERATE_EXPORT_HEADER(epanet BASE_NAME epanet diff --git a/include/epanet2.h b/include/epanet2.h index f7ca1a9..3951cd7 100644 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -30,7 +30,9 @@ #define EN_API_FLOAT_TYPE float #endif -#ifdef NO_GENX +#ifdef WITH_GENX + #include "epanet_export.h" +#else // --- define WINDOWS #undef WINDOWS #ifdef _WIN32 @@ -60,8 +62,6 @@ #define DLLEXPORT #endif #endif -#else - #include "epanet_export.h" #endif @@ -932,15 +932,6 @@ extern "C" { @see ENgetbasedemand */ int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE baseDemand); - - /** - @brief Sets the index of the demand pattern assigned to a node for a category index. - @param nodeIndex The index of a node (first node is index 1). - @param demandIndex The index of a category (first category is index 1). - @param pattIndex The index of the pattern for this node and category. - @return Error code - */ - int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIdx, int patIndex); /** @brief Retrieves index of curve with specific ID. @@ -1179,6 +1170,9 @@ extern "C" { ***************************************************/ int DLLEXPORT EN_createproject(EN_ProjectHandle *ph); int DLLEXPORT EN_deleteproject(EN_ProjectHandle *ph); + + int DLLEXPORT EN_runproject(EN_ProjectHandle ph, const char *inpFile, + const char *rptFile, const char *binOutFile, void (*callback) (char *)); void DLLEXPORT EN_clearError(EN_ProjectHandle ph); int DLLEXPORT EN_checkError(EN_ProjectHandle ph, char** msg_buffer); @@ -1274,7 +1268,7 @@ extern "C" { int DLLEXPORT EN_getqualinfo(EN_ProjectHandle ph, int *qualcode, char *chemname, char *chemunits, int *tracenode); int DLLEXPORT EN_setbasedemand(EN_ProjectHandle ph, int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE baseDemand); - int DLLEXPORT EN_setdemandpattern(EN_ProjectHandle ph, int nodeIndex, int demandIdx, int patIndex); + int DLLEXPORT EN_setdemandpattern(EN_ProjectHandle ph, int nodeIndex, int demandIdx, int patIndex); int DLLEXPORT EN_getcurveindex(EN_ProjectHandle ph, char *id, int *index); int DLLEXPORT EN_getcurveid(EN_ProjectHandle ph, int index, char *id); int DLLEXPORT EN_getcurvelen(EN_ProjectHandle ph, int index, int *len); From 78999ea795e3341c5f8f2f08cf2fe3a3ab683729 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Tue, 4 Sep 2018 13:13:56 -0400 Subject: [PATCH 2/3] Getting runepanet to link on 32bit --- run/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/run/CMakeLists.txt b/run/CMakeLists.txt index 4822e95..18b28aa 100644 --- a/run/CMakeLists.txt +++ b/run/CMakeLists.txt @@ -17,6 +17,7 @@ include_directories(include) source_group("CLI" FILES ${EPANET_CLI_SOURCES}) +add_definitions(-DWITH_GENX) # Creates the EPANET command line executable add_executable(runepanet ${EPANET_CLI_SOURCES}) From 30a694d62e25a91441c4df7906a8d2c70c78602b Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Tue, 4 Sep 2018 14:42:24 -0400 Subject: [PATCH 3/3] Removing NO_GENX from win_build Makefile.bat --- win_build/WinSDK/Makefile.bat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win_build/WinSDK/Makefile.bat b/win_build/WinSDK/Makefile.bat index e5188c2..91ffc95 100644 --- a/win_build/WinSDK/Makefile.bat +++ b/win_build/WinSDK/Makefile.bat @@ -21,9 +21,9 @@ Find /i "x86" < checkOS.tmp > StringCheck.tmp If %ERRORLEVEL% == 1 ( CALL "%SDK_PATH%bin\"SetEnv.cmd /x64 /release rem : create EPANET2.DLL - cl -o epanet2.dll /D NO_GENX epanet.c util\errormanager.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /link /DLL + cl -o epanet2.dll epanet.c util\errormanager.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /link /DLL rem : create EPANET2.EXE - cl -o epanet2.exe /D NO_GENX epanet.c util\errormanager.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /I ..\src /link + cl -o epanet2.exe epanet.c util\errormanager.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /I ..\src /link md "%Build_PATH%"\64bit move /y "%SRC_PATH%"\*.dll "%Build_PATH%"\64bit move /y "%SRC_PATH%"\*.exe "%Build_PATH%"\64bit @@ -35,9 +35,9 @@ rem : 32 bit with DEF CALL "%SDK_PATH%bin\"SetEnv.cmd /x86 /release echo "32 bit with epanet2.def mapping" rem : create EPANET2.DLL -cl -o epanet2.dll /D NO_GENX epanet.c util\errormanager.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /link /DLL /def:..\win_build\WinSDK\epanet2.def /MAP +cl -o epanet2.dll epanet.c util\errormanager.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /link /DLL /def:..\win_build\WinSDK\epanet2.def /MAP rem : create EPANET2.EXE -cl -o epanet2.exe /D NO_GENX epanet.c util\errormanager.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /I ..\src /link +cl -o epanet2.exe epanet.c util\errormanager.c ..\run\main.c hash.c hydraul.c hydcoeffs.c hydstatus.c hydsolver.c inpfile.c input1.c input2.c input3.c mempool.c output.c quality.c report.c rules.c smatrix.c genmmd.c /I ..\include /I ..\run /I ..\src /link md "%Build_PATH%"\32bit move /y "%SRC_PATH%"\*.dll "%Build_PATH%"\32bit move /y "%SRC_PATH%"\*.exe "%Build_PATH%"\32bit