Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ on:
paths:
- 'Rhino.Templates/**'
- 'build/GenerateTemplates.proj'
- 'build/RhinoSdkCpp/**'
- 'build/WriteTemplateSummary.ps1'
- '.github/workflows/templates.yml'
pull_request:
branches: [ main ]
paths:
- 'Rhino.Templates/**'
- 'build/GenerateTemplates.proj'
- 'build/RhinoSdkCpp/**'
- 'build/WriteTemplateSummary.ps1'
- '.github/workflows/templates.yml'
workflow_dispatch:
Expand Down
9 changes: 8 additions & 1 deletion Rhino.Templates/content/CPPRhino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ endif()

add_library(${PLUGIN_TARGET} MODULE ${SOURCES})
set_target_properties(${PLUGIN_TARGET} PROPERTIES OUTPUT_NAME "${PLUGIN_NAME}")
target_include_directories(${PLUGIN_TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${RHINO_SDK}/inc")
target_include_directories(${PLUGIN_TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
if(APPLE)
# The SDK headers warn about their own include casing and deprecations; the Xcode
# project silences these with the SDK's xcconfig, here they're system headers instead.
target_include_directories(${PLUGIN_TARGET} SYSTEM PRIVATE "${RHINO_SDK}/inc")
else()
target_include_directories(${PLUGIN_TARGET} PRIVATE "${RHINO_SDK}/inc")
endif()

if(WIN32)
# Rhino plug-ins always link the release CRT and MFC, even when built with
Expand Down
8 changes: 4 additions & 4 deletions Rhino.Templates/content/CPPRhino/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#if defined(__APPLE__)

// Rhino SDK for macOS; the Windows headers below are MFC-only.
#include "SDK/inc/rhinoSdkStdafxPreamble.h"
#include "SDK/inc/rhinoSdk.h"
#include "SDK/inc/RhRdkHeaders.h"
#include "SDK/inc/rhinoSdkChecks.h"
#include "rhinoSdkStdafxPreamble.h"
#include "rhinoSdk.h"
#include "RhRdkHeaders.h"
#include "rhinoSdkChecks.h"

// Windows definitions the template code uses, which the Mac SDK does not declare.
#ifndef MB_OK
Expand Down
1 change: 1 addition & 0 deletions Rhino.Templates/content/CSRhinoTest/MyRhino.1Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<PackageReference Include="Rhino.Testing" Version="9.0.8-beta" />

<PackageReference Include="RhinoCommon" Version="9.0.26279.6303-beta" ExcludeAssets="runtime" />
<PackageReference Include="Grasshopper" Version="9.0.26279.6303-beta" ExcludeAssets="runtime" />
<!--#else-->
<PackageReference Include="Rhino.Testing" Version="8.0.23-beta" />

Expand Down
25 changes: 19 additions & 6 deletions build/GenerateTemplates.proj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

<!-- Rhino C++ SDK linked into the Xcode and CMake C++ projects as their SDK submodule -->
<RhinoSdkCppDir Condition="$(RhinoSdkCppDir) == ''">$([System.IO.Path]::Combine($([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', 'artifacts')), 'rhino_sdk_cpp'))</RhinoSdkCppDir>
<!-- Builds a .vcxproj against that checkout instead of the installed SDK; there's no Rhino 8 checkout, so Rhino 9 only -->
<RhinoSdkCppOptions>&quot;/p:RhinoSdkPath=$(MSBuildThisFileDirectory)RhinoSdkCpp/&quot; &quot;/p:RhinoSdkCppDir=$(RhinoSdkCppDir)&quot;</RhinoSdkCppOptions>

<!-- <BuildOptions Condition="$([MSBuild]::IsOSPlatform(windows))">$(BuildOptions) /p:YakExecutable=&quot;C:\Program Files\Rhino 8\System\yak.exe&quot;</BuildOptions> -->
<!-- <BuildOptions Condition="$([MSBuild]::IsOSPlatform(osx))">$(BuildOptions) /p:YakExecutable=&quot;/Applications/Rhino 8.app/Contents/Resources/bin/yak&quot;</BuildOptions> -->
Expand Down Expand Up @@ -47,9 +49,14 @@
ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="VSMSBuild2022" />
</Exec>
<Exec Command="&quot;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe&quot; -version &quot;[18,19)&quot; -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe"
ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="VSMSBuild2026" />
</Exec>
<PropertyGroup>
<VSMSBuild2019>&quot;$(VSMSBuild2019)&quot;</VSMSBuild2019>
<VSMSBuild2022>&quot;$(VSMSBuild2022)&quot;</VSMSBuild2022>
<VSMSBuild2026>&quot;$(VSMSBuild2026)&quot;</VSMSBuild2026>
</PropertyGroup>
</Target>

Expand Down Expand Up @@ -79,7 +86,7 @@
<TemplateGroup Include="TestingTemplates;CppSkinTemplates;CppRhinoTemplates;Grasshopper2Templates;GrasshopperTemplates;RhinoCommonTemplates;ZooTemplates" AdditionalProperties="TemplateGroup=%(Identity)" />
</ItemGroup>

<Target Name="GenerateTemplates" DependsOnTargets="CleanTemplates;CreateDirectoryProps">
<Target Name="GenerateTemplates" DependsOnTargets="CleanTemplates;CreateDirectoryProps;GetRhinoSdkCpp">
<MSBuild Projects="@(TemplateGroup->'$(MSBuildThisFileFullPath)')" Targets="GenerateTemplateGroup" BuildInParallel="true" />
</Target>

Expand Down Expand Up @@ -129,22 +136,26 @@
<CppOptions Update="@(CppOptions)" OutputDir="CppRhino%(VersionId)/%(TypeId).%(FeaturesId)%(PathSuffix)%(BuildSystemSuffix)/" />

<!-- Commands to build each kind of project, run from its folder -->
<CppOptions Update="@(CppOptions)" BuildSteps="$(VSMSBuild2022) /p:Platform=x64 $(LogOptions)" Condition="'%(BuildSystemId)' == 'Native' and $([MSBuild]::IsOSPlatform(Windows)) and $(RhinoInstalled) == 'true'" />
<CppOptions Update="@(CppOptions)" BuildSteps="$(VSMSBuild2022) /p:Platform=x64 $(LogOptions)" Condition="'%(BuildSystemId)' == 'Native' and $([MSBuild]::IsOSPlatform(Windows)) and '%(VersionId)' == '8' and $(RhinoInstalled) == 'true'" />
<CppOptions Update="@(CppOptions)" BuildSteps="$(VSMSBuild2026) /p:Platform=x64 $(LogOptions)" Condition="'%(BuildSystemId)' == 'Native' and $([MSBuild]::IsOSPlatform(Windows)) and '%(VersionId)' == '9' and $(RhinoInstalled) == 'true'" />
<CppOptions Update="@(CppOptions)" BuildSteps="$(VSMSBuild2026) /p:Platform=x64 $(LogOptions) $(RhinoSdkCppOptions)" Condition="'%(BuildSystemId)' == 'Native' and $([MSBuild]::IsOSPlatform(Windows)) and '%(VersionId)' == '9' and $(RhinoInstalled) != 'true'" />
<CppOptions Update="@(CppOptions)" BuildSteps="ln -s &quot;$(RhinoSdkCppDir)&quot; SDK &amp;&amp; xcodebuild -configuration Debug -quiet build" Condition="'%(BuildSystemId)' == 'Native' and '%(MacSupported)' == 'true' and !$([MSBuild]::IsOSPlatform(Windows))" />
<CppOptions Update="@(CppOptions)" BuildSteps="mklink /J SDK &quot;$(RhinoSdkCppDir)&quot; &amp;&amp; cmake -A x64 -S . -B build &amp;&amp; cmake --build build --config Debug" Condition="'%(BuildSystemId)' == 'CMake' and $([MSBuild]::IsOSPlatform(Windows))" />
<CppOptions Update="@(CppOptions)" BuildSteps="mklink /J SDK &quot;$(RhinoSdkCppDir)&quot; &amp;&amp; cmake -A x64 -S . -B build &amp;&amp; cmake --build build --config Debug -- &quot;-flp1:warningsonly;logfile=$(TemplateDir)%(OutputDir)build.warnings.log&quot; &quot;-flp2:errorsonly;logfile=$(TemplateDir)%(OutputDir)build.errors.log&quot;" Condition="'%(BuildSystemId)' == 'CMake' and $([MSBuild]::IsOSPlatform(Windows))" />
<CppOptions Update="@(CppOptions)" BuildSteps="ln -s &quot;$(RhinoSdkCppDir)&quot; SDK &amp;&amp; cmake -G Xcode -S . -B build &amp;&amp; cmake --build build --config Debug -- -quiet" Condition="'%(BuildSystemId)' == 'CMake' and !$([MSBuild]::IsOSPlatform(Windows))" />

<!-- Commands to generate then build -->
<CppOptions Update="@(CppOptions)" Command="dotnet new rhino -lang cpp %(Type) %(Version) %(Features) %(CustomName) %(BuildSystem) -o &quot;$(TemplateDir)%(OutputDir)&quot;" />
<CppOptions Update="@(CppOptions)" Command="%(Command) &amp;&amp; cd &quot;$(TemplateDir)%(OutputDir)&quot; &amp;&amp; %(BuildSteps)" Condition="$(BuildAllProjects) == 'true' and '%(BuildSteps)' != ''" />
<!-- Write the same logs as MSBuild for WriteTemplateSummary.ps1, including failures before MSBuild runs (e.g. CMake configure) -->
<CppOptions Update="@(CppOptions)" Command="%(Command) &amp;&amp; cd &quot;$(TemplateDir)%(OutputDir)&quot; &amp;&amp; (%(BuildSteps)) || ((if not exist build.errors.log echo error : Build failed&gt;build.errors.log) &amp; exit /b 1)" Condition="$(BuildAllProjects) == 'true' and '%(BuildSteps)' != '' and $([MSBuild]::IsOSPlatform(Windows))" />
<CppOptions Update="@(CppOptions)" Command="%(Command) &amp;&amp; cd &quot;$(TemplateDir)%(OutputDir)&quot; &amp;&amp; (set -o pipefail; (%(BuildSteps)) 2&gt;&amp;1 | tee build.log; status=$?; grep -E ': (fatal )?error:' build.log &gt; build.errors.log; grep ': warning:' build.log &gt; build.warnings.log; [ $status -eq 0 ] || [ -s build.errors.log ] || echo 'error : Build failed' &gt; build.errors.log; exit $status)" Condition="$(BuildAllProjects) == 'true' and '%(BuildSteps)' != '' and !$([MSBuild]::IsOSPlatform(Windows))" />

</ItemGroup>

<Exec Command="%(CppOptions.Command)" ContinueOnError="ErrorAndContinue" />

</Target>

<Target Name="CppSkinTemplates" DependsOnTargets="GetVSMSBuild">
<Target Name="CppSkinTemplates" DependsOnTargets="GetVSMSBuild;GetRhinoSdkCpp">
<!-- generate Rhino C++ skin templates -->
<ItemGroup>
<!-- Test all the different options -->
Expand All @@ -161,7 +172,9 @@

<!-- Commands to generate then build -->
<CppSkinOptions Update="@(CppSkinOptions)" GenerateCommand="dotnet new rhinoskin %(Version) %(Features) -o &quot;$(TemplateDir)%(OutputDir)&quot;" />
<CppSkinOptions Update="@(CppSkinOptions)" BuildCommand="&amp;&amp; cd &quot;$(TemplateDir)%(OutputDir)&quot; &amp;&amp; $(VSMSBuild2022) /p:Platform=x64 $(LogOptions)" Condition="$(BuildAllProjects) == 'true' and $(RhinoInstalled) == 'true'" />
<CppSkinOptions Update="@(CppSkinOptions)" BuildCommand="&amp;&amp; cd &quot;$(TemplateDir)%(OutputDir)&quot; &amp;&amp; $(VSMSBuild2022) /p:Platform=x64 $(LogOptions)" Condition="$(BuildAllProjects) == 'true' and '%(VersionId)' == '8' and $(RhinoInstalled) == 'true'" />
<CppSkinOptions Update="@(CppSkinOptions)" BuildCommand="&amp;&amp; cd &quot;$(TemplateDir)%(OutputDir)&quot; &amp;&amp; $(VSMSBuild2026) /p:Platform=x64 $(LogOptions)" Condition="$(BuildAllProjects) == 'true' and '%(VersionId)' == '9' and $(RhinoInstalled) == 'true'" />
<CppSkinOptions Update="@(CppSkinOptions)" BuildCommand="&amp;&amp; cd &quot;$(TemplateDir)%(OutputDir)&quot; &amp;&amp; $(VSMSBuild2026) /p:Platform=x64 $(LogOptions) $(RhinoSdkCppOptions)" Condition="$(BuildAllProjects) == 'true' and '%(VersionId)' == '9' and $(RhinoInstalled) != 'true'" />
<!-- <CppSkinOptions Update="@(CppSkinOptions)" BuildCommand="&amp;&amp; cd &quot;$(TemplateDir)%(OutputDir)&quot; &amp;&amp; $(VSMSBuild2019) /p:Platform=x64" Condition="%(VersionId) == '7' and $(BuildAllProjects) == 'true'" /> -->
<CppSkinOptions Update="@(CppSkinOptions)" Command="%(CppSkinOptions.GenerateCommand)" />
<CppSkinOptions Update="@(CppSkinOptions)" Command="%(CppSkinOptions.Command) %(CppSkinOptions.BuildCommand)" Condition="$([MSBuild]::IsOSPlatform(Windows))" />
Expand Down
23 changes: 23 additions & 0 deletions build/RhinoSdkCpp/PropertySheets/Rhino.Cpp.Common.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Stands in for the installed Rhino C++ SDK's property sheets so .vcxproj templates can build
against a rhino_sdk_cpp checkout. Use with /p:RhinoSdkPath=<this folder's parent>\ /p:RhinoSdkCppDir=<checkout>
-->
<PropertyGroup>
<RhinoSdkDir>$([MSBuild]::EnsureTrailingSlash($(RhinoSdkCppDir)))</RhinoSdkDir>
<RhinoIncDir>$(RhinoSdkDir)inc</RhinoIncDir>
<RhinoLibDir>$(RhinoSdkDir)lib</RhinoLibDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(RhinoIncDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>RHINO_LIB_DIR="$(RhinoLibDir.Replace('\','/'))";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<!-- Plug-ins link the release libs in every configuration -->
<PreprocessorDefinitions Condition="'$(Configuration)' == 'Debug'">RHINO_DEBUG_PLUGIN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalOptions Condition="'$(Configuration)' == 'Release'">/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(RhinoIncDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
</Project>
6 changes: 6 additions & 0 deletions build/RhinoSdkCpp/PropertySheets/Rhino.Cpp.PlugIn.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Rhino.Cpp.Common.props" />
<PropertyGroup>
<TargetExt>.rhp</TargetExt>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Rhino.Cpp.Common.props" />
</Project>
10 changes: 7 additions & 3 deletions build/WriteTemplateSummary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ function Get-Diagnostics([string]$logPath) {
}

$root = (Resolve-Path $TemplateDir).Path
$projects = Get-ChildItem $root -Recurse -File -Include *.csproj, *.vbproj, *.vcxproj |
Where-Object { $_.FullName -notmatch '[\\/](bin|obj)[\\/]' } |
# C++ folders hold a .vcxproj, .xcodeproj and/or CMakeLists.txt; count each folder once.
# build and SDK hold CMake/Xcode output and the linked Rhino C++ SDK, which has its own samples.
$projects = Get-ChildItem $root -Recurse -Include *.csproj, *.vbproj, *.vcxproj, *.xcodeproj, CMakeLists.txt |
Where-Object { [IO.Path]::GetRelativePath($root, $_.FullName) -notmatch '(^|[\\/])(bin|obj|build|SDK)[\\/]|\.xcodeproj[\\/]' } |
ForEach-Object { [IO.Path]::GetDirectoryName($_.FullName) } |
Sort-Object -Unique |
ForEach-Object {
$dir = $_.Directory.FullName
$dir = $_
$errorLog = Join-Path $dir 'build.errors.log'
$warnings = @(Get-Diagnostics (Join-Path $dir 'build.warnings.log'))
$errors = @(Get-Diagnostics $errorLog)
Expand Down
Loading