Skip to content

Commit

Permalink
Fixup C# native paths on osx-arm64 and use a git reset --soft
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec committed May 22, 2024
1 parent e852177 commit b13ed79
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 31 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/buildCSharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,21 @@ jobs:

steps:
- uses: actions/checkout@v4
# If you need to rebuild for a specific branch **after** you fixed the workflow...
with:
ref: v3.8.0
# If you need to rebuild for a specific branch or tag **after** you fixed the workflow and you have no other changes or only a few you can download from github
# with:
# ref: v3.8.0

# - name: download patched CMakeLists.txt
# shell: bash
# run: |
# rm CMakeLists.txt
# aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/CMakeLists.txt

- name: download patched CMakeLists.txt
- name: Soft reset to v3.8.0
shell: bash
run: |
rm CMakeLists.txt
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/CMakeLists.txt
rm conan.lock
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/conan.lock
rm conanfile.py
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/conanfile.py
cd src/measure/
rm Measure.i
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/src/measure/Measure.i
cd ../utilities/core/
rm jsoncpp.i
aria2c https://raw.githubusercontent.com/NREL/OpenStudio/CSharp/src/utilities/core/jsoncpp.i
git fetch --all
git reset --soft v3.8.0,HEAD
- uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -197,30 +193,30 @@ jobs:
- name: build nuget for Windows
if: runner.os == 'Windows'
run: |
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/ -v normal
- name: build nuget for Linux
if: runner.os == 'Linux'
run: |
cp ./csharp/*.targets ./build/Products
ls ./build/Products
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/ -v normal
- name: Fix dylib and build nuget for Mac
if: runner.os == 'macOS'
run: |
sudo install_name_tool -add_rpath "@loader_path/." ./build/Products/libopenstudio_csharp.dylib
sudo install_name_tool -delete_rpath "/Users/runner/work/OpenStudio/OpenStudio/build/Products" ./build/Products/libopenstudio_csharp.dylib
sudo install_name_tool -delete_rpath "${{ github.workspace }}/build/Products" ./build/Products/libopenstudio_csharp.dylib
sudo install_name_tool -add_rpath "@loader_path/." ./build/Products/libopenstudio_model_csharp.dylib
sudo install_name_tool -delete_rpath "/Users/runner/work/OpenStudio/OpenStudio/build/Products" ./build/Products/libopenstudio_model_csharp.dylib
sudo install_name_tool -delete_rpath "${{ github.workspace }}/build/Products" ./build/Products/libopenstudio_model_csharp.dylib
sudo install_name_tool -add_rpath "@loader_path/." ./build/Products/libopenstudio_translators_csharp.dylib
sudo install_name_tool -delete_rpath "/Users/runner/work/OpenStudio/OpenStudio/build/Products" ./build/Products/libopenstudio_translators_csharp.dylib
sudo install_name_tool -delete_rpath "${{ github.workspace }}/build/Products" ./build/Products/libopenstudio_translators_csharp.dylib
cp ./csharp/*.targets ./build/Products
ls ./build/Products
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/
dotnet pack ./build/csharp_wrapper/OpenStudio.csproj -o ./build/Products/csharp/Release/ -v normal
- name: list files
Expand Down Expand Up @@ -351,7 +347,7 @@ jobs:
dotnet test OpenStudio.Tests.x86.csproj --arch x86
Test_Mac_ubuntu:
name: "Test x64 nuget packages for macos and ubuntu"
name: "Test 64-bit nuget packages for macos and ubuntu"
runs-on: ${{ matrix.os }}
strategy:
# fail-fast: Default is true, switch to false to allow one platform to fail and still run others
Expand All @@ -361,10 +357,14 @@ jobs:
include:
- name: Ubuntu
os: ubuntu-latest
arch: x64
- name: macOS
os: macos-13
arch: x64
- name: macOS_arm64
os: macos-14
arch: arm64

timeout-minutes: 20
needs: build-csharp

Expand All @@ -389,4 +389,4 @@ jobs:
dotnet add OpenStudio.Tests.csproj package OpenStudio -s "./../../../nuget"
dotnet clean OpenStudio.Tests.csproj
dotnet test OpenStudio.Tests.csproj --arch x64
dotnet test OpenStudio.Tests.csproj --arch ${{ matrix.arch }} /p:Platform="${{ matrix.arch }}"
15 changes: 15 additions & 0 deletions csharp/OpenStudio-osx-arm64.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PlatformCheck" BeforeTargets="InjectReference"
Condition="'$(Platform)' != 'arm64'">
<Error Text="$(MSBuildThisFileName) does not work correctly on '$(Platform)' platform. You need to specify platform (arm64)." />
</Target>

<Target Name="InjectReference" BeforeTargets="ResolveAssemblyReferences">
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)/../runtimes/osx-arm64/native/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Target>
</Project>
34 changes: 27 additions & 7 deletions csharp/developer/OpenStudio/OpenStudio.csproj.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>full</DebugType>
<DebugType>full</DebugType>
</PropertyGroup>

<!-- Linux:
libopenstudio_csharp.so
libopenstudio_model_csharp.so
libopenstudio_translators_csharp.so
libopenstudiolib.so
libopenstudiolib.so
-->

<!-- Mac:
libopenstudio_csharp.dylib
libopenstudio_model_csharp.dylib
libopenstudio_translators_csharp.dylib
libopenstudiolib.dylib
libopenstudiolib.dylib
-->

<!-- Windows:
Expand All @@ -58,25 +58,45 @@ openstudiolib.dll
-->

<Target Name="IncludeReferencedLibInPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences">
<Message Text="DEBUGGING: OS=$(OS) TargetFramework=$(TargetFramework) Architecture=$(Architecture) Platform=$(Platform) RID=$(Rid)" />
<Message Text="DEBUGGING: is_osx1=$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX))) is_osx2=$([MSBuild]::IsOsPlatform('OSX'))" />
<Message Text="DEBUGGING: System.Runtime.InteropServices.RuntimeInformation: OSArchitecture=$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture), RuntimeIdentifier=$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier), OSDescription=$([System.Runtime.InteropServices.RuntimeInformation]::OSDescription)" />
<PropertyGroup>
<Rid>$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</Rid>
<IsLinux>$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))</IsLinux>
<IsDarwin>$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))</IsDarwin>
<IsWindows>$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))</IsWindows>
<IsArm64>False</IsArm64>
<IsArm64 Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64' ">true</IsArm64>
</PropertyGroup>
<Message Text="DEBUGGING: Rid=$(Rid), IsLinux=$(IsLinux), IsDarwin=$(IsDarwin), IsWindows=$(IsWindows), IsArm64=$(IsArm64), IsNotArm64=$(IsNotArm64)" />
<Message Condition=" $(IsDarwin) And !$(IsArm64) " Text="Darwin not arm64" />
<Message Condition=" $(IsDarwin) And $(IsArm64) " Text="Darwin arm64" />
<!-- for Windows -->
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<ItemGroup Condition=" $(IsWindows) ">
<TfmSpecificPackageFile Include="../Products/Release/openstudio*csharp.dll" PackagePath="lib/$(TargetFramework)" />
<TfmSpecificPackageFile Include="../Products/Release/openstudiolib.dll" PackagePath="lib/$(TargetFramework)" />
</ItemGroup>

<!-- for Linux -->
<ItemGroup Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' ">
<ItemGroup Condition=" $(IsLinux) ">
<TfmSpecificPackageFile Include="../Products/*openstudio*csharp.so" PackagePath="runtimes/linux-x64/native" />
<TfmSpecificPackageFile Include="../Products/*openstudiolib.so" PackagePath="runtimes/linux-x64/native" />
<TfmSpecificPackageFile Include="../Products/OpenStudio-linux-x64.targets" PackagePath="build/OpenStudio.targets" />
</ItemGroup>

<!-- for Mac -->
<ItemGroup Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' ">
<ItemGroup Condition=" $(IsDarwin) And !$(IsArm64) ">
<TfmSpecificPackageFile Include="../Products/*openstudio*csharp.dylib" PackagePath="runtimes/osx-x64/native" />
<TfmSpecificPackageFile Include="../Products/*openstudiolib.dylib" PackagePath="runtimes/osx-x64/native" />
<TfmSpecificPackageFile Include="../Products/OpenStudio-osx-x64.targets" PackagePath="build/OpenStudio.targets" />
</ItemGroup>
<ItemGroup Condition=" $(IsDarwin) And $(IsArm64) ">
<TfmSpecificPackageFile Include="../Products/*openstudio*csharp.dylib" PackagePath="runtimes/$(Rid)/native" />
<TfmSpecificPackageFile Include="../Products/*openstudiolib.dylib" PackagePath="runtimes/$(Rid)/native" />
<TfmSpecificPackageFile Include="../Products/OpenStudio-$(Rid).targets" PackagePath="build/OpenStudio.targets" />
</ItemGroup>

</Target>

</Project>

0 comments on commit b13ed79

Please sign in to comment.