mirror of
https://github.com/autc04/Retro68.git
synced 2024-12-27 23:31:44 +00:00
LaunchAPPL: improve detection for classic/carbon
This commit is contained in:
parent
da6426b207
commit
c6f6cddb68
@ -9,9 +9,7 @@ if(APPLE)
|
||||
LIST(APPEND LAUNCHMETHODS
|
||||
Classic.h Classic.cc
|
||||
)
|
||||
find_program(LAUNCHCFMAPP LaunchCFMApp)
|
||||
if(LAUNCHCFMAPP)
|
||||
add_definitions(-DHAS_LAUNCHCFMAPP)
|
||||
LIST(APPEND LAUNCHMETHODS
|
||||
Carbon.h Carbon.cc)
|
||||
endif()
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include "Carbon.h"
|
||||
#include "Launcher.h"
|
||||
|
||||
const std::string launchCFM =
|
||||
"/System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp";
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
class CarbonLauncher : public Launcher
|
||||
@ -26,7 +29,15 @@ CarbonLauncher::~CarbonLauncher()
|
||||
|
||||
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)
|
||||
|
@ -8,6 +8,7 @@ class Carbon : public LaunchMethod
|
||||
public:
|
||||
virtual std::string GetName() { return "carbon"; }
|
||||
|
||||
virtual bool CheckPlatform();
|
||||
virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options);
|
||||
};
|
||||
|
||||
|
@ -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 "Launcher.h"
|
||||
|
||||
#define ResType MacResType
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
@ -63,6 +65,16 @@ bool ClassicLauncher::Go(int timeout)
|
||||
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)
|
||||
{
|
||||
return std::unique_ptr<Launcher>(new ClassicLauncher(options));
|
||||
|
@ -8,6 +8,7 @@ class Classic : public LaunchMethod
|
||||
public:
|
||||
virtual std::string GetName() { return "classic"; }
|
||||
|
||||
virtual bool CheckPlatform();
|
||||
virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options);
|
||||
};
|
||||
|
||||
|
@ -8,10 +8,13 @@
|
||||
#include "LaunchMethod.h"
|
||||
#include "Launcher.h"
|
||||
|
||||
#if defined(__APPLE__) && defined(__powerpc)
|
||||
# include "Classic.h"
|
||||
#endif
|
||||
#ifdef HAS_LAUNCHCFMAPP
|
||||
#if defined(__APPLE__)
|
||||
# define ResType MacResType
|
||||
# include <ApplicationServices/ApplicationServices.h>
|
||||
# undef ResType
|
||||
# if TARGET_CPU_PPC
|
||||
# include "Classic.h"
|
||||
# endif
|
||||
# include "Carbon.h"
|
||||
#endif
|
||||
#include "Executor.h"
|
||||
@ -30,16 +33,22 @@ static vector<LaunchMethod*> launchMethods;
|
||||
|
||||
static void RegisterLaunchMethods()
|
||||
{
|
||||
launchMethods = {
|
||||
#if defined(__APPLE__) && defined(__powerpc)
|
||||
new Classic(),
|
||||
vector<LaunchMethod*> methods = {
|
||||
#if defined(__APPLE__)
|
||||
# if TARGET_CPU_PPC
|
||||
new Classic(),
|
||||
# endif
|
||||
new Carbon(),
|
||||
#endif
|
||||
#ifdef HAS_LAUNCHCFMAPP
|
||||
new Carbon(),
|
||||
#endif
|
||||
new Executor(), new MiniVMac()
|
||||
// #### Add new `LaunchMethod`s here.
|
||||
};
|
||||
new Executor(), new MiniVMac()
|
||||
// #### Add new `LaunchMethod`s here.
|
||||
};
|
||||
|
||||
for(LaunchMethod *m : methods)
|
||||
{
|
||||
if(m->CheckPlatform())
|
||||
launchMethods.push_back(m);
|
||||
}
|
||||
}
|
||||
|
||||
static void usage()
|
||||
@ -59,7 +68,7 @@ static void usage()
|
||||
vector<string> configuredMethods, unconfiguredMethods;
|
||||
for(LaunchMethod *method : launchMethods)
|
||||
(method->CheckOptions(options) ? configuredMethods : unconfiguredMethods)
|
||||
.push_back(method->GetName());
|
||||
.push_back(method->GetName());
|
||||
|
||||
if(!configuredMethods.empty())
|
||||
{
|
||||
@ -79,10 +88,10 @@ static void usage()
|
||||
string e = options["emulator"].as<string>();
|
||||
std::cerr << "\nChosen emulator/environment: " << e;
|
||||
if(std::find(configuredMethods.begin(), configuredMethods.end(), e)
|
||||
!= configuredMethods.end())
|
||||
!= configuredMethods.end())
|
||||
std::cerr << "\n";
|
||||
else if(std::find(unconfiguredMethods.begin(), unconfiguredMethods.end(), e)
|
||||
!= unconfiguredMethods.end())
|
||||
!= unconfiguredMethods.end())
|
||||
std::cerr << " (needs more configuration)\n";
|
||||
else
|
||||
std::cerr << " (UNKNOWN)\n";
|
||||
@ -101,33 +110,33 @@ int main(int argc, char *argv[])
|
||||
configFiles = { string(getenv("HOME")) + "/.LaunchAPPL.cfg", RETRO68_PREFIX "/LaunchAPPL.cfg"};
|
||||
|
||||
desc.add_options()
|
||||
("help,h", "show this help message")
|
||||
("list-emulators,l", "get the list of available, fully configured emulators/environments")
|
||||
("make-executable,x", po::value<std::string>(), "make a MacBinary file executable")
|
||||
("help,h", "show this help message")
|
||||
("list-emulators,l", "get the list of available, fully configured emulators/environments")
|
||||
("make-executable,x", po::value<std::string>(), "make a MacBinary file executable")
|
||||
;
|
||||
po::options_description configdesc;
|
||||
configdesc.add_options()
|
||||
("emulator,e", po::value<std::string>(), "what emulator/environment to use")
|
||||
("emulator,e", po::value<std::string>(), "what emulator/environment to use")
|
||||
;
|
||||
for(LaunchMethod *lm : launchMethods)
|
||||
lm->GetOptions(configdesc);
|
||||
desc.add(configdesc);
|
||||
|
||||
desc.add_options()
|
||||
("timeout,t", po::value<int>(),"abort after timeout")
|
||||
("timeout,t", po::value<int>(),"abort after timeout")
|
||||
;
|
||||
po::options_description hidden, alldesc;
|
||||
hidden.add_options()
|
||||
("application,a", po::value<std::string>(), "application" )
|
||||
("application,a", po::value<std::string>(), "application" )
|
||||
;
|
||||
alldesc.add(desc).add(hidden);
|
||||
try
|
||||
{
|
||||
auto parsed = po::command_line_parser(argc, argv)
|
||||
.options(alldesc)
|
||||
.positional(po::positional_options_description().add("application", -1))
|
||||
.style(po::command_line_style::default_style)
|
||||
.run();
|
||||
.options(alldesc)
|
||||
.positional(po::positional_options_description().add("application", -1))
|
||||
.style(po::command_line_style::default_style)
|
||||
.run();
|
||||
|
||||
po::store(parsed, options);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
return true;
|
||||
|
@ -20,6 +20,8 @@ public:
|
||||
|
||||
virtual std::string GetName() = 0;
|
||||
virtual void GetOptions(options_description& desc);
|
||||
|
||||
virtual bool CheckPlatform();
|
||||
virtual bool CheckOptions(variables_map& options);
|
||||
|
||||
virtual std::unique_ptr<Launcher> MakeLauncher(variables_map& options) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user