Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sat, 12 Oct 2019 10:24:24 UTC Commit: 5bba238e1644a5abbdcd9a6ef1fc26443c012265 https://github.com/geany/geany-osx/commit/5bba238e1644a5abbdcd9a6ef1fc26443c...
Log Message: ----------- Create and use binary launcher for GTK3 bundles
Since MacOS Catalina the OS asks for permissions when accessing directories like Documents or Desktop. Because Geany is executed using a launcher bash script which sets the necessary environment variables, these permissions would have to be assigned to /bin/bash and not Geany itself. The operating system doesn't offer to assign the permission to /bin/bash and lets the IO to these directories just fail (it is possible to assign the necessary permissions to /bin/bash manually but it's a bit clumsy).
Instead of using launcher script, let's create a launcher binary which does the same job as the script with some minor modifications:
1. We can avoid setting DYLD_LIBRARY_PATH which was used just for Geany to find libvte - instead we can specify the location of VTE by using the command-line parameter --vte-lib. This allows us to drop the com.apple.security.cs.allow-dyld-environment-variables entitlement so we don't need any special security workarounds to launch Geany.
2. XDG_CONFIG_HOME was used incorrectly and shouldn't be set, otherwise Geany searches its config file there. For some reason GTK doesn't seem to find settings.ini inside XDG_CONFIG_DIRS so let's specify the theme manually using GTK_THEME.
Modified Paths: -------------- .gitignore LauncherGtk3/geany/geany.xcodeproj/project.pbxproj LauncherGtk3/geany/geany.xcodeproj/project.xcworkspace/contents.xcworkspacedata LauncherGtk3/geany/geany.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist LauncherGtk3/geany/geany/main.m geany-gtk3.bundle geany.entitlements launcher-gtk2.sh launcher-gtk3.sh
Modified: .gitignore 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -1,3 +1,4 @@ Geany*.app Geany*.dmg - +LauncherGtk3/geany/build/ +xcuserdata/
Modified: LauncherGtk3/geany/geany.xcodeproj/project.pbxproj 286 lines changed, 286 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,286 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + B12DCC4B2350EF9300301186 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B12DCC4A2350EF9300301186 /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + B12DCC452350EF9300301186 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + B12DCC472350EF9300301186 /* geany */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = geany; sourceTree = BUILT_PRODUCTS_DIR; }; + B12DCC4A2350EF9300301186 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B12DCC442350EF9300301186 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B12DCC3E2350EF9300301186 = { + isa = PBXGroup; + children = ( + B12DCC492350EF9300301186 /* geany */, + B12DCC482350EF9300301186 /* Products */, + ); + sourceTree = "<group>"; + }; + B12DCC482350EF9300301186 /* Products */ = { + isa = PBXGroup; + children = ( + B12DCC472350EF9300301186 /* geany */, + ); + name = Products; + sourceTree = "<group>"; + }; + B12DCC492350EF9300301186 /* geany */ = { + isa = PBXGroup; + children = ( + B12DCC4A2350EF9300301186 /* main.m */, + ); + path = geany; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B12DCC462350EF9300301186 /* geany */ = { + isa = PBXNativeTarget; + buildConfigurationList = B12DCC4E2350EF9300301186 /* Build configuration list for PBXNativeTarget "geany" */; + buildPhases = ( + B12DCC432350EF9300301186 /* Sources */, + B12DCC442350EF9300301186 /* Frameworks */, + B12DCC452350EF9300301186 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = geany; + productName = geany; + productReference = B12DCC472350EF9300301186 /* geany */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B12DCC3F2350EF9300301186 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1110; + ORGANIZATIONNAME = Geany; + TargetAttributes = { + B12DCC462350EF9300301186 = { + CreatedOnToolsVersion = 11.1; + }; + }; + }; + buildConfigurationList = B12DCC422350EF9300301186 /* Build configuration list for PBXProject "geany" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B12DCC3E2350EF9300301186; + productRefGroup = B12DCC482350EF9300301186 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B12DCC462350EF9300301186 /* geany */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + B12DCC432350EF9300301186 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B12DCC4B2350EF9300301186 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + B12DCC4C2350EF9300301186 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + B12DCC4D2350EF9300301186 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + B12DCC4F2350EF9300301186 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + B12DCC502350EF9300301186 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B12DCC422350EF9300301186 /* Build configuration list for PBXProject "geany" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B12DCC4C2350EF9300301186 /* Debug */, + B12DCC4D2350EF9300301186 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B12DCC4E2350EF9300301186 /* Build configuration list for PBXNativeTarget "geany" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B12DCC4F2350EF9300301186 /* Debug */, + B12DCC502350EF9300301186 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B12DCC3F2350EF9300301186 /* Project object */; +}
Modified: LauncherGtk3/geany/geany.xcodeproj/project.xcworkspace/contents.xcworkspacedata 7 lines changed, 7 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "self:geany.xcodeproj"> + </FileRef> +</Workspace>
Modified: LauncherGtk3/geany/geany.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist 8 lines changed, 8 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IDEDidComputeMac32BitWarning</key> + <true/> +</dict> +</plist>
Modified: LauncherGtk3/geany/geany/main.m 93 lines changed, 93 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,93 @@ +#import <Foundation/Foundation.h> + + +int run_geany() +{ + NSString *bundle_dir = [[NSBundle mainBundle] bundlePath]; + + NSString *bundle_contents = [bundle_dir stringByAppendingPathComponent: @"Contents"]; + NSString *bundle_res = [bundle_contents stringByAppendingPathComponent: @"Resources"]; + NSString *bundle_lib = [bundle_res stringByAppendingPathComponent: @"lib"]; + //NSString *bundle_bin = [bundle_res stringByAppendingPathComponent: @"bin"]; + NSString *bundle_data = [bundle_res stringByAppendingPathComponent: @"share"]; + NSString *bundle_etc = [bundle_res stringByAppendingPathComponent: @"etc"]; + + NSString *lang = @"en_US.UTF-8"; + bool ignore_locale = [[NSFileManager defaultManager] fileExistsAtPath: [@"~/.config/geany/ignore_locale" stringByExpandingTildeInPath]]; + if (!ignore_locale) + { + lang = [[[NSLocale currentLocale] localeIdentifier] stringByAppendingString:@".UTF-8"]; + } + + //set environment variables + //see https://developer.gnome.org/gtk3/stable/gtk-running.html + NSMutableDictionary<NSString *, NSString *> *env = [[[NSProcessInfo processInfo] environment] mutableCopy]; + NSDictionary<NSString *, NSString *> *env2 = @{ + @"XDG_CONFIG_DIRS": bundle_etc, + @"XDG_DATA_DIRS": bundle_data, + + @"GTK_PATH": bundle_res, + @"GTK_EXE_PREFIX": bundle_res, + @"GTK_DATA_PREFIX": bundle_res, + @"GTK_IM_MODULE_FILE": [bundle_etc stringByAppendingPathComponent: @"gtk-3.0/gtk.immodules"], + @"GDK_PIXBUF_MODULE_FILE": [bundle_lib stringByAppendingPathComponent: @"gdk-pixbuf-2.0/2.10.0/loaders.cache"], + + //for some reason GTK doesn't find settings.ini file inside $XDG_CONFIG_DIRS + //even though it should, so specify manually + @"GTK_THEME": @"Sierra-light-solid", + + //Locale variables + @"LANG": lang, + @"LC_MESSAGES": lang, + @"LC_MONETARY": lang, + @"LC_COLLATE": lang, + @"LC_ALL": lang, + + //Geany variables + @"GEANY_PLUGINS_SHARE_PATH": [bundle_res stringByAppendingPathComponent: @"share/geany-plugins"], + @"ENCHANT_MODULE_PATH": [bundle_lib stringByAppendingPathComponent: @"enchant"], + @"GIO_MODULE_DIR": [bundle_lib stringByAppendingPathComponent: @"gio/modules"], + }; + [env addEntriesFromDictionary: env2]; + + //set binary name and command line arguments + NSArray<NSString *> *argv = NSProcessInfo.processInfo.arguments; + NSString *binary = [argv[0] stringByAppendingString:@"-bin"]; + NSMutableArray<NSString *> *args = [argv mutableCopy]; + [args removeObjectAtIndex: 0]; + + if (args.count > 0 && [args[0] hasPrefix:@"-psn_"]) + { + [args removeObjectAtIndex: 0]; + } + + [args addObject:[NSString stringWithFormat:@"--vte-lib=%@/libvte-2.91.0.dylib", bundle_lib]]; + + //debugging + NSString *verbose_param = @"--osx-verbose"; + if ([args containsObject: verbose_param]) + { + [args removeObject:verbose_param]; + NSLog(@"env: %@", env); + NSLog(@"args: %@", args); + NSLog(@"binary: %@", binary); + } + + //run Geany binary + NSTask *task = [[NSTask alloc] init]; + task.launchPath = binary; + task.environment = env; + task.arguments = args; + [task launch]; + [task waitUntilExit]; + + return task.terminationStatus; +} + + +int main(int argc, const char * argv[]) { + @autoreleasepool { + return run_geany(); + } + return 0; +}
Modified: geany-gtk3.bundle 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -33,7 +33,7 @@ not needed. If the source path is left out, the default script will be used. --> - <launcher-script>${project}/launcher-gtk3.sh</launcher-script > + <launcher-script>${project}/LauncherGtk3/geany/build/Release/geany</launcher-script >
<!-- Not implemented: Optional runtime, could be python or mono for example.
Modified: geany.entitlements 5 lines changed, 1 insertions(+), 4 deletions(-) =================================================================== @@ -1,8 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> -<dict> - <key>com.apple.security.cs.allow-dyld-environment-variables</key> - <true/> -</dict> +<dict/> </plist>
Modified: launcher-gtk2.sh 5 lines changed, 2 insertions(+), 3 deletions(-) =================================================================== @@ -38,8 +38,7 @@ 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_CONFIG_DIRS="$bundle_etc" export XDG_DATA_DIRS="$bundle_data" export GTK_DATA_PREFIX="$bundle_res" export GTK_EXE_PREFIX="$bundle_res" @@ -86,4 +85,4 @@ export GEANY_PLUGINS_SHARE_PATH="$bundle_res/share/geany-plugins" export ENCHANT_MODULE_PATH="$bundle_lib/enchant" export GIO_MODULE_DIR="$bundle_lib/gio/modules"
-$EXEC "$bundle_contents/MacOS/$name-bin" "$@" $EXTRA_ARGS +$EXEC "$bundle_contents/MacOS/$name-bin" "$@" "--vte-lib=$bundle_lib/libvte-2.91.0.dylib" $EXTRA_ARGS
Modified: launcher-gtk3.sh 8 lines changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -38,14 +38,14 @@ 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_CONFIG_HOME="$bundle_etc" +export XDG_CONFIG_DIRS="$bundle_etc" export XDG_DATA_DIRS="$bundle_data" export GTK_DATA_PREFIX="$bundle_res" export GTK_EXE_PREFIX="$bundle_res" export GTK_PATH="$bundle_res"
+export GTK_THEME="Sierra-light-solid" + # PANGO_* is no longer needed for pango >= 1.38 export PANGO_RC_FILE="$bundle_etc/pango/pangorc" export PANGO_SYSCONFDIR="$bundle_etc" @@ -87,4 +87,4 @@ export GEANY_PLUGINS_SHARE_PATH="$bundle_res/share/geany-plugins" export ENCHANT_MODULE_PATH="$bundle_lib/enchant" export GIO_MODULE_DIR="$bundle_lib/gio/modules"
-$EXEC "$bundle_contents/MacOS/$name-bin" "$@" $EXTRA_ARGS +$EXEC "$bundle_contents/MacOS/$name-bin" "$@" "--vte-lib=$bundle_lib/libvte-2.91.0.dylib" $EXTRA_ARGS
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).