(#238) Wrap a C library as a Logos core module#239
Conversation
|
|
||
| > [!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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
Each other time shows Linux first, only time macOS shown first
No description provided.