From 04ec408ee19ce49a6322c97fba85f8ef6eacd31a Mon Sep 17 00:00:00 2001 From: Eran Ifrah Date: Thu, 30 Dec 2021 20:49:04 +0200 Subject: [PATCH] Added an option to create wxCrafter standalong deb package wxCrafter standalone: removed calls "Register your wxCrafter" --- CMakeLists.txt | 183 ++++++++++++++++++------------------ Plugin/bitmap_loader.cpp | 13 +-- wxcrafter/CMakeLists.txt | 78 +++++++-------- wxcrafter/main.cpp | 7 ++ wxcrafter/wxCrafter.desktop | 9 ++ wxcrafter/wxc_settings.cpp | 63 ++++--------- 6 files changed, 167 insertions(+), 186 deletions(-) create mode 100644 wxcrafter/wxCrafter.desktop diff --git a/CMakeLists.txt b/CMakeLists.txt index b4f79de434..30d4b453f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -634,6 +634,7 @@ if( NOT SQLITE3_FOUND ) add_subdirectory(sqlite3) endif() +# build the Core part of CodeLite (regardless of the final target) add_subdirectory(sdk/wxsqlite3) add_subdirectory(sdk/wxshapeframework) add_subdirectory(sdk/databaselayer) @@ -641,102 +642,106 @@ add_subdirectory(CodeLite) add_subdirectory(Plugin) add_subdirectory(PCH) -if(NOT NO_CORE_PLUGINS) - add_subdirectory(abbreviation) - if(NOT DISABLE_CXX) - add_subdirectory(Gizmos) - add_subdirectory(Debugger) - add_subdirectory(UnitTestCPP) - add_subdirectory(QmakePlugin) - add_subdirectory(cppchecker) - add_subdirectory(wxformbuilder) - add_subdirectory(CMakePlugin) - add_subdirectory(cscope) - add_subdirectory(EOSWiki) - endif() - add_subdirectory(AutoSave) - add_subdirectory(CodeLiteDiff) - add_subdirectory(git) - add_subdirectory(Outline) - add_subdirectory(CodeFormatter) - add_subdirectory(Copyright) - add_subdirectory(DatabaseExplorer) - add_subdirectory(ExternalTools) - add_subdirectory(SnipWiz) - add_subdirectory(Subversion2) - add_subdirectory(ZoomNavigator) - add_subdirectory(SpellChecker) - add_subdirectory(Tail) - add_subdirectory(EditorConfigPlugin) - add_subdirectory(PHPLint) - add_subdirectory(PHPRefactoring) - add_subdirectory(codelite_vim) - add_subdirectory(Docker) - add_subdirectory(LanguageServer) - add_subdirectory(Rust) - if (WITH_SFTP) - add_subdirectory(SFTP) - add_subdirectory(Remoty) - endif(WITH_SFTP) - - if (WITH_LLDB AND NOT DISABLE_CXX) - add_subdirectory(LLDBDebugger) - endif() +if (WXC_APP) + add_subdirectory(wxcrafter) +else() + if(NOT NO_CORE_PLUGINS) + add_subdirectory(abbreviation) + if(NOT DISABLE_CXX) + add_subdirectory(Gizmos) + add_subdirectory(Debugger) + add_subdirectory(UnitTestCPP) + add_subdirectory(QmakePlugin) + add_subdirectory(cppchecker) + add_subdirectory(wxformbuilder) + add_subdirectory(CMakePlugin) + add_subdirectory(cscope) + add_subdirectory(EOSWiki) + endif() + add_subdirectory(AutoSave) + add_subdirectory(CodeLiteDiff) + add_subdirectory(git) + add_subdirectory(Outline) + add_subdirectory(CodeFormatter) + add_subdirectory(Copyright) + add_subdirectory(DatabaseExplorer) + add_subdirectory(ExternalTools) + add_subdirectory(SnipWiz) + add_subdirectory(Subversion2) + add_subdirectory(ZoomNavigator) + add_subdirectory(SpellChecker) + add_subdirectory(Tail) + add_subdirectory(EditorConfigPlugin) + add_subdirectory(PHPLint) + add_subdirectory(PHPRefactoring) + add_subdirectory(codelite_vim) + add_subdirectory(Docker) + add_subdirectory(LanguageServer) + add_subdirectory(Rust) + if (WITH_SFTP) + add_subdirectory(SFTP) + add_subdirectory(Remoty) + endif(WITH_SFTP) + + if (WITH_LLDB AND NOT DISABLE_CXX) + add_subdirectory(LLDBDebugger) + endif() - add_subdirectory(codelitephp) - add_subdirectory(WordCompletion) - add_subdirectory(HelpPlugin) - add_subdirectory(WebTools) - add_subdirectory(SmartCompletion) + add_subdirectory(codelitephp) + add_subdirectory(WordCompletion) + add_subdirectory(HelpPlugin) + add_subdirectory(WebTools) + add_subdirectory(SmartCompletion) - if(UNIX AND NOT APPLE AND NOT DISABLE_CXX) - ## Add valgrind plugin - add_subdirectory(MemCheck) - endif() + if(UNIX AND NOT APPLE AND NOT DISABLE_CXX) + ## Add valgrind plugin + add_subdirectory(MemCheck) + endif() - if(APPLE AND NOT DISABLE_CXX) - message("-- Adding MacBundler...") - add_subdirectory(MacBundler) - endif() -endif(NOT NO_CORE_PLUGINS) + if(APPLE AND NOT DISABLE_CXX) + message("-- Adding MacBundler...") + add_subdirectory(MacBundler) + endif() + endif(NOT NO_CORE_PLUGINS) -# wxCrafter is not a core plugin so we include it we find the directory -if(IS_DIRECTORY "${CL_SRC_ROOT}/wxcrafter" AND NOT DISABLE_CXX AND NOT NO_CORE_PLUGINS) - add_subdirectory(wxcrafter) -endif() + # wxCrafter is not a core plugin so we include it we find the directory + if(IS_DIRECTORY "${CL_SRC_ROOT}/wxcrafter" AND NOT DISABLE_CXX AND NOT NO_CORE_PLUGINS) + add_subdirectory(wxcrafter) + endif() -## Executables -if(NOT SDK_ONLY) - add_subdirectory(LiteEditor) - add_subdirectory(codelitegcc) - add_subdirectory(codelite_make) - add_subdirectory(codelite_terminal) - add_subdirectory(sdk/codelite_indexer) - add_subdirectory(sdk/codelite_cppcheck) - add_subdirectory(codelite_echo) - add_subdirectory(ctagsd) -endif() -## -## Setup the proper dependencies -## -if(NOT SQLITE3_FOUND) - if ( USE_PCH AND NOT MINGW ) - add_dependencies(sqlite3lib ${CL_PCH_TARGET}) + ## Executables + if(NOT SDK_ONLY) + add_subdirectory(LiteEditor) + add_subdirectory(codelitegcc) + add_subdirectory(codelite_make) + add_subdirectory(codelite_terminal) + add_subdirectory(sdk/codelite_indexer) + add_subdirectory(sdk/codelite_cppcheck) + add_subdirectory(codelite_echo) + add_subdirectory(ctagsd) + endif() + ## + ## Setup the proper dependencies + ## + if(NOT SQLITE3_FOUND) + if ( USE_PCH AND NOT MINGW ) + add_dependencies(sqlite3lib ${CL_PCH_TARGET}) + endif() + add_dependencies(wxsqlite3 sqlite3lib) endif() - add_dependencies(wxsqlite3 sqlite3lib) -endif() -add_dependencies(databaselayersqlite wxsqlite3) -add_dependencies(wxshapeframework wxsqlite3) -add_dependencies(libcodelite wxshapeframework databaselayersqlite wxsqlite3) -add_dependencies(plugin libcodelite) + add_dependencies(databaselayersqlite wxsqlite3) + add_dependencies(wxshapeframework wxsqlite3) + add_dependencies(libcodelite wxshapeframework databaselayersqlite wxsqlite3) + add_dependencies(plugin libcodelite) -if(NOT SDK_ONLY) - add_dependencies(codelite plugin) -endif() + if(NOT SDK_ONLY) + add_dependencies(codelite plugin) + endif() -## Include our custom plugin.cmake module -include(plugin) + ## Include our custom plugin.cmake module + include(plugin) -## Scan for user plugins -CL_SCAN_FOR_PLUGINS() + ## Scan for user plugins + CL_SCAN_FOR_PLUGINS() +endif() # NOT WXC_APP \ No newline at end of file diff --git a/Plugin/bitmap_loader.cpp b/Plugin/bitmap_loader.cpp index 12c2ebc6dc..cb71bbcc86 100644 --- a/Plugin/bitmap_loader.cpp +++ b/Plugin/bitmap_loader.cpp @@ -84,21 +84,14 @@ wxIcon BitmapLoader::GetIcon(const wxBitmap& bmp) const void BitmapLoader::Initialize(bool darkTheme) { wxString zipname; - wxFileName fn; - -// Under linux, take into account the --prefix -#ifdef __WXGTK__ - wxString bitmapPath = wxString(INSTALL_DIR, wxConvUTF8); - fn = wxFileName(bitmapPath, zipname); -#else - fn = wxFileName(clStandardPaths::Get().GetDataDir(), zipname); -#endif - // Load the bitmaps based on the current theme background colour wxFileName fnLight(clStandardPaths::Get().GetDataDir(), "codelite-bitmaps-light.zip"); wxFileName fnDark(clStandardPaths::Get().GetDataDir(), "codelite-bitmaps-dark.zip"); wxFileName fnNewZip = darkTheme ? fnDark : fnLight; + clDEBUG() << "Loading bitmap resources:" << fnLight << endl; + clDEBUG() << "Loading bitmap resources:" << fnDark << endl; + #ifdef __WXOSX__ if(fnNewZip.FileExists()) { clZipReader zip(fnNewZip); diff --git a/wxcrafter/CMakeLists.txt b/wxcrafter/CMakeLists.txt index a29b7c299a..25293b4072 100644 --- a/wxcrafter/CMakeLists.txt +++ b/wxcrafter/CMakeLists.txt @@ -1,27 +1,25 @@ - - - -if ( WXC_APP ) +if(WXC_APP) message("-- Building wxCrafter as a standalone executable ") add_definitions( -DSTANDALONE_BUILD=1 ) add_definitions( -DINSTALL_PREFIX=\"${CL_PREFIX}\") -else ( WXC_APP ) +else() message("-- Building wxCrafter as codelite plugin ") add_definitions( -DWXCAPP=0 ) -if (OFFICIAL_CL_BUILD) - message("-- Building wxCrafter for an official CodeLite build") -endif (OFFICIAL_CL_BUILD) - -endif ( WXC_APP ) +endif(WXC_APP) # set the plugin name here -if ( WXC_APP ) - set( PLUGIN_NAME "wxcrafter") -else ( WXC_APP ) - set( PLUGIN_NAME "wxCrafter") -endif ( WXC_APP) +if(WXC_APP) + set(PLUGIN_NAME "wxcrafter") +else() + set(PLUGIN_NAME "wxCrafter") +endif() -set( WXC_DIR "${CL_SRC_ROOT}/wxcrafter") +if(NOT CL_SRC_ROOT) + message(STATUS "Please set CL_SRC_ROOT to CodeLite source directory as in -DCL_SRC_ROOT=...") + message(FATAL_ERROR "Missing CL_SRC_ROOT") +endif() + +set(WXC_DIR "${CL_SRC_ROOT}/wxcrafter") message("-- Generating makefile for wxCrafter") @@ -101,7 +99,9 @@ else ( NOT WXC_APP ) add_executable(${PLUGIN_NAME} ${SRCS}) endif ( NOT WXC_APP ) -target_precompile_headers(${PLUGIN_NAME} REUSE_FROM PCH) +if(NOT WXC_APP) + target_precompile_headers(${PLUGIN_NAME} REUSE_FROM PCH) +endif() # Remove the "lib" prefix from the plugin name set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "") @@ -131,24 +131,23 @@ if ( NOT WXC_APP ) ## wxCrafter as codelite's plugin CL_INSTALL_PLUGIN(${PLUGIN_NAME}) CL_INSTALL_FILE_SHARED(${WXC_DIR}/wxgui.zip) - -else ( NOT WXC_APP ) - +else () set(CPACK_DEB_COMPONENT_INSTALL 1) - ## Installing an application install(TARGETS ${PLUGIN_NAME} DESTINATION ${CL_PREFIX}/bin PERMISSIONS ${EXE_PERM} COMPONENT standalone) - install(FILES "${WXC_DIR}/wxgui.zip" DESTINATION ${CL_PREFIX}/share/${PLUGIN_NAME} COMPONENT standalone) - install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/liblibcodelite.so" DESTINATION ${WXC_LIBS_DIR} COMPONENT standalone) - install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libplugin.so" DESTINATION ${WXC_LIBS_DIR} COMPONENT standalone) - install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libwxsqlite3.so" DESTINATION ${WXC_LIBS_DIR} COMPONENT standalone) - install(FILES "${CL_SRC_ROOT}/wxcrafter/resources/wxc-logo-64.png" DESTINATION ${CL_PREFIX}/share/${PLUGIN_NAME} COMPONENT standalone) - install(FILES "${CL_SRC_ROOT}/Runtime/config/codelite.xml.default.gtk" DESTINATION ${CL_PREFIX}/share/${PLUGIN_NAME}/config RENAME codelite.xml.default COMPONENT standalone) - -if ( NOT DEBUG_BUILD ) - message("-- Will install ${CL_SRC_ROOT}/wxcrafter/wxCrafter.desktop to /usr/share/applications") - install(FILES "${CL_SRC_ROOT}/wxcrafter/wxCrafter.desktop" DESTINATION /usr/share/applications COMPONENT standalone) -endif ( NOT DEBUG_BUILD ) + install(FILES "${WXC_DIR}/wxgui.zip" DESTINATION ${CL_PREFIX}/share/${PLUGIN_NAME} COMPONENT standalone) + install(FILES "${CL_SRC_ROOT}/Runtime/codelite-bitmaps-light.zip" DESTINATION ${CL_PREFIX}/share/${PLUGIN_NAME} COMPONENT standalone) + install(FILES "${CL_SRC_ROOT}/Runtime/codelite-bitmaps-dark.zip" DESTINATION ${CL_PREFIX}/share/${PLUGIN_NAME} COMPONENT standalone) + install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/liblibcodelite.so" DESTINATION ${WXC_LIBS_DIR} COMPONENT standalone) + install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libplugin.so" DESTINATION ${WXC_LIBS_DIR} COMPONENT standalone) + install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libwxsqlite3.so" DESTINATION ${WXC_LIBS_DIR} COMPONENT standalone) + install(FILES "${CL_SRC_ROOT}/wxcrafter/resources/wxc-logo-64.png" DESTINATION ${CL_PREFIX}/share/${PLUGIN_NAME} COMPONENT standalone) + install(FILES "${CL_SRC_ROOT}/Runtime/config/codelite.xml.default.gtk" DESTINATION ${CL_PREFIX}/share/${PLUGIN_NAME}/config RENAME codelite.xml.default COMPONENT standalone) + + if ( NOT DEBUG_BUILD ) + message("-- Will install ${CL_SRC_ROOT}/wxcrafter/wxCrafter.desktop to /usr/share/applications") + install(FILES "${CL_SRC_ROOT}/wxcrafter/wxCrafter.desktop" DESTINATION /usr/share/applications COMPONENT standalone) + endif ( NOT DEBUG_BUILD ) ## Install codelite lexer files install( @@ -164,13 +163,8 @@ endif ( NOT DEBUG_BUILD ) ## CPack ############################################## message("-- Generating deb target") - if( ${ARCH} EQUAL 32 ) - message("-- CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386") - else () - message("-- CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") - endif () + message("-- CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64") + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") ################################################################# ## We need to deduce the location of the wx libs to be installed @@ -199,13 +193,13 @@ endif ( NOT DEBUG_BUILD ) install(FILES ${wxfilepaths} DESTINATION ${WXC_LIBS_DIR} COMPONENT standalone) set(CPACK_GENERATOR "DEB") - set(CPACK_PACKAGE_NAME "wxCrafter") + set(CPACK_PACKAGE_NAME "wxCrafter${GTKNAME}") set(CPACK_PACKAGE_VERSION "2.9") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Eran Ifrah ") #required + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Eran Ifrah ") #required set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GUI Rad Tool for wxWidgets") set(CPACK_DEBIAN_PACKAGE_SECTION "devel") set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "build-essential") set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libssh-4, libsqlite3-dev") INCLUDE(CPack) -endif ( NOT WXC_APP ) +endif(NOT WXC_APP) diff --git a/wxcrafter/main.cpp b/wxcrafter/main.cpp index c009eb16a3..2f4ff8e2f6 100644 --- a/wxcrafter/main.cpp +++ b/wxcrafter/main.cpp @@ -1,4 +1,6 @@ #include "main.h" + +#include "file_logger.h" #include "serial_number.h" #include "wx/frame.h" #include "wx/toplevel.h" @@ -8,6 +10,7 @@ #include "wxgui_bitmaploader.h" #include "wxgui_defs.h" #include "wxguicraft_main_view.h" + #include #include #include @@ -143,6 +146,10 @@ bool wxcApp::OnInit() ColoursAndFontsManager::Get().Load(); ColoursAndFontsManager::Get().RestoreDefaults(); + // Open log file + FileLogger::OpenLog("wxcrafter.log", FileLogger::Dbg); + clDEBUG() << "wxCrafter started" << endl; + m_wxcPlugin = new wxCrafterPlugin(NULL, m_hiddenMainFrame); SetTopWindow(m_wxcPlugin->GetMainFrame()); if(m_hiddenMainFrame) { diff --git a/wxcrafter/wxCrafter.desktop b/wxcrafter/wxCrafter.desktop new file mode 100644 index 0000000000..21fc08b2cf --- /dev/null +++ b/wxcrafter/wxCrafter.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=wxCrafter +Exec=wxcrafter %f +Icon=wxcrafter +Terminal=false +Type=Application +Categories=Development; +StartupNotify=true +Keywords=development;programming; diff --git a/wxcrafter/wxc_settings.cpp b/wxcrafter/wxc_settings.cpp index 879abdc7a4..3a71084cd5 100644 --- a/wxcrafter/wxc_settings.cpp +++ b/wxcrafter/wxc_settings.cpp @@ -1,7 +1,9 @@ +#include "wxc_settings.h" + #include "FreeTrialVersionDlg.h" #include "serial_number.h" -#include "wxc_settings.h" #include "wxgui_helpers.h" + #include #include #include @@ -78,7 +80,9 @@ void wxcSettings::Save() void wxcSettings::RegisterCustomControl(CustomControlTemplate& cct) { CustomControlTemplateMap_t::iterator iter = m_templateClasses.find(cct.GetClassName()); - if(iter != m_templateClasses.end()) { m_templateClasses.erase(iter); } + if(iter != m_templateClasses.end()) { + m_templateClasses.erase(iter); + } cct.SetControlId(::wxNewEventType()); m_templateClasses.insert(std::make_pair(cct.GetClassName(), cct)); } @@ -87,7 +91,9 @@ CustomControlTemplate wxcSettings::FindByControlId(int controlId) const { CustomControlTemplateMap_t::const_iterator iter = m_templateClasses.begin(); for(; iter != m_templateClasses.end(); ++iter) { - if(iter->second.GetControlId() == controlId) { return iter->second; } + if(iter->second.GetControlId() == controlId) { + return iter->second; + } } return CustomControlTemplate(); } @@ -95,14 +101,16 @@ CustomControlTemplate wxcSettings::FindByControlId(int controlId) const CustomControlTemplate wxcSettings::FindByControlName(const wxString& name) const { CustomControlTemplateMap_t::const_iterator iter = m_templateClasses.find(name); - if(iter == m_templateClasses.end()) return CustomControlTemplate(); + if(iter == m_templateClasses.end()) + return CustomControlTemplate(); return iter->second; } void wxcSettings::DeleteCustomControl(const wxString& name) { CustomControlTemplateMap_t::iterator iter = m_templateClasses.find(name); - if(iter == m_templateClasses.end()) return; + if(iter == m_templateClasses.end()) + return; m_templateClasses.erase(iter); } @@ -130,54 +138,19 @@ JSONElement wxcSettings::GetCustomControlsAsJSON(const wxArrayString& controls) JSONElement arr = JSONElement::createArray(wxT("m_templateClasses")); CustomControlTemplateMap_t::const_iterator iter = m_templateClasses.begin(); for(; iter != m_templateClasses.end(); ++iter) { - if(controls.Index(iter->first) != wxNOT_FOUND) arr.append(iter->second.ToJSON()); + if(controls.Index(iter->first) != wxNOT_FOUND) + arr.append(iter->second.ToJSON()); } return arr; } bool wxcSettings::IsLicensed() const { return true; } -bool wxcSettings::IsLicensed2() const -{ - // SerialNumber sn; - // return sn.Isvalid2(m_serialNumber, m_username) && (m_flags & LICENSE_ACTIVATED); - return IsLicensed(); -} +bool wxcSettings::IsLicensed2() const { return IsLicensed(); } -bool wxcSettings::IsRegistered() const -{ - SerialNumber sn; - bool isLicensed = sn.IsValid(m_serialNumber, m_username) && (m_flags & LICENSE_ACTIVATED); - return isLicensed; -} +bool wxcSettings::IsRegistered() const { return true; } -#define ONE_HOUR (60 * 60 * 1) - -void wxcSettings::ShowNagDialogIfNeeded() -{ -#if STANDALONE_BUILD - if(!IsRegistered()) { - // Free trial version - static time_t lastCheck = 0; - time_t curtime = time(NULL); - if(((curtime - lastCheck) > ONE_HOUR) || true) { - lastCheck = curtime; - FreeTrialVersionDlg dlg(wxCrafter::TopFrame()); - dlg.ShowModal(); - switch(dlg.GetAnswer()) { - case FreeTrialVersionDlg::kPurchase: - ::wxLaunchDefaultBrowser("http://wxcrafter.codelite.org/checkout.php"); - break; - default: - break; - } - } - } -#else - // CodeLite's plugin, nothing to be done here - return; -#endif -} +void wxcSettings::ShowNagDialogIfNeeded() {} // ---------------------------------------------------------------------- // CustomControlTemplate