Skip to content

Commit

Permalink
fix(CSharp): build CSharpSDK for Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
MingboPeng committed May 7, 2022
1 parent 2731258 commit dc03abd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/buildCSharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ developer/msvc/Visualizers/all_concat.natvis
.clangd/
cppcheck.txt*
clang_format.patch

.DS_Store
15 changes: 10 additions & 5 deletions csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ 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 `<TargetFrameworks>` 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 `<TargetFrameworks>` 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)

# custom command to make OPENSTUDIO_CSHARP_DLL
add_custom_command(
OUTPUT ${OPENSTUDIO_CSHARP_DLL}
COMMAND "${DOTNET}" "build" "-c" "$<CONFIGURATION>" "-f" "netcoreapp3.0" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj"
COMMAND "${DOTNET}" "build" "-c" "$<CONFIGURATION>" "-f" "netstandard2.0" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj"
DEPENDS ${ALL_CSHARP_WRAPPER_TARGETS} ${ALL_CSHARP_WRAPPER_FILES}
)

Expand Down Expand Up @@ -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")
Expand All @@ -287,7 +292,7 @@ if( BUILD_NUGET_PACKAGE )
#dotnet pack OpenStudio.csproj --configuration $<CONFIG> -p:NuspecFile="${PROJECT_BINARY_DIR}/OpenStudio.nuspec" -p:NuspectProperties="Configuration=$<CONFIG>"
# dotnet pack <path to .csproj file> -p:NuspecFile=<path to nuspec file> -p:NuspecProperties=<> -p:NuspecBasePath=<Base path>
add_custom_target(nuget_package
COMMAND ${DOTNET} pack --configuration $<CONFIG> -p:TargetFrameworks=netcoreapp3.0 -p:Configuration=$<CONFIG> -p:NuspecProperties="Configuration=$<CONFIG>" ${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj
COMMAND ${DOTNET} pack --configuration $<CONFIG> -p:TargetFrameworks=netstandard2.0 -p:Configuration=$<CONFIG> -p:NuspecProperties="Configuration=$<CONFIG>" ${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj
DEPENDS csharp_sdk
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/csharp_wrapper/"
)
Expand Down

0 comments on commit dc03abd

Please sign in to comment.