Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Role of extlibs in build  (Read 4491 times)

0 Members and 1 Guest are viewing this topic.

Anonymouseable

  • Newbie
  • *
  • Posts: 14
    • View Profile
Role of extlibs in build
« on: July 02, 2013, 05:15:26 pm »
Hi,

I've been working on writing a homebrew formula for SFML, and am slightly perplexed as to why/how the extlibs are necessary. Why not install them separately?

Anyway, in this scenario, I see 2 options:
  • Use the extlibs (though to my knowledge homebrew doesn't provide any mechanisms or standards for installing frameworks, which would make this a sub-optimal solution)
  • To specify freetype, sndfile, GLEW and jpeg as dependencies of SFML in the formula. This would mean that if other homebrew formulae depending on these libraries are installed, they wouldn't have to be installed in double. However, it would not install the frameworks for these libraries, and I don't know how that will play along with using SFML in XCode.
Which of these would be preferable, or can anyone propose another alternative?

Thanks in advance.

EDIT:
Quote from: Homebrew website
Homebrew won’t install files outside its prefix, and you can place a Homebrew installation wherever you like.
I can't break this convention if I want the formula to get included in the main Homebrew repository, so seeing as Mac OS doesn't search /usr/local/ for frameworks (right? correct me if I'm wrong) installing frameworks from a homebrew formula isn't really a possibility/desirable functionality.
« Last Edit: July 02, 2013, 05:22:01 pm by Anonymouseable »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: Role of extlibs in build
« Reply #1 on: July 02, 2013, 05:42:15 pm »
I'm not experienced with OS X at all, but it applies to all the different OS.
The short answer is: convenience.
The long one, if you have precompiled versions of SFML, you have to make sure, that the external libraries which SFML links to are always of the same version. So while the current version might match the other libraries, it might not be the case in the future, so someone will have to maintain the repository of SFML. By providing fixed external libraries, it's guaranteed that it will work no matter what and the user won't have to manually install and maybe compile the other libraries.

If Homebrew can work against the problem of incompatibility you might just use the external libraries from there.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Role of extlibs in build
« Reply #2 on: July 02, 2013, 08:20:35 pm »
For reference, here is some work done to create a Formula for Homebrew with a beginning of discussion: https://github.com/mxcl/homebrew/pull/20765

Currently, I'm not sure how to approach this issue. I'm not experienced enough with Homebrew, I guess. But it would really be nice to make `brew install sfml` possible. :)

In the discussion on github I mentioned, vaguely, the possibility to use a special patch to build SFML from brew. I don't know exactly how the patching system works with brew but I've seen it with vim formula, I think. But here are a (non-exhaustive) list of issues that need to be addressed with such patch:

  • Xcode templates needs sndfile.framework, freetype.framework and SFML frameworks in /Library/Frameworks/. If they are saved in another location, such as /usr/local/somewhere, that's not an issue as long as this location is fixed and can be determined when installing the templates. I can create a patch for the current template to do that quite easily.
  • Xcode templates needs sndfile.framework and freetype.framework. This is because the shell script used by the templates expect frameworks. But a patch can easily be written to use dylibs instead of frameworks.
  • Xcode templates need to be installed in /Library/Developer/Xcode/Templates/. You mentioned that brew won't install anything outside its prefix. This can be worked around with some linking, I think. I've seen some formulae installing application to ~/Applications.
  • Theoretically, custom version of extlibs can be used to compile SFML when configuring properly CMake. I haven't tested it though. But, as eXpl0it3r said, it would be easier to use brew version of these external libs.
  • If SFML is compiled as frameworks, but are not installed in /Library/Frameworks, and cannot be linked there, I can patch the Xcode templates and make sure the compiler will look for them in the right place.
SFML / OS X developer

Anonymouseable

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Role of extlibs in build
« Reply #3 on: July 03, 2013, 12:07:30 am »
For reference, here is some work done to create a Formula for Homebrew with a beginning of discussion: https://github.com/mxcl/homebrew/pull/20765
Yes, that was me (see the similar name? ;) )
Having messed up quite a bit in the pull request and whatnot, I'm starting the formula anew. This is why I actually created this thread.

Currently, I'm not sure how to approach this issue. I'm not experienced enough with Homebrew, I guess. But it would really be nice to make `brew install sfml` possible. :)

In the discussion on github I mentioned, vaguely, the possibility to use a special patch to build SFML from brew. I don't know exactly how the patching system works with brew but I've seen it with vim formula, I think. But here are a (non-exhaustive) list of issues that need to be addressed with such patch:

  • Xcode templates needs sndfile.framework, freetype.framework and SFML frameworks in /Library/Frameworks/. If they are saved in another location, such as /usr/local/somewhere, that's not an issue as long as this location is fixed and can be determined when installing the templates. I can create a patch for the current template to do that quite easily.
  • Xcode templates needs sndfile.framework and freetype.framework. This is because the shell script used by the templates expect frameworks. But a patch can easily be written to use dylibs instead of frameworks.
  • Xcode templates need to be installed in /Library/Developer/Xcode/Templates/. You mentioned that brew won't install anything outside its prefix. This can be worked around with some linking, I think. I've seen some formulae installing application to ~/Applications.
  • Theoretically, custom version of extlibs can be used to compile SFML when configuring properly CMake. I haven't tested it though. But, as eXpl0it3r said, it would be easier to use brew version of these external libs.
  • If SFML is compiled as frameworks, but are not installed in /Library/Frameworks, and cannot be linked there, I can patch the Xcode templates and make sure the compiler will look for them in the right place.
You participated in the discussion on github? Are you mantognini?
So, now for addressing these...

  • I think the best/neatest/correct way to do this would be to have a templated template* where CMake replaces the strings appropriate to generate the working XCode project template. Then we could install the frameworks to an arbitrary location, like /usr/local/Library/ (assuming the default brew prefix, /usr/local).
  • If we do the above that should fix this issue too.
  • That seems like an ugly way of doing it to me - the point isn't that brew cannot install outside its prefix, but should not.
  • Using the brew versions makes the most sense to me, seeing the reason why they were included with SFML in the first place (thanks eXpl0it3r).
  • See 1.

*

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Role of extlibs in build
« Reply #4 on: July 03, 2013, 09:13:24 pm »
Yep, that was me on github.

  • Exactly. That's what I had in mind. The output folder for frameworks can be set with CMAKE_INSTALL_FRAMEWORK_PREFIX and then I can use cmake to generate the appropriate Xcode template. I haven't done so yet mostly because those templates are already hard to code and install. But I guess it won't kill anybody if I had this little bit of complexity after all.
  • Exactly.
  • Alternatively, instead of having an option to install the templates, the forumla can install them in Homebrew's Cellar and if the user wants them he can link them to /Library/Developer/Xcode/Templates/.
  • Yes, we just need to test that and see if SFML compiles fine with them.

If you're stuck at any point with the formula let me know.
SFML / OS X developer

Anonymouseable

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Role of extlibs in build
« Reply #5 on: July 10, 2013, 07:07:44 pm »
So I've finally had some time to look at it (been busy, moving to a different country and whatnot).

Homebrew simply doesn't seem to be framework-friendly enough. The freetype and sndfile formulae both don't support building/installing frameworks. This leaves us with three options (as far as I can tell):
  • Use the extlibs (ugly)
  • Modify freetype and sndfile formulae (probably not a good option because so many other formulae depend on them and I'm not sure everyone really wants them to change)
  • Drop framework support; modify the XCode templates to use dylibs; (this seems the nicest option to me; Any input on this?)
None of these are great, but homebrew simply doesn't have any in-house support or standardisation for frameworks so to me it seems nicer to just leave them out completely.


EDIT: I've done option 3, having added an option in the SFML CMakeLists that allows the user to decide not to use the extlibs. I've put it in a patch which I've included in the formula as well as submitting a pull request for this option at the SFML github repo. I'll wait for some input on the whole thing before making a pull request to homebrew; meanwhile you can check it out on the appropriate branch in my fork of homebrew.
« Last Edit: July 10, 2013, 08:14:03 pm by Anonymouseable »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Role of extlibs in build
« Reply #6 on: July 10, 2013, 11:48:19 pm »
Not sure what you exactly mean by «drop framework support» so here is how I would do it (maybe it's what you have in mind but for the sake of clarity..):

since the Xcode templates already supports dylibs for SFML, and because it is relatively simple to modify them to import sndfile and freetype as dylibs to the built bundle application, we can keep the framework support for manual compilation and only use dylib compilation with the brew formula.
SFML / OS X developer

Anonymouseable

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Role of extlibs in build
« Reply #7 on: July 11, 2013, 12:11:08 am »
Yes, that's what I meant - not supporting frameworks from the homebrew formula at all.

Also my patch that allows choosing not to use the extlibs seems to be generating quite some controversy... *sigh* I guess I'll just include it in the formula.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Role of extlibs in build
« Reply #8 on: July 11, 2013, 12:02:37 pm »
Quote
I guess I'll just include it in the formula.
I don't think it's a good idea: the patch can become invalid if we edit some files on the git.

Plus, having this discussion is quite important to find the best way to do it.
SFML / OS X developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Role of extlibs in build
« Reply #9 on: July 11, 2013, 12:34:33 pm »
There is something we haven't discussed yet.

What about older OS version? I fear that using homebrew to build SFML for older OS version (say, 10.5 since we currently support it) won't be possible.

One other thing: what happen when SFML if build & installed with freetype x.y and then freetype is upgraded to x.z or v.w without rebuilding SFML? That may introduced some incompatibility, or am I wrong?
« Last Edit: July 11, 2013, 12:53:15 pm by Hiura »
SFML / OS X developer

Anonymouseable

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Role of extlibs in build
« Reply #10 on: July 15, 2013, 11:34:28 pm »
There is something we haven't discussed yet.

What about older OS version? I fear that using homebrew to build SFML for older OS version (say, 10.5 since we currently support it) won't be possible.

One other thing: what happen when SFML if build & installed with freetype x.y and then freetype is upgraded to x.z or v.w without rebuilding SFML? That may introduced some incompatibility, or am I wrong?
I'm not sure. We'd have to test it. I need to ask my dad if he has some OS 10.5 installation media, if he does I can test it in a VM.

The other thing: I'm also not sure. I think they should be compatible.