[Build] Fix the NO_LINK build

The NO_LINK build had bitrot and was no longer building. This fixes the
issue by properly disabling Link-related code, including unreachable
functions when the project is built with ENABLE_LINK=FALSE
This commit is contained in:
Fabrice de Gans 2023-09-04 13:35:47 -07:00
parent 7a7778c644
commit 0f4ec57557
3 changed files with 36 additions and 8 deletions

View File

@ -2521,6 +2521,8 @@ EVT_HANDLER(VSync, "Wait for vertical sync")
GetMenuOptionConfig("VSync", config::OptionID::kPrefVsync); GetMenuOptionConfig("VSync", config::OptionID::kPrefVsync);
} }
#ifndef NO_LINK
void MainFrame::EnableNetworkMenu() void MainFrame::EnableNetworkMenu()
{ {
cmd_enable &= ~CMDEN_LINK_ANY; cmd_enable &= ~CMDEN_LINK_ANY;
@ -2545,12 +2547,12 @@ void SetLinkTypeMenu(const char* type, int value)
mf->SetMenuOption(type, 1); mf->SetMenuOption(type, 1);
gopts.gba_link_type = value; gopts.gba_link_type = value;
update_opts(); update_opts();
#ifndef NO_LINK
CloseLink(); CloseLink();
#endif
mf->EnableNetworkMenu(); mf->EnableNetworkMenu();
} }
#endif // NO_LINK
EVT_HANDLER_MASK(LanLink, "Start Network link", CMDEN_LINK_ANY) EVT_HANDLER_MASK(LanLink, "Start Network link", CMDEN_LINK_ANY)
{ {
#ifndef NO_LINK #ifndef NO_LINK
@ -2577,42 +2579,58 @@ EVT_HANDLER_MASK(LanLink, "Start Network link", CMDEN_LINK_ANY)
EVT_HANDLER(LinkType0Nothing, "Link nothing") EVT_HANDLER(LinkType0Nothing, "Link nothing")
{ {
#ifndef NO_LINK
SetLinkTypeMenu("LinkType0Nothing", 0); SetLinkTypeMenu("LinkType0Nothing", 0);
#endif
} }
EVT_HANDLER(LinkType1Cable, "Link cable") EVT_HANDLER(LinkType1Cable, "Link cable")
{ {
#ifndef NO_LINK
SetLinkTypeMenu("LinkType1Cable", 1); SetLinkTypeMenu("LinkType1Cable", 1);
#endif
} }
EVT_HANDLER(LinkType2Wireless, "Link wireless") EVT_HANDLER(LinkType2Wireless, "Link wireless")
{ {
#ifndef NO_LINK
SetLinkTypeMenu("LinkType2Wireless", 2); SetLinkTypeMenu("LinkType2Wireless", 2);
#endif
} }
EVT_HANDLER(LinkType3GameCube, "Link GameCube") EVT_HANDLER(LinkType3GameCube, "Link GameCube")
{ {
#ifndef NO_LINK
SetLinkTypeMenu("LinkType3GameCube", 3); SetLinkTypeMenu("LinkType3GameCube", 3);
#endif
} }
EVT_HANDLER(LinkType4Gameboy, "Link Gameboy") EVT_HANDLER(LinkType4Gameboy, "Link Gameboy")
{ {
#ifndef NO_LINK
SetLinkTypeMenu("LinkType4Gameboy", 4); SetLinkTypeMenu("LinkType4Gameboy", 4);
#endif
} }
EVT_HANDLER(LinkAuto, "Enable link at boot") EVT_HANDLER(LinkAuto, "Enable link at boot")
{ {
#ifndef NO_LINK
GetMenuOptionConfig("LinkAuto", config::OptionID::kGBALinkAuto); GetMenuOptionConfig("LinkAuto", config::OptionID::kGBALinkAuto);
#endif
} }
EVT_HANDLER(SpeedOn, "Enable faster network protocol by default") EVT_HANDLER(SpeedOn, "Enable faster network protocol by default")
{ {
#ifndef NO_LINK
GetMenuOptionConfig("SpeedOn", config::OptionID::kGBALinkFast); GetMenuOptionConfig("SpeedOn", config::OptionID::kGBALinkFast);
#endif
} }
EVT_HANDLER(LinkProto, "Local host IPC") EVT_HANDLER(LinkProto, "Local host IPC")
{ {
#ifndef NO_LINK
GetMenuOptionConfig("LinkProto", config::OptionID::kGBALinkProto); GetMenuOptionConfig("LinkProto", config::OptionID::kGBALinkProto);
#endif
} }
EVT_HANDLER(LinkConfigure, "Link options...") EVT_HANDLER(LinkConfigure, "Link options...")

View File

@ -827,13 +827,13 @@ MainFrame::MainFrame()
menus_opened(0), menus_opened(0),
dialog_opened(0), dialog_opened(0),
focused(false), focused(false),
#ifndef NO_LINK
gba_link_observer_(config::OptionID::kGBALinkHost,
std::bind(&MainFrame::EnableNetworkMenu, this)),
#endif
keep_on_top_styler_(this), keep_on_top_styler_(this),
status_bar_observer_(config::OptionID::kGenStatusBar, status_bar_observer_(config::OptionID::kGenStatusBar,
std::bind(&MainFrame::OnStatusBarChanged, std::bind(&MainFrame::OnStatusBarChanged, this, std::placeholders::_1)) {
this,
std::placeholders::_1)),
gba_link_observer_(config::OptionID::kGBALinkHost,
std::bind(&MainFrame::EnableNetworkMenu, this)) {
jpoll = new JoystickPoller(); jpoll = new JoystickPoller();
this->Connect(wxID_ANY, wxEVT_SHOW, wxShowEventHandler(JoystickPoller::ShowDialog), jpoll, jpoll); this->Connect(wxID_ANY, wxEVT_SHOW, wxShowEventHandler(JoystickPoller::ShowDialog), jpoll, jpoll);
} }
@ -1263,6 +1263,8 @@ void MainFrame::StopModal()
panel->Resume(); panel->Resume();
} }
#ifndef NO_LINK
LinkMode MainFrame::GetConfiguredLinkMode() LinkMode MainFrame::GetConfiguredLinkMode()
{ {
switch (gopts.gba_link_type) { switch (gopts.gba_link_type) {
@ -1306,6 +1308,8 @@ LinkMode MainFrame::GetConfiguredLinkMode()
return LINK_DISCONNECTED; return LINK_DISCONNECTED;
} }
#endif // NO_LINK
void MainFrame::IdentifyRom() void MainFrame::IdentifyRom()
{ {
if (!panel->rom_name.empty()) if (!panel->rom_name.empty())

View File

@ -246,7 +246,9 @@ public:
// adjust menus based on current cmd_enable // adjust menus based on current cmd_enable
void enable_menus(); void enable_menus();
#ifndef NO_LINK
void EnableNetworkMenu(); void EnableNetworkMenu();
#endif
// adjust menus based on available save game states // adjust menus based on available save game states
void update_state_ts(bool force = false); void update_state_ts(bool force = false);
@ -268,8 +270,10 @@ public:
return focused; return focused;
} }
#ifndef NO_LINK
// Returns the link mode to set according to the options // Returns the link mode to set according to the options
LinkMode GetConfiguredLinkMode(); LinkMode GetConfiguredLinkMode();
#endif
void IdentifyRom(); void IdentifyRom();
@ -352,9 +356,11 @@ private:
JoystickPoller* jpoll = nullptr; JoystickPoller* jpoll = nullptr;
// quicker & more accurate than FindFocus() != NULL // quicker & more accurate than FindFocus() != NULL
bool focused; bool focused;
#ifndef NO_LINK
const config::OptionsObserver gba_link_observer_;
#endif
const widgets::KeepOnTopStyler keep_on_top_styler_; const widgets::KeepOnTopStyler keep_on_top_styler_;
const config::OptionsObserver status_bar_observer_; const config::OptionsObserver status_bar_observer_;
const config::OptionsObserver gba_link_observer_;
// helper function for adding menu to accel editor // helper function for adding menu to accel editor
void add_menu_accels(wxTreeCtrl* tc, wxTreeItemId& parent, wxMenu* menu); void add_menu_accels(wxTreeCtrl* tc, wxTreeItemId& parent, wxMenu* menu);