-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #4931 - Install C# OpenStudio.dll properly. #4933
Conversation
@@ -60,14 +61,11 @@ target_compile_options(csharp_warnings INTERFACE "$<${is_gnu_or_clang_genex}:-Wn | |||
# custom command to make OPENSTUDIO_CSHARP_DLL | |||
add_custom_command( | |||
OUTPUT ${OPENSTUDIO_CSHARP_DLL} | |||
COMMAND "${DOTNET}" "build" "-c" "$<CONFIGURATION>" "/p:Platform=${CSHARP_PLATFORM}" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj" | |||
COMMAND "${DOTNET}" "build" "-c" "$<CONFIG>" "/p:Platform=${CSHARP_PLATFORM}" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONFIGURATION genex is deprecated since cmake 3.0 and replaced with CONFIG
install(FILES "${OPENSTUDIO_CSHARP_DLL}" DESTINATION CSharp/openstudio/ CONFIGURATIONS DEBUG COMPONENT "CSharpAPI") | ||
|
||
|
||
install(FILES "${OPENSTUDIO_CSHARP_DLL}" DESTINATION CSharp/openstudio/ COMPONENT "CSharpAPI") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Install it regardless of the configuration. It was done only for DEBUG prior
csharp/CMakeLists.txt
Outdated
# Note: can't use CMAKE_BUILD_TYPE as it's empty for multi generators (MSVC for eg). So we use a genex | ||
set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/$<CONFIG>/netstandard2.0/OpenStudio.dll") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced the CMAKE_BUILD_TYPE with a genex too. This was working on CI because we do pass explicitly cmake -DCMAKE_BUILD_TYPE:STRING=Release
when building on MSVC. But MSVC by default is Multi-configuration and CMAKE_BUILD_TYPE is empty if used like this.
CONFIGURATION genex is deprecated since cmake 3.0 and replaced with CONFIG
2ba6376
to
5e33131
Compare
if (BUILD_CSHARP_BINDINGS) | ||
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "CSharp/openstudio/" COMPONENT "CSharpAPI") | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't install the runtimes libs there if C# isn't selected to begin with.
This threw me off when I was looking at the CI-built packages, because actually the incremental runner does not build C#!
# The -py3 flag is now deprecated as Python 3 is the default the version used is Python 3 | ||
set(SWIG_PYTHON_3_FLAGS "-relativeimport") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated cleanup: Avoid having multiple warnings from swig saying "-py3 flag is deprecated"
@@ -66,7 +66,7 @@ | |||
// and nested classes and "nothing known about <type>" | |||
// also ignoring #509, shadowed method. Its a red herring for all of our cases | |||
//#pragma SWIG nowarn=401,362,365,366,368,378,503,801,312 | |||
#pragma SWIG nowarn=362,365,366,368,378,503,801,312,509,401 | |||
#pragma SWIG nowarn=362,365,366,368,378,503,801,312,509,401,516 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid thousands of "overloaded method ignore, using XXX instead". In particular for every modelObject, the Ctor is overloaded (rule of 5/6) so it was getting out of control.
@@ -9,7 +9,7 @@ set(Python_USE_STATIC_LIBS OFF) | |||
if (PYTHON_VERSION) | |||
find_package(Python ${PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development OPTIONAL_COMPONENTS NumPy) | |||
else() | |||
find_package(Python REQUIRED COMPONENTS Interpreter Development OPTIONAL_COMPONENTS NumPy) | |||
find_package(Python 3 EXACT REQUIRED COMPONENTS Interpreter Development OPTIONAL_COMPONENTS NumPy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force finding python3, not python2, related to SWIG using py3 now. Python 2 is EOL since 2020 anyways, we do not want to support it.
@@ -511,7 +499,7 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S | |||
# This is not working: "cannot open file 'python37.lib'" | |||
target_link_libraries(${swig_target} PUBLIC ${${PARENT_TARGET}_depends}) | |||
if (MSVC) | |||
message("Python_LIBRARIES=${Python_LIBRARIES}") | |||
message(DEBUG "Python_LIBRARIES=${Python_LIBRARIES}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shush this message too
// ignores toJSON/fromJSON globally | ||
%rename("$ignore", regextarget=1, fullname=1) "openstudio::.*::toJSON$"; | ||
%rename("$ignore", regextarget=1, fullname=1) "openstudio::.*::fromJSON$"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If SWIGCSHARP, ignore toJSON and fromJSON globally.
// Ignore Json::Value return type (toJSON / fromJSON are globally ignored already) | ||
%ignore openstudio::StandardsJSON::getPrimaryKey; | ||
|
||
%ignore openstudio::CustomOutputAdapter::CustomOutputAdapter; | ||
%ignore openstudio::CustomOutputAdapter::optionsJSON; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore other Json::Value related things in Filetypes.i when C#
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will unbrick the develop build (@wenyikuang FYI), which fails due to this problem currently, after the merge of #4917 (which we didn't realize it was going to break the build because the CI incremental windows runner does not build c# bindings...), cf https://ci.openstudio.net/blue/organizations/jenkins/openstudio-develop-full/detail/openstudio-develop-full/360/pipeline/98#step-101-log-921
D:\OSN\build\csharp_wrapper\generated_sources\OpenStudioUtilitiesData\SWIGTYPE_p_Json__Value.cs(13,14):
error CS0101: The namespace 'OpenStudio' already contains a definition for 'SWIGTYPE_p_Json__Value' [D:\OSN\build\csharp_wrapper\OpenStudio.csproj]
D:\OSN\build\csharp_wrapper\generated_sources\OpenStudioUtilitiesFileTypes\SWIGTYPE_p_Json__Value.cs(13,14):
error CS0101: The namespace 'OpenStudio' already contains a definition for 'SWIGTYPE_p_Json__Value' [D:\OSN\build\csharp_wrapper\OpenStudio.csproj]
D:\OSN\build\csharp_wrapper\generated_sources\OpenStudioUtilitiesData\SWIGTYPE_p_Json__Value.cs(16,12): error CS0111: Type 'SWIGTYPE_p_Json__Value' already defines a member called 'SWIGTYPE_p_Json__Value' with the same parameter types [D:\OSN\build\csharp_wrapper\OpenStudio.csproj]
D:\OSN\build\csharp_wrapper\generated_sources\OpenStudioUtilitiesData\SWIGTYPE_p_Json__Value.cs(20,13): error CS0111: Type 'SWIGTYPE_p_Json__Value' already defines a member called 'SWIGTYPE_p_Json__Value' with the same parameter types [D:\OSN\build\csharp_wrapper\OpenStudio.csproj]
D:\OSN\build\csharp_wrapper\generated_sources\OpenStudioUtilitiesFileTypes\SWIGTYPE_p_Json__Value.cs(16,12): error CS0111: Type 'SWIGTYPE_p_Json__Value' already defines a member called 'SWIGTYPE_p_Json__Value' with the same parameter types [D:\OSN\build\csharp_wrapper\OpenStudio.csproj]
Running a full build on this branch at https://ci.openstudio.net/blue/organizations/jenkins/openstudio-develop-full/detail/openstudio-develop-full/363/pipeline/11 Meh that failed due to a mt python error (concurrency?), replaying on the windows build at 364. I Tested the changes locally on Windows 10 + macOS m1 too. C# build now works, and I do get the installed OpenStudio.dll |
CI Results for 709fec9:
|
Ok 364 replay worked on windows as well: https://ci.openstudio.net/blue/organizations/jenkins/openstudio-develop-full/detail/openstudio-develop-full/364/pipeline/ Testing the windows installer to see if the OpenStudio.dll is in there OpenStudio-3.7.0-alpha+709fec93d1-Windows$ find . -name "*.dll"
./CSharp/openstudio/openstudio_model_csharp.dll
./CSharp/openstudio/vcruntime140_1.dll
./CSharp/openstudio/msvcp140_1.dll
./CSharp/openstudio/vcruntime140.dll
./CSharp/openstudio/concrt140.dll
./CSharp/openstudio/openstudio_csharp.dll
./CSharp/openstudio/msvcp140_2.dll
./CSharp/openstudio/openstudio_translators_csharp.dll
./CSharp/openstudio/msvcp140.dll
./CSharp/openstudio/msvcp140_atomic_wait.dll
+./CSharp/openstudio/OpenStudio.dll
./CSharp/openstudio/msvcp140_codecvt_ids.dll |
Merging right away, tested it works, and this is going to fix develop nightly builds which is important! |
Pull request overview
Let's see if CI makes an installer with the OpenStudio.dll
Pull Request Author
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.