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
1 change: 0 additions & 1 deletion src/CodegenTests/CodegenTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@

<Import Project="$(MSBuildProjectDirectory)\..\Rcl.NET\build\Rcl.NET.targets" />
<Import Project="$(MSBuildProjectDirectory)\..\Rcl.NET\build\Rcl.NET.props" />
<Import Project="$(MSBuildProjectDirectory)\..\Rcl.NET\build\ros2cs.targets" />
</Project>
8 changes: 4 additions & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<Copyright>Copyright (c) 2022-2025, noelex@outlook.jp</Copyright>
<PackageTags>ros, ros2, rcl, rosidl, ros2cs, rclnet</PackageTags>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(ProjectDir)..\SigningKey.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\SigningKey.snk</AssemblyOriginatorKeyFile>
<PublicSign>True</PublicSign>
</PropertyGroup>
<ItemGroup >
<None Include="$(ProjectDir)..\..\README.md" Pack="True" PackagePath="\" Visible="False" />
<None Include="$(ProjectDir)..\..\LICENSE" Pack="True" PackagePath="\" Visible="False" />
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\README.md" Pack="True" PackagePath="\" Visible="False" />
<None Include="$(MSBuildThisFileDirectory)..\LICENSE" Pack="True" PackagePath="\" Visible="False" />
</ItemGroup>
</Project>
28 changes: 28 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<GetRos2csPropsDependsOn>
$(GetRos2csPropsDependsOn);Get_ros2cs
</GetRos2csPropsDependsOn>
</PropertyGroup>

<Target Name="Get_ros2cs">
<MSBuild Projects="$(MSBuildThisFileDirectory)\ros2cs\ros2cs.csproj"
Targets="Restore"
RemoveProperties="TargetFramework"
/>

<MSBuild Projects="$(MSBuildThisFileDirectory)\ros2cs\ros2cs.csproj"
Targets="Publish"
Properties="Configuration=$(Configuration);TargetFramework=$(Ros2csBundleTfm);Version=$(Version)"
/>

<PropertyGroup>
<Ros2csDir>$(MSBuildThisFileDirectory)\ros2cs\bin\$(Configuration)\$(Ros2csBundleTfm)\publish</Ros2csDir>
<Ros2csExe>&quot;$(Ros2csDir)\ros2cs.dll&quot;</Ros2csExe>
</PropertyGroup>

<Message Text="[$(MSBuildProjectName), Source Build] Using ros2cs from $(Ros2csExe)"/>
</Target>

</Project>
10 changes: 6 additions & 4 deletions src/Rcl.NET.Tests/Rcl.NET.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -28,11 +28,13 @@
<ProjectReference Include="..\Rcl.NET\Rcl.NET.csproj" />
</ItemGroup>

<Import Project="..\Rcl.NET\build\Rcl.NET.props"/>
<Import Project="..\Rcl.NET\build\Rcl.NET.targets"/>

<!-- ../Directory.Build.props & .targets are also imported to gather the source ros2cs -->

<ItemGroup>
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<Import Project="$(MSBuildProjectDirectory)\..\Rcl.NET\build\Rcl.NET.targets" />
<Import Project="$(MSBuildProjectDirectory)\..\Rcl.NET\build\Rcl.NET.props" />
<Import Project="$(MSBuildProjectDirectory)\..\Rcl.NET\build\ros2cs.targets" />
</Project>
45 changes: 21 additions & 24 deletions src/Rcl.NET/Rcl.NET.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -43,29 +43,26 @@
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="7.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Rosidl.Runtime\Rosidl.Runtime.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Rosidl.Runtime\Rosidl.Runtime.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="build\Rcl.NET.props" Pack="True" PackagePath="build" Visible="False" />
<None Include="build\Rcl.NET.targets" Pack="True" PackagePath="build" Visible="False" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ros2cs\ros2cs.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
Comment thread
noelex marked this conversation as resolved.

<Import Project="build\ros2cs.targets" />
<Import Project="build\Rcl.NET.props" />
<Import Project="build\Rcl.NET.targets" />
<Import Project="build\Rcl.NET.props" />
<!-- TODO: only generate changed interface packages,
because generating many packages can take considerably long time,
maybe not here but maybe by ros2cs generator code -->
<Import Project="build\Rcl.NET.targets" />

<ItemGroup Condition="'$(_IsPacking)' == 'true'">
<None Include="$(MSBuildProjectDirectory)\..\ros2cs\bin\$(Configuration)\net6.0\publish\*"
Pack="True"
PackagePath="tools\net6.0\ros2cs\"/>
</ItemGroup>
<PropertyGroup>
<Ros2csSourcePublish>$(MSBuildProjectDirectory)\..\ros2cs\bin\$(Configuration)\$(Ros2csBundleTfm)\publish</Ros2csSourcePublish>
</PropertyGroup>
<ItemGroup Condition="'$(_IsPacking)' == 'true'">
<None Include="build\Rcl.NET.props" Pack="True" PackagePath="build" />
<None Include="build\Rcl.NET.targets" Pack="True" PackagePath="build" />
<None Include="$(Ros2csSourcePublish)\*.dll;$(Ros2csSourcePublish)\ros2cs.runtimeconfig.json;$(Ros2csSourcePublish)\ros2cs.deps.json"
Pack="True" PackagePath="tools\$(Ros2csBundleTfm)\ros2cs\" />
</ItemGroup>

<!-- ../Directory.Build.props & .targets are also imported to gather the source ros2cs -->
</Project>
8 changes: 7 additions & 1 deletion src/Rcl.NET/build/Rcl.NET.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<Ros2csOutputDir Condition="$(Ros2csOutputDir) == ''">Ros2csGeneratedInterfaces</Ros2csOutputDir>
<Ros2csBundleTfm>net8.0</Ros2csBundleTfm>
<Ros2csExe Condition="'$(Ros2csExe)' == ''">$(MSBuildThisFileDirectory)\..\tools\$(Ros2csBundleTfm)\ros2cs\ros2cs.dll</Ros2csExe>
</PropertyGroup>

<ItemGroup>
<Ros2csGenFiles Include="$(IntermediateOutputPath)\$(Ros2csOutputDir)\**\*.g.cs" />

<Compile Include="$(IntermediateOutputPath)\$(Ros2csOutputDir)\**\*.g.cs">
<Compile Include="@(Ros2csGenFiles)">
<Link>$(Ros2csOutputDir)\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
</ItemGroup>
Expand Down
84 changes: 57 additions & 27 deletions src/Rcl.NET/build/Rcl.NET.targets
Original file line number Diff line number Diff line change
@@ -1,40 +1,70 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Target Name="GenerateInterfaces_ros2cs" BeforeTargets="CoreCompile">
<PropertyGroup>
<GenerateInterfaces_ros2csDependsOn>
$(GenerateInterfaces_ros2csDependsOn);GetRos2csProps
</GenerateInterfaces_ros2csDependsOn>
</PropertyGroup>

<PropertyGroup Condition="'$(Ros2csExe)' == ''">
<Ros2csExe>$(MSBuildThisFileDirectory)\..\tools\net6.0\ros2cs\ros2cs.dll</Ros2csExe>
</PropertyGroup>
<Target Name="GenerateInterfaces_ros2cs" BeforeTargets="BeforeCompile;CoreCompile"
DependsOnTargets="$(GenerateInterfaces_ros2csDependsOn)"
Inputs="$(Ros2csSpecFile)" Outputs="$(IntermediateOutputPath)\$(Ros2csOutputDir)\ros2cs.spec.cache">

<PropertyGroup>
<DefaultRos2csSpecFile>$(MSBuildProjectDirectory)\ros2cs.spec</DefaultRos2csSpecFile>
<Ros2csOutputDir Condition="$(Ros2csOutputDir) == ''">Ros2csGeneratedInterfaces</Ros2csOutputDir>
<Ros2csSpecFile Condition="$(Ros2csSpecFile) == '' and Exists('$(DefaultRos2csSpecFile)')">$(DefaultRos2csSpecFile)</Ros2csSpecFile>
<Ros2csCommand>dotnet &quot;$(Ros2csExe)&quot; -o $(IntermediateOutputPath)\$(Ros2csOutputDir) &quot;$(Ros2csSpecFile)&quot;</Ros2csCommand>
</PropertyGroup>
<Message Text="Ros2csSpec: $(Ros2csSpecFile)"/>

<Message Text="Ros2csSpec: $(Ros2csSpecFile)"/>
<Message Text="Ros2csCmd: $(Ros2csCommand)"/>

<Message Text="Ros2csCmd: $(Ros2csCommand)"/>
<Exec Command="$(Ros2csCommand)" WorkingDirectory="$(MSBuildProjectDirectory)"
ConsoleToMSBuild="true" IgnoreExitCode="true" Condition="'$(Ros2csSpecFile)' != ''">

<Output TaskParameter="ConsoleOutput" ItemName="Ros2csOutput"/>
<Output TaskParameter="ExitCode" PropertyName="Ros2csExitCode"/>
</Exec>

<Error Condition="'$(Ros2csSpecFile)' != '' and '$(Ros2csExitCode)' != '0'"
Text="'$(Ros2csCommand)' failed with exit code $(Ros2csExitCode):&#x0A;@(Ros2csOutput->'%(Identity)', '&#x0A;')" />

<Exec Command="$(Ros2csCommand)" WorkingDirectory="$(MSBuildProjectDirectory)"
ConsoleToMSBuild="true" IgnoreExitCode="true" Condition="'$(Ros2csSpecFile)' != ''">
<Copy SourceFiles="$(Ros2csSpecFile)"
DestinationFiles="$(IntermediateOutputPath)\$(Ros2csOutputDir)\ros2cs.spec.cache"
SkipUnchangedFiles="true"
Condition="'$(Ros2csSpecFile)' != ''"/>

<ItemGroup>
<Compile Remove="@(Ros2csGenFiles)" />
<Compile Include="$(IntermediateOutputPath)\$(Ros2csOutputDir)\**\*.g.cs"/>
</ItemGroup>
</Target>

<Output TaskParameter="ConsoleOutput" ItemName="Ros2csOutput"/>
<Output TaskParameter="ExitCode" PropertyName="Ros2csExitCode"/>
</Exec>

<Error Condition="'$(Ros2csSpecFile)' != '' and '$(Ros2csExitCode)' != '0'"
Text="ros2cs failed with exit code $(Ros2csExitCode):&#x0A;@(Ros2csOutput->'%(Identity)', '&#x0A;')" />
<PropertyGroup>
<CleanGenerated_ros2csDependsOn>
$(CleanGenerated_ros2csDependsOn);GetRos2csProps
</CleanGenerated_ros2csDependsOn>
</PropertyGroup>

<ItemGroup>
<Compile Remove="@(Ros2csGenFiles)"/>
<Compile Include="$(IntermediateOutputPath)\$(Ros2csOutputDir)\**\*.g.cs"/>
</ItemGroup>
</Target>
<Target Name="CleanGenerated_ros2cs" BeforeTargets="CoreClean" DependsOnTargets="$(CleanGenerated_ros2csDependsOn)">
<RemoveDir Directories="$(IntermediateOutputPath)\$(Ros2csOutputDir)" />
</Target>

<Target Name="CleanGenerated_ros2cs" BeforeTargets="CoreClean">
<RemoveDir Directories="$(IntermediateOutputPath)\$(Ros2csOutputDir)" />
</Target>

<Target Name="GetRos2csProps" DependsOnTargets="$(GetRos2csPropsDependsOn)">
Comment thread
noelex marked this conversation as resolved.
<PropertyGroup>
<DefaultRos2csSpecFile>$(MSBuildProjectDirectory)\ros2cs.spec</DefaultRos2csSpecFile>
<Ros2csSpecFile Condition="$(Ros2csSpecFile) == '' and Exists('$(DefaultRos2csSpecFile)')">$(DefaultRos2csSpecFile)</Ros2csSpecFile>

<Ros2csCommand>dotnet $(Ros2csExe.Trim()) $(Ros2csArgs.Trim()) -o &quot;$(IntermediateOutputPath)\$(Ros2csOutputDir.Trim())&quot; &quot;$(Ros2csSpecFile.Trim())&quot;</Ros2csCommand>
</PropertyGroup>
</Target>


<Target Name="CheckAmentPrefixPath" AfterTargets="GetRos2csProps">
<ReadLinesFromFile File="$(Ros2csSpecFile)">
<Output TaskParameter="Lines" ItemName="Ros2csSpecFileLines"/>
</ReadLinesFromFile>

<Warning Code="RCL0002" File="$(Ros2csSpecFile)"
Condition="'$(AMENT_PREFIX_PATH)' == '' AND @(Ros2csSpecFileLines->AnyHaveMetadataValue('Identity', 'from-ament-index'))"
Text="'from-ament-index' option is specified in ros2cs.spec file but 'AMENT_PREFIX_PATH' Property or Environment Variable is not set/empty. ROS 2 interface packages may not be found." />
</Target>

</Project>
16 changes: 0 additions & 16 deletions src/Rcl.NET/build/ros2cs.targets

This file was deleted.

5 changes: 4 additions & 1 deletion src/Rosidl.Generator.CSharp/Rosidl.Generator.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<!--<TargetFramework>net9.0</TargetFramework>-->
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -10,7 +11,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CppAst.CodeGen" Version="0.11.3" />
<PackageReference Include="CppAst.CodeGen" Version="0.11.3" />
<!--<PackageReference Include="CppAst.CodeGen" Version="0.27.0" />
<PackageReference Include="LibGit2Sharp" Version="0.31.0" />-->
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Rosidl.Runtime/Rosidl.Runtime.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
6 changes: 3 additions & 3 deletions src/ros2cs/ros2cs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>ros2cs</AssemblyName>
<PackAsTool>true</PackAsTool>
<DefaultItemExcludes>$(DefaultItemExcludes);TestOutput\**\*.cs</DefaultItemExcludes>
<RollForward>Major</RollForward>
</PropertyGroup>

<PropertyGroup>
<ToolCommandName>ros2cs</ToolCommandName>
<PackAsTool>true</PackAsTool>
<ToolCommandName>ros2cs</ToolCommandName>
<PackageId>ros2cs</PackageId>
<Description>
<![CDATA[Generates C# source codes from ROS2 interface definitions for use with rclnet.]]>
Expand Down
Loading