2021-05-02 21:43:25 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2024-05-01 22:48:28 +08:00
|
|
|
if [ -z "$GITLAB_CI" ]; then
|
2024-02-18 02:03:38 +08:00
|
|
|
# Make the script work locally
|
2024-07-23 23:41:35 +08:00
|
|
|
if [ "$0" != 'build/windows/2_build-gimp-msys2.sh' ] && [ ${PWD/*\//} != 'windows' ]; then
|
|
|
|
echo -e '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, read: https://developer.gimp.org/core/setup/build/windows/'
|
2024-02-18 02:03:38 +08:00
|
|
|
exit 1
|
2024-07-23 23:41:35 +08:00
|
|
|
elif [ ${PWD/*\//} = 'windows' ]; then
|
|
|
|
cd ../..
|
2023-12-17 08:22:21 +08:00
|
|
|
fi
|
2024-04-06 20:38:22 +08:00
|
|
|
git submodule update --init --force
|
2023-12-17 08:22:21 +08:00
|
|
|
fi
|
2021-05-15 02:27:33 +08:00
|
|
|
|
2024-08-21 03:02:23 +08:00
|
|
|
if [ "$MSYSTEM_CARCH" = "i686" ]; then
|
|
|
|
echo -e "\033[33m(WARNING)\033[0m: 32-bit builds will be dropped in a future release. See: https://gitlab.gnome.org/GNOME/gimp/-/issues/10922"
|
|
|
|
fi
|
|
|
|
|
2021-05-02 21:43:25 +08:00
|
|
|
|
2024-07-20 05:31:50 +08:00
|
|
|
if [ "$GITLAB_CI" ]; then
|
|
|
|
# Install the required (pre-built) packages for GIMP again
|
|
|
|
# We take code from deps script to better maintenance
|
|
|
|
echo "$(cat build/windows/1_build-deps-msys2.sh |
|
|
|
|
sed -n '/# Beginning of install/,/# End of install/p')" | bash
|
|
|
|
fi
|
2021-05-02 21:43:25 +08:00
|
|
|
|
2024-02-17 20:17:30 +08:00
|
|
|
|
2024-07-20 08:43:45 +08:00
|
|
|
# Prepare env
|
|
|
|
## We need to create the condition this ugly way to not break CI
|
2024-06-20 18:00:32 +08:00
|
|
|
if [ "$GITLAB_CI" ]; then
|
2024-07-20 06:54:58 +08:00
|
|
|
export GIMP_PREFIX="$PWD/_install"
|
2024-06-20 18:00:32 +08:00
|
|
|
elif [ -z "$GITLAB_CI" ] && [ -z "$GIMP_PREFIX" ]; then
|
2024-07-20 06:54:58 +08:00
|
|
|
export GIMP_PREFIX="$PWD/../_install"
|
2024-06-20 18:00:32 +08:00
|
|
|
fi
|
2024-04-21 22:42:18 +08:00
|
|
|
## Universal variables from .gitlab-ci.yml
|
|
|
|
IFS=$'\n' VAR_ARRAY=($(cat .gitlab-ci.yml | sed -n '/export PATH=/,/GI_TYPELIB_PATH}\"/p' | sed 's/ - //'))
|
2024-05-19 18:55:17 +08:00
|
|
|
IFS=$' \t\n'
|
2024-04-21 22:42:18 +08:00
|
|
|
for VAR in "${VAR_ARRAY[@]}"; do
|
|
|
|
eval "$VAR" || continue
|
|
|
|
done
|
2021-05-02 21:43:25 +08:00
|
|
|
|
2024-07-20 08:43:45 +08:00
|
|
|
|
|
|
|
# Build GIMP
|
2024-08-05 03:02:43 +08:00
|
|
|
if [ -z "$GITLAB_CI" ] && [ "$1" != "--relocatable" ]; then
|
|
|
|
echo "(INFO): GIMP will be built in MSYS2 friendly mode"
|
|
|
|
export MESON_OPTIONS='-Drelocatable-bundle=no -Dwindows-installer=false -Dms-store=false'
|
|
|
|
elif [ "$GITLAB_CI" ] || [ "$1" = '--relocatable' ]; then
|
|
|
|
echo "(INFO): GIMP will be built as a relocatable bundle"
|
|
|
|
export MESON_OPTIONS='-Drelocatable-bundle=yes -Dwindows-installer=true -Dms-store=true'
|
|
|
|
fi
|
|
|
|
|
2024-07-20 06:54:58 +08:00
|
|
|
if [ ! -f "_build/build.ninja" ]; then
|
|
|
|
mkdir -p "_build" && cd "_build"
|
2024-08-05 03:02:43 +08:00
|
|
|
echo "$1" > last_mode
|
2023-12-17 08:22:21 +08:00
|
|
|
# We disable javascript as we are not able for the time being to add a
|
|
|
|
# javascript interpreter with GObject Introspection (GJS/spidermonkey
|
|
|
|
# and Seed/Webkit are the 2 contenders so far, but they are not
|
|
|
|
# available on MSYS2 and we are told it's very hard to build them).
|
|
|
|
# TODO: re-enable javascript plug-ins when we can figure this out.
|
2024-05-19 18:55:17 +08:00
|
|
|
meson setup .. -Dprefix="${GIMP_PREFIX}" \
|
|
|
|
-Dgi-docgen=disabled \
|
|
|
|
-Djavascript=disabled \
|
|
|
|
-Ddirectx-sdk-dir="${MSYSTEM_PREFIX}" \
|
2024-06-05 20:40:30 +08:00
|
|
|
-Denable-default-bin=enabled \
|
2024-02-23 02:46:05 +08:00
|
|
|
-Dbuild-id=org.gimp.GIMP_official $MESON_OPTIONS
|
2023-12-17 08:22:21 +08:00
|
|
|
else
|
2024-07-20 06:54:58 +08:00
|
|
|
cd "_build"
|
2024-08-05 03:02:43 +08:00
|
|
|
if [[ $(head -1 last_mode) != "$1" ]]; then
|
|
|
|
echo "$1" > last_mode
|
|
|
|
meson setup .. --reconfigure $MESON_OPTIONS
|
|
|
|
fi
|
2023-12-17 08:22:21 +08:00
|
|
|
fi
|
2024-04-23 23:29:24 +08:00
|
|
|
ninja
|
|
|
|
ninja install
|
2024-04-11 21:39:21 +08:00
|
|
|
ccache --show-stats
|
2024-08-05 03:02:43 +08:00
|
|
|
cd ..
|
2024-04-11 21:39:21 +08:00
|
|
|
|
2021-05-05 08:12:52 +08:00
|
|
|
|
2024-04-29 18:12:41 +08:00
|
|
|
# Wrapper just for easier GIMP running
|
2024-02-17 20:17:30 +08:00
|
|
|
make_cmd ()
|
|
|
|
{
|
2024-05-29 02:46:46 +08:00
|
|
|
if [ "$4" == "do_wizardry" ]; then
|
|
|
|
interp_lua="(
|
|
|
|
echo lua=$2\bin\luajit.exe
|
|
|
|
echo luajit=$2\bin\luajit.exe
|
|
|
|
echo /usr/bin/lua=$2\bin\luajit.exe
|
|
|
|
echo /usr/bin/luajit=$2\bin\luajit.exe
|
|
|
|
echo :Lua:E::lua::luajit:
|
|
|
|
) >%cd%\lib\gimp\GIMP_API_VERSION\interpreters\lua.interp"
|
|
|
|
interp_pyt="(
|
|
|
|
echo python=$2\bin\python.exe
|
|
|
|
echo python3=$2\bin\python.exe
|
|
|
|
echo /usr/bin/python=$2\bin\python.exe
|
|
|
|
echo /usr/bin/python3=$2\bin\python.exe
|
|
|
|
echo :Python:E::py::python:
|
|
|
|
) >%cd%\lib\gimp\GIMP_API_VERSION\interpreters\pygimp.interp"
|
|
|
|
interp_scm="(
|
|
|
|
echo gimp-script-fu-interpreter=%cd%\bin\gimp-script-fu-interpreter-GIMP_API_VERSION.exe
|
|
|
|
echo gimp-script-fu-interpreter-GIMP_API_VERSION=%cd%\bin\gimp-script-fu-interpreter-GIMP_API_VERSION.exe
|
|
|
|
echo /usr/bin/gimp-script-fu-interpreter=%cd%\bin\gimp-script-fu-interpreter-GIMP_API_VERSION.exe
|
|
|
|
echo :ScriptFu:E::scm::gimp-script-fu-interpreter-GIMP_API_VERSION.exe:
|
|
|
|
) >%cd%\lib\gimp\GIMP_API_VERSION\interpreters\gimp-script-fu-interpreter.interp"
|
2024-08-05 03:02:43 +08:00
|
|
|
cp_typelib="@if not exist MSYS2_PREFIX\lib\girepository-1.0\babl*.typelib (copy lib\girepository-1.0\babl*.typelib $2\lib\girepository-1.0) > nul
|
|
|
|
@if not exist MSYS2_PREFIX\lib\girepository-1.0\gegl*.typelib (copy lib\girepository-1.0\gegl*.typelib $2\lib\girepository-1.0) > nul
|
|
|
|
@if not exist MSYS2_PREFIX\lib\girepository-1.0\gimp*.typelib (copy lib\girepository-1.0\gimp*.typelib $2\lib\girepository-1.0) > nul"
|
2024-05-29 02:46:46 +08:00
|
|
|
set_path="set PATH=%PATH%;$2\bin"
|
2024-08-05 03:02:43 +08:00
|
|
|
dl_typelib="@if exist MSYS2_PREFIX\lib\girepository-1.0\babl*.typelib (if exist lib\girepository-1.0\babl*.typelib (del $2\lib\girepository-1.0\babl*.typelib)) > nul
|
|
|
|
@if exist MSYS2_PREFIX\lib\girepository-1.0\gegl*.typelib (if exist lib\girepository-1.0\gegl*.typelib (del $2\lib\girepository-1.0\gegl*.typelib)) > nul
|
|
|
|
@if exist MSYS2_PREFIX\lib\girepository-1.0\gimp*.typelib (if exist lib\girepository-1.0\gimp*.typelib (del $2\lib\girepository-1.0\gimp*.typelib)) > nul"
|
2024-05-29 02:46:46 +08:00
|
|
|
fi
|
2023-12-17 22:06:22 +08:00
|
|
|
echo "@echo off
|
2024-04-29 18:12:41 +08:00
|
|
|
echo This is a $1 native build of GIMP$3.
|
2023-12-17 22:06:22 +08:00
|
|
|
echo .js (JavaScript) plug-ins ^|^ NOT supported!
|
2024-05-29 02:46:46 +08:00
|
|
|
$interp_lua
|
2023-12-17 22:06:22 +08:00
|
|
|
echo .lua (Lua) plug-ins ^|^ supported.
|
2024-05-29 02:46:46 +08:00
|
|
|
$interp_pyt
|
2023-12-17 22:06:22 +08:00
|
|
|
echo .py (Python) plug-ins ^|^ supported.
|
2024-05-29 02:46:46 +08:00
|
|
|
$interp_scm
|
2023-12-17 22:06:22 +08:00
|
|
|
echo .scm (ScriptFu) plug-ins ^|^ supported.
|
|
|
|
echo .vala (Vala) plug-ins ^|^ supported.
|
|
|
|
echo.
|
2024-05-29 02:46:46 +08:00
|
|
|
$cp_typelib
|
|
|
|
$set_path
|
2024-08-05 03:02:43 +08:00
|
|
|
bin\gimp-GIMP_APP_VERSION.exe
|
2024-05-29 02:46:46 +08:00
|
|
|
$dl_typelib" > ${GIMP_PREFIX}/gimp.cmd
|
2024-08-05 03:02:43 +08:00
|
|
|
sed -i "s/GIMP_API_VERSION/$(grep GIMP_PKGCONFIG_VERSION _build/config.h | head -1 | sed 's/^.*"\([^"]*\)"$/\1/')/g" ${GIMP_PREFIX}/gimp.cmd
|
|
|
|
sed -i "s/GIMP_APP_VERSION/$(grep GIMP_APP_VERSION _build/config.h | head -1 | sed 's/^.*"\([^"]*\)"$/\1/')/g" ${GIMP_PREFIX}/gimp.cmd
|
|
|
|
sed -i -e "s|MSYS2_PREFIX|c:\/msys64${MSYSTEM_PREFIX}|g" -e 's|c:/|c:\\|g;s|msys64/|msys64\\|g' ${GIMP_PREFIX}/gimp.cmd
|
2023-12-17 22:06:22 +08:00
|
|
|
}
|
|
|
|
|
2024-08-05 03:02:43 +08:00
|
|
|
if [ -z "$GITLAB_CI" ] && [ "$1" != "--relocatable" ]; then
|
|
|
|
make_cmd local MSYS2_PREFIX " (please run bin/gimp-GIMP_APP_VERSION.exe under $MSYSTEM shell)" do_wizardry
|
|
|
|
elif [ "$GITLAB_CI" ] || [ "$1" = "--relocatable" ]; then
|
2024-04-29 18:12:41 +08:00
|
|
|
make_cmd CI %cd% ""
|
2024-08-05 03:02:43 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$GITLAB_CI" ] || [ "$1" = "--relocatable" ]; then
|
|
|
|
# Bundle GIMP
|
|
|
|
bash build/windows/2_bundle-gimp-uni_base.sh --authorized
|
2024-02-08 07:43:01 +08:00
|
|
|
fi
|