memononen / nanovg

Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.
zlib License
5.18k stars 775 forks source link

Feature request - homebrew package #407

Open indianakernick opened 7 years ago

indianakernick commented 7 years ago

I've only been using NanoVG for about a week and I think it's awesome! Installing the library is easy but it's not as easy as letting a package manager install the library for me. If this library is no-longer being updated then there would be little benefit in creating a homebrew package because the user would only need to install the library once. Of course, this is your decision. I just think creating a homebrew package would be more convenient for the user.

claui commented 6 years ago

I wrote a first draft of a libnanovg Homebrew formula. It seems to work quite well so far.

You can try it out by downloading the file, cding to the folder, and then running:

brew install --HEAD libnanovg.rb

Before we can submit the formula to Homebrew, there are a few minor issues left to fix in nanovg:

@memononen I understand there is little incentive for you to add Homebrew support. I feel that Mac users are going to find the formula very convenient. Apart from the necessary up-front fixes listed above, a Homebrew formula will not cause the project any maintenance burden. It’s Homebrew contributors who are responsible for maintaining the formula, not you as the upstream project maintainer.

memononen commented 6 years ago

@claui thanks for taking the time to make this too easy for me :)

The library is intended to be included as source, so no shared library.

NanoVG itself does not need GLFW, but the examples need it. How does homebrew deal with libraries which have kind of the "library" part and demos in it?

I'm fine with the glfw3 vs glfw thing as long as I can make it work on my machine. I'm still hesitant to use homebrew. I have previously had annoying problems using it. I think the problem case was if I had to manually install something which was also available at homebrew, so things just got messed up big time. Maybe I could give it another go.

indianakernick commented 6 years ago

NanoVG itself does not need GLFW, but the examples need it. How does homebrew deal with libraries which have kind of the "library" part and demos in it?

By default, glfw is installed and the examples are built. If the --without-examples option is present, glfw is not installed and the examples are not built. Homebrew itself doesn't specifically handle libraries with examples in them. Formulae can just choose to build the examples if they want to. Specifically, the formula installs the examples in the libexec directory of the keg.

claui commented 6 years ago

@memononen What @Kerndog73 says is 100 % correct. In case you’re interested in a few more details:

Homebrew uses package-specific directories to install packages, e. g. /usr/local/Cellar/libnanovg/0.1 for nanovg.

As to organizing libs vs. examples, Homebrew provides standards for this. According to my formula (which aims to stick to those standards), Homebrew will install nanovg as follows:

/usr/local/Cellar/libnanovg/0.1/
    bin/
        example_fbo       ← Bash shims for libexec/bin/…
        …                 ← (nanovg-specific workaround; needed
                          ← because binaries rely on the cwd)

    include/
        nanovg.h
        …

    lib/
        libnanovg.a
        libnanovg.dylib

    libexec/
        bin/
            example_fbo   ← binaries
            …
        example/          ← example code; runtime resources
            …             ← (basically a copy of `example`)

    share/doc/libnanovg/
        LICENSE.txt
        README.md

As a post-install step, Homebrew will then create appropriate symlinks:

/usr/local/Cellar/libnanovg/0.1/
    bin/
        example_fbo       ← /usr/local/bin/example_fbo
        …                   …

    include/
        nanovg.h          ← /usr/local/include/nanovg.h
        …

    lib/
        libnanovg.a       ← /usr/local/lib/libnanovg.a
        libnanovg.dylib   ← …

    libexec/              ← By convention, Homebrew will not
        bin/                create symlinks to any of these.
            example_fbo
            …
        example/
            …

    share/doc/libnanovg/  ← /usr/local/share/doc/libnanovg/
        LICENSE.txt
        README.md
claui commented 6 years ago

The library is intended to be included as source

@memononen By as source, are you referring to e. g. nanovg.c? Where exactly would you want the source file included?

so no shared library

That’s fine. I was suggesting a dylib option mainly because I’ve seen instances of nanovg used as a dylib in the wild. Of course I respect your choice to not offer a shared library build.

Just to understand your words 100 % correctly: you are not willing to accept a PR based on this patch, correct? (Just asking because I’ve been preparing that exact PR.)