LaunchAPPL: improve detection for classic/carbon

This commit is contained in:
Wolfgang Thaller 2017-10-05 15:30:58 +02:00
parent da6426b207
commit c6f6cddb68
8 changed files with 71 additions and 32 deletions

View File

@ -9,9 +9,7 @@ if(APPLE)
LIST(APPEND LAUNCHMETHODS LIST(APPEND LAUNCHMETHODS
Classic.h Classic.cc Classic.h Classic.cc
) )
find_program(LAUNCHCFMAPP LaunchCFMApp)
if(LAUNCHCFMAPP) if(LAUNCHCFMAPP)
add_definitions(-DHAS_LAUNCHCFMAPP)
LIST(APPEND LAUNCHMETHODS LIST(APPEND LAUNCHMETHODS
Carbon.h Carbon.cc) Carbon.h Carbon.cc)
endif() endif()

View File

@ -1,6 +1,9 @@
#include "Carbon.h" #include "Carbon.h"
#include "Launcher.h" #include "Launcher.h"
const std::string launchCFM =
"/System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp";
namespace po = boost::program_options; namespace po = boost::program_options;
class CarbonLauncher : public Launcher class CarbonLauncher : public Launcher
@ -26,7 +29,15 @@ CarbonLauncher::~CarbonLauncher()
bool CarbonLauncher::Go(int timeout) bool CarbonLauncher::Go(int timeout)
{ {
return ChildProcess("LaunchCarbon", { appPath.string() }, timeout) == 0; return ChildProcess(launchCFM, { appPath.string() }, timeout) == 0;
}
bool Carbon::CheckPlatform()
{
/* If LaunchCFMApp doesn't exist, we're likely on a Mac OS X version
where it doesn't exist anymore (10.7 Lion or later),
or on an entirely different platform. */
return CheckExecutable(launchCFM);
} }
std::unique_ptr<Launcher> Carbon::MakeLauncher(variables_map &options) std::unique_ptr<Launcher> Carbon::MakeLauncher(variables_map &options)

View File

@ -8,6 +8,7 @@ class Carbon : public LaunchMethod
public: public:
virtual std::string GetName() { return "carbon"; } virtual std::string GetName() { return "carbon"; }
virtual bool CheckPlatform();
virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options); virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options);
}; };

View File

@ -1,9 +1,11 @@
#if defined(__APPLE__) && defined(__powerpc) #define ResType MacResType
#include <ApplicationServices/ApplicationServices.h>
#undef ResType
#if TARGET_CPU_PPC
#include "Classic.h" #include "Classic.h"
#include "Launcher.h" #include "Launcher.h"
#define ResType MacResType
#include <ApplicationServices/ApplicationServices.h>
namespace po = boost::program_options; namespace po = boost::program_options;
@ -63,6 +65,16 @@ bool ClassicLauncher::Go(int timeout)
return false; return false;
} }
bool Classic::CheckPlatform()
{
long sysver = 0;
Gestalt(gestaltSystemVersion, &sysver);
if(sysver >= 0x1050)
return false;
else
return true;
}
std::unique_ptr<Launcher> Classic::MakeLauncher(variables_map &options) std::unique_ptr<Launcher> Classic::MakeLauncher(variables_map &options)
{ {
return std::unique_ptr<Launcher>(new ClassicLauncher(options)); return std::unique_ptr<Launcher>(new ClassicLauncher(options));

View File

@ -8,6 +8,7 @@ class Classic : public LaunchMethod
public: public:
virtual std::string GetName() { return "classic"; } virtual std::string GetName() { return "classic"; }
virtual bool CheckPlatform();
virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options); virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options);
}; };

View File

@ -8,10 +8,13 @@
#include "LaunchMethod.h" #include "LaunchMethod.h"
#include "Launcher.h" #include "Launcher.h"
#if defined(__APPLE__) && defined(__powerpc) #if defined(__APPLE__)
# define ResType MacResType
# include <ApplicationServices/ApplicationServices.h>
# undef ResType
# if TARGET_CPU_PPC
# include "Classic.h" # include "Classic.h"
#endif # endif
#ifdef HAS_LAUNCHCFMAPP
# include "Carbon.h" # include "Carbon.h"
#endif #endif
#include "Executor.h" #include "Executor.h"
@ -30,16 +33,22 @@ static vector<LaunchMethod*> launchMethods;
static void RegisterLaunchMethods() static void RegisterLaunchMethods()
{ {
launchMethods = { vector<LaunchMethod*> methods = {
#if defined(__APPLE__) && defined(__powerpc) #if defined(__APPLE__)
# if TARGET_CPU_PPC
new Classic(), new Classic(),
#endif # endif
#ifdef HAS_LAUNCHCFMAPP
new Carbon(), new Carbon(),
#endif #endif
new Executor(), new MiniVMac() new Executor(), new MiniVMac()
// #### Add new `LaunchMethod`s here. // #### Add new `LaunchMethod`s here.
}; };
for(LaunchMethod *m : methods)
{
if(m->CheckPlatform())
launchMethods.push_back(m);
}
} }
static void usage() static void usage()

View File

@ -18,6 +18,11 @@ void LaunchMethod::GetOptions(boost::program_options::options_description &desc)
{ {
} }
bool LaunchMethod::CheckPlatform()
{
return true;
}
bool LaunchMethod::CheckOptions(boost::program_options::variables_map &options) bool LaunchMethod::CheckOptions(boost::program_options::variables_map &options)
{ {
return true; return true;

View File

@ -20,6 +20,8 @@ public:
virtual std::string GetName() = 0; virtual std::string GetName() = 0;
virtual void GetOptions(options_description& desc); virtual void GetOptions(options_description& desc);
virtual bool CheckPlatform();
virtual bool CheckOptions(variables_map& options); virtual bool CheckOptions(variables_map& options);
virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options) = 0; virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options) = 0;