From dc03abd8efb46b19588ce84500cfdba63eeb0713 Mon Sep 17 00:00:00 2001 From: Mingbo Peng Date: Tue, 30 Mar 2021 00:43:14 -0400 Subject: [PATCH] fix(CSharp): build CSharpSDK for Mac --- .github/workflows/buildCSharp.yml | 29 ++++++++++++++++++++++------- .gitignore | 2 ++ csharp/CMakeLists.txt | 15 ++++++++++----- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/.github/workflows/buildCSharp.yml b/.github/workflows/buildCSharp.yml index 6c0c04fdd73..824377b5eda 100644 --- a/.github/workflows/buildCSharp.yml +++ b/.github/workflows/buildCSharp.yml @@ -117,19 +117,16 @@ jobs: - name: Compile shell: bash - env: - CC: clang - CMAKE_OSX_ARCHITECTURES: x86_64 run: | + export CC=clang + export CMAKE_OSX_ARCHITECTURES=x86_64 mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_CSHARP_BINDINGS=ON -DBUILD_NUGET_PACKAGE=ON \ - -DBUILD_TESTING=ON \ - -DBUILD_PACKAGE=ON -DCPACK_BINARY_DEB=ON -DCPACK_BINARY_TGZ=ON \ + -DBUILD_CSHARP_BINDINGS=ON -DBUILD_NUGET_PACKAGE=OFF \ + -DBUILD_PACKAGE=OFF -DCPACK_BINARY_DEB=OFF -DCPACK_BINARY_TGZ=OFF \ -DCPACK_BINARY_IFW=OFF -DCPACK_BINARY_NSIS=OFF -DCPACK_BINARY_RPM=OFF -DCPACK_BINARY_STGZ=OFF \ -DCPACK_BINARY_TBZ2=OFF -DCPACK_BINARY_TXZ=OFF -DCPACK_BINARY_TZ=OFF ../ - make -j2 - name: list files @@ -143,5 +140,23 @@ jobs: echo "Listing ./build/Products/==========================================" ls -R ./build/Products + - name: Zip Build Artifact + run: | + mkdir ./build/zip + cp ./build/Products/*.dylib ./build/zip + mv ./build/Products/csharp/Release/ ./build/zip + sudo zip -r OpenStudio_CSharpSDK.zip ./build/zip + sudo zip -r OpenStduio_CSharp_Source.zip ./csharp/csharp_wrapper + + - name: Upload artifact + uses: actions/upload-artifact@v1 + with: + name: OpenStudio_CSharpSDK + path: OpenStudio_CSharpSDK.zip + - name: Upload artifact + uses: actions/upload-artifact@v1 + with: + name: OpenStduio_CSharp_Source + path: OpenStduio_CSharp_Source.zip \ No newline at end of file diff --git a/.gitignore b/.gitignore index 23f03d3d558..0a6da235ad1 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ developer/msvc/Visualizers/all_concat.natvis .clangd/ cppcheck.txt* clang_format.patch + +.DS_Store diff --git a/csharp/CMakeLists.txt b/csharp/CMakeLists.txt index c602a63b5f9..218bfa1dd90 100644 --- a/csharp/CMakeLists.txt +++ b/csharp/CMakeLists.txt @@ -88,8 +88,8 @@ else() # TODO: there are probably adjustments to make to OpenStudio.csproj_dotnet.in # The Release/Debug can be stripped probably - # Also probably don't need to use multiple `` which is the reason there's an extra netcoreapp3.0/ level - set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/netcoreapp3.0/OpenStudio.dll") + # Also probably don't need to use multiple `` which is the reason there's an extra netstandard2.0/ level + set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/netstandard2.0/OpenStudio.dll") # ignore deprecated warnings since we will export deprecated methods add_definitions(-Wno-deprecated-declarations) @@ -97,7 +97,7 @@ else() # custom command to make OPENSTUDIO_CSHARP_DLL add_custom_command( OUTPUT ${OPENSTUDIO_CSHARP_DLL} - COMMAND "${DOTNET}" "build" "-c" "$" "-f" "netcoreapp3.0" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj" + COMMAND "${DOTNET}" "build" "-c" "$" "-f" "netstandard2.0" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj" DEPENDS ${ALL_CSHARP_WRAPPER_TARGETS} ${ALL_CSHARP_WRAPPER_FILES} ) @@ -274,9 +274,14 @@ if( BUILD_NUGET_PACKAGE ) DEPENDS csharp_sdk WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" ) + elseif(APPLE) + set(OPENSTUDIO_CSHARP_DLLNAME "Products/csharp/$CONFIGURATION$/netstandard2.0/OpenStudio.dll") + set(OPENSTUDIO_CSHARP_LIBNAME "Products/libopenstudio_csharp.dylib") + set(OPENSTUDIO_MODEL_CSHARP_LIBNAME "Products/libopenstudio_model_csharp.dylib") + set(OPENSTUDIO_TRANSLATORS_CSHARP_LIBNAME "Products/libopenstudio_translators_csharp.dylib") else() - set(OPENSTUDIO_CSHARP_DLLNAME "Products/csharp/$CONFIGURATION$/netcoreapp3.0/OpenStudio.dll") + set(OPENSTUDIO_CSHARP_DLLNAME "Products/csharp/$CONFIGURATION$/netstandard2.0/OpenStudio.dll") set(OPENSTUDIO_CSHARP_LIBNAME "Products/libopenstudio_csharp.so") set(OPENSTUDIO_MODEL_CSHARP_LIBNAME "Products/libopenstudio_model_csharp.so") set(OPENSTUDIO_TRANSLATORS_CSHARP_LIBNAME "Products/libopenstudio_translators_csharp.so") @@ -287,7 +292,7 @@ if( BUILD_NUGET_PACKAGE ) #dotnet pack OpenStudio.csproj --configuration $ -p:NuspecFile="${PROJECT_BINARY_DIR}/OpenStudio.nuspec" -p:NuspectProperties="Configuration=$" # dotnet pack -p:NuspecFile= -p:NuspecProperties=<> -p:NuspecBasePath= add_custom_target(nuget_package - COMMAND ${DOTNET} pack --configuration $ -p:TargetFrameworks=netcoreapp3.0 -p:Configuration=$ -p:NuspecProperties="Configuration=$" ${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj + COMMAND ${DOTNET} pack --configuration $ -p:TargetFrameworks=netstandard2.0 -p:Configuration=$ -p:NuspecProperties="Configuration=$" ${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj DEPENDS csharp_sdk WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/csharp_wrapper/" )