Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OpenCPN/OpenCPN
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbcat committed Aug 7, 2023
2 parents 1864151 + 3841f29 commit 20a781e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 14 deletions.
18 changes: 7 additions & 11 deletions buildwin/winConfig.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ goto :main
@echo * Example: mkdir \Users\myname\source\repos *
@echo * cd \Users\myname\source\repos *
@echo * 5. Clone Opencpn *
@echo * Example: clone https://github.com/transmitterdan/opencpn *
@echo * Example: clone https://github.com/opencpn/opencpn *
@echo * cd \Users\myname\source\repos\opencpn *
@echo * git checkout localWinBuild *
@echo * git checkout master *
@echo * 6. Set up local build environment by executing this script *
@echo * Example: .\buildwin\winConfig.bat *
@echo * 7. Open solution file *
Expand All @@ -54,14 +54,14 @@ goto :main
@echo * Command line options: *
@echo * --clean Remove build folder entirely before building *
@echo * MUST HAVE INTERNET CONNECTION FOR clean OPTION! *
@echo * --rebuild Rebuild all sources *
@echo * --rebuild Rebuild all sources *
@echo * *
@echo * --release Build Release configuration *
@echo * --relwithdebinfo Build RelWithDebInfo configuration *
@echo * --minsizerel Build MinSizeRel configuration *
@echo * --debug Build Debug configuration *
@echo * *
@echo * --all Build all 4 configurations *
@echo * --all Build all 4 configurations (default) *
@echo * *
@echo * --help Print thie message *
@echo * *
Expand All @@ -87,9 +87,9 @@ if [%VisualStudioVersion%]==[17.0] (^
set "VCstr=Visual Studio 17"
)
::-------------------------------------------------------------
:: Initialize local helper script to reinitialize environment
:: Initialize local helper script that can reinitialize environment
::-------------------------------------------------------------
@echo set "wxDIR=%wxDIR%" >> "%OCPN_Dir%\buildwin\configdev.bat"
@echo set "wxDIR=%wxDIR%" > "%OCPN_Dir%\buildwin\configdev.bat"
@echo set "wxWidgets_ROOT_DIR=%wxWidgets_ROOT_DIR%" >> "%OCPN_DIR%\buildwin\configdev.bat"
@echo set "wxWidgets_LIB_DIR=%wxWidgets_LIB_DIR%" >> "%OCPN_DIR%\buildwin\configdev.bat"
@echo set "VCver=%VCver%" >> "%OCPN_DIR%\buildwin\configdev.bat"
Expand Down Expand Up @@ -316,17 +316,14 @@ if [%ocpn_debug%]==[1] (^
if not exist "%OCPN_DIR%\build\Debug\plugins" (mkdir "%OCPN_DIR%\build\Debug\plugins")
)
if [%ocpn_release%]==[1] (^
:: call "%OCPN_DIR%\buildwin\docopyAll.bat" Release
if not exist "%OCPN_DIR%\build\Release" (mkdir "%OCPN_DIR%\build\Release")
if not exist "%OCPN_DIR%\build\Release\plugins" (mkdir "%OCPN_DIR%\build\Release\plugins")
)
if [%ocpn_relwithdebinfo%]==[1] (^
:: call "%OCPN_DIR%\buildwin\docopyAll.bat" RelWithDebInfo
if not exist "%OCPN_DIR%\build\RelWithDebInfo" (mkdir "%OCPN_DIR%\build\RelWithDebInfo")
if not exist "%OCPN_DIR%\build\RelWithDebInfo\plugins" (mkdir "%OCPN_DIR%\build\RelWithDebInfo\plugins")
)
if [%ocpn_minsizerel%]==[1] (^
:: call "%OCPN_DIR%\buildwin\docopyAll.bat" MinSizeRel
if not exist "%OCPN_DIR%\build\MinSizeRel" (mkdir "%OCPN_DIR%\build\MinSizeRel")
if not exist "%OCPN_DIR%\build\MinSizeRel\plugins" (mkdir "%OCPN_DIR%\build\MinSizeRel\plugins")
)
Expand All @@ -348,8 +345,7 @@ cd %OCPN_DIR%
set "_addpath=%OCPN_DIR%\build\%nsis%\NSIS\;%OCPN_DIR%\build\%nsis%\NSIS\bin\"
set "_addpath=%_addpath%;%OCPN_DIR%\build\%gettext%\tools\bin\"
@echo path^|find /i "%_addpath%" ^>nul ^|^| set "path=%path%;%_addpath%" >> "%OCPN_DIR%\buildwin\configdev.bat"
@set _addpath=
:: @echo cd "%OCPN_DIR%\build" >> "%OCPN_DIR%\buildwin\configdev.bat"
set _addpath=
endlocal
::-------------------------------------------------------------
:: Setup environment
Expand Down
1 change: 1 addition & 0 deletions include/plugin_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class PlugInData {

PlugInData();

bool m_has_setup_options; //!< Has run NotifySetupOptionsPlugin()
bool m_enabled;
bool m_init_state;
bool m_toolbox_panel;
Expand Down
3 changes: 3 additions & 0 deletions src/catalog_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ catalog_status CatalogHandler::DoParseCatalog(const std::string xml,
std::stringstream ss;
ss << plugin_xml.rdbuf();
PluginMetadata metadata;
if (ss.str().size() == 0) {
continue;
}
::ParsePlugin(ss.str().c_str(), metadata);
metadata.is_imported = true;
ctx->plugins.push_back(metadata);
Expand Down
36 changes: 34 additions & 2 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <wx/cmdline.h>
#include <wx/dynlib.h>
#include <wx/fileconf.h>
#include <wx/init.h>
#include <wx/string.h>

#include "base_platform.h"
Expand Down Expand Up @@ -261,7 +262,9 @@ class CliApp : public wxAppConsole {
auto plugins = PluginHandler::getInstance()->getInstalled();
for (const auto& p : plugins) {
if (p.version == "0.0") continue;
cout << left << setw(25) << p.name << p.version << "\n";
auto path = PluginHandler::ImportedMetadataPath(p.name);
std::string suffix(ocpn::exists(path) ? "[imported]" : "");
cout << left << setw(25) << p.name << p.version << suffix << "\n";
}
}

Expand Down Expand Up @@ -292,7 +295,31 @@ class CliApp : public wxAppConsole {
}

void import_plugin(const std::string& tarball_path) {
PluginHandler::getInstance()->installPlugin(tarball_path);
auto handler = PluginHandler::getInstance();
PluginMetadata metadata;
bool ok = handler->ExtractMetadata(tarball_path, metadata);
if (!ok) {
std::cerr << "Cannot extract metadata (malformed tarball?)\n";
exit(2);
}
if (!PluginHandler::isCompatible(metadata)) {
std::cerr << "Incompatible plugin detected\n";
exit(2);
}
ok = handler->installPlugin(metadata, tarball_path);
if (!ok) {
std::cerr << "Error extracting import plugin tarball.\n";
exit(2);
}
metadata.is_imported = true;
auto metadata_path = PluginHandler::ImportedMetadataPath(metadata.name);
std::ofstream file(metadata_path);
file << metadata.to_string();
if (!file.good()) {
std::cerr << "Error saving metadata file: " << metadata_path
<< " for imported plugin: " << metadata.name;
exit(2);
}
exit(0);
}

Expand Down Expand Up @@ -378,6 +405,11 @@ class CliApp : public wxAppConsole {
}

bool OnCmdLineParsed(wxCmdLineParser& parser) {
wxInitializer initializer;
if (!initializer) {
std::cerr << "Failed to initialize the wxWidgets library, aborting.";
exit(1);
}
wxAppConsole::OnCmdLineParsed(parser);
if (argc == 1) {
std::cout << "OpenCPN CLI application. Use -h for help\n";
Expand Down
5 changes: 4 additions & 1 deletion src/plugin_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ PlugInContainer::PlugInContainer()
: PlugInData(), m_pplugin(nullptr), m_library(), m_destroy_fn(nullptr) {}

PlugInData::PlugInData()
: m_enabled(false),
: m_has_setup_options(false),
m_enabled(false),
m_init_state(false),
m_toolbox_panel(false),
m_cap_flag(0),
Expand Down Expand Up @@ -288,6 +289,8 @@ void PluginLoader::ShowPreferencesDialog(const PlugInData& pd,
void PluginLoader::NotifySetupOptionsPlugin(const PlugInData* pd) {
auto pic = GetContainer(*pd, *GetPlugInArray());
if (!pic) return;
if (pic->m_has_setup_options) return;
pic->m_has_setup_options = true;
if (pic->m_enabled && pic->m_init_state) {
if (pic->m_cap_flag & INSTALLS_TOOLBOX_PAGE) {
switch (pic->m_api_version) {
Expand Down

0 comments on commit 20a781e

Please sign in to comment.