diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 080e4bc..07fcbd1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -204,3 +204,46 @@ flatpak: - target_test/ when: 'manual' + +macos installer stable: + stage: test + tags: + - gst-macos-11.1 + before_script: + - pip3 install --upgrade pip + # Make sure meson is up to date + - pip3 install -U meson + # Need to install certificates for python + - pip3 install --upgrade certifi + # Another way to install certificates + - open /Applications/Python\ 3.8/Install\ Certificates.command + # Get ninja + - pip3 install -U ninja + script: + # rust toolchain + - curl https://sh.rustup.rs -sSf | sh -s -- -y + - source $HOME/.cargo/env + # brew install + - /bin/bash -c "./installer/macos/brew_setup.sh" + - /bin/bash -c "./installer/macos/deploy_macos.sh" + artifacts: + name: "MacOS installer" + paths: + - installer/**/GstPipelineStudio*.dmg + - installer/**/GstPipelineStudio*.tar.gz + expire_in: 14 days + when: 'manual' + +macos installer release: + extends: 'macos installer stable' + stage: release + only: + - flatpak + - tags + artifacts: + name: "MacOS installer" + paths: + - installer/**/GstPipelineStudio*.dmg + - installer/**/GstPipelineStudio*.tar.gz + when: 'always' + diff --git a/data/icons/org.freedesktop.dabrain34.GstPipelineStudio.ico b/data/icons/org.freedesktop.dabrain34.GstPipelineStudio.ico new file mode 100644 index 0000000..27bd53b Binary files /dev/null and b/data/icons/org.freedesktop.dabrain34.GstPipelineStudio.ico differ diff --git a/data/icons/org.freedesktop.dabrain34.GstPipelineStudio.png b/data/icons/org.freedesktop.dabrain34.GstPipelineStudio.png new file mode 100644 index 0000000..b9a2f70 Binary files /dev/null and b/data/icons/org.freedesktop.dabrain34.GstPipelineStudio.png differ diff --git a/installer/macos/brew_setup.sh b/installer/macos/brew_setup.sh new file mode 100755 index 0000000..fdf0683 --- /dev/null +++ b/installer/macos/brew_setup.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +HOMEBREW_NO_INSTALL_CLEANUP=1 + +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + +brew install gtk4 gstreamer gst-plugins-base gst-plugins-bad gst-plugins-good + +brew install npm + +npm install -g appdmg + +exit 0 diff --git a/installer/macos/deploy_macos.sh b/installer/macos/deploy_macos.sh new file mode 100755 index 0000000..000f7f5 --- /dev/null +++ b/installer/macos/deploy_macos.sh @@ -0,0 +1,189 @@ +#!/bin/bash + + +test_ok() { + $* + if [ $? != 0 ]; then + exit 1 + fi + +} + +# depenency library: +# Make a .app file: https://gist.github.com/oubiwann/453744744da1141ccc542ff75b47e0cf +# Make a .dmg file: https://github.com/LinusU/node-appdmg +# Can't find library: https://www.jianshu.com/p/441a7553700f +BUILD_DIR=builddir +PROJECTDIR="$( cd "$(dirname "$0")/../" ; pwd -P )" +TARGETDIR="${PROJECTDIR}/${BUILD_DIR}/INSTALL_GPS" +VERSION="$(date +%y%m%d)" +export VERSION +echo "VERSION=$VERSION" + +# rebuild app release version +rm -rf "${TARGETDIR}" +test_ok meson --prefix=$TARGETDIR --buildtype=release ${BUILD_DIR} +test_ok ninja -C "${PROJECTDIR}/${BUILD_DIR}" install + + +# copy app data files to target dir +echo -n "Copy app data files......" +test_ok mkdir -p "${TARGETDIR}/etc/" +mkdir -p "${TARGETDIR}/lib/gstreamer-1.0" +mkdir -p "${TARGETDIR}/share/doc" +mkdir -p "${TARGETDIR}/share/themes" +mkdir -p "${TARGETDIR}/share/glib-2.0/schemas" +mkdir -p "${TARGETDIR}/share/licenses/GstPipelineStudio" +mkdir -p "${TARGETDIR}/share/icons/hicolor/scalable/apps" +echo "[done]" + +function lib_dependency_copy +{ + local target=$1 + local folder=$2 + + lib_dir="$( cd "$( dirname "$1" )" >/dev/null 2>&1 && pwd )" + libraries="$(otool -L $target | grep "/*.*dylib" -o | xargs)" + for lib in $libraries; do + if [[ '/usr/lib/' != ${lib:0:9} && '/System/Library/' != ${lib:0:16} ]]; then + if [[ '@' == ${lib:0:1} ]]; then + if [[ '@loader_path' == ${lib:0:12} ]]; then + cp -n "${lib/@loader_path/$lib_dir}" $folder + else + echo "Unsupport path: $lib" + fi + else + cp -n $lib $folder + fi + fi + done +} + +function lib_dependency_analyze +{ + # This function use otool to analyze library dependency. + # then copy the dependency libraries to destination path + + local library_dir=$1 + local targets_dir=$2 + + libraries="$(find $library_dir -name \*.dylib -o -name \*.so -type f)" + for lib in $libraries; do + lib_dependency_copy $lib $targets_dir + # otool -L $lib | grep "/usr/local/*.*dylib" -o | xargs -I{} cp -n "{}" "$targets_dir" + done +} + +# copy app dependency library to target dir +echo -n "Copy app dependency library......" + + +lib_dependency_copy ${TARGETDIR}/bin/gst_pipeline_studio "${TARGETDIR}/bin" +lib_dependency_copy ${TARGETDIR}/lib/libgobject-2.0.0.dylib "${TARGETDIR}/bin" +lib_dependency_copy ${TARGETDIR}/lib/libsoup-2.4.1.dylib "${TARGETDIR}/bin" + +# lib_dependency_copy ${TARGETDIR}/bin/libunistring.2.dylib "${TARGETDIR}/bin" +# lib_dependency_copy /usr/local/lib/libcairo-script-interpreter.2.dylib "${TARGETDIR}/bin" +# lib_dependency_copy /usr/local/lib/libgettextsrc-0.20.1.dylib "${TARGETDIR}/bin" +# lib_dependency_copy /usr/local/lib/libharfbuzz-icu.0.dylib "${TARGETDIR}/bin" + + +for file in ${TARGETDIR}/lib/gstreamer-1.0/*.dylib +do + echo "${file}" + lib_dependency_copy ${file} "${TARGETDIR}/lib/gstreamer-1.0" +done + +test_ok cp -f "${PROJECTDIR}/macos/mac_launcher.sh" "${TARGETDIR}/bin/launcher.sh" +# cp -f /usr/local/lib/libgtk-gtk4.1.dylib "${TARGETDIR}/bin" +# cp -f /usr/local/lib/libgirepository-1.0.1.dylib "${TARGETDIR}/bin" +# cp -f /usr/local/lib/librsvg-2.2.dylib "${TARGETDIR}/bin" +# cp -f /usr/local/lib/libgthread-2.0.0.dylib "${TARGETDIR}/bin" +# echo "[done]" + +# copy GStreamer dependencies +# cp -f /usr/local/lib/gstreamer-1.0/libgtk-gtk4.1.dylib "${TARGETDIR}/lib/gstreamer-1.0" + +# copy GDBus/Helper and dependencies files +# echo -n "Copy GDBus/Helper and dependencies......" +# cp -f /usr/local/bin/gdbus "${TARGETDIR}/bin" +# cp -f /usr/local/bin/gdk-pixbuf-query-loaders "${TARGETDIR}/bin" +# lib_dependency_copy ${TARGETDIR}/bin/gdbus "${TARGETDIR}/bin" +# lib_dependency_copy ${TARGETDIR}/bin/gdk-pixbuf-query-loaders "${TARGETDIR}/bin" +# echo "[done]" + + + +# copy GTK runtime dependencies resource +# echo -n "Copy GTK runtime resource......" +# cp -rf /usr/local/lib/gio "${TARGETDIR}/lib/" +# cp -rf /usr/local/lib/gtk-3.0 "${TARGETDIR}/lib/" +# cp -rf /usr/local/lib/gdk-pixbuf-2.0 "${TARGETDIR}/lib/" +# cp -rf /usr/local/lib/girepository-1.0 "${TARGETDIR}/lib/" +# cp -rf /usr/local/lib/libgda-5.0 "${TARGETDIR}/lib/" +# # Avoid override the latest locale file +# cp -r /usr/local/share/locale "${TARGETDIR}/share/" +# cp -rf /usr/local/share/icons "${TARGETDIR}/share/" +# cp -rf /usr/local/share/fontconfig "${TARGETDIR}/share/" +# cp -rf /usr/local/share/themes/Mac "${TARGETDIR}/share/themes/" +# cp -rf /usr/local/share/themes/Default "${TARGETDIR}/share/themes/" +# cp -rf /usr/local/share/gtksourceview-4 "${TARGETDIR}/share/" +# glib-compile-schemas /usr/local/share/glib-2.0/schemas +# cp -f /usr/local/share/glib-2.0/schemas/gschema* "${TARGETDIR}/share/glib-2.0/schemas" +# # find "${TARGETDIR}/bin" -type f -path '*.dll.a' -exec rm '{}' \; +# lib_dependency_analyze ${TARGETDIR}/lib ${TARGETDIR}/bin +# lib_dependency_analyze ${TARGETDIR}/bin ${TARGETDIR}/bin +# echo "[done]" + +# copy app icons and license files to target dir +echo -n "Copy app icon(svg) files......" +cp -f "${PROJECTDIR}/../data/icons/org.freedesktop.dabrain34.GstPipelineStudio.ico" "${TARGETDIR}/bin" +cp -f "${PROJECTDIR}/../data/icons/org.freedesktop.dabrain34.GstPipelineStudio.svg" "${TARGETDIR}/share/icons/hicolor/scalable/apps" +echo "[done]" + + +# download license file: LGPL-3.0 +echo -n "Downloading the remote license file......" +cp -f "${PROJECTDIR}/../LICENSE" "${TARGETDIR}/share/licenses/GstPipelineStudio" +if [ ! -f "${TARGETDIR}/share/licenses/GstPipelineStudio/gpl-3.0.txt" ]; then + curl "https://www.gnu.org/licenses/gpl-3.0.txt" -o "${TARGETDIR}/share/licenses/GstPipelineStudio/gpl-3.0.txt" + if [ $? -eq 0 ]; then + echo "[done]" + else + echo "[failed]" + fi +else + echo "[done]" +fi + +echo "make macos executable file(.app)......" +cd "${PROJECTDIR}/${BUILD_DIR}" +cp "${PROJECTDIR}/macos/installers/Info.plist" "${PROJECTDIR}/${BUILD_DIR}" +cp "${PROJECTDIR}/macos/installers/mac.icns" "${PROJECTDIR}/${BUILD_DIR}/GstPipelineStudio.icns" +../macos/mac_app_pack.sh --path "${TARGETDIR}" --name "GstPipelineStudio" --info "Info.plist" --icons "GstPipelineStudio.icns" +if [ $? -eq 0 ]; then + echo "[done]" + else + echo "[failed]" +fi + +# make installer package +echo "make macos installer(.dmg)......" +cp "${PROJECTDIR}/macos/installers/dmg.json" gps_dmg.json +cp "${PROJECTDIR}/macos/installers/background.png" "${PROJECTDIR}/${BUILD_DIR}/gps_dmg_background.png" +rm -f ${PROJECTDIR}/GstPipelineStudio-${VERSION}-macos.dmg +appdmg gps_dmg.json "${PROJECTDIR}/GstPipelineStudio-${VERSION}-macos.dmg" +if [ $? -eq 0 ]; then + echo "[done]" + else + echo "[failed]" +fi + +# make portable package +echo -n "make macos portable......" +tar czf "${PROJECTDIR}/GstPipelineStudio-${VERSION}-macos.tar.gz" -C "${PROJECTDIR}" ${BUILD_DIR}/GstPipelineStudio.app +if [ $? -eq 0 ]; then + echo "[done]" + else + echo "[failed]" +fi diff --git a/installer/macos/installers/Info.plist b/installer/macos/installers/Info.plist new file mode 100644 index 0000000..de6666f --- /dev/null +++ b/installer/macos/installers/Info.plist @@ -0,0 +1,43 @@ + + + + + + CFBundleShortVersionString + 1.36 + CFBundleVersion + 1.36 + NSHumanReadableCopyright + Copyright (C)2022 Stephane Cerveau + CFBundleGetInfoString + Copyright (C)2022 Stephane Cerveau + CFBundleDevelopmentRegion + English + CFBundleName + GstPipelineStudio + GtkOSXLaunchScriptFile + launcher.sh + CFBundleExecutable + gst_pipeline_studio + CFBundleIconFile + GstPipelineStudio.icns + CFBundleIdentifier + org.freedesktop.dabrain34.GstPipelineStudio + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + LSMinimumSystemVersion + 10.9 + LSApplicationCategoryType + public.app-category.developer-tools + NSHighResolutionCapable + + CFBundleVersion + 1 + NSPrincipalClass + NSApplication + + diff --git a/installer/macos/installers/background.png b/installer/macos/installers/background.png new file mode 100644 index 0000000..517fd66 Binary files /dev/null and b/installer/macos/installers/background.png differ diff --git a/installer/macos/installers/background.xcf b/installer/macos/installers/background.xcf new file mode 100644 index 0000000..6bb30f6 Binary files /dev/null and b/installer/macos/installers/background.xcf differ diff --git a/installer/macos/installers/dmg.json b/installer/macos/installers/dmg.json new file mode 100644 index 0000000..425f7d7 --- /dev/null +++ b/installer/macos/installers/dmg.json @@ -0,0 +1,9 @@ +{ + "title": "GstPipelineStudio installer", + "icon": "GstPipelineStudio.icns", + "background": "gps_dmg_background.png", + "contents": [ + { "x": 948, "y": 270, "type": "link", "path": "/Applications" }, + { "x": 692, "y": 270, "type": "file", "path": "GstPipelineStudio.app" } + ] +} diff --git a/installer/macos/installers/mac.icns b/installer/macos/installers/mac.icns new file mode 100644 index 0000000..8c24521 Binary files /dev/null and b/installer/macos/installers/mac.icns differ diff --git a/installer/macos/mac_app_pack.sh b/installer/macos/mac_app_pack.sh new file mode 100755 index 0000000..1c6a85d --- /dev/null +++ b/installer/macos/mac_app_pack.sh @@ -0,0 +1,149 @@ +#!/usr/bin/env bash + +VERSION=4.0.1 +SCRIPT=`basename "$0"` +APP_NAME="GstPipelineStudio" +APP_ICONS="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplicationIcon.icns" +OSX_VERSION=`sw_vers -productVersion` +PWD=`pwd` + +function usage { + cat < + Modified by Mathias Bynens + Modified by Andrew Dvorak + Rewritten by Duncan McGreggor + Modified by Zuhong Tao +EOF + exit 1 +} + +function version { + echo "v${VERSION}" + exit 1 +} + +function error { + echo + echo "ERROR: $1" + echo + usage +} + +while :; do + case $1 in + -h | --help ) usage;; + -p | --path ) APP_BUILD="$2"; shift ;; + -n | --name ) APP_NAME="$2"; shift ;; + -o | --info ) APP_INFO="$2"; shift ;; + -i | --icons ) APP_ICONS="$2"; shift ;; + -v | --version ) version;; + -- ) shift; break ;; + * ) break ;; + esac + shift +done + +if [ -z ${APP_BUILD+nil} ]; then + error "The GTK app path to appify must be provided!" +fi + +if [ ! -d "$APP_BUILD" ]; then + error "Can't find the target path '$APP_BUILD'" +fi + +if [ -a "$APP_NAME.app" ]; then + rm -rf "$APP_NAME.app" +fi + +SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +APP_OUT_DIR="$( cd "$(dirname "$APP_BUILD")" >/dev/null 2>&1 ; pwd -P )" + +APP_TOP_DIR=$APP_OUT_DIR/$APP_NAME.app +APP_CON_DIR=$APP_TOP_DIR/Contents +APP_RES_DIR=$APP_CON_DIR/Resources +APP_EXE_DIR=$APP_CON_DIR/MacOS +APP_ETC_DIR=$APP_RES_DIR/etc +APP_LIB_DIR=$APP_RES_DIR/lib + +# Copy GstPipelineStudio.app resource +mkdir -vp "$APP_CON_DIR"/{MacOS,Resources} +cp -f "$APP_INFO" "$APP_CON_DIR/Info.plist" +cp -f "$APP_ICONS" "$APP_RES_DIR/$APP_NAME.icns" +cp -rf "$APP_BUILD/etc" "$APP_RES_DIR" +cp -rf "$APP_BUILD/lib" "$APP_RES_DIR" +cp -rf "$APP_BUILD/share" "$APP_RES_DIR" +cp -rf "$APP_BUILD/libexec" "$APP_RES_DIR" +cp $APP_BUILD/bin/gst_pipeline_studio $APP_EXE_DIR/gst_pipeline_studio-real +cp $APP_BUILD/bin/launcher.sh $APP_EXE_DIR/gst_pipeline_studio +chmod 766 "$APP_EXE_DIR/gst_pipeline_studio" +chmod 766 "$APP_EXE_DIR/gst_pipeline_studio-real" +chmod -R 766 "$APP_RES_DIR"/libexec/gstreamer-1.0 + + +# Copy dependency libraries and update their search path +source $SCRIPT_PATH/mac_app_path.sh +if ls $APP_BUILD/bin/*.so 1> /dev/null 2>&1; then + for sofile in $APP_BUILD/bin/*.so; do + cp $sofile $APP_LIB_DIR + done +fi +cp $APP_BUILD/bin/*.dylib $APP_LIB_DIR +chmod -R 766 $APP_LIB_DIR + +lib_change_paths \ + @executable_path/../Resources/lib \ + $APP_LIB_DIR \ + $APP_EXE_DIR/gst_pipeline_studio-real + +# lib_change_paths \ +# @executable_path/../Resources/lib \ +# $APP_LIB_DIR \ +# $APP_EXE_DIR/gdbus + +# lib_change_paths \ +# @executable_path/../Resources/lib \ +# $APP_LIB_DIR \ +# $APP_EXE_DIR/gdk-pixbuf-query-loaders + +lib_change_siblings $APP_LIB_DIR @loader_path + +# Gio modules +# gio_modules="$(find $APP_LIB_DIR/gio/modules/ -name \*.dylib -o -name \*.so -type f)" +# for gio_module in $gio_modules; do +# lib_change_paths \ +# @executable_path/../Resources/lib \ +# $APP_LIB_DIR \ +# $gio_module +# done + +# # Gdk-pixbuf plugins +# pixbuf_plugins="$(find $APP_LIB_DIR/gdk-pixbuf-2.0/2.10.0/loaders/ -name \*.dylib -o -name \*.so -type f)" +# for pixbuf_plugin in $pixbuf_plugins; do +# lib_change_paths \ +# @executable_path/../Resources/lib \ +# $APP_LIB_DIR \ +# $pixbuf_plugin +# done + + +echo "Mac app bundled at '$APP_TOP_DIR'" diff --git a/installer/macos/mac_app_path.sh b/installer/macos/mac_app_path.sh new file mode 100755 index 0000000..64405a9 --- /dev/null +++ b/installer/macos/mac_app_path.sh @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# https://gitlab.com/inkscape/inkscape/-/blob/master/packaging/macos/bash_d/lib_.sh +# examples: +# lib_change_path \ +# @executable_path/../Resources/lib/lib2geom.1.0.0.dylib \ +# $APP_LIB_DIR/inkscape/libinkscape_base.dylib \ +# $APP_EXE_DIR/inkscape +# +#lib_change_paths \ +# @executable_path/../lib \ +# $APP_LIB_DIR \ +# $APP_BIN_DIR/gs +# +# lib_change_siblings $APP_LIB_DIR dylib +# lib_change_siblings $APP_LIB_DIR so + +# include_guard + +### includes ################################################################### + +# Nothing here. + +### variables ################################################################## + +# Nothing here. + +### functions ################################################################## + +function lib_change_path +{ + # This is a simple wrapper around install_name_tool to reduce the + # number of arguments (like $source does not have to be provided + # here as it can be deducted from $target). + # Also, the requested change can be applied to multipe binaries + # at once since 2-n arguments can be supplied. + + local target=$1 # new path to dynamically linked library + local binaries=${*:2} # binaries to modify + + local source_lib=${target##*/} # get library filename from target location + + for binary in $binaries; do # won't work with spaces in paths + if [[ $binary == *.so ]] || [[ $binary == *.dylib ]]; then + lib_reset_id $binary + fi + local source=$(otool -L $binary | grep $source_lib | awk '{ print $1 }') + install_name_tool -change $source $target $binary + done +} + +function lib_change_paths +{ + # This is a slightly more advanced wrapper around install_name_tool. + # Given a directory $lib_dir that contains the libraries, all libraries + # linked in $binary can be changed at once to a specified $target path. + + local target=$1 # new path to dynamically linked library + local lib_dir=$2 + local binaries=${*:3} + + for binary in $binaries; do + if [[ $binary == *.so ]] || [[ $binary == *.dylib ]]; then + lib_reset_id $binary + fi + for linked_lib in $(otool -L $binary | tail -n +2 | awk '{ print $1 }'); do + if [ "$(basename $binary)" != "$(basename $linked_lib)" ] && + [ -f $lib_dir/$(basename $linked_lib) ]; then + lib_change_path $target/$(basename $linked_lib) $binary + fi + done + done +} + +function lib_change_siblings +{ + # This is a slightly more advanced wrapper around install_name_tool. + # All libraries inside a given $dir that are linked to libraries present + # in that $dir can be automatically adjusted. + + local dir=$1 + local target=$2 + + for lib in $dir/*.dylib; do + lib_reset_id $lib + for linked_lib in $(otool -L $lib | tail -n +2 | awk '{ print $1 }'); do + if [ "$(basename $lib)" != "$(basename $linked_lib)" ] && + [ -f $dir/$(basename $linked_lib) ]; then + lib_change_path $target/$(basename $linked_lib) $lib + fi + done + done + + if ls $dir/*.so 1> /dev/null 2>&1; then + for lib in $dir/*.so; do + lib_reset_id $lib + for linked_lib in $(otool -L $lib | tail -n +2 | awk '{ print $1 }'); do + if [ "$(basename $lib)" != "$(basename $linked_lib)" ] && + [ -f $dir/$(basename $linked_lib) ]; then + lib_change_path $target/$(basename $linked_lib) $lib + fi + done + done + fi +} + +function lib_reset_id +{ + local lib=$1 + + install_name_tool -id $(basename $lib) $lib +} + +### aliases #################################################################### + +# Nothing here. + +### main ####################################################################### + +# Nothing here. diff --git a/installer/macos/mac_launcher.sh b/installer/macos/mac_launcher.sh new file mode 100755 index 0000000..489cc4b --- /dev/null +++ b/installer/macos/mac_launcher.sh @@ -0,0 +1,170 @@ +#!/bin/sh + +if test "x$GTK_DEBUG_LAUNCHER" != x; then + set -x +fi + +if test "x$GTK_DEBUG_GDB" != x; then + EXEC="gdb --args" +else + EXEC=exec +fi + +name=`basename "$0"` +bundle_app="$( cd "$( dirname "$0" )/../.." >/dev/null 2>&1 && pwd )" +bundle_contents="$bundle_app"/Contents +bundle_res="$bundle_contents"/Resources +bundle_lib="$bundle_res"/lib +bundle_libexec="$bundle_res"/libexec +bundle_bin="$bundle_res"/bin +bundle_data="$bundle_res"/share +bundle_etc="$bundle_res"/etc + +export DYLD_LIBRARY_PATH="$bundle_lib" +export XDG_CONFIG_DIRS="$bundle_etc"/xdg +export XDG_DATA_DIRS="$bundle_data" +export GTK_DATA_PREFIX="$bundle_res" +export GTK_EXE_PREFIX="$bundle_res" +export GTK_PATH="$bundle_res" +export GST_PLUGIN_SCANNER="$bundle_libexec/gstreamer-1.0/gst-plugin-scanner" +export GIO_EXTRA_MODULES="$bundle_lib/gio/modules" + +# GIO modules +export GIO_MODULE_DIR="$bundle_lib/gio/modules" + + +#GStreamer plugins +export GST_PLUGIN_PATH="$bundle_lib/gstreamer-1.0" + +APP=$name +I18NDIR="$bundle_data/locale" +# Set the locale-related variables appropriately: +unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE + +# Has a language ordering been set? +# If so, set LC_MESSAGES and LANG accordingly; otherwise skip it. +# First step uses sed to clean off the quotes and commas, to change - to _, and change the names for the chinese scripts from "Hans" to CN and "Hant" to TW. +APPLELANGUAGES=`defaults read .GlobalPreferences AppleLanguages | sed -En -e 's/\-/_/' -e 's/Hant/TW/' -e 's/Hans/CN/' -e 's/[[:space:]]*\"?([[:alnum:]_]+)\"?,?/\1/p' ` +if test "$APPLELANGUAGES"; then + # A language ordering exists. + # Test, item per item, to see whether there is an corresponding locale. + for L in $APPLELANGUAGES; do + #test for exact matches: + if test -f "$I18NDIR/${L}/LC_MESSAGES/$APP.mo"; then + export LANG=$L + break + fi + #This is a special case, because often the original strings are in US + #English and there is no translation file. + if test "x$L" == "xen_US"; then + export LANG=$L + break + fi + #OK, now test for just the first two letters: + if test -f "$I18NDIR/${L:0:2}/LC_MESSAGES/$APP.mo"; then + export LANG=${L:0:2} + break + fi + #Same thing, but checking for any english variant. + if test "x${L:0:2}" == "xen"; then + export LANG=$L + break + fi; + done +fi +unset APPLELANGUAGES L + +# If we didn't get a language from the language list, try the Collation preference, in case it's the only setting that exists. +APPLECOLLATION=`defaults read .GlobalPreferences AppleCollationOrder` +if test -z ${LANG} -a -n $APPLECOLLATION; then + if test -f "$I18NDIR/${APPLECOLLATION:0:2}/LC_MESSAGES/$APP.mo"; then + export LANG=${APPLECOLLATION:0:2} + fi +fi +if test ! -z $APPLECOLLATION; then + export LC_COLLATE=$APPLECOLLATION +fi +unset APPLECOLLATION + +# Continue by attempting to find the Locale preference. +APPLELOCALE=`defaults read .GlobalPreferences AppleLocale` + +if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then + if test -z $LANG; then + export LANG="${APPLELOCALE:0:5}" + fi + +elif test -z $LANG -a -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then + export LANG="${APPLELOCALE:0:2}" +fi + +#Next we need to set LC_MESSAGES. If at all possible, we want a full +#5-character locale to avoid the "Locale not supported by C library" +#warning from Gtk -- even though Gtk will translate with a +#two-character code. +if test -n $LANG; then +#If the language code matches the applelocale, then that's the message +#locale; otherwise, if it's longer than two characters, then it's +#probably a good message locale and we'll go with it. + if test $LANG == ${APPLELOCALE:0:5} -o $LANG != ${LANG:0:2}; then + export LC_MESSAGES=$LANG +#Next try if the Applelocale is longer than 2 chars and the language +#bit matches $LANG + elif test $LANG == ${APPLELOCALE:0:2} -a $APPLELOCALE > ${APPLELOCALE:0:2}; then + export LC_MESSAGES=${APPLELOCALE:0:5} +#Fail. Get a list of the locales in $PREFIX/share/locale that match +#our two letter language code and pick the first one, special casing +#english to set en_US + elif test $LANG == "en"; then + export LC_MESSAGES="en_US" + else + LOC=`find $PREFIX/share/locale -name $LANG???` + for L in $LOC; do + export LC_MESSAGES=$L + done + fi +else +#All efforts have failed, so default to US english + export LANG="en_US" + export LC_MESSAGES="en_US" +fi +CURRENCY=`echo $APPLELOCALE | sed -En 's/.*currency=([[:alpha:]]+).*/\1/p'` +if test "x$CURRENCY" != "x"; then +#The user has set a special currency. Gtk doesn't install LC_MONETARY files, but Apple does in /usr/share/locale, so we're going to look there for a locale to set LC_CURRENCY to. + if test -f /usr/local/share/$LC_MESSAGES/LC_MONETARY; then + if test -a `cat /usr/local/share/$LC_MESSAGES/LC_MONETARY` == $CURRENCY; then + export LC_MONETARY=$LC_MESSAGES + fi + fi + if test -z "$LC_MONETARY"; then + FILES=`find /usr/share/locale -name LC_MONETARY -exec grep -H $CURRENCY {} \;` + if test -n "$FILES"; then + export LC_MONETARY=`echo $FILES | sed -En 's%/usr/share/locale/([[:alpha:]_]+)/LC_MONETARY.*%\1%p'` + fi + fi +fi +#No currency value means that the AppleLocale governs: +if test -z "$LC_MONETARY"; then + LC_MONETARY=${APPLELOCALE:0:5} +fi +#For Gtk, which only looks at LC_ALL: +export LC_ALL=$LC_MESSAGES + +unset APPLELOCALE FILES LOC + +if test -f "$bundle_lib/charset.alias"; then + export CHARSETALIASDIR="$bundle_lib" +fi + +# Extra arguments can be added in environment.sh. +EXTRA_ARGS= +if test -f "$bundle_res/environment.sh"; then + source "$bundle_res/environment.sh" +fi + +# Strip out the argument added by the OS. +if /bin/expr "x$1" : '^x-psn_' > /dev/null; then + shift 1 +fi + +$EXEC "$bundle_contents/MacOS/gst_pipeline_studio-real" "$@" $EXTRA_ARGS diff --git a/meson.build b/meson.build index 379aa77..6f2aa45 100644 --- a/meson.build +++ b/meson.build @@ -5,6 +5,9 @@ project('gst_pipeline_studio', ], license: 'GPL-3.0-or-later', ) + +host_system = host_machine.system() + python_mod = import('python') python3 = python_mod.find_installation() current_date = run_command(python3, '-c', 'import datetime; print(datetime.datetime.now().strftime("%Y-%m-%d"), end ="")').stdout()