From 83ef5fd7d6e54f5832e2b4fae45f64d66361a18b Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 19 Mar 2024 21:53:21 -0400 Subject: [PATCH] Move PGM_BASE to kicommon --- bitmap2component/bitmap2cmp_main.cpp | 19 ---- common/CMakeLists.txt | 95 ++++++++++--------- .../dialogs/dialog_migrate_settings_base.fbp | 2 +- common/dialogs/dialog_migrate_settings_base.h | 4 +- common/kiway.cpp | 8 +- common/pgm_base.cpp | 19 ++++ common/single_top.cpp | 9 +- cvpcb/cvpcb.cpp | 19 ---- eeschema/CMakeLists.txt | 6 +- eeschema/eeschema.cpp | 18 ---- .../symbol_editor/symbol_editor_settings.cpp | 2 +- gerbview/CMakeLists.txt | 6 +- gerbview/gerbview.cpp | 18 ---- include/background_jobs_monitor.h | 7 +- include/bitmap_store.h | 5 +- include/bitmaps/bitmap_types.h | 22 +++-- include/common.h | 30 +++--- include/database/database_lib_settings.h | 26 ++--- include/dialog_shim.h | 3 +- include/dialogs/dialog_migrate_settings.h | 2 +- include/env_vars.h | 19 ++-- include/gestfich.h | 18 ++-- include/kiway.h | 5 +- include/kiway_express.h | 3 +- include/kiway_holder.h | 4 +- include/launch_ext.h | 4 +- include/lib_table_base.h | 7 +- include/notifications_manager.h | 5 +- include/pgm_base.h | 13 ++- include/project.h | 4 +- include/project/board_project_settings.h | 18 ++-- include/project/net_settings.h | 2 +- include/project/project_archiver.h | 3 +- include/project/project_file.h | 2 +- include/project/project_local_settings.h | 4 +- include/search_stack.h | 3 +- include/settings/app_settings.h | 10 +- include/settings/color_settings.h | 2 +- include/settings/common_settings.h | 2 +- include/settings/kicad_settings.h | 2 +- include/settings/parameters.h | 33 ++++++- include/settings/settings_manager.h | 2 +- include/systemdirsappend.h | 4 +- include/widgets/bitmap_button.h | 3 +- include/widgets/kistatusbar.h | 4 +- include/widgets/ui_common.h | 55 +++++------ kicad/kicad.cpp | 18 +--- kicad/kicad_cli.cpp | 27 +----- pagelayout_editor/CMakeLists.txt | 6 +- pagelayout_editor/pl_editor.cpp | 18 ---- pcb_calculator/CMakeLists.txt | 6 +- pcb_calculator/pcb_calculator.cpp | 16 ---- pcbnew/pcbnew.cpp | 20 ---- qa/mocks/kicad/common_mocks.cpp | 16 ---- qa/qa_utils/test_app_main.cpp | 20 +--- qa/tests/common/test_module.cpp | 2 + qa/tests/eeschema/test_module.cpp | 2 + qa/tests/gerbview/CMakeLists.txt | 1 + qa/tests/gerbview/test_module.cpp | 2 + qa/tests/pcbnew/CMakeLists.txt | 1 + qa/tests/pcbnew/test_module.cpp | 2 + qa/tests/spice/test_module.cpp | 2 + scripting/CMakeLists.txt | 2 +- scripting/kicad_scripting_main.cpp | 17 ---- scripting/python_scripting.cpp | 3 - scripting/python_scripting.h | 23 +++-- 66 files changed, 311 insertions(+), 444 deletions(-) diff --git a/bitmap2component/bitmap2cmp_main.cpp b/bitmap2component/bitmap2cmp_main.cpp index 3fe594d9ef..e0c6636a08 100644 --- a/bitmap2component/bitmap2cmp_main.cpp +++ b/bitmap2component/bitmap2cmp_main.cpp @@ -69,8 +69,6 @@ static struct IFACE : public KIFACE_BASE using namespace BMP2CMP; -static PGM_BASE* process; - KIFACE_BASE& Kiface() { @@ -82,27 +80,10 @@ KIFACE_BASE& Kiface() // KIFACE_GETTER will not have name mangling due to declaration in kiway.h. KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram ) { - process = (PGM_BASE*) aProgram; return &kiface; } -#if defined(BUILD_KIWAY_DLLS) -PGM_BASE& Pgm() -{ - wxASSERT( process ); // KIFACE_GETTER has already been called. - return *process; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. -PGM_BASE* PgmOrNull() -{ - return process; -} -#endif - - bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) { return start_common( aCtlBits ); diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 2e9235f631..07b35d676c 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -97,44 +97,84 @@ set( KICOMMON_SRCS kicad_curl/kicad_curl.cpp kicad_curl/kicad_curl_easy.cpp + settings/app_settings.cpp settings/aui_settings.cpp settings/bom_settings.cpp + settings/color_settings.cpp + settings/common_settings.cpp settings/grid_settings.cpp settings/json_settings.cpp + settings/kicad_settings.cpp settings/nested_settings.cpp settings/parameters.cpp + settings/settings_manager.cpp + project/board_project_settings.cpp + project/net_settings.cpp + project/project_archiver.cpp + project/project_file.cpp + project/project_local_settings.cpp + + dialogs/dialog_migrate_settings.cpp + dialogs/dialog_migrate_settings_base.cpp + + widgets/bitmap_button.cpp + widgets/kistatusbar.cpp widgets/progress_reporter_base.cpp widgets/std_bitmap_button.cpp + widgets/ui_common.cpp + + database/database_lib_settings.cpp advanced_config.cpp asset_archive.cpp array_axis.cpp array_options.cpp + background_jobs_monitor.cpp + bitmap.cpp bitmap_info.cpp + bitmap_store.cpp build_version.cpp + common.cpp config_params.cpp confirm.cpp + dialog_shim.cpp dsnlexer.cpp eda_pattern_match.cpp eda_units.cpp + env_vars.cpp exceptions.cpp + gestfich.cpp kiid.cpp + kiway.cpp + kiway_express.cpp + kiway_holder.cpp + launch_ext.cpp + lib_table_base.cpp layer_id.cpp lib_id.cpp locale_io.cpp lset.cpp markup_parser.cpp netclass.cpp + notifications_manager.cpp page_info.cpp paths.cpp + project.cpp richio.cpp + search_stack.cpp + searchhelpfilefullpath.cpp string_utils.cpp + systemdirsappend.cpp ui_events.cpp trace_helpers.cpp wildcards_and_files_ext.cpp wx_filename.cpp + pgm_base.cpp + + ../scripting/python_scripting.cpp + io/kicad/kicad_io_utils.cpp # needed by richio ) @@ -161,8 +201,19 @@ target_link_libraries( kicommon ${FREETYPE_LIBRARIES} ${HarfBuzz_LIBRARIES} ${Fontconfig_LIBRARIES} + + # needed because of python_scripting.cpp + ${PYTHON_LIBRARIES} ) + +if( KICAD_USE_SENTRY ) + target_link_libraries( kicommon + sentry ) + + set_property(SOURCE pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}") +endif() + include( ${KICAD_CMAKE_MODULE_PATH}/KiCadVersion.cmake ) include( ${KICAD_CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake ) create_git_version_header(${CMAKE_SOURCE_DIR}) @@ -250,8 +301,6 @@ set( COMMON_DLG_SRCS dialogs/dialog_import_choose_project_base.cpp dialogs/dialog_locked_items_query.cpp dialogs/dialog_locked_items_query_base.cpp - dialogs/dialog_migrate_settings.cpp - dialogs/dialog_migrate_settings_base.cpp dialogs/dialog_page_settings_base.cpp dialogs/dialog_paste_special.cpp dialogs/dialog_paste_special_base.cpp @@ -301,7 +350,6 @@ endif() set( COMMON_WIDGET_SRCS widgets/app_progress_dialog.cpp - widgets/bitmap_button.cpp widgets/bitmap_toggle.cpp widgets/button_row_panel.cpp widgets/color_swatch.cpp @@ -322,7 +370,6 @@ set( COMMON_WIDGET_SRCS widgets/html_window.cpp widgets/indicator_icon.cpp widgets/wx_infobar.cpp - widgets/kistatusbar.cpp widgets/layer_box_selector.cpp widgets/lib_tree.cpp widgets/mathplot.cpp @@ -336,7 +383,6 @@ set( COMMON_WIDGET_SRCS widgets/split_button.cpp widgets/stepped_slider.cpp widgets/text_ctrl_eval.cpp - widgets/ui_common.cpp widgets/unit_binder.cpp widgets/widget_save_restore.cpp widgets/widget_hotkey_list.cpp @@ -455,17 +501,12 @@ set( COMMON_SRCS ${COMMON_IMPORT_GFX_SRCS} ${COMMON_GIT_SRCS} jobs/job_dispatcher.cpp - background_jobs_monitor.cpp base_screen.cpp bin_mod.cpp - bitmap.cpp bitmap_base.cpp - bitmap_store.cpp board_printout.cpp cli_progress_reporter.cpp commit.cpp - common.cpp - dialog_shim.cpp dpi_scaling_common.cpp draw_panel_gal.cpp gal_display_options_common.cpp @@ -479,7 +520,6 @@ set( COMMON_SRCS eda_text.cpp eda_tools.cpp env_paths.cpp - env_vars.cpp executable_names.cpp filename_resolver.cpp file_history.cpp @@ -487,38 +527,27 @@ set( COMMON_SRCS footprint_filter.cpp footprint_info.cpp gbr_metadata.cpp - gestfich.cpp gr_basic.cpp grid_tricks.cpp hotkey_store.cpp hotkeys_basic.cpp kiface_base.cpp - kiway.cpp - kiway_express.cpp - kiway_holder.cpp kiway_player.cpp - launch_ext.cpp - lib_table_base.cpp lib_table_grid_tricks.cpp lib_tree_model.cpp lib_tree_model_adapter.cpp marker_base.cpp - notifications_manager.cpp origin_transforms.cpp printout.cpp - project.cpp ptree.cpp rc_item.cpp refdes_utils.cpp render_settings.cpp reporter.cpp scintilla_tricks.cpp - search_stack.cpp - searchhelpfilefullpath.cpp status_popup.cpp string_utf8_map.cpp stroke_params.cpp - systemdirsappend.cpp template_fieldnames.cpp textentry_tricks.cpp title_block.cpp @@ -529,16 +558,6 @@ set( COMMON_SRCS view/wx_view_controls.cpp ) -if( TRUE OR NOT USE_KIWAY_DLLS ) -#if( NOT USE_KIWAY_DLLS ) - # We DO NOT want pgm_base.cpp linked into the KIFACE, only into the KIWAY. - # Check the map files to verify eda_pgm.o not being linked in. - list( APPEND COMMON_SRCS pgm_base.cpp ) - if( KICAD_USE_SENTRY ) - set_property(SOURCE pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}") - endif() -endif() - set( COMMON_SRCS ${COMMON_SRCS} @@ -572,18 +591,7 @@ set( COMMON_SRCS tool/zoom_menu.cpp tool/zoom_tool.cpp - settings/app_settings.cpp - settings/color_settings.cpp settings/cvpcb_settings.cpp - settings/common_settings.cpp - settings/settings_manager.cpp - settings/kicad_settings.cpp - - project/board_project_settings.cpp - project/net_settings.cpp - project/project_archiver.cpp - project/project_file.cpp - project/project_local_settings.cpp properties/color4d_variant.cpp properties/eda_angle_variant.cpp @@ -594,7 +602,6 @@ set( COMMON_SRCS properties/std_optional_variants.cpp database/database_connection.cpp - database/database_lib_settings.cpp http_lib/http_lib_connection.cpp http_lib/http_lib_settings.cpp diff --git a/common/dialogs/dialog_migrate_settings_base.fbp b/common/dialogs/dialog_migrate_settings_base.fbp index 6c2ecdc229..94a58407ea 100644 --- a/common/dialogs/dialog_migrate_settings_base.fbp +++ b/common/dialogs/dialog_migrate_settings_base.fbp @@ -2,7 +2,7 @@ - ; + KICOMMON_API; kicommon.h C++ 1 source_name diff --git a/common/dialogs/dialog_migrate_settings_base.h b/common/dialogs/dialog_migrate_settings_base.h index 252f3f439d..4b9c443c70 100644 --- a/common/dialogs/dialog_migrate_settings_base.h +++ b/common/dialogs/dialog_migrate_settings_base.h @@ -30,13 +30,15 @@ class STD_BITMAP_BUTTON; #include #include +#include "kicommon.h" + /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_MIGRATE_SETTINGS_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM +class KICOMMON_API DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM { private: diff --git a/common/kiway.cpp b/common/kiway.cpp index b7b986d890..6cb629c05f 100644 --- a/common/kiway.cpp +++ b/common/kiway.cpp @@ -54,8 +54,8 @@ int KIWAY::m_kiface_version[KIWAY_FACE_COUNT]; -KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ): - m_program( aProgram ), m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE ) +KIWAY::KIWAY( int aCtlBits, wxFrame* aTop ): + m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE ) { SetTop( aTop ); // hook player_destroy_handler() into aTop. @@ -296,7 +296,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad ) { KIFACE_GETTER_FUNC* ki_getter = (KIFACE_GETTER_FUNC*) addr; - KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, m_program ); + KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, &Pgm() ); // KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional. wxASSERT_MSG( kiface, @@ -311,7 +311,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad ) try { - startSuccess = kiface->OnKifaceStart( m_program, m_ctl, this ); + startSuccess = kiface->OnKifaceStart( &Pgm(), m_ctl, this ); } catch (...) { diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 44f2c5fc1a..5fc3272531 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -1025,3 +1025,22 @@ void PGM_BASE::WritePdfBrowserInfos() GetCommonSettings()->m_System.pdf_viewer_name = GetPdfBrowserName(); GetCommonSettings()->m_System.use_system_pdf_viewer = m_use_system_pdf_browser; } + +static PGM_BASE* process; + +PGM_BASE& Pgm() +{ + wxASSERT( process ); // KIFACE_GETTER has already been called. + return *process; +} + +// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. +PGM_BASE* PgmOrNull() +{ + return process; +} + +void SetPgm(PGM_BASE* pgm) +{ + process = pgm; +} \ No newline at end of file diff --git a/common/single_top.cpp b/common/single_top.cpp index f6ddbc261a..4c85457d98 100644 --- a/common/single_top.cpp +++ b/common/single_top.cpp @@ -60,7 +60,7 @@ // Only a single KIWAY is supported in this single_top top level component, // which is dedicated to loading only a single DSO. -KIWAY Kiway( &Pgm(), KFCTL_STANDALONE ); +KIWAY Kiway( KFCTL_STANDALONE ); // implement a PGM_BASE and a wxApp side by side: @@ -115,12 +115,6 @@ static struct PGM_SINGLE_TOP : public PGM_BASE } program; - -PGM_BASE& Pgm() -{ - return program; -} - // A module to allow Html module initialization/cleanup // When a wxHtmlWindow is used *only* in a dll/so module, the Html text is displayed // as plain text. @@ -158,6 +152,7 @@ struct APP_SINGLE_TOP : public wxApp { APP_SINGLE_TOP() : wxApp() { + SetPgm( &program ); // Init the environment each platform wants KIPLATFORM::ENV::Init(); } diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index cc59a8141a..253f73ae4c 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -133,9 +133,6 @@ static struct IFACE : public KIFACE_BASE using namespace CV; -static PGM_BASE* process; - - KIFACE_BASE& Kiface() { return kiface; } @@ -143,26 +140,10 @@ KIFACE_BASE& Kiface() { return kiface; } // KIFACE_GETTER will not have name mangling due to declaration in kiway.h. KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram ) { - process = (PGM_BASE*) aProgram; return &kiface; } -PGM_BASE& Pgm() -{ - wxASSERT( process ); // KIFACE_GETTER has already been called. - return *process; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face -// is run from a python script, mot from a Kicad application -PGM_BASE* PgmOrNull() -{ - return process; -} - - /// The global footprint library table. This is not dynamically allocated because /// in a multiple project environment we must keep its address constant (since it is /// the fallback table for multiple projects). diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 801970d72c..0cbc750d36 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -535,14 +535,9 @@ endif() add_executable( eeschema WIN32 MACOSX_BUNDLE ${CMAKE_SOURCE_DIR}/common/single_top.cpp - ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp ${EESCHEMA_RESOURCES} ) -if( KICAD_USE_SENTRY ) - set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}") -endif() - set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES COMPILE_DEFINITIONS "TOP_FRAME=FRAME_SCH;PGM_DATA_FILE_EXT=\"kicad_sch\";BUILD_KIWAY_DLL" ) @@ -553,6 +548,7 @@ target_link_libraries( eeschema common pcbcommon argparse::argparse + kicommon ${wxWidgets_LIBRARIES} ) diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 3a9c131e69..5d671eaf03 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -347,8 +347,6 @@ private: using namespace SCH; -static PGM_BASE* process; - KIFACE_BASE& Kiface() { return kiface; } @@ -357,26 +355,10 @@ KIFACE_BASE& Kiface() { return kiface; } // KIFACE_GETTER will not have name mangling due to declaration in kiway.h. KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram ) { - process = aProgram; return &kiface; } -PGM_BASE& Pgm() -{ - wxASSERT( process ); // KIFACE_GETTER has already been called. - return *process; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from -// a python script or something else. -PGM_BASE* PgmOrNull() -{ - return process; -} - - bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) { // This is process-level-initialization, not project-level-initialization of the DSO. diff --git a/eeschema/symbol_editor/symbol_editor_settings.cpp b/eeschema/symbol_editor/symbol_editor_settings.cpp index 863809bbc1..07436369d0 100644 --- a/eeschema/symbol_editor/symbol_editor_settings.cpp +++ b/eeschema/symbol_editor/symbol_editor_settings.cpp @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 669a26d366..f3e6b5ec3f 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -103,14 +103,9 @@ endif() add_executable( gerbview WIN32 MACOSX_BUNDLE ${CMAKE_SOURCE_DIR}/common/single_top.cpp - ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp ${GERBVIEW_RESOURCES} ) -if( KICAD_USE_SENTRY ) - set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}") -endif() - set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES COMPILE_DEFINITIONS "TOP_FRAME=FRAME_GERBER;BUILD_KIWAY_DLL" ) @@ -120,6 +115,7 @@ target_link_libraries( gerbview gal common core + kicommon nlohmann_json ${wxWidgets_LIBRARIES} ) diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index 7222861c23..6b3f5bd149 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -130,9 +130,6 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER using namespace GERBV; -static PGM_BASE* process; - - KIFACE_BASE& Kiface() { return kiface; } @@ -140,25 +137,10 @@ KIFACE_BASE& Kiface() { return kiface; } // KIFACE_GETTER will not have name mangling due to declaration in kiway.h. KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram ) { - process = aProgram; return &kiface; } -PGM_BASE& Pgm() -{ - wxASSERT( process ); // KIFACE_GETTER has already been called. - return *process; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. -PGM_BASE* PgmOrNull() -{ - return process; -} - - bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) { InitSettings( new GERBVIEW_SETTINGS ); diff --git a/include/background_jobs_monitor.h b/include/background_jobs_monitor.h index 006a70a364..762d8da4ec 100644 --- a/include/background_jobs_monitor.h +++ b/include/background_jobs_monitor.h @@ -25,6 +25,7 @@ #ifndef BACKGROUND_JOBS_MONITOR_H #define BACKGROUND_JOBS_MONITOR_H +#include #include #include #include @@ -41,7 +42,7 @@ class BACKGROUND_JOBS_MONITOR; class wxWindow; class wxCloseEvent; -class BACKGROUND_JOB_REPORTER : public PROGRESS_REPORTER_BASE +class KICOMMON_API BACKGROUND_JOB_REPORTER : public PROGRESS_REPORTER_BASE { public: BACKGROUND_JOB_REPORTER( BACKGROUND_JOBS_MONITOR* aMonitor, @@ -69,7 +70,7 @@ private: }; -struct BACKGROUND_JOB +struct KICOMMON_API BACKGROUND_JOB { public: wxString m_name; @@ -81,7 +82,7 @@ public: }; -class BACKGROUND_JOBS_MONITOR +class KICOMMON_API BACKGROUND_JOBS_MONITOR { friend class BACKGROUND_JOB_REPORTER; friend class BACKGROUND_JOB_LIST; diff --git a/include/bitmap_store.h b/include/bitmap_store.h index 8f6ba09ced..d38173d2eb 100644 --- a/include/bitmap_store.h +++ b/include/bitmap_store.h @@ -26,6 +26,7 @@ #include #include +#include class ASSET_ARCHIVE; class wxImage; @@ -33,7 +34,7 @@ class wxImage; namespace std { - template<> struct hash> + template<> struct KICOMMON_API hash> { size_t operator()( const std::pair& aPair ) const; }; @@ -42,7 +43,7 @@ namespace std /** * Helper to retrieve bitmaps while handling icon themes and scaling */ -class BITMAP_STORE +class KICOMMON_API BITMAP_STORE { public: BITMAP_STORE(); diff --git a/include/bitmaps/bitmap_types.h b/include/bitmaps/bitmap_types.h index e095f126fa..fd91990568 100644 --- a/include/bitmaps/bitmap_types.h +++ b/include/bitmaps/bitmap_types.h @@ -26,6 +26,8 @@ #ifndef BITMAP_TYPES_H_ #define BITMAP_TYPES_H_ +#include + //FIXME: cannot include only this file in wxWidgets 2.9.3 // test if it works under stable release // #include // only to define wxBitmap @@ -44,7 +46,7 @@ enum class BITMAP_TYPE BMP }; -BITMAP_STORE* GetBitmapStore(); +KICOMMON_API BITMAP_STORE* GetBitmapStore(); /** * Construct a wxBitmap from an image identifier @@ -52,17 +54,17 @@ BITMAP_STORE* GetBitmapStore(); * @param aBitmap is from the BITMAPS enum in bitmaps_list.h * @param aHeightTag is the requested height tag for multi-res bitmaps (-1 for any) */ -wxBitmap KiBitmap( BITMAPS aBitmap, int aHeightTag = -1 ); +KICOMMON_API wxBitmap KiBitmap( BITMAPS aBitmap, int aHeightTag = -1 ); -wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap ); +KICOMMON_API wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap ); -wxBitmapBundle KiDisabledBitmapBundle( BITMAPS aBitmap ); +KICOMMON_API wxBitmapBundle KiDisabledBitmapBundle( BITMAPS aBitmap ); /** * Wipes out the scaled bitmap cache so that the icon theme can be changed. * TODO: move scaling system into BITMAP_STORE so this global doesn't need to exist */ -void ClearScaledBitmapCache(); +KICOMMON_API void ClearScaledBitmapCache(); /** * Construct a wxBitmap from a memory record, scaling it if device DPI demands it. @@ -75,8 +77,8 @@ void ClearScaledBitmapCache(); * @param aHeight is the requested image height for the source bitmap, or -1 for any height * @param aQuantized if true scaling will be rounded to integers (2X, 3X, etc.). */ -wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1, - bool aQuantized = false ); +KICOMMON_API wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1, + bool aQuantized = false ); /** * Overload of the above function that takes another wxBitmap as a parameter. @@ -84,13 +86,13 @@ wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1, * @param aBitmap is the source bitmap to scale * @param aWindow target window for scaling context */ -wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, wxWindow* aWindow ); +KICOMMON_API wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, wxWindow* aWindow ); /** * Return the automatic scale factor that would be used for a given window by * KiScaledBitmap and KiScaledSeparator. */ -int KiIconScale( wxWindow* aWindow ); +KICOMMON_API int KiIconScale( wxWindow* aWindow ); /** * Allocate a wxBitmap on heap from a memory record, held in a BITMAPS. @@ -98,6 +100,6 @@ int KiIconScale( wxWindow* aWindow ); * @param aBitmap is from the BITMAPS enum in bitmaps_list.h * @return wxBitmap* - caller owns it. */ -wxBitmap* KiBitmapNew( BITMAPS aBitmap ); +KICOMMON_API wxBitmap* KiBitmapNew( BITMAPS aBitmap ); #endif // BITMAP_TYPES_H_ diff --git a/include/common.h b/include/common.h index af4d03fbb4..85ec06464b 100644 --- a/include/common.h +++ b/include/common.h @@ -32,6 +32,7 @@ #ifndef INCLUDE__COMMON_H_ #define INCLUDE__COMMON_H_ +#include #include #include @@ -55,7 +56,7 @@ class REPORTER; * @param aBaseName is the name of the help file to search for (without extension). * @return the full path and filename if \a aBaseName is found, else wxEmptyString. */ -wxString SearchHelpFileFullPath( const wxString& aBaseName ); +KICOMMON_API wxString SearchHelpFileFullPath( const wxString& aBaseName ); /** * Make \a aTargetFullFileName absolute and create the path of this file if it doesn't yet exist. @@ -66,14 +67,14 @@ wxString SearchHelpFileFullPath( const wxString& aBaseName ); * @param aReporter a point to a REPORTER object use to show messages (can be NULL) * @return true if \a aOutputDir already exists or was successfully created. */ -bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, - const wxString& aBaseFilename, - REPORTER* aReporter = nullptr ); +KICOMMON_API bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, + const wxString& aBaseFilename, + REPORTER* aReporter = nullptr ); /** * It's annoying to throw up nag dialogs when the extension isn't right. Just fix it. */ -wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtension ); +KICOMMON_API wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtension ); /** * Replace any environment variable & text variable references with their values. @@ -81,34 +82,35 @@ wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtens * @param aString a string containing (perhaps) references to env var * @return the expanded environment variable. */ -const wxString ExpandEnvVarSubstitutions( const wxString& aString, const PROJECT* aProject ); +KICOMMON_API const wxString ExpandEnvVarSubstitutions( const wxString& aString, + const PROJECT* aProject ); /** * Expand '${var-name}' templates in text. */ -wxString ExpandTextVars( const wxString& aSource, - const std::function* aResolver ); +KICOMMON_API wxString ExpandTextVars( const wxString& aSource, + const std::function* aResolver ); -wxString ExpandTextVars( const wxString& aSource, const PROJECT* aProject ); +KICOMMON_API wxString ExpandTextVars( const wxString& aSource, const PROJECT* aProject ); /** * Returns any variables unexpanded, e.g. ${VAR} -> VAR */ -wxString GetTextVars( const wxString& aSource ); +KICOMMON_API wxString GetTextVars( const wxString& aSource ); /** * Returns true if the string is a text var, e.g starts with ${ */ -bool IsTextVar( const wxString& aSource ); +KICOMMON_API bool IsTextVar( const wxString& aSource ); /** * Replace any environment and/or text variables in file-path uris (leaving network-path URIs * alone). */ -const wxString ResolveUriByEnvVars( const wxString& aUri, PROJECT* aProject ); +KICOMMON_API const wxString ResolveUriByEnvVars( const wxString& aUri, PROJECT* aProject ); -long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec ); +KICOMMON_API long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec ); /** @@ -116,7 +118,7 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec ); * * @return true if the operating system is unsupported */ -bool WarnUserIfOperatingSystemUnsupported(); +KICOMMON_API bool WarnUserIfOperatingSystemUnsupported(); #endif // INCLUDE__COMMON_H_ diff --git a/include/database/database_lib_settings.h b/include/database/database_lib_settings.h index c090011476..5661c9883b 100644 --- a/include/database/database_lib_settings.h +++ b/include/database/database_lib_settings.h @@ -32,7 +32,7 @@ enum class DATABASE_SOURCE_TYPE }; -struct DATABASE_SOURCE +struct KICOMMON_API DATABASE_SOURCE { DATABASE_SOURCE_TYPE type; std::string dsn; @@ -43,15 +43,15 @@ struct DATABASE_SOURCE }; -struct DATABASE_FIELD_MAPPING +struct KICOMMON_API DATABASE_FIELD_MAPPING { - const std::string column; ///< Database column name - const std::string name; ///< KiCad field name - const wxString name_wx; ///< KiCad field name (converted) - const bool visible_on_add; ///< Whether to show the field when placing the symbol - const bool visible_in_chooser; ///< Whether the column is shown by default in the chooser - const bool show_name; ///< Whether or not to show the field name as well as its value - const bool inherit_properties; ///< Whether or not to inherit properties from symbol field + std::string column; ///< Database column name + std::string name; ///< KiCad field name + wxString name_wx; ///< KiCad field name (converted) + bool visible_on_add; ///< Whether to show the field when placing the symbol + bool visible_in_chooser; ///< Whether the column is shown by default in the chooser + bool show_name; ///< Whether or not to show the field name as well as its value + bool inherit_properties; ///< Whether or not to inherit properties from symbol field explicit DATABASE_FIELD_MAPPING( std::string aColumn, std::string aName, bool aVisibleOnAdd, bool aVisibleInChooser, bool aShowName, @@ -59,7 +59,7 @@ struct DATABASE_FIELD_MAPPING }; -struct MAPPABLE_SYMBOL_PROPERTIES +struct KICOMMON_API MAPPABLE_SYMBOL_PROPERTIES { std::string description; std::string footprint_filters; @@ -83,7 +83,7 @@ struct MAPPABLE_SYMBOL_PROPERTIES * table called "Capacitors", with `key_col` set to "Part Number", the LIB_ID for a capacitor placed * from this table will look something like `PartsDB-Capacitors:CAP-001` */ -struct DATABASE_LIB_TABLE +struct KICOMMON_API DATABASE_LIB_TABLE { std::string name; ///< KiCad library nickname (will form part of the LIB_ID) std::string table; ///< Database table to pull content from @@ -96,14 +96,14 @@ struct DATABASE_LIB_TABLE }; -struct DATABASE_CACHE_SETTINGS +struct KICOMMON_API DATABASE_CACHE_SETTINGS { int max_size; ///< Maximum number of single-row results to cache int max_age; ///< Max age of cached rows before they expire, in seconds }; -class DATABASE_LIB_SETTINGS : public JSON_SETTINGS +class KICOMMON_API DATABASE_LIB_SETTINGS : public JSON_SETTINGS { public: DATABASE_LIB_SETTINGS( const std::string& aFilename ); diff --git a/include/dialog_shim.h b/include/dialog_shim.h index c7249d36ab..2b54f65653 100644 --- a/include/dialog_shim.h +++ b/include/dialog_shim.h @@ -25,6 +25,7 @@ #ifndef DIALOG_SHIM_ #define DIALOG_SHIM_ +#include #include #include class wxGridEvent; @@ -79,7 +80,7 @@ class WX_EVENT_LOOP; *
* in the dialog window's properties. */ -class DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER +class KICOMMON_API DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER { public: DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title, diff --git a/include/dialogs/dialog_migrate_settings.h b/include/dialogs/dialog_migrate_settings.h index d65ac31580..396125a3fd 100644 --- a/include/dialogs/dialog_migrate_settings.h +++ b/include/dialogs/dialog_migrate_settings.h @@ -27,7 +27,7 @@ class SETTINGS_MANAGER; -class DIALOG_MIGRATE_SETTINGS : public DIALOG_MIGRATE_SETTINGS_BASE +class KICOMMON_API DIALOG_MIGRATE_SETTINGS : public DIALOG_MIGRATE_SETTINGS_BASE { public: DIALOG_MIGRATE_SETTINGS( SETTINGS_MANAGER* aManager ); diff --git a/include/env_vars.h b/include/env_vars.h index ee7b78b2ac..ffb6ba8e8a 100644 --- a/include/env_vars.h +++ b/include/env_vars.h @@ -25,6 +25,7 @@ #ifndef ENV_VARS_H #define ENV_VARS_H +#include #include #include #include @@ -43,19 +44,19 @@ namespace ENV_VAR * @param aEnvVar the variable to check * @return true if predefined */ - bool IsEnvVarImmutable( const wxString& aEnvVar ); + KICOMMON_API bool IsEnvVarImmutable( const wxString& aEnvVar ); /** * Get the list of pre-defined environment variables. */ - const ENV_VAR_LIST& GetPredefinedEnvVars(); + KICOMMON_API const ENV_VAR_LIST& GetPredefinedEnvVars(); /** * Constructs a versioned environment variable based on this KiCad major version * @param aBaseName is the suffix, like TEMPLATE_DIR * @return an environment variable name, like KICAD8_TEMPLATE_DIR */ - wxString GetVersionedEnvVarName( const wxString& aBaseName ); + KICOMMON_API wxString GetVersionedEnvVarName( const wxString& aBaseName ); /** * Attempts to retrieve the value of a versioned environment variable, such as @@ -65,8 +66,8 @@ namespace ENV_VAR * @param aMap is an ENV_VAR_MAP (@see environment.h) * @param aBaseName is the suffix for the environment variable (@see GetVersionedEnvVarName) */ - std::optional GetVersionedEnvVarValue( const std::map& aMap, - const wxString& aBaseName ); + KICOMMON_API std::optional GetVersionedEnvVarValue( const std::map& aMap, + const wxString& aBaseName ); /** * Look up long-form help text for a given environment variable. @@ -78,7 +79,7 @@ namespace ENV_VAR * @return A string with help for that variable. Empty if * no help available for this variable. */ - wxString LookUpEnvVarHelp( const wxString& aEnvVar ); + KICOMMON_API wxString LookUpEnvVarHelp( const wxString& aEnvVar ); /** * Get an environment variable as a specific type, if set correctly @@ -87,7 +88,7 @@ namespace ENV_VAR * @return an std::optional containing the value, if set and parseable, otherwise empty. */ template - std::optional GetEnvVar( const wxString& aEnvVarName ); + KICOMMON_API std::optional GetEnvVar( const wxString& aEnvVarName ); /** * Get a string environment variable, if it is set. @@ -96,7 +97,7 @@ namespace ENV_VAR * @return an std::optional containing the value, if set, otherwise empty. */ template<> - std::optional GetEnvVar( const wxString& aEnvVarName ); + KICOMMON_API std::optional GetEnvVar( const wxString& aEnvVarName ); /** * Get a double from an environment variable, if set @@ -106,7 +107,7 @@ namespace ENV_VAR * otherwise empty. */ template <> - std::optional GetEnvVar( const wxString& aEnvVarName ); + KICOMMON_API std::optional GetEnvVar( const wxString& aEnvVarName ); }; #endif /* ENV_VARS_H */ diff --git a/include/gestfich.h b/include/gestfich.h index 9be97b9bbd..a4a75291ac 100644 --- a/include/gestfich.h +++ b/include/gestfich.h @@ -25,6 +25,7 @@ #ifndef GESTFICH_H #define GESTFICH_H +#include #include #include @@ -45,15 +46,16 @@ class EDA_LIST_DIALOG; * @param file the PDF file to open. * @return true is success or false if no PDF viewer found. */ -bool OpenPDF( const wxString& file ); -void OpenFile( const wxString& file ); +KICOMMON_API bool OpenPDF( const wxString& file ); +KICOMMON_API void OpenFile( const wxString& file ); /** * @param aSrcPath is the full filename of the source. * @param aDestPath is the full filename of the target * @param aErrors a wxString to *append* any errors to */ -void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString& aErrors ); +KICOMMON_API void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, + wxString& aErrors ); /** * Call the executable file \a aEditorName with the parameter \a aFileName. @@ -64,7 +66,7 @@ void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString& * In this case aFileName is a shortname and FindKicadFile() is called to return the path. * In the other case, aFileName is a full file name (passed prefixed with the path). */ -int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmptyString, +KICOMMON_API int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmptyString, wxProcess* aCallback = nullptr, bool aFileForKicad = true ); /** @@ -72,7 +74,7 @@ int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmpt * * @param string string to modify. */ -void QuoteString( wxString& string ); +KICOMMON_API void QuoteString( wxString& string ); /** * Search the executable file shortname in KiCad binary path and return full file @@ -84,7 +86,7 @@ void QuoteString( wxString& string ); * - c:\\kicad or /usr/local/kicad (the default). * - default binary path. */ -wxString FindKicadFile( const wxString& shortname ); +KICOMMON_API wxString FindKicadFile( const wxString& shortname ); /** * Quote return value of wxFileName::GetFullPath(). @@ -96,13 +98,13 @@ wxString FindKicadFile( const wxString& shortname ); * @param format if provided, can be used to transform the nature of the wrapped filename * to another platform. */ -extern wxString QuoteFullPath( wxFileName& fn, wxPathFormat format = wxPATH_NATIVE ); +KICOMMON_API extern wxString QuoteFullPath( wxFileName& fn, wxPathFormat format = wxPATH_NATIVE ); /** * Removes the directory \a aDirName and all its contents including * subdirectories and their files */ -bool RmDirRecursive( const wxString& aDirName, wxString* aErrors = nullptr ); +KICOMMON_API bool RmDirRecursive( const wxString& aDirName, wxString* aErrors = nullptr ); #endif /* GESTFICH_H */ diff --git a/include/kiway.h b/include/kiway.h index ab28a03a1e..b6ab629a2c 100644 --- a/include/kiway.h +++ b/include/kiway.h @@ -275,7 +275,7 @@ struct KIFACE * and a #NETLIST, (anything relating to production of a single #BOARD and added to class * #PROJECT.) */ -class KIWAY : public wxEvtHandler +class KICOMMON_API KIWAY : public wxEvtHandler { friend struct PGM_SINGLE_TOP; // can use set_kiface() @@ -403,7 +403,7 @@ public: */ virtual void ProjectChanged(); - KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop = nullptr ); + KIWAY( int aCtlBits, wxFrame* aTop = nullptr ); /** * Overwrites previously set ctl bits, only for use in kicad.cpp to flip between @@ -459,7 +459,6 @@ private: static KIFACE* m_kiface[KIWAY_FACE_COUNT]; static int m_kiface_version[KIWAY_FACE_COUNT]; - PGM_BASE* m_program; int m_ctl; wxFrame* m_top; // Usually m_top is the Project manager diff --git a/include/kiway_express.h b/include/kiway_express.h index 4c58f6b834..01a8d2bddd 100644 --- a/include/kiway_express.h +++ b/include/kiway_express.h @@ -28,6 +28,7 @@ // @see http://wiki.wxwidgets.org/Custom_Events_Tutorial #include #include +#include #include #include @@ -35,7 +36,7 @@ /** * Carry a payload from one #KIWAY_PLAYER to another within a #PROJECT. */ -class KIWAY_EXPRESS : public wxEvent +class KICOMMON_API KIWAY_EXPRESS : public wxEvent { public: /** diff --git a/include/kiway_holder.h b/include/kiway_holder.h index 336432c4fe..61acee91c9 100644 --- a/include/kiway_holder.h +++ b/include/kiway_holder.h @@ -24,6 +24,8 @@ #ifndef KIWAY_HOLDER_H_ #define KIWAY_HOLDER_H_ +#include + class KIWAY; class PROJECT; class wxWindow; @@ -33,7 +35,7 @@ class wxWindow; * * It allows calls to Kiway() and SetKiway(). */ -class KIWAY_HOLDER +class KICOMMON_API KIWAY_HOLDER { public: enum HOLDER_TYPE { DIALOG, FRAME, PANEL }; diff --git a/include/launch_ext.h b/include/launch_ext.h index 372a76f16c..72aef84e34 100644 --- a/include/launch_ext.h +++ b/include/launch_ext.h @@ -21,12 +21,14 @@ #ifndef LAUNCH_EXT_H #define LAUNCH_EXT_H +#include + class wxString; /** * Launches the given file or folder in the host OS * @param aPath is a path to a file or folder */ -bool LaunchExternal( const wxString& aPath ); +KICOMMON_API bool LaunchExternal( const wxString& aPath ); #endif diff --git a/include/lib_table_base.h b/include/lib_table_base.h index 3b4892f210..e30b9126d5 100644 --- a/include/lib_table_base.h +++ b/include/lib_table_base.h @@ -34,6 +34,7 @@ #include #include #include +#include class OUTPUTFORMATTER; class LIB_TABLE_LEXER; @@ -55,14 +56,14 @@ typedef LIB_TABLE_ROWS::const_iterator LIB_TABLE_ROWS_CITER; * store pointers the data is cloned. Copying and assigning pointers would cause ownership * issues if the standard C++ containers were used. */ -LIB_TABLE_ROW* new_clone( const LIB_TABLE_ROW& aRow ); +KICOMMON_API LIB_TABLE_ROW* new_clone( const LIB_TABLE_ROW& aRow ); /** * Hold a record identifying a library accessed by the appropriate plug in object in the * #LIB_TABLE. This is an abstract base class from which to derive library specific rows. */ -class LIB_TABLE_ROW +class KICOMMON_API LIB_TABLE_ROW { public: LIB_TABLE_ROW() : @@ -292,7 +293,7 @@ private: * * @author Wayne Stambaugh */ -class LIB_TABLE : public PROJECT::_ELEM +class KICOMMON_API LIB_TABLE : public PROJECT::_ELEM { public: /** diff --git a/include/notifications_manager.h b/include/notifications_manager.h index c64bfa5aa1..c79b55f482 100644 --- a/include/notifications_manager.h +++ b/include/notifications_manager.h @@ -25,6 +25,7 @@ #ifndef NOTIFICATIONS_MANAGER_H #define NOTIFICATIONS_MANAGER_H +#include #include #include @@ -36,7 +37,7 @@ class wxWindow; class wxCloseEvent; -struct NOTIFICATION +struct KICOMMON_API NOTIFICATION { public: wxString title; ///< Title of the notification @@ -47,7 +48,7 @@ public: }; -class NOTIFICATIONS_MANAGER +class KICOMMON_API NOTIFICATIONS_MANAGER { friend class NOTIFICATION_LIST; diff --git a/include/pgm_base.h b/include/pgm_base.h index c25ccd7519..22acf09112 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -31,6 +31,7 @@ #ifndef PGM_BASE_H_ #define PGM_BASE_H_ +#include #include #include #include @@ -58,7 +59,7 @@ class SCRIPTING; * maintainer's convenience. To add a support to a new translation add a new item * to #LanguagesList[]. */ -struct LANGUAGE_DESCR +struct KICOMMON_API LANGUAGE_DESCR { /// wxWidgets locale identifier (See wxWidgets doc) int m_WX_Lang_Identifier; @@ -77,7 +78,7 @@ struct LANGUAGE_DESCR /** * An array containing all the languages that KiCad supports. */ -extern LANGUAGE_DESCR LanguagesList[]; +KICOMMON_API extern LANGUAGE_DESCR LanguagesList[]; /** * Container for data for KiCad programs. @@ -92,7 +93,7 @@ extern LANGUAGE_DESCR LanguagesList[]; * - OnPgmEnd() is virtual, may be overridden, and parallels wxApp::OnExit(), from where it * should be called. */ -class PGM_BASE +class KICOMMON_API PGM_BASE { public: PGM_BASE(); @@ -430,11 +431,13 @@ protected: /// The global Program "get" accessor. /// Implemented in: 1) common/single_top.cpp, 2) kicad/kicad.cpp, and 3) scripting/kiway.i -extern PGM_BASE& Pgm(); +KICOMMON_API extern PGM_BASE& Pgm(); /// similar to PGM_BASE& Pgm(), but return a reference that can be nullptr /// when running a shared lib from a script, not from a kicad appl -extern PGM_BASE* PgmOrNull(); +KICOMMON_API extern PGM_BASE* PgmOrNull(); + +KICOMMON_API extern void SetPgm( PGM_BASE* pgm ); #endif // PGM_BASE_H_ diff --git a/include/project.h b/include/project.h index 8425e266f7..ebc20adae4 100644 --- a/include/project.h +++ b/include/project.h @@ -58,7 +58,7 @@ class PROJECT_LOCAL_SETTINGS; * Because it is in the neutral program top, which is not linked to by subsidiary DSOs, * any functions in this interface must be virtual. */ -class PROJECT +class KICOMMON_API PROJECT { public: /** @@ -69,7 +69,7 @@ public: * include derived class headers in this file, you are doing incompatible with the goal * of this class. Keep knowledge of derived classes opaque to class PROJECT please. */ - class _ELEM + class KICOMMON_API _ELEM { public: virtual ~_ELEM() {} diff --git a/include/project/board_project_settings.h b/include/project/board_project_settings.h index d596706864..889d4d6ba8 100644 --- a/include/project/board_project_settings.h +++ b/include/project/board_project_settings.h @@ -39,7 +39,7 @@ * Selection filtering that applies all the time (not the "filter selection" dialog that modifies * the current selection) */ -struct PCB_SELECTION_FILTER_OPTIONS +struct KICOMMON_API PCB_SELECTION_FILTER_OPTIONS { bool lockedItems; ///< Allow selecting locked items bool footprints; ///< Allow selecting entire footprints @@ -125,7 +125,7 @@ enum class RATSNEST_MODE }; ///< BOM Data choices for IPC2581 export -struct IP2581_BOM +struct KICOMMON_API IP2581_BOM { wxString mfg; ///< Manufacturer name column wxString MPN; ///< Manufacturer part number column @@ -137,7 +137,7 @@ struct IP2581_BOM /** * A saved set of layers that are visible. */ -struct LAYER_PRESET +struct KICOMMON_API LAYER_PRESET { LAYER_PRESET( const wxString& aName = wxS( "" ) ) : name( aName ), @@ -184,7 +184,7 @@ struct LAYER_PRESET }; -class PARAM_LAYER_PRESET : public PARAM_LAMBDA +class KICOMMON_API PARAM_LAYER_PRESET : public PARAM_LAMBDA { public: PARAM_LAYER_PRESET( const std::string& aPath, std::vector* aPresetList ); @@ -198,7 +198,7 @@ private: }; -struct VIEWPORT +struct KICOMMON_API VIEWPORT { VIEWPORT( const wxString& aName = wxEmptyString ) : name( aName ) @@ -214,7 +214,7 @@ struct VIEWPORT }; -class PARAM_VIEWPORT : public PARAM_LAMBDA +class KICOMMON_API PARAM_VIEWPORT : public PARAM_LAMBDA { public: PARAM_VIEWPORT( const std::string& aPath, std::vector* aViewportList ); @@ -228,7 +228,7 @@ private: }; -struct VIEWPORT3D +struct KICOMMON_API VIEWPORT3D { VIEWPORT3D( const wxString& aName = wxEmptyString ) : name( aName ) @@ -244,7 +244,7 @@ struct VIEWPORT3D }; -class PARAM_VIEWPORT3D : public PARAM_LAMBDA +class KICOMMON_API PARAM_VIEWPORT3D : public PARAM_LAMBDA { public: PARAM_VIEWPORT3D( const std::string& aPath, std::vector* aViewportList ); @@ -260,7 +260,7 @@ private: /** * Persisted state for the net inspector panel */ -struct PANEL_NET_INSPECTOR_SETTINGS +struct KICOMMON_API PANEL_NET_INSPECTOR_SETTINGS { wxString filter_text; bool filter_by_net_name; diff --git a/include/project/net_settings.h b/include/project/net_settings.h index ec2ec822c6..d60710ad78 100644 --- a/include/project/net_settings.h +++ b/include/project/net_settings.h @@ -30,7 +30,7 @@ * NET_SETTINGS stores various net-related settings in a project context. These settings are * accessible and editable from both the schematic and PCB editors. */ -class NET_SETTINGS : public NESTED_SETTINGS +class KICOMMON_API NET_SETTINGS : public NESTED_SETTINGS { public: NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ); diff --git a/include/project/project_archiver.h b/include/project/project_archiver.h index a6ddd3f3d7..1fccbb4478 100644 --- a/include/project/project_archiver.h +++ b/include/project/project_archiver.h @@ -21,6 +21,7 @@ #define KICAD_PROJECT_ARCHIVER_H #include +#include class PROJECT; @@ -28,7 +29,7 @@ class REPORTER; class SETTINGS_MANAGER; -class PROJECT_ARCHIVER +class KICOMMON_API PROJECT_ARCHIVER { public: PROJECT_ARCHIVER(); diff --git a/include/project/project_file.h b/include/project/project_file.h index 506a03f8b0..9041b42acc 100644 --- a/include/project/project_file.h +++ b/include/project/project_file.h @@ -66,7 +66,7 @@ enum LAST_PATH_TYPE : unsigned int * There is either zero or one PROJECT_FILE for every PROJECT * (you can have a dummy PROJECT that has no file) */ -class PROJECT_FILE : public JSON_SETTINGS +class KICOMMON_API PROJECT_FILE : public JSON_SETTINGS { public: /** diff --git a/include/project/project_local_settings.h b/include/project/project_local_settings.h index e79734b6d0..11888fec1f 100644 --- a/include/project/project_local_settings.h +++ b/include/project/project_local_settings.h @@ -31,7 +31,7 @@ class PROJECT; -struct PROJECT_FILE_STATE +struct KICOMMON_API PROJECT_FILE_STATE { wxString fileName; bool open; @@ -51,7 +51,7 @@ struct PROJECT_FILE_STATE * This file doesn't need to exist for a project to be loaded. It will be created on-demand if * any of the things stored here are modified by the user. */ -class PROJECT_LOCAL_SETTINGS : public JSON_SETTINGS +class KICOMMON_API PROJECT_LOCAL_SETTINGS : public JSON_SETTINGS { public: PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxString& aFilename ); diff --git a/include/search_stack.h b/include/search_stack.h index 5a2b134424..d237739956 100644 --- a/include/search_stack.h +++ b/include/search_stack.h @@ -26,6 +26,7 @@ #ifndef SEARCH_STACK_H_ #define SEARCH_STACK_H_ +#include #include #include #include @@ -38,7 +39,7 @@ * reminder that anything you put in here means searching work at some point in time. * (An alternative is to simply know where something is.) */ -class SEARCH_STACK : public wxPathList, public PROJECT::_ELEM +class KICOMMON_API SEARCH_STACK : public wxPathList, public PROJECT::_ELEM { public: KICAD_T Type() override { return SEARCH_STACK_T; } diff --git a/include/settings/app_settings.h b/include/settings/app_settings.h index f7d4b7264d..2c63f847f8 100644 --- a/include/settings/app_settings.h +++ b/include/settings/app_settings.h @@ -28,7 +28,7 @@ /** * Cross-probing behavior */ -struct CROSS_PROBING_SETTINGS +struct KICOMMON_API CROSS_PROBING_SETTINGS { bool on_selection; ///< Synchronize the selection for multiple items too bool center_on_items; ///< Automatically pan to cross-probed items @@ -39,7 +39,7 @@ struct CROSS_PROBING_SETTINGS /** * Common cursor settings, available to every frame */ -struct CURSOR_SETTINGS +struct KICOMMON_API CURSOR_SETTINGS { bool always_show_cursor; bool fullscreen_cursor; @@ -57,7 +57,7 @@ enum class ARC_EDIT_MODE /** * Stores the window positioning/state */ -struct WINDOW_STATE +struct KICOMMON_API WINDOW_STATE { bool maximized; int size_x; @@ -70,7 +70,7 @@ struct WINDOW_STATE /** * Stores the common settings that are saved and loaded for each window / frame */ -struct WINDOW_SETTINGS +struct KICOMMON_API WINDOW_SETTINGS { WINDOW_STATE state; wxString mru_path; @@ -88,7 +88,7 @@ struct WINDOW_SETTINGS * * COMMON_SETTINGS stores settings that are always the same across all applications. */ -class APP_SETTINGS_BASE : public JSON_SETTINGS +class KICOMMON_API APP_SETTINGS_BASE : public JSON_SETTINGS { public: struct FIND_REPLACE diff --git a/include/settings/color_settings.h b/include/settings/color_settings.h index ab8338bc0c..319c533877 100644 --- a/include/settings/color_settings.h +++ b/include/settings/color_settings.h @@ -48,7 +48,7 @@ using KIGFX::COLOR4D; * Each application (eeschema, gerbview, pcbnew) can have a different active color scheme selected. * The "child applications" (library editors) inherit from either eeschema or pcbnew. */ -class COLOR_SETTINGS : public JSON_SETTINGS +class KICOMMON_API COLOR_SETTINGS : public JSON_SETTINGS { public: explicit COLOR_SETTINGS( const wxString& aFilename = wxT( "user" ), diff --git a/include/settings/common_settings.h b/include/settings/common_settings.h index 7c3c68d743..e4e765e7c6 100644 --- a/include/settings/common_settings.h +++ b/include/settings/common_settings.h @@ -44,7 +44,7 @@ enum class ICON_THEME }; -class COMMON_SETTINGS : public JSON_SETTINGS +class KICOMMON_API COMMON_SETTINGS : public JSON_SETTINGS { public: struct APPEARANCE diff --git a/include/settings/kicad_settings.h b/include/settings/kicad_settings.h index 260d6e29f0..20e6905841 100644 --- a/include/settings/kicad_settings.h +++ b/include/settings/kicad_settings.h @@ -25,7 +25,7 @@ #define PCM_DEFAULT_REPOSITORY_URL "https://repository.kicad.org/repository.json" -class KICAD_SETTINGS : public APP_SETTINGS_BASE +class KICOMMON_API KICAD_SETTINGS : public APP_SETTINGS_BASE { public: KICAD_SETTINGS(); diff --git a/include/settings/parameters.h b/include/settings/parameters.h index dc6308758b..15a3826d9a 100644 --- a/include/settings/parameters.h +++ b/include/settings/parameters.h @@ -300,7 +300,8 @@ public: m_default( std::move( aDefault ) ), m_getter( std::move( aGetter ) ), m_setter( std::move( aSetter ) ) - { } + { + } void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override { @@ -367,11 +368,17 @@ private: std::function m_setter; }; - +#ifdef _MSC_VER +template class KICOMMON_API PARAM_LAMBDA; +template class KICOMMON_API PARAM_LAMBDA; +template class KICOMMON_API PARAM_LAMBDA; +template class KICOMMON_API PARAM_LAMBDA; +#else extern template class APIVISIBLE PARAM_LAMBDA; extern template class APIVISIBLE PARAM_LAMBDA; extern template class APIVISIBLE PARAM_LAMBDA; extern template class APIVISIBLE PARAM_LAMBDA; +#endif /** * Represents a parameter that has a scaling factor between the value in the file and the @@ -550,15 +557,25 @@ protected: }; +#ifdef _MSC_VER +template class KICOMMON_API PARAM_LIST; +template class KICOMMON_API PARAM_LIST; +template class KICOMMON_API PARAM_LIST; +template class KICOMMON_API PARAM_LIST; +template class KICOMMON_API PARAM_LIST; +template class KICOMMON_API PARAM_LIST; +template class KICOMMON_API PARAM_LIST; +template class KICOMMON_API PARAM_LIST; +#else extern template class APIVISIBLE PARAM_LIST; extern template class APIVISIBLE PARAM_LIST; extern template class APIVISIBLE PARAM_LIST; extern template class APIVISIBLE PARAM_LIST; -//template KICOMMON_EXTERN_DECL class PARAM_LIST; extern template class APIVISIBLE PARAM_LIST; extern template class APIVISIBLE PARAM_LIST; extern template class APIVISIBLE PARAM_LIST; extern template class APIVISIBLE PARAM_LIST; +#endif template @@ -639,7 +656,11 @@ protected: std::set m_default; }; +#ifdef _MSC_VER +template class KICOMMON_API PARAM_SET; +#else extern template class APIVISIBLE PARAM_SET; +#endif /** * Represents a list of strings holding directory paths. @@ -776,9 +797,15 @@ private: }; +#ifdef _MSC_VER +template class KICOMMON_API PARAM_MAP; +template class KICOMMON_API PARAM_MAP; +template class KICOMMON_API PARAM_MAP; +#else extern template class APIVISIBLE PARAM_MAP; extern template class APIVISIBLE PARAM_MAP; extern template class APIVISIBLE PARAM_MAP; +#endif /** diff --git a/include/settings/settings_manager.h b/include/settings/settings_manager.h index bf390084b7..62da063a54 100644 --- a/include/settings/settings_manager.h +++ b/include/settings/settings_manager.h @@ -41,7 +41,7 @@ class LOCKFILE; #define PROJECT_BACKUPS_DIR_SUFFIX wxT( "-backups" ) -class SETTINGS_MANAGER +class KICOMMON_API SETTINGS_MANAGER { public: SETTINGS_MANAGER( bool aHeadless = false ); diff --git a/include/systemdirsappend.h b/include/systemdirsappend.h index 1f7348f11c..2f9dd51f93 100644 --- a/include/systemdirsappend.h +++ b/include/systemdirsappend.h @@ -37,12 +37,12 @@ class SEARCH_STACK; * Append system places to \a aSearchStack in a platform specific way and pertinent * to KiCad programs. */ -void SystemDirsAppend( SEARCH_STACK* aSearchStack ); +KICOMMON_API void SystemDirsAppend( SEARCH_STACK* aSearchStack ); /** * Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings. * Adds libraries, docs, template paths to the search stack. */ -void GlobalPathsAppend( SEARCH_STACK* aDst, KIWAY::FACE_T aId ); +KICOMMON_API void GlobalPathsAppend( SEARCH_STACK* aDst, KIWAY::FACE_T aId ); #endif // INCLUDE__SYSTEM_DIRS_APPEND_H_ diff --git a/include/widgets/bitmap_button.h b/include/widgets/bitmap_button.h index 05ced04548..95d869ffa5 100644 --- a/include/widgets/bitmap_button.h +++ b/include/widgets/bitmap_button.h @@ -25,6 +25,7 @@ #ifndef BITMAP_BUTTON_H_ #define BITMAP_BUTTON_H_ +#include #include #include #include @@ -37,7 +38,7 @@ * * It has a rectangle highlight when the mouse is hovering/pressed * * It has the ability to be checked/toggled */ -class BITMAP_BUTTON : public wxPanel +class KICOMMON_API BITMAP_BUTTON : public wxPanel { public: BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos = wxDefaultPosition, diff --git a/include/widgets/kistatusbar.h b/include/widgets/kistatusbar.h index a192bdae3f..674f15f9ac 100644 --- a/include/widgets/kistatusbar.h +++ b/include/widgets/kistatusbar.h @@ -25,6 +25,8 @@ #ifndef KISTATUSBAR_H #define KISTATUSBAR_H +#include + class wxGauge; class wxButton; class wxStaticText; @@ -39,7 +41,7 @@ class BITMAP_BUTTON; * Background notifications button (FIELD_OFFSET_NOTIFICATION_BUTTON offset id) */ -class KISTATUSBAR : public wxStatusBar +class KICOMMON_API KISTATUSBAR : public wxStatusBar { public: KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ); diff --git a/include/widgets/ui_common.h b/include/widgets/ui_common.h index 05b0ec8584..ae06f45e1a 100644 --- a/include/widgets/ui_common.h +++ b/include/widgets/ui_common.h @@ -26,6 +26,7 @@ #ifndef UI_COMMON_H #define UI_COMMON_H +#include #include "report_severity.h" // enum SEVERITY #include #include @@ -51,20 +52,20 @@ namespace KIUI * Get the standard margin around a widget in the KiCad UI * @return margin in pixels */ -int GetStdMargin(); +KICOMMON_API int GetStdMargin(); /** * Return the size of @a aSingleLine of text when it is rendered in @a aWindow * using whatever font is currently set in that window. */ -wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow ); +KICOMMON_API wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow ); -wxFont GetMonospacedUIFont(); +KICOMMON_API wxFont GetMonospacedUIFont(); -wxFont GetControlFont( wxWindow* aWindow ); -wxFont GetInfoFont( wxWindow* aWindow ); -wxFont GetDockedPaneFont( wxWindow* aWindow ); -wxFont GetStatusFont( wxWindow* aWindow ); +KICOMMON_API wxFont GetControlFont( wxWindow* aWindow ); +KICOMMON_API wxFont GetInfoFont( wxWindow* aWindow ); +KICOMMON_API wxFont GetDockedPaneFont( wxWindow* aWindow ); +KICOMMON_API wxFont GetStatusFont( wxWindow* aWindow ); /** * Set the minimum pixel width on a text control in order to make a text @@ -80,33 +81,33 @@ wxFont GetStatusFont( wxWindow* aWindow ); * the text already within the control is used. * @return true if the \a aCtrl had its size changed, else false. */ -bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = nullptr ); +KICOMMON_API bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = nullptr ); /** * Select the number (or "?") in a reference for ease of editing. */ -void SelectReferenceNumber( wxTextEntry* aTextEntry ); +KICOMMON_API void SelectReferenceNumber( wxTextEntry* aTextEntry ); /** * Ellipsize text (at the end) to be no more than 1/3 of the window width. * * @return shortened text ending with an ellipsis. */ -wxString EllipsizeStatusText( wxWindow* aWindow, const wxString& aString ); +KICOMMON_API wxString EllipsizeStatusText( wxWindow* aWindow, const wxString& aString ); /** * Ellipsize text (at the end) to be no more than 36 characters. * * @return shortened text ending with an ellipsis. */ -wxString EllipsizeMenuText( const wxString& aString ); +KICOMMON_API wxString EllipsizeMenuText( const wxString& aString ); /** * Check if a input control has focus. * * @param aFocus Control that has focus, if null, wxWidgets will be queried */ -bool IsInputControlFocused( wxWindow* aFocus = nullptr ); +KICOMMON_API bool IsInputControlFocused( wxWindow* aFocus = nullptr ); /** * Check if a input control has focus. @@ -115,17 +116,17 @@ bool IsInputControlFocused( wxWindow* aFocus = nullptr ); * @return True if control is input and editable OR control is not a input. False if control is * input and not editable. */ -bool IsInputControlEditable( wxWindow* aControl ); +KICOMMON_API bool IsInputControlEditable( wxWindow* aControl ); -bool IsModalDialogFocused(); +KICOMMON_API bool IsModalDialogFocused(); /** * Makes a window read-only. Does some extra work over wxWindow::Disable() to make sure you * can still scroll around in sub-windows. */ -void Disable( wxWindow* aWindow ); +KICOMMON_API void Disable( wxWindow* aWindow ); -extern const wxString s_FocusStealableInputName; +KICOMMON_API extern const wxString s_FocusStealableInputName; /** @@ -138,7 +139,7 @@ extern const wxString s_FocusStealableInputName; * @param aMenu is the menuitem. * @param aImage is the icon to add to aMenu. */ -void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage ); +KICOMMON_API void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage ); /** @@ -151,8 +152,8 @@ void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage ); * @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ... * @return a pointer to the new created wxMenuItem. */ -wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxBitmap& aImage, - wxItemKind aType = wxITEM_NORMAL ); +KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxBitmap& aImage, + wxItemKind aType = wxITEM_NORMAL ); /** @@ -166,8 +167,8 @@ wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wx * @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ... * @return a pointer to the new created wxMenuItem. */ -wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxString& aHelpText, - const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL ); +KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxString& aHelpText, + const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL ); /** @@ -180,8 +181,8 @@ wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wx * @param aImage is the icon to add to the new menu item. * @return a pointer to the new created wxMenuItem, */ -wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText, - const wxBitmap& aImage ); +KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText, + const wxBitmap& aImage ); /** @@ -196,12 +197,12 @@ wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxStrin * @param aImage is the icon to add to the new menu item. * @return a pointer to the new created wxMenuItem. */ -wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText, - const wxString& aHelpText, const wxBitmap& aImage ); +KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText, + const wxString& aHelpText, const wxBitmap& aImage ); } -SEVERITY SeverityFromString( const wxString& aSeverity ); +KICOMMON_API SEVERITY SeverityFromString( const wxString& aSeverity ); -wxString SeverityToString( const SEVERITY& aSeverity ); +KICOMMON_API wxString SeverityToString( const SEVERITY& aSeverity ); #endif // UI_COMMON_H diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 8c4ac5cf7b..8ada0831fa 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -73,20 +73,6 @@ KIFACE_BASE& Kiface() static PGM_KICAD program; - -PGM_BASE& Pgm() -{ - return program; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. -PGM_BASE* PgmOrNull() -{ - return &program; -} - - PGM_KICAD& PgmTop() { return program; @@ -414,7 +400,7 @@ void PGM_KICAD::Destroy() } -KIWAY Kiway( &Pgm(), KFCTL_CPP_PROJECT_SUITE ); +KIWAY Kiway( KFCTL_CPP_PROJECT_SUITE ); #ifdef NDEBUG // Define a custom assertion handler @@ -435,6 +421,8 @@ struct APP_KICAD : public wxApp { APP_KICAD() : wxApp() { + SetPgm( &program ); + // Init the environment each platform wants KIPLATFORM::ENV::Init(); } diff --git a/kicad/kicad_cli.cpp b/kicad/kicad_cli.cpp index fde643f717..4332863e21 100644 --- a/kicad/kicad_cli.cpp +++ b/kicad/kicad_cli.cpp @@ -94,28 +94,6 @@ KIFACE_BASE& Kiface() } -static PGM_KICAD program; - - -PGM_BASE& Pgm() -{ - return program; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. -PGM_BASE* PgmOrNull() -{ - return &program; -} - - -PGM_KICAD& PgmTop() -{ - return program; -} - - struct COMMAND_ENTRY { CLI::COMMAND* handler; @@ -463,8 +441,9 @@ void PGM_KICAD::Destroy() } -KIWAY Kiway( &Pgm(), KFCTL_CPP_PROJECT_SUITE | KFCTL_CLI ); +KIWAY Kiway( KFCTL_CPP_PROJECT_SUITE | KFCTL_CLI ); +static PGM_KICAD program; /** * Not publicly visible because most of the action is in #PGM_KICAD these days. @@ -473,6 +452,8 @@ struct APP_KICAD_CLI : public wxAppConsole { APP_KICAD_CLI() : wxAppConsole() { + SetPgm( &program ); + // Init the environment each platform wants KIPLATFORM::ENV::Init(); } diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index 731b7e712f..3003c132d2 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -74,14 +74,9 @@ endif() # a very small program launcher for pl_editor_kiface add_executable( pl_editor WIN32 MACOSX_BUNDLE ${CMAKE_SOURCE_DIR}/common/single_top.cpp - ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp ${PL_EDITOR_RESOURCES} ) -if( KICAD_USE_SENTRY ) - set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}") -endif() - set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PL_EDITOR;PGM_DATA_FILE_EXT=\"kicad_wks\";BUILD_KIWAY_DLL" ) @@ -91,6 +86,7 @@ target_link_libraries( pl_editor gal common core + kicommon ${wxWidgets_LIBRARIES} ) diff --git a/pagelayout_editor/pl_editor.cpp b/pagelayout_editor/pl_editor.cpp index b83cd47ff7..cc01d7bbbe 100644 --- a/pagelayout_editor/pl_editor.cpp +++ b/pagelayout_editor/pl_editor.cpp @@ -124,9 +124,6 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER using namespace PGE; -static PGM_BASE* process; - - KIFACE_BASE& Kiface() { return kiface; } @@ -134,24 +131,9 @@ KIFACE_BASE& Kiface() { return kiface; } // KIFACE_GETTER will not have name mangling due to declaration in kiway.h. KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram ) { - process = (PGM_BASE*) aProgram; return &kiface; } - -PGM_BASE& Pgm() -{ - wxASSERT( process ); // KIFACE_GETTER has already been called. - return *process; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. -PGM_BASE* PgmOrNull() -{ - return process; -} - bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) { InitSettings( new PL_EDITOR_SETTINGS ); diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt index b1e4be0f54..b019eefc00 100644 --- a/pcb_calculator/CMakeLists.txt +++ b/pcb_calculator/CMakeLists.txt @@ -88,14 +88,9 @@ endif() add_executable( pcb_calculator WIN32 MACOSX_BUNDLE ${CMAKE_SOURCE_DIR}/common/single_top.cpp - ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp ${PCB_CALCULATOR_RESOURCES} ) -if( KICAD_USE_SENTRY ) - set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}") -endif() - set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES COMPILE_DEFINITIONS "TOP_FRAME=FRAME_CALC;BUILD_KIWAY_DLL" ) @@ -103,6 +98,7 @@ target_link_libraries( pcb_calculator #singletop # replaces common, giving us restrictive control and link warnings. # There's way too much crap coming in from common yet. common + kicommon ${wxWidgets_LIBRARIES} ) diff --git a/pcb_calculator/pcb_calculator.cpp b/pcb_calculator/pcb_calculator.cpp index 6ce2e49f7d..8480b11147 100644 --- a/pcb_calculator/pcb_calculator.cpp +++ b/pcb_calculator/pcb_calculator.cpp @@ -72,8 +72,6 @@ static struct IFACE : public KIFACE_BASE using namespace PCBCALC; -static PGM_BASE* process; - KIFACE_BASE& Kiface() { return kiface; } @@ -82,24 +80,10 @@ KIFACE_BASE& Kiface() { return kiface; } // KIFACE_GETTER will not have name mangling due to declaration in kiway.h. KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram ) { - process = (PGM_BASE*) aProgram; return &kiface; } -PGM_BASE& Pgm() -{ - wxASSERT( process ); // KIFACE_GETTER has already been called. - return *process; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. -PGM_BASE* PgmOrNull() -{ - return process; -} - bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) { InitSettings( new PCB_CALCULATOR_SETTINGS ); diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 44f3943e87..548dfc5e57 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -351,9 +351,6 @@ private: using namespace PCB; -static PGM_BASE* process; - - KIFACE_BASE& Kiface() { return kiface; } @@ -361,27 +358,10 @@ KIFACE_BASE& Kiface() { return kiface; } // KIFACE_GETTER will not have name mangling due to declaration in kiway.h. KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram ) { - process = aProgram; return &kiface; } -#if defined( BUILD_KIWAY_DLL ) -PGM_BASE& Pgm() -{ - wxASSERT( process ); // KIFACE_GETTER has already been called. - return *process; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. -PGM_BASE* PgmOrNull() -{ - return process; -} -#endif - - /// The global footprint library table. This is not dynamically allocated because /// in a multiple project environment we must keep its address constant (since it is /// the fallback table for multiple projects). diff --git a/qa/mocks/kicad/common_mocks.cpp b/qa/mocks/kicad/common_mocks.cpp index 02018743b1..c949c8e31f 100644 --- a/qa/mocks/kicad/common_mocks.cpp +++ b/qa/mocks/kicad/common_mocks.cpp @@ -30,22 +30,6 @@ #include -PGM_BASE& Pgm() -{ - static MOCK_PGM_BASE program; - return program; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from -// a python script or something else. -// Therefore here return always nullptr -PGM_BASE* PgmOrNull() -{ - return nullptr; -} - - KIFACE_BASE& Kiface() { static MOCK_KIFACE_BASE kiface; diff --git a/qa/qa_utils/test_app_main.cpp b/qa/qa_utils/test_app_main.cpp index e5409fb59c..d89956d89b 100644 --- a/qa/qa_utils/test_app_main.cpp +++ b/qa/qa_utils/test_app_main.cpp @@ -89,7 +89,7 @@ static struct IFACE : public KIFACE_BASE kiface( "pcb_test_frame", KIWAY::FACE_PCB ); -KIWAY Kiway( &Pgm(), KFCTL_STANDALONE ); +KIWAY Kiway( KFCTL_STANDALONE ); static struct PGM_TEST_FRAME : public PGM_BASE @@ -129,20 +129,6 @@ static struct PGM_TEST_FRAME : public PGM_BASE program; -PGM_BASE& Pgm() -{ - return program; -} - - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face -// is run from a python script, mot from a Kicad application -PGM_BASE* PgmOrNull() -{ - return &program; -} - - KIFACE_BASE& Kiface() { return kiface; @@ -156,7 +142,9 @@ KIFACE_BASE& Kiface() struct APP_TEST : public wxApp { APP_TEST() - {} + { + SetPgm( &program ); + } bool OnInit() override { diff --git a/qa/tests/common/test_module.cpp b/qa/tests/common/test_module.cpp index 2ab1c443e6..6ad7f05e54 100644 --- a/qa/tests/common/test_module.cpp +++ b/qa/tests/common/test_module.cpp @@ -25,6 +25,7 @@ * Main file for the libcommon tests to be compiled */ #include +#include #include #include @@ -32,6 +33,7 @@ bool init_unit_test() { + SetPgm( new MOCK_PGM_BASE() ); boost::unit_test::framework::master_test_suite().p_name.value = "Common library module tests"; bool ok = wxInitialize(); diff --git a/qa/tests/eeschema/test_module.cpp b/qa/tests/eeschema/test_module.cpp index 9f7e816e75..6db986798d 100644 --- a/qa/tests/eeschema/test_module.cpp +++ b/qa/tests/eeschema/test_module.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -52,6 +53,7 @@ void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc, bool init_unit_test() { + SetPgm( new MOCK_PGM_BASE() ); KIPLATFORM::APP::Init(); boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests"; diff --git a/qa/tests/gerbview/CMakeLists.txt b/qa/tests/gerbview/CMakeLists.txt index 635c891137..8a1b0442c3 100644 --- a/qa/tests/gerbview/CMakeLists.txt +++ b/qa/tests/gerbview/CMakeLists.txt @@ -51,6 +51,7 @@ target_compile_definitions( qa_gerbview target_include_directories( qa_gerbview PRIVATE ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/qa/mocks/include ) # Anytime we link to the kiface_objects, we have to add a dependency on the last object diff --git a/qa/tests/gerbview/test_module.cpp b/qa/tests/gerbview/test_module.cpp index d396602f08..a29e655756 100644 --- a/qa/tests/gerbview/test_module.cpp +++ b/qa/tests/gerbview/test_module.cpp @@ -26,12 +26,14 @@ */ #include #include +#include #include bool init_unit_test() { + SetPgm( new MOCK_PGM_BASE() ); KIPLATFORM::APP::Init(); boost::unit_test::framework::master_test_suite().p_name.value = "Gerbview module tests"; return wxInitialize(); diff --git a/qa/tests/pcbnew/CMakeLists.txt b/qa/tests/pcbnew/CMakeLists.txt index 4878266b18..e5713396d7 100644 --- a/qa/tests/pcbnew/CMakeLists.txt +++ b/qa/tests/pcbnew/CMakeLists.txt @@ -104,6 +104,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/polygon ${CMAKE_SOURCE_DIR}/common/geometry ${CMAKE_SOURCE_DIR}/qa/qa_utils + ${CMAKE_SOURCE_DIR}/qa/mocks/include ${INC_AFTER} ) diff --git a/qa/tests/pcbnew/test_module.cpp b/qa/tests/pcbnew/test_module.cpp index ced0cd3663..1dde0d7c7b 100644 --- a/qa/tests/pcbnew/test_module.cpp +++ b/qa/tests/pcbnew/test_module.cpp @@ -26,6 +26,7 @@ */ #include #include +#include #include #include @@ -33,6 +34,7 @@ bool init_unit_test() { + SetPgm( new MOCK_PGM_BASE() ); KIPLATFORM::APP::Init(); boost::unit_test::framework::master_test_suite().p_name.value = "Pcbnew module tests"; diff --git a/qa/tests/spice/test_module.cpp b/qa/tests/spice/test_module.cpp index 7535e79a30..978495c722 100644 --- a/qa/tests/spice/test_module.cpp +++ b/qa/tests/spice/test_module.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -52,6 +53,7 @@ void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc, bool init_unit_test() { + SetPgm( new MOCK_PGM_BASE() ); KIPLATFORM::APP::Init(); boost::unit_test::framework::master_test_suite().p_name.value = "Common spice integration tests"; diff --git a/scripting/CMakeLists.txt b/scripting/CMakeLists.txt index 36ca25a882..5ec2face6b 100644 --- a/scripting/CMakeLists.txt +++ b/scripting/CMakeLists.txt @@ -1,6 +1,5 @@ set( KIPYTHON_SRCS kipython_settings.cpp - python_scripting.cpp ) add_library( scripting STATIC @@ -12,6 +11,7 @@ target_link_libraries( scripting ${PYTHON_LIBRARIES} Boost::headers common + kicommon ) target_include_directories( scripting PUBLIC diff --git a/scripting/kicad_scripting_main.cpp b/scripting/kicad_scripting_main.cpp index 21051169d1..a2bed14049 100644 --- a/scripting/kicad_scripting_main.cpp +++ b/scripting/kicad_scripting_main.cpp @@ -78,8 +78,6 @@ static struct IFACE : public KIFACE_BASE using namespace KIPYTHON; -static PGM_BASE* process; - KIFACE_BASE& Kiface() { return kiface; @@ -90,25 +88,10 @@ KIFACE_BASE& Kiface() // KIFACE_GETTER will not have name mangling due to declaration in kiway.h. KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram ) { - process = (PGM_BASE*) aProgram; return &kiface; } -PGM_BASE& Pgm() -{ - wxASSERT( process ); // KIFACE_GETTER has already been called. - return *process; -} - -// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from -// a python script or something else. -PGM_BASE* PgmOrNull() -{ - return process; -} - - bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) { InitSettings( new KIPYTHON_SETTINGS ); diff --git a/scripting/python_scripting.cpp b/scripting/python_scripting.cpp index fef827a75b..47e3b09e5c 100644 --- a/scripting/python_scripting.cpp +++ b/scripting/python_scripting.cpp @@ -36,10 +36,7 @@ #include #include -#include #include -#include -#include #include #include #include diff --git a/scripting/python_scripting.h b/scripting/python_scripting.h index a6df3c32a9..41ce6d29c1 100644 --- a/scripting/python_scripting.h +++ b/scripting/python_scripting.h @@ -45,7 +45,9 @@ #include #include -class SCRIPTING +#include + +class KICOMMON_API SCRIPTING { public: SCRIPTING(); @@ -82,14 +84,15 @@ private: * @param aVar is the variable to set * @param aValue is the value to give it */ -void UpdatePythonEnvVar( const wxString& aVar, const wxString& aValue ); +KICOMMON_API void UpdatePythonEnvVar( const wxString& aVar, const wxString& aValue ); -void RedirectStdio(); -wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameId ); -bool InitPythonScripting( const char* aStockScriptingPath, const char* aUserScriptingPath ); -bool IsWxPythonLoaded(); +KICOMMON_API void RedirectStdio(); +KICOMMON_API wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameId ); +KICOMMON_API bool InitPythonScripting( const char* aStockScriptingPath, + const char* aUserScriptingPath ); +KICOMMON_API bool IsWxPythonLoaded(); -class PyLOCK +class KICOMMON_API PyLOCK { PyGILState_STATE gil_state; public: @@ -97,8 +100,8 @@ public: ~PyLOCK() { PyGILState_Release( gil_state ); } }; -wxString PyStringToWx( PyObject* str ); -wxArrayString PyArrayStringToWx( PyObject* arr ); -wxString PyErrStringWithTraceback(); +KICOMMON_API wxString PyStringToWx( PyObject* str ); +KICOMMON_API wxArrayString PyArrayStringToWx( PyObject* arr ); +KICOMMON_API wxString PyErrStringWithTraceback(); #endif // __PYTHON_SCRIPTING_H