This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

source: ps/trunk/source/lib/sysdep/os/osx/osx_bundle.mm

Last change on this file was 24343, checked in by wraitii, 4 years ago

Rework bundle creation scripts.

This reworks the OSX bundle script, to run it easily on CI and to further also build the unix tarballs and the windows installer.

Clean up the MacOS bundle detection, by not forcing a compilation-time switch.
Clean up shared library compilation: changing the installation name isn't necessary for 0 A.D.

Differential Revision: https://code.wildfiregames.com/D3161

  • Property svn:eol-style set to native
File size: 2.5 KB
RevLine 
[19899]1/* Copyright (C) 2013 Wildfire Games.
[11389]2 *
3 * Permission is hereby granted, free of charge, to any person obtaining
4 * a copy of this software and associated documentation files (the
5 * "Software"), to deal in the Software without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Software, and to
8 * permit persons to whom the Software is furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
[11757]23#import <AvailabilityMacros.h> // MAC_OS_X_VERSION_MIN_REQUIRED
[11389]24#import <Foundation/Foundation.h>
25#import <string>
26
27#import "osx_bundle.h"
28
29bool osx_IsAppBundleValid()
30{
31 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
32
[24343]33 NSBundle *bundle = [NSBundle mainBundle];
34 // mainBundle can create an NSBundle even with a loose executable.
35 // Assume that if the identifier is defined, we are actually inside a bundle.
36 NSString *identifier = [bundle bundleIdentifier];
[11389]37
38 [pool drain];
[24343]39 return bundle != nil && identifier != nil;
[11389]40}
41
[24343]42namespace {
43std::string GetBundlePath(SEL selector)
[11389]44{
45 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
46 std::string path;
47
[24343]48 NSBundle *bundle = [NSBundle mainBundle];
[11389]49 if (bundle != nil)
50 {
[14140]51 NSString *pathStr;
[11389]52 // Retrieve NSURL and convert to POSIX path, then get C-string
53 // encoded as UTF-8, and use it to construct std::string
54 // NSURL:path "If the receiver does not conform to RFC 1808, returns nil."
[24343]55 pathStr = [[bundle performSelector:selector] path];
[14140]56
[11389]57 if (pathStr != nil)
58 path = std::string([pathStr UTF8String]);
59 }
60
61 [pool drain];
62 return path;
63}
[24343]64}
[11389]65
[24343]66std::string osx_GetBundlePath()
67{
68 return GetBundlePath(@selector(bundleURL));
69}
70
[11389]71std::string osx_GetBundleResourcesPath()
72{
[24343]73 return GetBundlePath(@selector(resourceURL));
[11389]74}
75
76std::string osx_GetBundleFrameworksPath()
77{
[24343]78 return GetBundlePath(@selector(privateFrameworksURL));
[11389]79}
Note: See TracBrowser for help on using the repository browser.