Skip to content

Commit a27efdb

Browse files
committed
Add GitHub Actions workflow for build and release process, update CMakeLists for Rerun SDK integration, and enhance README with installation instructions
1 parent 34f3017 commit a27efdb

3 files changed

Lines changed: 208 additions & 3 deletions

File tree

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: Build ${{ matrix.package_name }}
14+
runs-on: ${{ matrix.runner }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- package_name: machinetool-windows-amd64
20+
runner: windows-2025
21+
plugin_suffix: amd64
22+
cmake_generator: Visual Studio 17 2022
23+
cmake_generator_platform: x64
24+
- package_name: machinetool-linux-x86_64
25+
runner: ubuntu-24.04
26+
plugin_suffix: x86_64
27+
cmake_generator: Ninja
28+
- package_name: machinetool-linux-arm64
29+
runner: ubuntu-24.04-arm
30+
plugin_suffix: arm64
31+
cmake_generator: Ninja
32+
- package_name: machinetool-macos-universal
33+
runner: macos-15-intel
34+
plugin_suffix: universal
35+
cmake_generator: Ninja
36+
cmake_osx_architectures: x86_64;arm64
37+
rerun_c_crate_version: 0.27.3
38+
defaults:
39+
run:
40+
shell: bash
41+
env:
42+
PACKAGE_NAME: ${{ matrix.package_name }}
43+
PLUGIN_SUFFIX: ${{ matrix.plugin_suffix }}
44+
CMAKE_GENERATOR: ${{ matrix.cmake_generator }}
45+
CMAKE_GENERATOR_PLATFORM: ${{ matrix.cmake_generator_platform }}
46+
CMAKE_OSX_ARCHITECTURES: ${{ matrix.cmake_osx_architectures }}
47+
RERUN_C_CRATE_VERSION: ${{ matrix.rerun_c_crate_version }}
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v6
51+
52+
- name: Configure
53+
run: |
54+
cmake_args=(
55+
-S .
56+
-B build
57+
-DCMAKE_INSTALL_PREFIX="$PWD/dist/${PACKAGE_NAME}"
58+
-DPLUGIN_SUFFIX="${PLUGIN_SUFFIX}"
59+
)
60+
61+
if [ -n "${CMAKE_GENERATOR:-}" ]; then
62+
cmake_args+=(-G "${CMAKE_GENERATOR}")
63+
fi
64+
65+
if [ -n "${CMAKE_GENERATOR_PLATFORM:-}" ]; then
66+
cmake_args+=(-A "${CMAKE_GENERATOR_PLATFORM}")
67+
else
68+
cmake_args+=(-DCMAKE_BUILD_TYPE=Release)
69+
fi
70+
71+
if [ -n "${CMAKE_OSX_ARCHITECTURES:-}" ]; then
72+
cmake_args+=("-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}")
73+
fi
74+
75+
if [ -n "${RERUN_C_CRATE_VERSION:-}" ]; then
76+
rustup target add x86_64-apple-darwin
77+
cmake -E make_directory "$PWD/.ci-rerun-c"
78+
curl -L "https://crates.io/api/v1/crates/rerun_c/${RERUN_C_CRATE_VERSION}/download" \
79+
-o "$PWD/.ci-rerun-c/rerun_c-${RERUN_C_CRATE_VERSION}.crate"
80+
cmake -E chdir "$PWD/.ci-rerun-c" \
81+
cmake -E tar xf "$PWD/.ci-rerun-c/rerun_c-${RERUN_C_CRATE_VERSION}.crate"
82+
cargo build \
83+
--manifest-path "$PWD/.ci-rerun-c/rerun_c-${RERUN_C_CRATE_VERSION}/Cargo.toml" \
84+
--release \
85+
--target x86_64-apple-darwin
86+
cmake_args+=(
87+
"-DRERUN_MACOS_X64_C_LIB=$PWD/.ci-rerun-c/rerun_c-${RERUN_C_CRATE_VERSION}/target/x86_64-apple-darwin/release/librerun_c.a"
88+
)
89+
fi
90+
91+
cmake "${cmake_args[@]}"
92+
93+
- name: Build
94+
run: cmake --build build --config Release --parallel
95+
96+
- name: Install
97+
run: cmake --install build --config Release --prefix "dist/${PACKAGE_NAME}"
98+
99+
- name: Add runtime assets
100+
run: |
101+
cmake -E copy_directory models "dist/${PACKAGE_NAME}/models"
102+
cmake -E copy_if_different README.md "dist/${PACKAGE_NAME}/README.md"
103+
104+
- name: Archive package
105+
run: cmake -E chdir dist cmake -E tar cf "${PACKAGE_NAME}.zip" --format=zip -- "${PACKAGE_NAME}"
106+
107+
- name: Upload package
108+
uses: actions/upload-artifact@v7
109+
with:
110+
path: dist/${{ matrix.package_name }}.zip
111+
if-no-files-found: error
112+
archive: false
113+
114+
release:
115+
name: Publish GitHub release
116+
needs: build
117+
runs-on: ubuntu-24.04
118+
permissions:
119+
actions: read
120+
contents: write
121+
defaults:
122+
run:
123+
shell: bash
124+
steps:
125+
- name: Download packages
126+
uses: actions/download-artifact@v8
127+
with:
128+
path: release-assets
129+
pattern: machinetool-*
130+
merge-multiple: true
131+
skip-decompress: true
132+
133+
- name: Create release
134+
env:
135+
GH_REPO: ${{ github.repository }}
136+
GH_TOKEN: ${{ github.token }}
137+
run: |
138+
short_sha="${GITHUB_SHA::7}"
139+
tag_name="build-${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}-${short_sha}"
140+
141+
gh release create "${tag_name}" release-assets/*.zip \
142+
--target "${GITHUB_SHA}" \
143+
--title "machinetool ${short_sha}" \
144+
--notes "Automated build from main at ${GITHUB_SHA}." \
145+
--latest=false

CMakeLists.txt

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,30 @@ FetchContent_Declare(json
5656
EXCLUDE_FROM_ALL
5757
)
5858

59+
set(RERUN_CPP_SDK_VERSION "0.27.3" CACHE STRING "Rerun C++ SDK version.")
60+
set(RERUN_CPP_SDK_URL
61+
"https://github.com/rerun-io/rerun/releases/download/${RERUN_CPP_SDK_VERSION}/rerun_cpp_sdk.zip"
62+
CACHE STRING "Rerun C++ SDK archive URL."
63+
)
64+
# Rerun 0.27.x no longer ships macOS x86_64 rerun_c, so universal
65+
# builds must provide that slice separately and lipo it with arm64.
66+
set(RERUN_MACOS_X64_C_LIB "" CACHE FILEPATH "Path to librerun_c.a for macOS x86_64 universal builds.")
67+
68+
set(_rerun_macos_universal OFF)
69+
if(APPLE)
70+
list(FIND CMAKE_OSX_ARCHITECTURES "x86_64" _rerun_macos_x64_index)
71+
list(FIND CMAKE_OSX_ARCHITECTURES "arm64" _rerun_macos_arm64_index)
72+
if(NOT _rerun_macos_x64_index EQUAL -1 AND NOT _rerun_macos_arm64_index EQUAL -1)
73+
set(_rerun_macos_universal ON)
74+
set(_rerun_macos_universal_c_lib
75+
"${CMAKE_CURRENT_BINARY_DIR}/_deps/rerun_cpp_sdk-src/lib/librerun_c__macos_universal.a"
76+
)
77+
set(RERUN_C_LIB "${_rerun_macos_universal_c_lib}" CACHE PATH "Universal macOS rerun_c static library." FORCE)
78+
endif()
79+
endif()
80+
5981
FetchContent_Declare(rerun_cpp_sdk
60-
URL https://github.com/rerun-io/rerun/releases/download/0.27.3/rerun_cpp_sdk.zip
82+
URL ${RERUN_CPP_SDK_URL}
6183
EXCLUDE_FROM_ALL
6284
)
6385

@@ -74,6 +96,28 @@ endif()
7496

7597
FetchContent_MakeAvailable(pugg json rerun_cpp_sdk)
7698

99+
if(_rerun_macos_universal)
100+
set(_rerun_macos_arm64_c_lib "${rerun_cpp_sdk_SOURCE_DIR}/lib/librerun_c__macos_arm64.a")
101+
if(RERUN_MACOS_X64_C_LIB STREQUAL "")
102+
message(FATAL_ERROR "RERUN_MACOS_X64_C_LIB must point to a macOS x86_64 rerun_c static library.")
103+
endif()
104+
if(NOT EXISTS "${RERUN_MACOS_X64_C_LIB}")
105+
message(FATAL_ERROR "RERUN_MACOS_X64_C_LIB does not exist: ${RERUN_MACOS_X64_C_LIB}")
106+
endif()
107+
if(NOT EXISTS "${_rerun_macos_arm64_c_lib}")
108+
message(FATAL_ERROR "Rerun SDK arm64 rerun_c library does not exist: ${_rerun_macos_arm64_c_lib}")
109+
endif()
110+
111+
execute_process(
112+
COMMAND lipo -create "${RERUN_MACOS_X64_C_LIB}" "${_rerun_macos_arm64_c_lib}" -output "${RERUN_C_LIB}"
113+
RESULT_VARIABLE _rerun_lipo_result
114+
ERROR_VARIABLE _rerun_lipo_error
115+
)
116+
if(NOT _rerun_lipo_result EQUAL 0)
117+
message(FATAL_ERROR "Failed to create universal macOS rerun_c library: ${_rerun_lipo_error}")
118+
endif()
119+
endif()
120+
77121
FetchContent_Populate(plugin
78122
GIT_REPOSITORY https://github.com/pbosetti/mads_plugin.git
79123
GIT_TAG v2.0-P7

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a Sink plugin for [MADS](https://github.com/MADS-NET/MADS).
44

5-
<provide here some introductory info>
5+
This plugin visualizes on [Rerun](https://rerun.io) a 3D model of a machine tool, updating axes positions according to the received commands. It is just a viewer and does not provide any dinamics simulation. Foor that, head to <https://gitbub.com/mads-net/FMU_agent>.
66

77
*Required MADS version: 2.0.0.*
88

@@ -16,7 +16,7 @@ Currently, the supported platforms are:
1616
* **Windows**
1717

1818

19-
## Installation
19+
## Build from source
2020

2121
Linux and MacOS:
2222

@@ -34,6 +34,22 @@ cmake --build build --config Release
3434
cmake --install build --config Release
3535
```
3636

37+
## Install from release
38+
39+
Download a release from GitHub, unzip it, then:
40+
41+
## Requirement: Rerun
42+
43+
The easiest way to install the Rerun viewer is via pip:
44+
45+
```sh
46+
python3 -mvenv .venv
47+
source .venv/bin/activate # or, on Windows: .venv\script\activate.bat
48+
pip install rerun-sdk==0.27.3
49+
```
50+
51+
Then launch the agent from same shell.
52+
3753

3854
## INI settings
3955

0 commit comments

Comments
 (0)