Skip to content
Open
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
87 changes: 77 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,99 @@ on:
workflow_dispatch:

jobs:
build:
# ── Windows: full build, test, and managed code compilation ──────────
windows-build:
runs-on: windows-latest

env:
# This ensures the build script can find CMake if not in default path (though it usually is on runners)
CMAKE_GENERATOR: "Visual Studio 17 2022"

CMAKE_GENERATOR: "Visual Studio 18 2026"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for Nerdbank.GitVersioning to determine version
fetch-depth: 0
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x

- name: Display Tools Versions
run: |
dotnet --version
cmake --version

- name: Build, Test, and Pack
- name: Build Native (win-x64)
shell: pwsh
run: .\build\native-win.ps1

- name: Build Managed Code
shell: pwsh
run: dotnet build CycloneDDS.NET.Core.slnf -c Release

- name: Run Tests
shell: pwsh
run: dotnet test CycloneDDS.NET.Core.slnf -c Release --no-build --verbosity normal

- name: Upload win-x64 Native Artifacts
uses: actions/upload-artifact@v4
with:
name: native-win-x64
path: artifacts/native/win-x64/*

# ── Linux: native compilation only ───────────────────────────────────
linux-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Build Native (linux-x64)
shell: bash
run: |
chmod +x build/native-linux.sh
build/native-linux.sh Release

- name: Upload linux-x64 Native Artifacts
uses: actions/upload-artifact@v4
with:
name: native-linux-x64
path: artifacts/native/linux-x64/*

# ── Pack: combine native artifacts and create NuGet package ──────────
pack:
runs-on: windows-latest
needs: [windows-build, linux-build]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 10.0.x

- name: Download win-x64 Native Artifacts
uses: actions/download-artifact@v4
with:
name: native-win-x64
path: artifacts/native/win-x64/

- name: Download linux-x64 Native Artifacts
uses: actions/download-artifact@v4
with:
name: native-linux-x64
path: artifacts/native/linux-x64/

- name: Build and Pack
shell: pwsh
run: .\build\pack.ps1
run: |
dotnet build CycloneDDS.NET.Core.slnf -c Release
dotnet pack src/CycloneDDS.Runtime/CycloneDDS.Runtime.csproj -c Release --no-build -o artifacts/nuget

- name: Upload NuGet Packages
uses: actions/upload-artifact@v4
Expand All @@ -50,4 +117,4 @@ jobs:
with:
name: symbol-packages
path: artifacts/nuget/*.snupkg
if-no-files-found: warn
if-no-files-found: warn
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ nunit-*.xml
cyclone-compiled/
cyclone-compiled-debug/
build/native/
build/native-linux/
test-extract/
test-output/
**/Generated/*
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.10.85" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300" PrivateAssets="All" />
</ItemGroup>
</Project>
116 changes: 116 additions & 0 deletions build/native-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env bash
set -euo pipefail

# ===================================================================================
# build/native-linux.sh
#
# PURPOSE:
# Compiles the native (C/C++) Cyclone DDS submodule for Linux and copies the
# resulting binaries to the local 'artifacts' directory.
# This is a prerequisite for packing the NuGet package with linux-x64 support.
#
# USAGE:
# ./build/native-linux.sh [Release|Debug]
# Default: Release
# ===================================================================================

CONFIG="${1:-Release}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
SOURCE_DIR="$REPO_ROOT/cyclonedds"
BUILD_DIR="$REPO_ROOT/build/native-linux"
INSTALL_DIR="$REPO_ROOT/artifacts/native-install"
ARTIFACTS_DIR="$REPO_ROOT/artifacts/native/linux-x64"

echo "============================================================"
echo " Building Native CycloneDDS for Linux ($CONFIG)"
echo "============================================================"

# Check prerequisites
if ! command -v cmake &> /dev/null; then
echo "ERROR: cmake is not installed or not in PATH." >&2
exit 1
fi

if ! command -v gcc &> /dev/null; then
echo "ERROR: gcc is not installed or not in PATH." >&2
exit 1
fi

if [ ! -d "$SOURCE_DIR" ]; then
echo "ERROR: Native source directory not found: $SOURCE_DIR" >&2
echo " Run: git submodule update --init --recursive" >&2
exit 1
fi

# Ensure output directories exist
mkdir -p "$BUILD_DIR" "$INSTALL_DIR" "$ARTIFACTS_DIR"

# ----------------------------------------------------------------
# [1/3] CMake Configure
# ----------------------------------------------------------------
echo ""
echo "[1/3] Configuring CMake..."

cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DBUILD_IDLC=ON \
-DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
-DENABLE_SSL=OFF \
-DENABLE_SHM=OFF \
-DENABLE_SECURITY=OFF \
-DCMAKE_BUILD_TYPE="$CONFIG"

# ----------------------------------------------------------------
# [2/3] Build & Install
# ----------------------------------------------------------------
echo ""
echo "[2/3] Building & Installing..."

NPROC="${NPROC:-$(nproc 2>/dev/null || echo 4)}"
cmake --build "$BUILD_DIR" --config "$CONFIG" -j "$NPROC"
cmake --install "$BUILD_DIR" --config "$CONFIG"

# ----------------------------------------------------------------
# [3/3] Copy Artifacts & Fix RPATH
# ----------------------------------------------------------------
echo ""
echo "[3/3] Copying artifacts to $ARTIFACTS_DIR..."

# Runtime library (include both .so.0 for soname and .so for convention)
cp -f "$INSTALL_DIR/lib/libddsc.so.0.11.0" "$ARTIFACTS_DIR/libddsc.so.0" 2>/dev/null || echo " [-] Missing libddsc.so.0.11.0"
cp -f "$INSTALL_DIR/lib/libddsc.so.0.11.0" "$ARTIFACTS_DIR/libddsc.so" 2>/dev/null || true
echo " [+] libddsc.so / libddsc.so.0"

# IDL compiler executable
cp -f "$INSTALL_DIR/bin/idlc" "$ARTIFACTS_DIR/" 2>/dev/null || echo " [-] Missing idlc"
echo " [+] idlc"

# IDL compiler support libraries
for lib in libcycloneddsidl libcycloneddsidlc libcycloneddsidljson; do
cp -f "$INSTALL_DIR/lib/${lib}.so.0.11.0" "$ARTIFACTS_DIR/${lib}.so.0" 2>/dev/null || echo " [-] Missing ${lib}.so.0.11.0"
cp -f "$INSTALL_DIR/lib/${lib}.so.0.11.0" "$ARTIFACTS_DIR/${lib}.so" 2>/dev/null || true
echo " [+] ${lib}.so / ${lib}.so.0"
done

# Fix RPATH: cmake sets RPATH to $ORIGIN/../lib (bin/ -> lib/), but in the
# NuGet tools/ directory all files are flat. Change RPATH to $ORIGIN/ so the
# dynamic linker finds .so dependencies alongside the executable.
if command -v patchelf &> /dev/null; then
echo ""
echo " [+] Fixing RPATH to \$ORIGIN/..."
chmod +w "$ARTIFACTS_DIR/"*.so* "$ARTIFACTS_DIR/idlc" 2>/dev/null || true
for f in "$ARTIFACTS_DIR/"*.so* "$ARTIFACTS_DIR/idlc"; do
patchelf --set-rpath '$ORIGIN/' "$f" 2>/dev/null || true
done
echo " [+] RPATH fixed."
else
echo " [!] patchelf not found. Run: sudo apt-get install patchelf"
echo " [!] Without patchelf, LD_LIBRARY_PATH must be set at runtime."
fi

echo ""
echo "Native build complete."
echo "Artifacts staged at: $ARTIFACTS_DIR"
ls -la "$ARTIFACTS_DIR"
2 changes: 1 addition & 1 deletion debug_tool/DebugOffsets.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
6 changes: 3 additions & 3 deletions examples/FeatureDemo/FeatureDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Spectre.Console" Version="0.57.0" />
<PackageReference Include="System.CommandLine" Version="2.0.9" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions examples/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Ensure we can find the local package -->
<RestoreSources>../../artifacts/nuget;$(RestoreSources)</RestoreSources>
<!-- Force NuGet to ignore cache for local packages -->
<RestoreNoCache>true</RestoreNoCache>
<RestoreForce>true</RestoreForce>
<!-- Ensure we can find the local package -->
<RestoreSources>../../artifacts/nuget;$(RestoreSources)</RestoreSources>
<!-- Force NuGet to ignore cache for local packages -->
<RestoreNoCache>true</RestoreNoCache>
<RestoreForce>true</RestoreForce>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/IdlImportDemo/AppLib/AppLib.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
2 changes: 1 addition & 1 deletion examples/IdlImportDemo/CommonLib/CommonLib.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
2 changes: 1 addition & 1 deletion examples/IdlImportDemo/generate_and_run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Write-Host "Building Importer and CodeGen..." -ForegroundColor Cyan
dotnet build $ImporterProj -c Release
dotnet build $CodeGenProj -c Release

$IdlImporterExe = Join-Path $RootDir "tools\CycloneDDS.IdlImporter\bin\Release\net8.0\CycloneDDS.IdlImporter.exe"
$IdlImporterExe = Join-Path $RootDir "tools\CycloneDDS.IdlImporter\bin\Release\net10.0\CycloneDDS.IdlImporter.exe"

if (-not (Test-Path $IdlImporterExe)) {
Write-Error "Importer executable not found at $IdlImporterExe"
Expand Down
11 changes: 9 additions & 2 deletions src/CycloneDDS.Core/CycloneDDS.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageId>CycloneDDS.Core</PackageId>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<Content Include="..\..\artifacts\native\win-x64\**\*.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
Expand All @@ -19,4 +19,11 @@
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
</Content>
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
<Content Include="..\..\artifacts\native\linux-x64\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
</Content>
</ItemGroup>
</Project>
Loading