Code Monkey home page Code Monkey logo

Comments (26)

cody271 avatar cody271 commented on June 2, 2024 1

The easiest way to do this is for libui-ng to release binary files for the various platforms, and LibUI to include them in the gem.

ARM builds is definitely a priority, at least for macOS and Linux. See issue here

from libui.

AndyObtiva avatar AndyObtiva commented on June 2, 2024 1

The instructions worked (on Mac ARM64)!

Screen Shot 2022-02-20 at 11 24 32 AM

Just a few minor modifications to the instructions:

git clone https://github.com/kojix2/LibUI
cd LibUI
git fetch
git checkout andlabs
bundle
rake -T
rake vendor:mac_arm
bundle exec ruby examples/control_gallery.rb

By the way, I also tested the instructions on my Mac x86_64, and they worked too (using the vendor:mac_arm)!

from libui.

cody271 avatar cody271 commented on June 2, 2024 1

I think I closed this issue too soon forgetting arm64 on Linux, aka aarch64. I am re-opening due to this new issue in glimmer-dsl-libui:

AndyObtiva/glimmer-dsl-libui#23

We now have an official Linux package that supports both ARM and x86, at least on Arch:

$ yay -S libui-ng-git

from libui.

cody271 avatar cody271 commented on June 2, 2024 1

@kojix2 Try this: master/macOS-x64-shared-debug.zip

from libui.

cody271 avatar cody271 commented on June 2, 2024 1

It would be even better if a shared library for Windows were available :)

Absolutely. Improvements to the Windows CI builds are in progress, see PR here.

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

I didn't know that LibUI doesn't work on new Macs
I rented an Apple silicon server on Macincloud and confirmed that I do indeed get the above error.

git clone https://github.com/kojix2/LibUI
cd LibUI
bundle
bundle exec rake vendor:mac_x64
bundle exec rake test # ERROR

However, after compiling libui-ng from source code and creating a shared library, the error no longer occurred.

git clone https://github.com/libui-ng/libui-ng
cd libui-ng
meson setup build
ninja -C build

Copy the created shared library libui.A.dylib to vendor directory.
Don't forget to rename the file to remove A.

cp libui-ng/build/meson-out/libui.A.dylib LibUI/vendor/libui.dylib

Then run

bundle exec rake test

The test will now pass.

glimmer-dsl-libui works in a similar way. (Replaced vendor/bundle/ruby/3.0.0/gems/libui-0.0.13/vendor/libui.dylib.)

image

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

Of course, we don't want to go to all this trouble.
LibUI should work on various platforms just by installing the gem.

The easiest way to do this is for libui-ng to release binary files for the various platforms, and LibUI to include them in the gem.

This is an issue for the future.

from libui.

rubyFeedback avatar rubyFeedback commented on June 2, 2024

Having libui work EVERYWHERE would be pretty cool - imagine people using arduino + libui + mruby. :D

Hopefully libui-ng can improve stuff there.

kojix2 wrote:

LibUI should work on various platforms just by installing the gem.

I think so too. That's by far LibUI's most compelling advantage - you just "gem install" it. Imagine if we could
do this for ruby-gtk on windows too ... (I kind of gave up trying to compile the gtk stack on windows ... on
linux it works very well though).

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

Another practical way to include shared files for various platforms in your Gem is to automatically build LibUI when you install the Gem. You may think of a C-extended Gem, but it is also possible to do this with FFI.

For example, ruby-minimap2 does this; it uses FFI, but compiles minimap2 at installation time.

The method is as follows
First, place minimap2 (or libui) as a Git submodule in the ext directory, and write a build task as the default task in the Rakefile. Next, write in gemspec.

spec.extensions = %w[ext/Rakefile]`

This will fire the build task at installation time.

It looks good.

However, I think this method may not work as expected with LibUI, because LibUI compilation depends on meson and ninja. In contrast, all you need to build minimap2 is make, and unlike make and cc, meson and ninja are not supposed to be installed in all environments. There are a few people in my office who use Macs, but they are not programmers, so they do not install these tools. It is quite possible that they have Microsoft Office installed, but not Homebrew or MacPorts.

So I guess it might be practical to prepare binary files for major platforms and build libui from source code for minor environments. I don't want to put a lot of binary files and libui code in LibUI. From the user's point of view, binary files that are not used in their environment are just a waste of disk space. I want libui to be a small gem.

Another option would be to release a new gem to build LibUI at installation time (e.g. libui-build), or simply add a task to the Rakefile to help build libui. It is also possible to add a task to build libui using only make or cc, without relying on meson or ninja. However, this may be difficult to maintain for me.

from libui.

AndyObtiva avatar AndyObtiva commented on June 2, 2024

@kojix2 it would be cool if you could make one more release with the andlabs libui that includes binaries for ARM64 on Mac and AARCH64 on Linux before you consider moving to libui-ng going forward. Sorry, I didn't mention this before your just released 0.0.14 (I did not expect you to make that release). Maybe you could push libui-ng changes to a temporary branch while you make one more release for ARM64/AARCH64 with andlabs libui and then bring the libui-ng changes back when it is a good time.

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

@AndyObtiva
I admit that the fact that LibUI does not support M1 is not a small problem. However, I don't know the best practices for making fat gems compatible with both Intel64-based and ARM64-based Macintosh computers.

  • In v0.0.14, three binary files (one for Windows, one for Mac, and one for Linux) are packed in the vendor directory, the same way ankane is doing it.

  • Nokogiri provides a different gem for each platform.

nokogiri (1.13.1 ruby aarch64-linux arm64-darwin java x64-mingw-ucrt x64-mingw32 x86-linux x86-mingw32 x86_64-darwin x86_64-linux, 1.6.1 x86-mswin32-60, 1.4.4.1 x86-mswin32)

  • My personal mentor, kou, don't like fat gems. He used to create ruby-gnome as a fat gem, but now he thinks it is a best practice to avoid using fat gems.

Probably v0.0.14 will be alive for a long time, so a workaround is needed. The easiest way I can think of is to compile libui in my macincloud and include it in the vendor directory. When I have time, I will see if this will work. And hopefully I will be able to release a new gem.

However, even if I can find a way to manually create binaries in Macincloud, it's just a workaround. cody said "GitHub Actions are x86 only...". I think this is the real bottleneck.

So we need to support libui-ng and find a way to deploy with less pain.

If there are any skilled...or not-so-skilled, Mac users watching this thread, please consider whether you can contribute to the continuous deployment of libui-ng...

from libui.

AndyObtiva avatar AndyObtiva commented on June 2, 2024

I can give you a few tips since I had to support arm64 recently in Glimmer DSL for SWT, which is a sort of a JRuby fat gem (includes Java JAR files within).

I use the OS gem that senses what platform the user is on and outputs x86_64 or arm64, and based on that, I activate the SWT Mac libraries for x86_64 or arm64, both of which are included in the glimmer-dsl-swt gem.

In fact, you don't need the OS gem (that's just an extra convenience). If you run this command, you can do the same thing:

uname -m

It returns arm64 or x86_64 depending on the system. You would sense that in addition to the other variable that is the platform of Mac, Windows, or Linux (which is easy to detect in Ruby as far as I know):

RbConfig::CONFIG['host_os']

You can also sense the architecture using RbConfig now that I am thinking about it (probably simpler than shelling out with the uname command):

RbConfig::CONFIG['host_cpu'] # returns "arm64" on Mac ARM64 and "x86_64" on Mac x86_64

Adding Mac ARM64 in a release to start (without Linux AARCH64) is a great idea! That way, you break the problem down bit by bit instead of tackling everything at once.

However, even if I can find a way to manually create binaries in Macincloud, it's just a workaround.

A workaround is better than nothing for the short term. I have a Mac ARM64 machine I can verify your workaround on.

We'll cross the libui-ng bridge when we get to it. But, I think given that you can compile the andlabs libui on a Macincloud machine, if that works successfully, it would be a big win for the time being until libui-ng makes a release (still has no release yet, so it is too early to support).

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

I created libui.dylib in universal binary format and uploaded it to the v0.0.14 release page.

This libui.dylib is a simple merge of the official dylib distributed by andlabs with the dylib compiled on MacinCloud M1 Mac server.

compilation:

git clone https://github.com/andlabs/libui
git checkout alpha4.1
mkdir -p release
cd release
cmake -DCMAKE_BUILD_TYPE=Release ..
make

merge:

lipo -create libui.x86_64.dylib libui.arm64.dylib -output libui.dylib

More precisely I have created a new universal shared library by adding new binary files to the original binary files distributed by andlabs. I believe this is a permitted activity under the MIT license. However, those who take the position that the word "software" in the MIT license means purely source code may find problems with editing and redistribution of binary files.

Finally, I added a task to the Rakefile to download the shared library for this M1 Mac.

(While working on a Mac, I noticed that when I call UI.init, I get an error message. However, I don't think this has anything to do with the new libui.dylib, because it happens with the current version of the gem. )

@AndyObtiva

A workaround is better than nothing for the short term. I have a Mac ARM64 machine I can verify your workaround on.

Thanks.
You can try it with the command below.

git clone https://github.com/kojix2/LibUI
git fetch
git checkout andlabs
rake -T
rake vendor:mac_arm
bundle
bundle exec ruby examples/control_gallery.rb

This is my first attempt to create and distribute software in binary format. I'm not sure if it will really work, so I'm not going to release it for a while and see how it goes. Please give it a try if you like.

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

I have released v0.0.15.pre so that you don't have to use the rake task to fetch the shared library.
https://github.com/kojix2/LibUI/releases/tag/v0.0.15.pre

gem install libui --pre

If no one reports a bug, I'll upload it to rubygem as v0.0.15 next weekend or the weekend after.

from libui.

AndyObtiva avatar AndyObtiva commented on June 2, 2024

I just tested 0.0.15.pre, and it worked on both Mac arm64 and Mac x86_64. It also worked on Windows 10 and Linux.

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

@AndyObtiva
Released v0.0.15. Thanks for the report and your strong support!!

from libui.

AndyObtiva avatar AndyObtiva commented on June 2, 2024

That's excellent news!!!

I just upgraded the required libui version in glimmer-dsl-libui to 0.0.15 and released v0.5.5:
https://github.com/AndyObtiva/glimmer-dsl-libui/tree/v0.5.5

Cheers!

from libui.

AndyObtiva avatar AndyObtiva commented on June 2, 2024

I think I closed this issue too soon forgetting arm64 on Linux, aka aarch64. I am re-opening due to this new issue in glimmer-dsl-libui:

AndyObtiva/glimmer-dsl-libui#23

from libui.

cody271 avatar cody271 commented on June 2, 2024

CI now builds for ARM and x86 on macOS, so you could use the prebuilt binaries from here.

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

Thank you @cody271.
Now I can use the latest pre-built binaries.

It would be better if the github actions Artifact data were persistent and there were URLs that will always download the latest build.

from libui.

cody271 avatar cody271 commented on June 2, 2024

Thank you @cody271. Now I can use the latest pre-built binaries.

It would be better if the github actions Artifact data were persistent and there were URLs that will always download the latest build.

This isn't supported by the API for GitHub Actions CI unfortunately..

from libui.

cody271 avatar cody271 commented on June 2, 2024

There are a few workarounds out there though, I am investigating which is best.

from libui.

kojix2 avatar kojix2 commented on June 2, 2024

@cody271

Thanks.
I just added a rake task that allow you to download development builds for Mac and Ubuntu from the links you provided.
Now it is very easy to try out the development version of libui-ng.
It would be even better if a shared library for Windows were available :)

from libui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.