Skip to content

Refactor: allow alternatives for Lua libraries loaded with all profiles#3648

Merged
SlySven merged 1 commit intoMudlet:developmentfrom
SlySven:Refactor_allowAlteranativesForLuaLibrariesLoadedWithAllProfiles
Apr 20, 2020
Merged

Refactor: allow alternatives for Lua libraries loaded with all profiles#3648
SlySven merged 1 commit intoMudlet:developmentfrom
SlySven:Refactor_allowAlteranativesForLuaLibrariesLoadedWithAllProfiles

Conversation

@SlySven
Copy link
Copy Markdown
Member

@SlySven SlySven commented Apr 19, 2020

This allows a bit of flexibility especially as I have recently changed the library used to provide the zip library. After this PR the following are allowed for the following libraries:

  • zip:
    • lua-zip (the "Brimworks" one that MacOs has recently been switched to to avoid a zziplib dependency.
    • luazip (the one originally by the Kepler organisation)
  • utf8:
    • lua-utf8 (a "Starwing" one, what we were using up to now)
    • utf8 (an alternative version from the same GitHub repository which the user might grab instead)

This has been test and confirmed to work as I expect (particularly for luazip & lua-zip modules) on Linux.

Signed-off-by: Stephen Lyons slysven@virginmedia.com

This allows a bit of flexibility especially as I have recently changed
the library used to provide the `zip` library. After this PR the following
are allowed for the following libaries:
* `zip`:
  * lua-zip (the Brimworks one that MacOs has recently been switched to to
    avoid a zziplib dependency.
  * luazip (the one originally by the Kepler organisation)
* `utf8`:
  * `lua-utf8` (a "Starwing" one, what we were using up to now)
  * `utf8` (an alternative version from the same GitHub repository
    which the user might grab instead, might be an older version)

This has been test and confirmed to work as I expect (particularly for
luazip & lua-zip modules).

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven SlySven requested a review from a team as a code owner April 19, 2020 19:43
@SlySven SlySven requested review from a team April 19, 2020 19:43
@add-deployment-links
Copy link
Copy Markdown

add-deployment-links bot commented Apr 19, 2020

Hey there! Thanks for helping Mudlet improve. 🌟

Test versions

You can directly test the changes here:

No need to install anything - just unzip and run.
Let us know if it works well, and if it doesn't, please give details.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 20, 2020

Hm... but I don't want to spend my energy helping people who install something else other than what we support - it doesn't work for them, so they come to us for help. Why can't they follow instructions and install what we require? Seems like less hassle for everyone involved? And the loading code doesn't have to be complicated with message queues (!).

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 20, 2020

I don't like having to use different luarocks for different systems and this will allow for flexibility if we add any more rocks to our requirements. It will also make it easier to swap the Linux and Windows installer builds to be swapped over to lua-zip from luazip as we won't have to jump through the changing two repositories (mudlet and installers) at the same time hoop.

Edit: I am quite happy to not have even an indirect dependence on that confusingly name extra library i.e. zzip/zziplib/libzzip or whatever is it's official name!

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 20, 2020

So you'd like it that way - okay sounds good.

It looks like the queue only ever stores one message at a time, can we use a multi-return from the function to return boolean+string ?

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 20, 2020

The queue stores the error messages for all the attempts to provide a particular Lua module - and either ends up with a single [ OK ] - message from the particular one that succeeded or the accumulated ones in order from all the alternatives for that one module.

Passing that Queue as a reference allows for a Queue<T>::swap(const T& other) to quickly both dump any accumulated [ ERROR ] messages and stick in the OK one without having to clear the existing ones out - and it was simpler/cleaner to do it that way than coding up a whole new abstraction for the multiple alternate luarocks for the same module/library that was different to the one for the single choice ones - however that does require a bool result so as to know whether to try another one - but that can be ignored for the single choice ones.

If I had been aware of it at the time the (QStringList) cTelnet::messageStack would also have been a QQueue<QString> I guess...

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 20, 2020

Sorry, I still only see it enqueing only 1 message at a time - either a success or a failure one. The queue's size is 1 item at most, ever. Am I missing something?

Copy link
Copy Markdown
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

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

Right, I see where it comes into play now 👍

Bur module loading went from something simple to a complex beast now with message queues and support for library alternatives - let's not move further than this. Remember that code can break and someone will have to fix it and not get frustrated by how complicated something that should have been so simple is...

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 20, 2020

If you do not have/or they cannot both be loaded lua-zip NOR luazip for example you will get the list of all the file names and other possibilities that were tried. They will be different for each luarock or however it could be packaged, like the lfs often comes from it's own system package. Therefore it is valid (and bloody useful when working on a different OS/System to normal) to see every possibility that was actually tried. In that case you will have thus have as many sets of error messages as there are alternatives. Try deleting both lua-zip and luazip rocks from your test system and see.

BTW I am just finding that there is merit in ensuring that your system environment defines LUA_PATH and LUA_CPATH to include your path for --local rocks in the user login process...

@SlySven SlySven merged commit c379ac1 into Mudlet:development Apr 20, 2020
@SlySven SlySven deleted the Refactor_allowAlteranativesForLuaLibrariesLoadedWithAllProfiles branch April 20, 2020 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants