diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llcommon/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | indra/llcommon/llsys.cpp | 21 | ||||
| -rw-r--r-- | indra/llcommon/llsys_objc.h | 33 | ||||
| -rw-r--r-- | indra/llcommon/llsys_objc.mm | 64 | ||||
| -rw-r--r-- | indra/newview/CMakeLists.txt | 2 | 
5 files changed, 107 insertions, 24 deletions
| diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index ca8b5e946f..fd8fbf70c8 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -265,6 +265,11 @@ set(llcommon_HEADER_FILES      workqueue.h      StackWalker.h      ) +     +if (DARWIN) +  list(APPEND llcommon_HEADER_FILES llsys_objc.h) +  list(APPEND llcommon_SOURCE_FILES llsys_objc.mm) +endif (DARWIN)  set_source_files_properties(${llcommon_HEADER_FILES}                              PROPERTIES HEADER_FILE_ONLY TRUE) @@ -312,12 +317,6 @@ target_link_libraries(      ${TRACY_LIBRARY}      ) -if (DARWIN) -  include(CMakeFindFrameworks) -  find_library(CARBON_LIBRARY Carbon) -  target_link_libraries(llcommon ${CARBON_LIBRARY}) -endif (DARWIN) -  add_dependencies(llcommon stage_third_party_libs)  if (LL_TESTS) diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index f717b2cf34..6d0483903b 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -64,6 +64,7 @@ using namespace llsd;  #   include <psapi.h>               // GetPerformanceInfo() et al.  #	include <VersionHelpers.h>  #elif LL_DARWIN +#   include "llsys_objc.h"  #	include <errno.h>  #	include <sys/sysctl.h>  #	include <sys/utsname.h> @@ -74,12 +75,6 @@ using namespace llsd;  #	include <mach/mach_host.h>  #	include <mach/task.h>  #	include <mach/task_info.h> - -// disable warnings about Gestalt calls being deprecated -// until Apple get's on the ball and provides an alternative -// -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -  #elif LL_LINUX  #	include <errno.h>  #	include <sys/utsname.h> @@ -278,12 +273,9 @@ LLOSInfo::LLOSInfo() :  	{  		const char * DARWIN_PRODUCT_NAME = "Mac OS X"; -		SInt32 major_version, minor_version, bugfix_version; -		OSErr r1 = Gestalt(gestaltSystemVersionMajor, &major_version); -		OSErr r2 = Gestalt(gestaltSystemVersionMinor, &minor_version); -		OSErr r3 = Gestalt(gestaltSystemVersionBugFix, &bugfix_version); +		S32 major_version, minor_version, bugfix_version = 0; -		if((r1 == noErr) && (r2 == noErr) && (r3 == noErr)) +		if (LLGetDarwinOSInfo(major_version, minor_version, bugfix_version))  		{  			mMajorVer = major_version;  			mMinorVer = minor_version; @@ -1315,10 +1307,3 @@ BOOL gzip_file(const std::string& srcfile, const std::string& dstfile)  	if (dst != NULL) gzclose(dst);  	return retval;  } - -#if LL_DARWIN -// disable warnings about Gestalt calls being deprecated -// until Apple get's on the ball and provides an alternative -// -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif diff --git a/indra/llcommon/llsys_objc.h b/indra/llcommon/llsys_objc.h new file mode 100644 index 0000000000..35599a574b --- /dev/null +++ b/indra/llcommon/llsys_objc.h @@ -0,0 +1,33 @@ +/** + * @file llsys_objc.h + * @brief Header file for llsys_objc.mm + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLSYS_OBJC_H +#define LL_LLSYS_OBJC_H + +bool LLGetDarwinOSInfo(int &major, int &minor, int &patch); + + +#endif // LL_LLSYS_OBJC_H diff --git a/indra/llcommon/llsys_objc.mm b/indra/llcommon/llsys_objc.mm new file mode 100644 index 0000000000..cdb1e320d5 --- /dev/null +++ b/indra/llcommon/llsys_objc.mm @@ -0,0 +1,64 @@ +/** + * @file llsys_objc.mm + * @brief obj-c implementation of the system information functions + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA + * $/LicenseInfo$ + */ + +#import "llsys_objc.h" +#import <AppKit/AppKit.h> + +static int intAtStringIndex(NSArray *array, int index) +{ +    return [(NSString *)[array objectAtIndex:index] integerValue]; +} + +bool LLGetDarwinOSInfo(int &major, int &minor, int &patch) +{ +    if (NSAppKitVersionNumber > NSAppKitVersionNumber10_8) +    { +        NSOperatingSystemVersion osVersion = [[NSProcessInfo processInfo] operatingSystemVersion]; +        major = osVersion.majorVersion; +        minor = osVersion.minorVersion; +        patch = osVersion.patchVersion; +    } +    else +    { +        NSString* versionString = [[NSDictionary dictionaryWithContentsOfFile: +                                    @"/System/Library/CoreServices/SystemVersion.plist"] objectForKey:@"ProductVersion"]; +        NSArray* versions = [versionString componentsSeparatedByString:@"."]; +        NSUInteger count = [versions count]; +        if (count > 0) +        { +            major = intAtStringIndex(versions, 0); +            if (count > 1) +            { +                minor = intAtStringIndex(versions, 1); +                if (count > 2) +                { +                    patch = intAtStringIndex(versions, 2); +                } +            } +        } +    } +    return true; +} diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 964615320d..ae8d8d51a4 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1413,12 +1413,14 @@ if (DARWIN)    find_library(COCOA_LIBRARY Cocoa)    find_library(IOKIT_LIBRARY IOKit)    find_library(COREAUDIO_LIBRARY CoreAudio) +  find_library(CARBON_LIBRARY Carbon)    set(viewer_LIBRARIES      ${COCOA_LIBRARY}      ${AGL_LIBRARY}      ${IOKIT_LIBRARY}      ${COREAUDIO_LIBRARY} +    ${CARBON_LIBRARY}      )    if (USE_BUGSPLAT) | 
