Skip to content

(#238) Wrap a C library as a Logos core module#239

Open
cheny0 wants to merge 2 commits into
mainfrom
238-wrap-a-c-library-as-a-logos-core-module
Open

(#238) Wrap a C library as a Logos core module#239
cheny0 wants to merge 2 commits into
mainfrom
238-wrap-a-c-library-as-a-logos-core-module

Conversation

@cheny0
Copy link
Copy Markdown
Contributor

@cheny0 cheny0 commented May 7, 2026

No description provided.

@cheny0 cheny0 self-assigned this May 7, 2026
@cheny0 cheny0 added area:core Docs related to Logos Core journeys. quality:stub Placeholder page. Title, status, and known gaps only. Not runnable. type:journey A user journey document (the primary deliverable). release:testnet-v0.2 Items for Testnet v0.1 release. status:doc-ready-for-review blocked-by:red-team labels May 7, 2026
@cheny0 cheny0 linked an issue May 7, 2026 that may be closed by this pull request
@fryorcraken fryorcraken requested review from jzaki and removed request for fryorcraken May 8, 2026 02:54

> [!TIP]
>
> If you don't have a C library, you can try the `libtictactoe.h` and `libtictactoe.c` from example [`libtictactoe`](https://github.com/fryorcraken/logos-module-tictactoe/tree/master/tictactoe/lib). Copy them into your `lib/` directory.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a trivial inlined .c and .h code would be less distracting from the goal.
This tip takes them to another repo to copy a specific .c/.h file code back, and it is it's own module repo too.
EDIT: later does do the inline calc example, seems more confusing to direct them away at this point. Perhaps move to later once they've done a bit more.

>
> Check out an [example](https://github.com/fryorcraken/logos-module-tictactoe/tree/master/tictactoe) of a working core module that wraps a small C library.

## Step 1: Scaffold the module project with external-lib support
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should clarify use of "Scaffold" as a verb here, since it's the same name as the tool


## Step 1: Scaffold the module project with external-lib support

Use the `with-external-lib` variant of the module builder template. Compared to the plain template, its `metadata.json` is pre-populated with an `external_libraries` block and `extra_include_dirs`, and its `CMakeLists.txt` calls `logos_module()` with `EXTERNAL_LIBS`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explaining a specific attribute of a command before presenting the command or even mentioning module builder (perhaps they are assumed to know it if they're here).

Q_DECLARE_INTERFACE(<ModuleName>Interface, "org.logos.<ModuleName>Interface")
```

- Supported parameter and return types: `int`, `bool`, `QString`, `QByteArray`, `QVariant`, `QJsonArray`, `QStringList`, `LogosResult`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It quite mechanical around here, acting as both a how-to and a reference in one. If it's more of a tutorial type, can the person following the tutorial be primed to come across these elsewhere? Eg if these types are defined somewhere intuitive in this context. Or later, showing where the global logosAPI is defined.

```

- Use `nix build '.#lib'` to build only the plugin shared library.
- Use `nix build '.#include'` to build only the generated SDK headers.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read this in the original tutorial, and it'd be helpful to expand what this means.

nix build .#lgx
```

- Use `#lgx-portable` for a self-contained package with all dependencies bundled: `nix build .#lgx-portable`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be helpful to explain what "all dependencies" means in this context: wrapped lib, module deps, something more, ..?


1. Check the `result/` directory and confirm the `<module-name>-<version>.lgx` file is present.

#### Use the `nix bundle` command
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I'd read somewhere this path wasn't preferred, will see what khushboo responds to above.


```bash
mkdir <module-name> && cd <module-name>
nix flake init -t github:logos-co/logos-module-builder/tutorial-v1#with-external-lib
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will eventually update to v3 soon 🤞 To go with the basecamp release 0.1.2


#### Install a locally built `.lgx` package

1. Build the Logos Package Manager (`lgpm`) CLI.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of consecutive instructions (like a how-to), it could benefit with some context here.

./logos-basecamp/bin/logos-basecamp
```

- To find the data directory, check the log for `plugins directory`, or look for the directory containing `modules/` and `plugins/` at `~/Library/Application Support/Logos/` (macOS) or `~/.local/share/Logos/` (Linux).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each other time shows Linux first, only time macOS shown first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Docs related to Logos Core journeys. blocked-by:red-team quality:stub Placeholder page. Title, status, and known gaps only. Not runnable. release:testnet-v0.2 Items for Testnet v0.1 release. status:doc-ready-for-review type:journey A user journey document (the primary deliverable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrap a C library as a Logos core module

3 participants