Bug 2975

Summary: Bake fails to find dependencies
Product: bake Reporter: Tommaso Pecorella <tommaso.pecorella>
Component: bakeAssignee: Daniel Camara <daniel.camara>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, tomh
Priority: P3    
Version: unspecified   
Hardware: Mac Intel   
OS: Mac OS   
Attachments: patch to try
New patch

Description Tommaso Pecorella 2018-08-22 07:59:14 UTC
This happens if you use brew (https://brew.sh/) instead of MacPorts.

This is an example.

- Install qt (brew install qt)
- Add qt to the compiler and linker:
    export PATH="/usr/local/opt/qt/bin:$PATH"
    export LDFLAGS="-L/usr/local/opt/qt/lib"
    export CPPFLAGS="-I/usr/local/opt/qt/include"
    PKG_CONFIG_PATH="/usr/local/opt/qt/lib/pkgconfig"
- Check that everything is there:
    tommy-pc:~ pecos$ find -L /usr/local/opt/qt/include -name qobject.h
    /usr/local/opt/qt/include/QtCore/qobject.h
    tommy-pc:~ pecos$ find -L /usr/local/opt/qt/include -name qapplication.h
    /usr/local/opt/qt/include/QtWidgets/qapplication.h
- ./bake.py show:
 > qt - Missing
   >> Didn't find: Qt (version 4 or 5); install it from packages, or download from https://info.qt.io/download-qt-for-application-development
   >> Try: "sudo port install qt", if you have sudo rights.

The test for file existence is done through Python, and I have no idea how to fix it. It's not a big issue (later on the compiler will find the includes), but it's annoying, and it could disable unnecessarily some modules.
Comment 1 Tom Henderson 2018-08-23 20:48:08 UTC
Created attachment 3163 [details]
patch to try
Comment 2 Tom Henderson 2018-08-23 20:48:55 UTC
patch is untested; a guess at what is needed for homebrew.
Comment 3 Tommaso Pecorella 2018-08-24 04:36:45 UTC
(In reply to Tom Henderson from comment #2)
> patch is untested; a guess at what is needed for homebrew.

Tested. Doesn't work.
It's like if it doesn't recurse through the subdirectories.
Comment 4 Tommaso Pecorella 2018-08-24 17:04:13 UTC
Created attachment 3164 [details]
New patch

I searched what the problem was, and I found out that MacOS (and brew) are symlinks lovers.

The [ugly and slow] solution is to follow the symlinks.
Note that activating the symlinks following makes the check way slower. Alas, it's the right thing to do.

The only downside is that following the symlinks is potentially dangerous. Citing the manual:

By default, walk() will not walk down into symbolic links that resolve to directories. Set followlinks to True to visit directories pointed to by symlinks, on systems that support them.

Note: Be aware that setting followlinks to True can lead to infinite recursion if a link points to a parent directory of itself. walk() does not keep track of the directories it visited already.
Comment 5 Tommaso Pecorella 2018-08-24 17:32:04 UTC
Sorry, in the patch there's a lot of space-related changes. My editor automatically "cleans" the code.
Blame Atom...
Comment 6 Tom Henderson 2018-08-24 20:30:04 UTC
I found it to be 2-3 times slower than before, so I configured it to only walk symlinks for MacOS.

Pushed in changeset 411:a9bc3124a563