mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-23 00:34:22 +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
|
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()
|
||||||
|
@ -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)
|
||||||
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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));
|
||||||
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,10 +8,13 @@
|
|||||||
#include "LaunchMethod.h"
|
#include "LaunchMethod.h"
|
||||||
#include "Launcher.h"
|
#include "Launcher.h"
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__powerpc)
|
#if defined(__APPLE__)
|
||||||
# include "Classic.h"
|
# define ResType MacResType
|
||||||
#endif
|
# include <ApplicationServices/ApplicationServices.h>
|
||||||
#ifdef HAS_LAUNCHCFMAPP
|
# undef ResType
|
||||||
|
# if TARGET_CPU_PPC
|
||||||
|
# include "Classic.h"
|
||||||
|
# endif
|
||||||
# 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__)
|
||||||
new Classic(),
|
# if TARGET_CPU_PPC
|
||||||
|
new Classic(),
|
||||||
|
# endif
|
||||||
|
new Carbon(),
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_LAUNCHCFMAPP
|
new Executor(), new MiniVMac()
|
||||||
new Carbon(),
|
// #### Add new `LaunchMethod`s here.
|
||||||
#endif
|
};
|
||||||
new Executor(), new MiniVMac()
|
|
||||||
// #### Add new `LaunchMethod`s here.
|
for(LaunchMethod *m : methods)
|
||||||
};
|
{
|
||||||
|
if(m->CheckPlatform())
|
||||||
|
launchMethods.push_back(m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage()
|
static void usage()
|
||||||
@ -59,7 +68,7 @@ static void usage()
|
|||||||
vector<string> configuredMethods, unconfiguredMethods;
|
vector<string> configuredMethods, unconfiguredMethods;
|
||||||
for(LaunchMethod *method : launchMethods)
|
for(LaunchMethod *method : launchMethods)
|
||||||
(method->CheckOptions(options) ? configuredMethods : unconfiguredMethods)
|
(method->CheckOptions(options) ? configuredMethods : unconfiguredMethods)
|
||||||
.push_back(method->GetName());
|
.push_back(method->GetName());
|
||||||
|
|
||||||
if(!configuredMethods.empty())
|
if(!configuredMethods.empty())
|
||||||
{
|
{
|
||||||
@ -79,10 +88,10 @@ static void usage()
|
|||||||
string e = options["emulator"].as<string>();
|
string e = options["emulator"].as<string>();
|
||||||
std::cerr << "\nChosen emulator/environment: " << e;
|
std::cerr << "\nChosen emulator/environment: " << e;
|
||||||
if(std::find(configuredMethods.begin(), configuredMethods.end(), e)
|
if(std::find(configuredMethods.begin(), configuredMethods.end(), e)
|
||||||
!= configuredMethods.end())
|
!= configuredMethods.end())
|
||||||
std::cerr << "\n";
|
std::cerr << "\n";
|
||||||
else if(std::find(unconfiguredMethods.begin(), unconfiguredMethods.end(), e)
|
else if(std::find(unconfiguredMethods.begin(), unconfiguredMethods.end(), e)
|
||||||
!= unconfiguredMethods.end())
|
!= unconfiguredMethods.end())
|
||||||
std::cerr << " (needs more configuration)\n";
|
std::cerr << " (needs more configuration)\n";
|
||||||
else
|
else
|
||||||
std::cerr << " (UNKNOWN)\n";
|
std::cerr << " (UNKNOWN)\n";
|
||||||
@ -101,33 +110,33 @@ int main(int argc, char *argv[])
|
|||||||
configFiles = { string(getenv("HOME")) + "/.LaunchAPPL.cfg", RETRO68_PREFIX "/LaunchAPPL.cfg"};
|
configFiles = { string(getenv("HOME")) + "/.LaunchAPPL.cfg", RETRO68_PREFIX "/LaunchAPPL.cfg"};
|
||||||
|
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("help,h", "show this help message")
|
("help,h", "show this help message")
|
||||||
("list-emulators,l", "get the list of available, fully configured emulators/environments")
|
("list-emulators,l", "get the list of available, fully configured emulators/environments")
|
||||||
("make-executable,x", po::value<std::string>(), "make a MacBinary file executable")
|
("make-executable,x", po::value<std::string>(), "make a MacBinary file executable")
|
||||||
;
|
;
|
||||||
po::options_description configdesc;
|
po::options_description configdesc;
|
||||||
configdesc.add_options()
|
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)
|
for(LaunchMethod *lm : launchMethods)
|
||||||
lm->GetOptions(configdesc);
|
lm->GetOptions(configdesc);
|
||||||
desc.add(configdesc);
|
desc.add(configdesc);
|
||||||
|
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("timeout,t", po::value<int>(),"abort after timeout")
|
("timeout,t", po::value<int>(),"abort after timeout")
|
||||||
;
|
;
|
||||||
po::options_description hidden, alldesc;
|
po::options_description hidden, alldesc;
|
||||||
hidden.add_options()
|
hidden.add_options()
|
||||||
("application,a", po::value<std::string>(), "application" )
|
("application,a", po::value<std::string>(), "application" )
|
||||||
;
|
;
|
||||||
alldesc.add(desc).add(hidden);
|
alldesc.add(desc).add(hidden);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto parsed = po::command_line_parser(argc, argv)
|
auto parsed = po::command_line_parser(argc, argv)
|
||||||
.options(alldesc)
|
.options(alldesc)
|
||||||
.positional(po::positional_options_description().add("application", -1))
|
.positional(po::positional_options_description().add("application", -1))
|
||||||
.style(po::command_line_style::default_style)
|
.style(po::command_line_style::default_style)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
po::store(parsed, options);
|
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)
|
bool LaunchMethod::CheckOptions(boost::program_options::variables_map &options)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user