build/windows: Prevent contributors from bundling GIMP wrongly

This makes the bundling script an "extension" of the building script, similar
to what Cmake-based projects does on Windows. By the way, this is inline with
the recent changes which clarified that bundling is just a finalization of the
building process when a bundle is aimed. See: d09a2a6f, 2dc6f411 and 9d86492b
This commit is contained in:
Bruno 2024-08-04 16:02:43 -03:00
parent 5f142dec44
commit 64e44ca490
5 changed files with 55 additions and 25 deletions

View File

@ -415,7 +415,6 @@ gimp-win-x64-cross:
stage: gimp
script:
- bash build/windows/2_build-gimp-crossroad.sh
- bash build/windows/2_bundle-gimp-uni_base.sh
allow_failure: true
artifacts:
expose_as: 'Windows zip'
@ -483,7 +482,6 @@ gimp-win-a64:
stage: gimp
script:
- C:\msys64\usr\bin\bash -lc "bash build/windows/2_build-gimp-msys2.sh"
- C:\msys64\usr\bin\bash -lc "bash build/windows/2_bundle-gimp-uni_base.sh"
artifacts:
paths:
- gimp-a64/
@ -531,7 +529,6 @@ gimp-win-x64:
stage: gimp
script:
- C:\msys64\usr\bin\bash -lc "bash build/windows/2_build-gimp-msys2.sh"
- C:\msys64\usr\bin\bash -lc "bash build/windows/2_bundle-gimp-uni_base.sh"
artifacts:
paths:
- gimp-x64/
@ -575,7 +572,6 @@ gimp-win-x86:
stage: gimp
script:
- C:\msys64\usr\bin\bash -lc "bash build/windows/2_build-gimp-msys2.sh"
- C:\msys64\usr\bin\bash -lc "bash build/windows/2_bundle-gimp-uni_base.sh"
- C:\msys64\usr\bin\bash -lc "bash build/windows/2_bundle-gimp-uni_sym.sh"
artifacts:
paths:

View File

@ -89,9 +89,12 @@ echo "@echo off
echo.
bin\gimp-$GIMP_APP_VERSION.exe" > ${CROSSROAD_PREFIX}/gimp.cmd
## Copy GIMP and all its deps to improvised GIMP_PREFIX
if [ "$GITLAB_CI" ]; then
# Copy GIMP and all its deps to improvised GIMP_PREFIX
cp -fr $CROSSROAD_PREFIX/ _install$ARTIFACTS_SUFFIX
# Bundle GIMP
bash build/windows/2_bundle-gimp-uni_base.sh --authorized
fi
fi # END OF CROSSROAD ENV

View File

@ -11,7 +11,6 @@ if [ -z "$GITLAB_CI" ]; then
cd ../..
fi
git submodule update --init --force
export MESON_OPTIONS="-Drelocatable-bundle=no"
fi
@ -39,8 +38,17 @@ done
# Build GIMP
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
if [ ! -f "_build/build.ninja" ]; then
mkdir -p "_build" && cd "_build"
echo "$1" > last_mode
# 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
@ -50,23 +58,22 @@ if [ ! -f "_build/build.ninja" ]; then
-Dgi-docgen=disabled \
-Djavascript=disabled \
-Ddirectx-sdk-dir="${MSYSTEM_PREFIX}" \
-Dwindows-installer=true \
-Dms-store=true \
-Denable-default-bin=enabled \
-Dbuild-id=org.gimp.GIMP_official $MESON_OPTIONS
else
cd "_build"
if [[ $(head -1 last_mode) != "$1" ]]; then
echo "$1" > last_mode
meson setup .. --reconfigure $MESON_OPTIONS
fi
fi
ninja
ninja install
ccache --show-stats
cd ..
# Wrapper just for easier GIMP running
MSYS2_PREFIX="c:/msys64${MSYSTEM_PREFIX}"
GIMP_APP_VERSION=$(grep GIMP_APP_VERSION config.h | head -1 | sed 's/^.*"\([^"]*\)"$/\1/')
GIMP_API_VERSION=$(grep GIMP_PKGCONFIG_VERSION config.h | head -1 | sed 's/^.*"\([^"]*\)"$/\1/')
make_cmd ()
{
if [ "$4" == "do_wizardry" ]; then
@ -90,13 +97,13 @@ make_cmd ()
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"
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"
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"
set_path="set PATH=%PATH%;$2\bin"
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"
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"
fi
echo "@echo off
echo This is a $1 native build of GIMP$3.
@ -111,14 +118,21 @@ make_cmd ()
echo.
$cp_typelib
$set_path
bin\gimp-$GIMP_APP_VERSION.exe
bin\gimp-GIMP_APP_VERSION.exe
$dl_typelib" > ${GIMP_PREFIX}/gimp.cmd
sed -i "s/GIMP_API_VERSION/${GIMP_API_VERSION}/g" ${GIMP_PREFIX}/gimp.cmd
sed -i 's|c:/|c:\\|g;s|msys64/|msys64\\|g' ${GIMP_PREFIX}/gimp.cmd
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
}
if [ "$GITLAB_CI" ]; then
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
make_cmd CI %cd% ""
else
make_cmd local $MSYS2_PREFIX " (please run bin/gimp-${GIMP_APP_VERSION}.exe under $MSYSTEM shell)" do_wizardry
fi
if [ "$GITLAB_CI" ] || [ "$1" = "--relocatable" ]; then
# Bundle GIMP
bash build/windows/2_bundle-gimp-uni_base.sh --authorized
fi

View File

@ -2,6 +2,14 @@
set -e
if [ "$1" != '--authorized' ] && [ "$1" != '--force' ]; then
# We can't easily figure out if GIMP was built relocatable so
# let's prevent contributors from creating broken bundles
echo -e "\033[31m(ERROR)\033[0m: Script called standalone. Please, run GIMP build script with '--relocatable' or this bundling script with '--force'"
exit 1
fi
# NOTE: The bundling scripts, different from building scripts, need to set
# the ARTIFACTS_SUFFIX, even locally: 1) to avoid confusion (bundle dirs are
# relocatable so can be copied to a machine with other arch); and 2) to our
@ -82,6 +90,10 @@ clean ()
}
## Prevent Git going crazy
mkdir -p $GIMP_DISTRIB
echo "*" > $GIMP_DISTRIB/.gitignore
## Copy a previously built wrapper at tree root, less messy than
## having to look inside bin/, in the middle of all the DLLs.
## This also configure the interpreters for local builds as courtesy.
@ -194,3 +206,8 @@ done
#if [ "$CI_JOB_NAME" != "gimp-win-x64-cross" ]; then
# cp -fr ${GIMP_PREFIX}/bin/*.pdb ${GIMP_DISTRIB}/bin/
#fi
# Delete wrapper to prevent contributors from running a
# relocatable build expecting it to work non-relocatable
rm -r $GIMP_PREFIX/gimp.cmd

View File

@ -143,7 +143,7 @@ foreach ($bundle in $supported_archs)
Copy-Item "$bundle" "$vfs" -Recurse -Force
## Remove uneeded files (to match the Inno Windows Installer artifact)
Remove-Item "$vfs\gimp.cmd"
Get-ChildItem "$vfs" -Recurse -Include (".gitignore", "gimp.cmd") | Remove-Item -Recurse
## Disable Update check (ONLY FOR RELEASES)
if ($CI_COMMIT_TAG -or ($GIMP_CI_MS_STORE -eq 'MSIXUPLOAD'))