(#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
There was a problem hiding this comment.
That one's for LEZ, no connection to here. I'll add clarifying sentences here to make this more obvious.
|
|
||
| ## 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
|
@iurimatias @dlipicar Has this process been updated compared to the original doc packet? I'm just noticing here: https://github.com/logos-co/logos-tutorial/blob/master/outputs/tutorial-wrapping-c-library.md that you don't have to replace Q_INVOKABLE functions in the updated tutorial. Are the changes major enough to warrant a full rewrite? What about the other module tutorials (the core module and QML + C++ ones have already been merged in)? |
|
@kashepavadan this is the correct version btw (tutorial-v3) https://github.com/logos-co/logos-tutorial/blob/releases/v3/outputs/tutorial-wrapping-c-library.md
|
|
the apps writing has also changed and needs to be relooked at |
|
@iurimatias I was referring to this step in the tutorial: "In the interface header, replace the class name, interface ID, include guard, and placeholder Ok, understood. Can I just use the v3 release tutorials as doc packets to create the updated docs, or will more major changes be coming soon? If so, I'd rather wait until you reach a stable version. |
…/github.com/logos-co/logos-docs into 238-wrap-a-c-library-as-a-logos-core-module
|
@jzaki Completely updated the tutorial, please take a look |
No description provided.