From 7b8f313c621f865c01e619331cf9f95d1f96d905 Mon Sep 17 00:00:00 2001 From: Youssef Abukwaik Date: Sun, 2 Dec 2018 14:16:14 -0800 Subject: [PATCH] OSX - new wrapper script, no_chdir, -O2 compile option for environment --- osx/build_app.sh | 4 +++- osx/build_env.sh | 8 +++++--- osx/jhbuildrc-custom | 5 ++++- osx/meld.applescript | 39 +++++++++++++++++++++++++++++++++++++++ setup_py2app.py | 4 +++- 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100755 osx/meld.applescript diff --git a/osx/build_app.sh b/osx/build_app.sh index 86d64af26..48525f4eb 100755 --- a/osx/build_app.sh +++ b/osx/build_app.sh @@ -1,5 +1,7 @@ #!/bin/sh +export PATH=$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH + APP="$PWD/dist/Meld.app" MAIN="$APP/" RES="$MAIN/Contents/Resources/" @@ -92,7 +94,7 @@ rsync -t $INSTROOT/lib/libgtkmacintegration-gtk3.2.dylib $FRAMEWORKS/libgtkmacin # rename script, use wrapper mv $MAIN/Contents/MacOS/Meld $MAIN/Contents/MacOS/Meld-bin -rsync -t osx/Meld $MAIN/Contents/MacOS/meld_wrapper +rsync -t osx/meld.applescript $MAIN/Contents/MacOS/meld_wrapper mv $MAIN/Contents/MacOS/meld_wrapper $MAIN/Contents/MacOS/Meld chmod +x $MAIN/Contents/MacOS/Meld chmod +x $MAIN/Contents/MacOS/Meld-bin diff --git a/osx/build_env.sh b/osx/build_env.sh index cd2c438e0..65797f6f7 100755 --- a/osx/build_env.sh +++ b/osx/build_env.sh @@ -1,7 +1,7 @@ #!/bin/bash export MACOSX_DEPLOYMENT_TARGET=10.9 -export PATH=$HOME/.local/bin:$PATH +export PATH=$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH pushd . > /dev/null jhbuild bootstrap @@ -9,8 +9,10 @@ jhbuild buildone libffi openssl python3 libxml2 $HOME/gtk/inst/bin/python3 -m ensurepip $HOME/gtk/inst/bin/pip3 install six PYTHON=$HOME/gtk/inst/bin/python3 jhbuild build -~/gtk/inst/bin/pip3 install pyobjc-core -~/gtk/inst/bin/pip3 install pyobjc-framework-Cocoa +$HOME/gtk/inst/bin/pip3 install pyobjc-core +$HOME/gtk/inst/bin/pip3 install pyobjc-framework-Cocoa +$HOME/gtk/inst/bin/pip3 install py2app +(cd $HOME/gtk/inst/lib && ln -s libpython3.6m.dylib libpython3.6.dylib) exit diff --git a/osx/jhbuildrc-custom b/osx/jhbuildrc-custom index 916061fa0..d78227b25 100644 --- a/osx/jhbuildrc-custom +++ b/osx/jhbuildrc-custom @@ -11,8 +11,10 @@ _gtk_osx_use_jhbuild_python = True os.environ["CC"] = "/usr/local/bin/ccache /usr/bin/clang" os.environ["CXX"] = "/usr/local/bin/ccache /usr/bin/clang++" -os.environ["CXXFLAGS"] = "-std=c++11 -stdlib=libc++" +os.environ['CFLAGS'] = '-O2' +os.environ["CXXFLAGS"] = "-std=c++11 -stdlib=libc++ -O2" os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.9" +os.environ["DYLD_FALLBACK_LIBRARY_PATH"] = "@executable_path/../Frameworks/:@executable_path/../Resources/lib" #skip.append("libiconv") # Lion issues skip.append("cups") @@ -66,6 +68,7 @@ global autogenargs autogenargs = autogenargs + ' --disable-documentation --disable-docs --enable-introspection --enable-gtk-doc=no --enable-gtk-doc-html=no --enable-gtk-doc-pdf=no' # autogenargs += ' --cache-file=' + checkoutroot + '/autoconf-cache ' +module_autogenargs['gettext-tools'] = 'CFLAGS=-O0' module_autogenargs['yelp'] = '--disable-Werror' module_autogenargs['zlib']= ''# + autogenargs module_autogenargs['librsvg'] = autogenargs diff --git a/osx/meld.applescript b/osx/meld.applescript new file mode 100755 index 000000000..c886a3e9d --- /dev/null +++ b/osx/meld.applescript @@ -0,0 +1,39 @@ +#!/usr/bin/env osascript + +on run argv + --set current_path to do shell script "echo $PWD" + set macos_path to POSIX path of ((path to me as text) & "::") + set contents_path to parentFolder for macos_path + set frameworks_path to contents_path & "/Frameworks" + set resources_path to contents_path & "/Resources" + set library_path to (quoted form of frameworks_path) & ":" & (quoted form of (resources_path & "/lib")) + + -- return do shell script "cd " & quoted form of current_path & ";DYLD_LIBRARY_PATH=" & library_path & " " & quoted form of (macos_path & "Meld-bin") & " " & argv + + set oldDelims to AppleScript's text item delimiters + set AppleScript's text item delimiters to " " + do shell script "DYLD_LIBRARY_PATH=" & library_path & " exec " & quoted form of (macos_path & "Meld-bin") & " " & argv as text & " --" +end run + +-- FUNCTIONS + +-- From https://stackoverflow.com/a/30824337 +to parentFolder for aPath + set aPath to posixPath for aPath + set {tids, text item delimiters, i} to {text item delimiters, "/", ((aPath ends with "/") as integer) + 1} + set {pF, text item delimiters} to {text 1 thru text item -(i + 1) of aPath, tids} + return pF +end parentFolder + +-- From https://stackoverflow.com/a/30824337 +to posixPath for aPath + if class of aPath is not text then set aPath to aPath as text + if aPath contains ":" then set aPath to POSIX path of aPath + repeat while aPath starts with "//" + set aPath to (characters 2 thru -1 of aPath) as text + end repeat + repeat while aPath ends with "//" + set aPath to (characters 1 thru -2 of aPath) as text + end repeat + return aPath +end posixPath \ No newline at end of file diff --git a/setup_py2app.py b/setup_py2app.py index 2a22ef69c..5ad41b877 100644 --- a/setup_py2app.py +++ b/setup_py2app.py @@ -39,7 +39,8 @@ 'NSHighResolutionCapable': True, 'LSApplicationCategoryType': 'public.app-category.productivity', 'LSRequiresNativeExecution': True, - 'NSRequiresAquaSystemAppearance': False + 'NSRequiresAquaSystemAppearance': False, + 'NSUIElement': 1 } #find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]) @@ -103,6 +104,7 @@ 'librsvg-2.2.dylib,' , 'argv_emulation': True, + 'no_chdir': True, 'iconfile': 'osx/meld.icns', 'plist': PLIST, 'prefer_ppc': False,