Bug 456452

Summary: Craft blueprint qtbase fails to build on macOS when using the Qt Patch Collection
Product: [Unmaintained] Craft Reporter: Javier O. Cordero Pérez (Cuperino) <javiercorderoperez>
Component: BlueprintsAssignee: Hannah von Reth <vonreth>
Status: RESOLVED FIXED    
Severity: normal CC: julius.kuenzel, kde-windows
Priority: NOR    
Version: stable   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Javier O. Cordero Pérez (Cuperino) 2022-07-07 14:58:06 UTC
SUMMARY
qtbase blueprint fails to build on macOS when libs/qt5 version is set to kde/5.15. 

STEPS TO REPRODUCE
1. Create and start a new Craft environment on an x86_64 system that runs macOS:
> curl https://raw.githubusercontent.com/KDE/craft/master/setup/CraftBootstrap.py -o setup.py && python3 setup.py --prefix ~/CraftRoot
> source /Users/javier/CraftRoot/craft/craftenv.sh
2. Configure Craft to use KDE's Qt Patch Collection
> craft --set version=kde/5.15 libs/qt5
3. Build qtbase
> craft libs/qt5/qtbase

OBSERVED RESULT
The Patch Collection's version fails to evaluate correctly in the following lines:
>128            if self.qtVer >= "5.14":
>129                mac_required = "10.13"
>130            elif self.qtVer >= "5.12":
>131                mac_required = "10.12"

Resulting in mac_required being undefined when accessed in line 132:
>132            if not CraftVersion(os.environ["MACOSX_DEPLOYMENT_TARGET"]) >= mac_required:

EXPECTED RESULT
1. self.qtVer should be sanitized, such that self.qtVer >= "5.14" holds true for kde/5.15.
2. An else condition is set, preventing mac_required from ever being undefined.

SOFTWARE/OS VERSIONS
macOS: Big Sur 11.6 (x86_64)
Qt Version: 5.15.5 kde-patched
Comment 1 Javier O. Cordero Pérez (Cuperino) 2022-07-07 15:17:07 UTC
Craft blueprint qtbase fails to build on macOS when using the Qt Patch Collection (continuation)

STEPS TO REPRODUCE
1. Fix or work around the bug stated in my previous comment.
2. Repeat the same steps to reproduce as in my previous comment.

OBSERVED RESULT
Compilation fails because of a command line option that is no longer valid:
> Creating qmake...
> Done.
> Info: creating cache file /Users/javier/CraftRoot/build/libs/qt5/qtbase/work/build/.qmake.cache
> ERROR: Unknown command line option '-macos-additional-datadirs'.
> Action: compile for libs/qt5/qtbase:kde/5.15 FAILED

Error lies at libs/qt5/qtbase lines:
>189            if CraftCore.compiler.isMacOS:
>190                command += f"-macos-additional-datadirs \"{CraftCore.standardDirs.locations.data}\" "

Removing those lines results in a successful build for me, but I don't know if doing so is a good idea.

EXPECTED RESULT
libs/qt5/qtbase builds successfully

SOFTWARE/OS VERSIONS
macOS: Big Sur 11.6 (x86_64)
Qt Version: 5.15.5 kde-patched
Comment 2 Julius Künzel 2024-03-16 18:47:06 UTC
We are using the patch collection again and the build succeeds on macOS now