FLTK logo

Re: [fltk.coredev] Understanding macOS build environments

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Understanding macOS build environments Albrecht Schlosser Mar 04, 2021  
 
On 3/3/21 5:46 PM Greg Ercolano wrote:

Q: If you are using Homebrew, what is your Homebrew install directory?
A: /opt/homebrew

    Ya, that's why I don't like homebrew; creating directories in root just seems wrong,     and I think in recent OS versions (Big Sur, Catalina), it's seriously frowned apon by the OS
     and actively prevented by having the root system mounted read only.

And that's why I *like* Homebrew; creating directories in /opt just seems right. ;-)

Well, /opt is well-defined in the "Filesystem Hierarchy Standard (FHS)" for years and used to store "Optional application software packages", see
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

It's a good way to separate different software packages like Homebrew, Fink, and MacPorts:

- Homebrew:  /opt/homebrew
- Fink:      /opt/sw
- MacPorts:  /opt/local

I do like specifically /opt/homebrew because it's a qualified name. /opt/sw is IMHO questionable but if no other package selects it, then it's fine. I don't like /opt/local though because "local" can be anything. /opt/macports would have been a *much* better decision.

Installing everything in /usr/local is likely to cause conflicts and one package install overwriting another package.

Specifically for my testing (as a FLTK developer, not a user!) I like the idea that I can switch development environments by just changing the PATH environment variable. I hope I can install MacPorts in parallel and switch between Homebrew and MacPorts as I like and need.

That's the theory, I need to install MacPorts before I can finally judge.

Note: I like Ninja (brew install ninja). It's much faster than "Unix Makefiles" particularly if only a few files were changed.

     'make -j 4' works so well, I've never needed anything faster myself.

     But I'm slow to replace old tools cause I hate learning new stuff..
     I need less things that get in the way of daily maintenance.

Sure, I understand. But once I got curious what that "Ninja" build system was and how fast it was said to be I tried it and I was convinced.

Here my suggestion (try yourself, it's simple):

On a Mac with homebrew: see above. On a Debian/Ubuntu based Linux system: `sudo apt install ninja-build' (note it's not 'ninja', that's something different).

With CMake: use the generator "Ninja" instead of "Unix Makefiles" (the latter is the default):

$ mkdir -p build/ninja
$ cd build/ninja
$ cmake -G Ninja ../..
$ cmake --build .

alternatively for the build step execute:

$ ninja

Advantages: ninja is super fast when determining what to build. If nothing is to do it's almost instantaneous. Try this with Makefiles instead and wait ...

Admittedly, it's /only/ a factor of 2.7 an my MacBook (0.168s vs 0.062s) but on a slower machine it's noticeable.

I like also that ninja writes the progress messages in one line, overwriting the count and message. Warnings and error messages are output clearly in one block, not intertwined with messages from unrelated build tasks, even in highly parallel builds (Ninja uses -j N like make, but the default is N == number or processors).

The only difference you need to know is to select -G Ninja and to run 'ninja' instead of 'make'.

Here's a log from my MacBook with a full FLTK build with shared libs ON:

$ time ninja clean
[1/1] Cleaning all built files...
Cleaning... 879 files.

real	0m0.131s
user	0m0.037s
sys	0m0.058s

$ time ninja
[735/735] Linking CXX executable bin/examples/howto-browser-with-icons.app/Contents/MacOS/howto-browser-with-icons

[ ^^^ no warnings: shows only the last message ]

real	0m13.300s
user	1m17.530s
sys	0m14.980s

$ time ninja
ninja: no work to do.

real	0m0.062s
user	0m0.033s
sys	0m0.027s

I generally find I have to do very little when setting up new macs to build FLTK other than installing Xcode.

Yes, that's the goal for all possible build environments. And as little setup as possible if you need to enable configure or CMake options.

Maybe I'm forgetting something. I think I've had to build git from source a few times, but I think it "comes with" these days.

git comes with the Xcode commandline tools but autoconf was not included. The only 'autoconf' on my system is from Homebrew.

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/690597b7-f9c8-8296-fabb-45576cab9f11%40online.de.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.