build/macos: Build GIMP with MacPorts targeting macOS 11 on our CI

We still need to implement cache and better timeouts in the future.

(cherry picked from commit 962291dbb7)
This commit is contained in:
Bruno Lopes 2026-01-13 09:28:01 -03:00
parent d09747589d
commit 8ea18cd908
5 changed files with 54 additions and 14 deletions

View file

@ -647,7 +647,7 @@ gimp-win-eol:
artifacts: !reference [gimp-win, artifacts]
## macOS pipelines (Homebrew) ##
## macOS pipelines (MacPorts) ##
.macos-inhouse:
extends: .default
rules:
@ -658,13 +658,13 @@ gimp-win-eol:
- macos
variables:
#FIXME: Our runner #926 (by MacStadium) do not have cache nor timeout for MacPorts builds
OPT_PREFIX: /opt/homebrew
OPT_PREFIX: /opt/macports
PKGCONF_RELOCATABLE_OPTION: '-Dpkgconfig.relocatable=true'
DMG_OPTION: '-Ddmg=true'
before_script:
- export GIMP_PREFIX="$PWD/_install-$(uname -m)"
- export PATH="$OPT_PREFIX/bin:$PATH"
timeout: 30m
timeout: 150m
.macos_environ: &MAC_ENVIRON
- printf "\e[0Ksection_start:`date +%s`:macos_environ[collapsed=true]\r\e[0KPreparing build environment\n"
@ -676,14 +676,39 @@ gimp-win-eol:
- export GI_TYPELIB_PATH="${GIMP_PREFIX}/lib/girepository-1.0:${OPT_PREFIX}/lib/girepository-1.0"
- printf "\e[0Ksection_end:`date +%s`:macos_environ\r\e[0K\n"
deps-macos-inhouse-part1:
extends: .macos-inhouse
stage: dependencies
script:
# Do not call sh since it is old bash on macOS, not the default zsh
- zsh build/macos/1_build-deps-macports.sh --part1
artifacts:
paths:
- macports.tar.gz
expire_in: 2 hours
deps-macos-inhouse-part2:
extends: .macos-inhouse
needs: ["deps-macos-inhouse-part1"]
stage: dependencies
script:
# Do not call sh since it is old bash on macOS, not the default zsh
- zsh build/macos/1_build-deps-macports.sh --part2
artifacts:
paths:
- macports.tar.gz
expire_in: 2 hours
deps-macos-inhouse:
extends: .macos-inhouse
needs: ["deps-macos-inhouse-part2"]
stage: dependencies
script:
# Do not call sh since it is old bash on macOS, not the default zsh
- zsh build/macos/1_build-deps-macports.sh
artifacts:
paths:
- macports.tar.gz
- _install-*
# The full build dir is needed due to its .o for .dSYM creation on next job
- babl/_build-*

View file

@ -28,15 +28,31 @@ if [ -z "$OPT_PREFIX" ]; then
exit 1
fi
fi
export MACOSX_DEPLOYMENT_TARGET=$(awk '/LSMinimumSystemVersion/{found=1} found && /<string>/{gsub(/.*<string>|<\/string>.*/, ""); print; exit}' build/macos/Info.plist)
if [ "$OPT_PREFIX" != '/opt/local' ] && [ "$OPT_PREFIX" != '/opt/homebrew' ]; then
echo "macosx_deployment_target ${MACOSX_DEPLOYMENT_TARGET}" | tee -a ${OPT_PREFIX}/etc/macports/macports.conf >/dev/null 2>&1 || true
sed -i .bak "s/^#build_arch.*/build_arch $(uname -m)/" "${OPT_PREFIX}/etc/macports/macports.conf" >/dev/null 2>&1 || true
fi
export MACOSX_DEPLOYMENT_TARGET=$(awk '/LSMinimumSystemVersion/{found=1} found && /<string>/{gsub(/.*<string>|<\/string>.*/, ""); print; exit}' build/macos/Info.plist) #End of config
fi #End of config
printf "\e[0Ksection_start:`date +%s`:deps_install[collapsed=true]\r\e[0KInstalling dependencies provided by $( [ -f "$OPT_PREFIX/bin/port" ] && echo MacPorts || echo Homebrew )\n"
if [ -f "$OPT_PREFIX/bin/port" ]; then
eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port sync && eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port upgrade outdated
eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port install -N $(grep -v '^#' build/macos/all-deps-uni.txt | sed 's/|homebrew:[^ ]*//g' | tr -d '\' | xargs)
if [ -f 'macports.tar.gz' ]; then
bsdtar xf macports.tar.gz -C / || true
fi
if [ "$1" = '--part1' ]; then
eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port install -N $(grep -v '^#' build/macos/all-deps-uni.txt | sed 's/|homebrew:[^ ]*//g' | tr -d '\' | awk '{print} /vala/{exit}' | xargs)
elif [ "$1" = '--part2' ]; then
eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port install -N $(grep -v '^#' build/macos/all-deps-uni.txt | sed 's/|homebrew:[^ ]*//g' | tr -d '\' | awk '{print} /appstream/{exit}' | xargs)
else
eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port install -N $(grep -v '^#' build/macos/all-deps-uni.txt | sed 's/|homebrew:[^ ]*//g' | tr -d '\' | xargs)
fi
if echo "$CI_JOB_NAME" | grep -q 'deps'; then
bsdtar -cf macports.tar.gz --gzip "$OPT_PREFIX" || true
fi
if echo "$1" | grep -q 'part'; then
exit 0
fi
git apply -v build/macos/patches/0001-meson-Patch-python-version.patch || true
else
brew upgrade --quiet

View file

@ -257,10 +257,10 @@ bundle(GIMP_PREFIX, "lib/girepository-*/*.typelib")
bundle(OPT_PREFIX, "lib/libgirepository-*.dylib")
#### Python support
bundle(OPT_PREFIX, f"bin/python{os.getenv('PYTHON_VERSION')}", "--rename", "MacOS/python3")
if os.path.exists(OPT_PREFIX / "bin/port"):
bundle(OPT_PREFIX, f"Library/Frameworks/Python.framework/Versions/{os.getenv('PYTHON_VERSION')}", "--dest", "Frameworks/Python.framework/Versions")
else: #os.path.exists(OPT_PREFIX / "bin/brew"):
if os.path.exists(OPT_PREFIX / "bin/brew") or (os.path.exists(OPT_PREFIX / "bin/port") and os.getenv('GITLAB_CI')):
bundle(OPT_PREFIX, f"Frameworks/Python.framework/Versions/{os.getenv('PYTHON_VERSION')}", "--dest", "Frameworks/Python.framework/Versions")
elif os.path.exists(OPT_PREFIX / "bin/port"):
bundle(OPT_PREFIX, f"Library/Frameworks/Python.framework/Versions/{os.getenv('PYTHON_VERSION')}", "--dest", "Frameworks/Python.framework/Versions")
bundle(OPT_PREFIX, f"lib/python{os.getenv('PYTHON_VERSION')}/site-packages/*", "--dest", f"Frameworks/Python.framework/Versions/{os.getenv('PYTHON_VERSION')}/lib/python{os.getenv('PYTHON_VERSION')}/site-packages")
clean(GIMP_DISTRIB, "Frameworks/Python.framework/*.pyc")
#####Needed for internet connection on python. See: https://gitlab.gnome.org/GNOME/gimp/-/issues/14722
@ -318,7 +318,7 @@ for dir in ["MacOS", "Frameworks"]:
subprocess.run(["dsymutil", binary, "-o", f"{binary}.dSYM"], check=True, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError as e:
sys.stderr.write(f"Failed to generate debug symbols from {binary}: {e}\n")
elif "unable to open object file" in result.stdout + result.stderr and not os.getenv("OPT_PREFIX") in result.stdout + result.stderr:
elif "unable to open object file" in result.stdout + result.stderr and not os.getenv("OPT_PREFIX") in result.stdout + result.stderr and "Python.framework" not in str(binary):
print(f"\n\033[31m(ERROR)\033[0m: {binary} is orphaned from .o file for .dSYM generation. Please make sure its build dir is present")
sys.exit(1)

View file

@ -32,7 +32,7 @@
<string>public.app-category.photography</string>
<!--keep LSMinimumSystemVersion consistent with devel-docs/os-support.txt-->
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<string>11.0</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSRequiresAquaSystemAppearance</key>

View file

@ -1,7 +1,6 @@
## Note about macOS build situation
These macOS build files on GIMP repo do not fully support older macOS yet.
You can use them only the latest 3 versions of macOS.
These build files on GIMP repo are the recommended to build on macOS.
The build files for older macOS are in: [gimp-macos-build]
The legacy build files are in: [gimp-macos-build]
(https://gitlab.gnome.org/Infrastructure/gimp-macos-build) repo.