Skip to content

Commit fe1e927

Browse files
committed
Update README
1 parent cd6fc4e commit fe1e927

File tree

1 file changed

+81
-29
lines changed

1 file changed

+81
-29
lines changed

README.md

Lines changed: 81 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lf-trace-xronos
1+
# LF Trace Plugin for the Xronos Dashboard
22

33
An LF trace plugin for displaying live traces on the Xronos Dashboard using OpenTelemetry.
44

@@ -8,54 +8,105 @@ This plugin provides OpenTelemetry tracing support for Lingua Franca programs. I
88

99
## Building the Plugin
1010

11-
### Step 1: Build the plugin and create install directory
11+
### Step 1: Build (choose one)
1212

13-
Run the build script:
13+
`build.sh` is a thin wrapper around CMake. Step 1 **configures + builds** (it does not install). Choose one:
14+
15+
#### 1a) Configure/build for the system prefix (default CMake prefix)
1416

1517
```bash
1618
./build.sh
1719
```
1820

19-
This will:
20-
- Build `lib/liblf-trace-impl.a` and all dependencies
21-
- Create an `install/` directory containing:
22-
- `install/include/` - All required headers
23-
- `install/lib/` - All static libraries (113+ archives including OpenTelemetry, gRPC, Protobuf, Abseil, etc.)
21+
This produces:
22+
- `lib/liblf-trace-impl.a`
23+
- A build directory with cached dependencies under `build/_deps/`
24+
25+
#### 1b) Configure/build for a user-chosen prefix (install anywhere you like)
26+
27+
Choose any `PREFIX` directory you want. Installation will populate:
28+
- `<PREFIX>/include`
29+
- `<PREFIX>/lib`
30+
- `<PREFIX>/lib/cmake/lf-trace-xronos`
31+
32+
Example (configure/build for this repo’s `./install` directory; this is what CI uses):
33+
34+
```bash
35+
./build.sh --prefix "$(pwd)/install"
36+
```
37+
38+
### Step 2: Install
2439

25-
The install directory is created at `./install` by default. You can specify a custom location:
40+
Installing is a separate step (required to use the plugin from LF). Run this after Step 1:
2641

2742
```bash
28-
./build.sh --install /custom/path/to/install
43+
./build.sh --install
2944
```
3045

46+
(Use `sudo` only if your chosen prefix requires it.)
47+
3148
**Note:** Dependencies are cached in `build/_deps/` and won't be re-downloaded on subsequent builds unless you delete that directory.
3249

33-
### Step 2: Use the plugin in your LF program
50+
## Step 3: Using the Plugin from Lingua Franca (three supported flows)
3451

35-
Set the install directory via environment variable and include `plugin.cmake`:
52+
- If you chose **1a (system prefix)**, use **3a**.
53+
- If you chose **1b (user-chosen prefix)**, use **3b** or **3c**.
3654

37-
```bash
38-
export LF_TRACE_INSTALL=/abs/path/to/lf-trace-xronos/install
39-
lfc-dev -c MyProgram.lf --tracing
55+
### 3a) System package on default CMake search path (cleanest LF file)
56+
57+
Install the plugin to the system prefix (see above), then in your `.lf`:
58+
59+
```lf
60+
target C {
61+
tracing: true, // Turn on tracing.
62+
trace-plugin: {
63+
package: "lf-trace-xronos",
64+
library: "lf::trace-impl",
65+
},
66+
}
4067
```
4168

42-
In your LF file:
69+
See a working example in `tests/src/TracePluginSystemPath.lf`.
70+
71+
### 3b) Package + explicit path (no system install; easy to remove)
72+
73+
Install the plugin to a user-chosen prefix (Step 1b + Step 2), then in your `.lf` set `path` to that prefix.
74+
75+
Example (install prefix is this repo’s `./install`, referenced relative to the `.lf` file):
4376

4477
```lf
4578
target C {
46-
tracing: true,
47-
trace-plugin: true,
48-
cmake-include: ["/abs/path/to/lf-trace-xronos/plugin.cmake"],
79+
tracing: true, // Turn on tracing.
80+
trace-plugin: {
81+
package: "lf-trace-xronos",
82+
library: "lf::trace-impl",
83+
path: "../../install/", // Relative to this LF file's location
84+
},
4985
}
5086
```
5187

52-
## What plugin.cmake Does
88+
See a working example in `tests/src/TracePluginUserPath.lf`.
89+
90+
### 3c) Custom CMake integration (most flexible; dev-focused)
91+
92+
Use `plugin.cmake` to link everything from an install directory and pass `LF_TRACE_INSTALL` (set to the Step 1b install prefix):
93+
94+
```lf
95+
target C {
96+
tracing: true, // Turn on tracing.
97+
cmake-include: ["../../plugin.cmake"], // Relative to this LF file.
98+
cmake-args: {
99+
LF_TRACE_PLUGIN: "lf-trace-xronos",
100+
LF_TRACE_INSTALL: "../../../install", // Relative to the generated C project directory
101+
},
102+
}
103+
```
104+
105+
See a working example in `tests/src/TracePluginCustomCmake.lf`.
106+
107+
## End-to-end CI reference
53108

54-
The `plugin.cmake` file automatically:
55-
- Links all required static libraries from the install directory
56-
- Adds include directories for headers
57-
- Links system libraries (zlib, pthread, C++ standard library, CoreFoundation on macOS, c-ares)
58-
- Sets appropriate C++ standard (C++14)
109+
For a complete working sequence (build lfc, install plugin both to `./install` and to system prefix, then compile+run the LF programs), see `.github/workflows/ci.yml`.
59110

60111
## Dependencies
61112

@@ -75,12 +126,13 @@ All dependencies are built as static libraries and included in the `install/` di
75126
The `build.sh` script supports several options:
76127

77128
```bash
78-
./build.sh [--log-level <n>] [--install <install-dir>] [--no-clean]
129+
./build.sh [--log-level <n>] [--prefix <prefix>] [--install] [--clean]
79130
```
80131

81132
- `--log-level <n>`: Set the log level (default: 4)
82-
- `--install <install-dir>`: Specify custom install directory (default: `./install`)
83-
- `--no-clean`: Skip cleaning CMake cache (faster for incremental builds)
133+
- `--prefix <prefix>`: Set `CMAKE_INSTALL_PREFIX` for the build (used by `--install`)
134+
- `--install`: Install to the configured prefix
135+
- `--clean`: Clear top-level CMake cache files (keeps `build/_deps/`)
84136

85137
## Troubleshooting
86138

@@ -107,7 +159,7 @@ The plugin uses a two-stage build process:
107159

108160
1. **Plugin build stage** (`./build.sh`):
109161
- Builds the plugin library and all dependencies
110-
- Copies headers and libraries to `install/` directory
162+
- Optionally installs headers, libraries, and CMake config via `./build.sh --install`
111163
- Dependencies are cached in `build/_deps/` for reuse
112164

113165
2. **LF program build stage** (`plugin.cmake`):

0 commit comments

Comments
 (0)