From dbca8cdb2a3c8e65c814521ba98f50a582194a73 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 2 Jul 2018 14:05:54 +0200 Subject: Add configuration/defaults.h --- doc/Building.md | 28 ++++++++++++++++++++++++++++ doc/Windows.md | 19 ------------------- lib/configuration/CMakeLists.txt | 6 ++++++ lib/configuration/configuration.cpp | 17 +++++++++-------- lib/configuration/defaults.h.linux | 10 ++++++++++ lib/configuration/defaults.h.win32 | 10 ++++++++++ plugins/ConfigurationEditor/CMakeLists.txt | 4 ++-- plugins/ProfileEditor/CMakeLists.txt | 4 ++-- 8 files changed, 67 insertions(+), 31 deletions(-) create mode 100644 doc/Building.md delete mode 100644 doc/Windows.md create mode 100644 lib/configuration/defaults.h.linux create mode 100644 lib/configuration/defaults.h.win32 diff --git a/doc/Building.md b/doc/Building.md new file mode 100644 index 0000000..ab731dc --- /dev/null +++ b/doc/Building.md @@ -0,0 +1,28 @@ +## Customizing +### Version + +### Configuration +Configuration values are set from defaults.h, which is generated from +defaults.h.{linux;win32}. + +## Building on Windows + +~~~ +set INSTALL_DIR="C:\projects\smolbote-install" +mkdir %INSTALL_DIR% + +mkdir C:\projects\smolbote-build +cd C:\projects\smolbote-build + +set QT="C:\Qt\5.11.0\msvc2017_64" +set BOOST_ROOT="C:\Libraries\boost_1_66_0" +set BOOST_LIBDIR="C:\Libraries\boost_1_66_0\lib64-msvc-14.1" +cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%QT%;%BOOST_ROOT% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBDIR% -DBoost_USE_STATIC_LIBS=On C:\projects\smolbote-hg +cmake --build . --target poi --config Release +cmake --build . --target install --config Release +cd %INSTALL_DIR% +C:\Qt\5.10.1\msvc2017_64\bin\windeployqt.exe bin\poi.exe + +7z a C:\projects\smolbote-hg\smolbote.7z %INSTALL_DIR% +~~~ + diff --git a/doc/Windows.md b/doc/Windows.md deleted file mode 100644 index aee65b3..0000000 --- a/doc/Windows.md +++ /dev/null @@ -1,19 +0,0 @@ -~~~ -set INSTALL_DIR="C:\projects\smolbote-install" -mkdir %INSTALL_DIR% - -mkdir C:\projects\smolbote-build -cd C:\projects\smolbote-build - -set QT="C:\Qt\5.11.0\msvc2017_64" -set BOOST_ROOT="C:\Libraries\boost_1_66_0" -set BOOST_LIBDIR="C:\Libraries\boost_1_66_0\lib64-msvc-14.1" -cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%QT%;%BOOST_ROOT% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBDIR% -DBoost_USE_STATIC_LIBS=On C:\projects\smolbote-hg -cmake --build . --target poi --config Release -cmake --build . --target install --config Release -cd %INSTALL_DIR% -C:\Qt\5.10.1\msvc2017_64\bin\windeployqt.exe bin\poi.exe - -7z a C:\projects\smolbote-hg\smolbote.7z %INSTALL_DIR% -~~~ - diff --git a/lib/configuration/CMakeLists.txt b/lib/configuration/CMakeLists.txt index ed0235d..dc5bf6d 100644 --- a/lib/configuration/CMakeLists.txt +++ b/lib/configuration/CMakeLists.txt @@ -6,6 +6,12 @@ set(CMAKE_AUTOMOC ON) #set(CMAKE_AUTOUIC ON) #set(CMAKE_AUTORCC ON) +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + configure_file(defaults.h.win32 ${PROJECT_BINARY_DIR}/lib/configuration/defaults.h) +else() + configure_file(defaults.h.linux ${PROJECT_BINARY_DIR}/lib/configuration/defaults.h) +endif() + add_library(configuration configuration.cpp configuration.h) diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp index c7209e3..cae21fd 100644 --- a/lib/configuration/configuration.cpp +++ b/lib/configuration/configuration.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "defaults.h" namespace po = boost::program_options; @@ -90,28 +91,28 @@ Configuration::Configuration(QObject *parent) ("window.shortcuts.fullscreen", po::value()->default_value("F11")) // Filter settings - ("filter.path", po::value()->default_value("~/.config/smolbote/hosts.d")) - ("filter.cookies.block.all", po::value()->default_value(false)) - ("filter.cookies.block.thirdParty", po::value()->default_value(true)) - ("filter.cookies.path", po::value()->default_value("~/.config/smolbote/cookies.d")) + ("filter.path", po::value()->default_value(filter_path)) +// ("filter.cookies.block.all", po::value()->default_value(false)) +// ("filter.cookies.block.thirdParty", po::value()->default_value(true)) +// ("filter.cookies.path", po::value()->default_value("~/.config/smolbote/cookies.d")) // Plugin settings - ("plugins.path", po::value()->default_value("~/.config/smolbote/plugins.d")) + ("plugins.path", po::value()->default_value(plugins_path)) // Profile settings // default profile name the browser should use; "" is off-the-record ("profile.default", po::value()->default_value("")) - ("profile.path", po::value()->default_value("~/.config/smolbote/profiles.d")) + ("profile.path", po::value()->default_value(profiles_path)) ("profile.search", po::value()->default_value("https://duckduckgo.com/?q=%1&ia=web")) ("profile.homepage", po::value()->default_value("about:blank")) ("profile.newtab", po::value()->default_value("about:blank")) // Bookmark settings - ("bookmarks.path", po::value()->default_value("~/.config/smolbote/bookmarks.xbel")) + ("bookmarks.path", po::value()->default_value(bookmarks_path)) ("bookmarks.shortcut", po::value()->default_value("Ctrl+B")) // Downloads settings - ("downloads.path", po::value()->default_value("~/Downloads")) + ("downloads.path", po::value()->default_value(downloads_path)) ("downloads.shortcut", po::value()->default_value("Ctrl+D")) ; } diff --git a/lib/configuration/defaults.h.linux b/lib/configuration/defaults.h.linux new file mode 100644 index 0000000..983e36b --- /dev/null +++ b/lib/configuration/defaults.h.linux @@ -0,0 +1,10 @@ +#ifndef SMOLBOTE_DEFAULTS +#define SMOLBOTE_DEFAULTS + +#define filter_path "~/.config/smolbote/hosts.d" +#define plugins_path "~/.config/smolbote/plugins.d" +#define profiles_path "~/.config/smolbote/profiles.d" +#define bookmarks_path "~/.config/smolbote/bookmarks.xbel" +#define downloads_path "~/Downloads" + +#endif // SMOLBOTE_DEFAULTS diff --git a/lib/configuration/defaults.h.win32 b/lib/configuration/defaults.h.win32 new file mode 100644 index 0000000..9a8d5b3 --- /dev/null +++ b/lib/configuration/defaults.h.win32 @@ -0,0 +1,10 @@ +#ifndef SMOLBOTE_DEFAULTS +#define SMOLBOTE_DEFAULTS + +#define filter_path "hosts" +#define plugins_path "plugins" +#define profiles_path "profiles" +#define bookmarks_path "bookmarks.xbel" +#define downloads_path "~/Downloads" + +#endif // SMOLBOTE_DEFAULTS diff --git a/plugins/ConfigurationEditor/CMakeLists.txt b/plugins/ConfigurationEditor/CMakeLists.txt index 2d97cc5..ed88877 100644 --- a/plugins/ConfigurationEditor/CMakeLists.txt +++ b/plugins/ConfigurationEditor/CMakeLists.txt @@ -23,8 +23,8 @@ target_link_libraries(ConfigurationEditorPlugin PRIVATE configuration ) -if(WIN32) - install(TARGETS ConfigurationEditorPlugin RUNTIME DESTINATION lib/smolbote CONFIGURATIONS Release) +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + install(TARGETS ConfigurationEditorPlugin RUNTIME DESTINATION bin/plugins CONFIGURATIONS Release) else() install(TARGETS ConfigurationEditorPlugin LIBRARY DESTINATION lib/smolbote CONFIGURATIONS Release) endif() diff --git a/plugins/ProfileEditor/CMakeLists.txt b/plugins/ProfileEditor/CMakeLists.txt index fc7cf96..4f3e026 100644 --- a/plugins/ProfileEditor/CMakeLists.txt +++ b/plugins/ProfileEditor/CMakeLists.txt @@ -26,8 +26,8 @@ target_link_libraries(ProfileEditorPlugin PRIVATE web ) -if(WIN32) - install(TARGETS ProfileEditorPlugin RUNTIME DESTINATION lib/smolbote CONFIGURATIONS Release) +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + install(TARGETS ProfileEditorPlugin RUNTIME DESTINATION bin/plugins CONFIGURATIONS Release) else() install(TARGETS ProfileEditorPlugin LIBRARY DESTINATION lib/smolbote CONFIGURATIONS Release) endif() -- cgit v1.2.1