add(README) update

This commit is contained in:
Aire-One 2022-01-30 20:53:26 +01:00
parent 3baa006cb0
commit f9d66eadb4
1 changed files with 28 additions and 13 deletions

View File

@ -1,4 +1,6 @@
# Calculon : My try to build a library Distributable with Luarocks using Teal
# Calculon
My try to build a library with Luarocks using Teal!
![Calculon](doc/Calculon.webp "Calculon")
@ -6,14 +8,14 @@
## e18f54c977 init
Init a teal project with `cyan init`, then write the `calculon.tl` lua.
Initialize a teal project with `cyan init`, then write the `calculon.tl` Lua.
Note : I also added `.gitignore` and `.gitkeep` files to not commit generated
files from `cyan build`.
## d24e69a41e add(consumer) init
Add a Lua consumer script to try the calculon lib. It can be run with
Add a Lua consumer script to try the calculon lib. It can be run with:
```sh
lua consumer.lua
@ -26,41 +28,54 @@ Notes :
## a433eb2fe4 add(luarocks) init
Init a Luarocks module in the current directory.
Initialize a Luarocks module in the current directory.
I need to add the module `calculon = "build/calculon/init.lua"` to make the
rock not empty.
## b4d00c05ae add(build) force commit lua
Because the rock needs the generated lua, I force commit it :'(
Because the rock needs the generated Lua, I have force commit it 😭
## acb833e8e1 add(consumer) load calculon as module
The consumer can now load calculon as a "normal" module!
Now that the calculon lib ships the Lua files, the consumer can load it as a normal module!
## 5eb06ccafb chore(consumer) move it to a project
Move the consumer to its own project with Luarocks.
Notes : We need to install calculon manually from the rockspec with
`./luarocks install ../calculon-0.1-1.rockspec`
Notes : Calculon is not uploaded to Luarocks repositories. We need to install calculon manually from the rockspec file with: `./luarocks install ../calculon-0.1-1.rockspec`
## dac8260ea9 add(consumer) teal
Move the consumer to teal!
It can be build with `tl build`. Then run with `./lua build/consumer.lua`.
It can be built with `tl build`. Then run with `./lua build/consumer.lua`.
Note :
* To prevent the missing types definition error, I need to use the trick from tabular module
* We can't run the teal file directly `tl run src/consumer.tl` :'(
* We can't run the teal file directly `tl run src/consumer.tl` 😭
# 72c84c39e6 add(d.tl) calculon type definition
Add type definition to the calculon module and package.
Note : We force the type definition to be part of the module by abusing the `build.install.lua` table.
# 3baa006cb0 add(consumer) use type definitions
The consumer module doesn't need any trick thanks to the type definition file being part of the rock!
Note : We need to include the `lua_modules/share/lua/5.4` path to the tlconfig for this to work
# TODO
* The consumer works only because the generated file can "find" the module thanks to `./lua`
* Distribute teal files in the rock
* ~~The consumer works only because the generated file can find the module thanks to `./lua` that includes paths to locally installed packages~~ → is it really an issue?
* ~~Distribute teal files in the rock~~ → I think the rock should be Lua only (+ types definition for teal optionally)
* To not commit generated Lua files, the calculon module can have a `generate-rock` script that build and package the module (Can be done from a CI/CD like GitHub Actions 💡)
* The type definition trick works by abusing Luarocks specs, this needs to me standardized
# References