reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 46a8b9b2d0bd75e90f6cff35cc0bcc688deafd26
parent ac0ec38375acae2a0fcde1d65786bb7d4461c8bc
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Mon, 27 Feb 2017 17:03:42 -0500

Merge branch 'linux'

Diffstat:
Alinux.tup | 34++++++++++++++++++++++++++++++++++
Msrc/dialog.cpp | 18+++++++++---------
Msrc/dialog.hpp | 12++++--------
Msrc/main.cpp | 2+-
Msrc/platform.cpp | 10++++++++++
Msrc/platform.hpp | 5+++--
Msrc/remote.cpp | 4+---
Asrc/richedit-gtk.cpp | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Rsrc/richedit.cpp -> src/richedit-win32.cpp | 0
Msrc/transaction.cpp | 2+-
Mtest/index_v1.cpp | 4+++-
Mtest/indexes/v1/ReaPack/cache/src_platform.xml | 1+
Mtest/platform.cpp | 30+++++++++++++++++++++++++++---
Mtest/remote.cpp | 3+++
14 files changed, 146 insertions(+), 28 deletions(-)

diff --git a/linux.tup b/linux.tup @@ -0,0 +1,34 @@ +ifeq (@(ARCH),x86_64) + CXX := gcc +else + CXX := echo 'Unsupported architecture: @(ARCH)' && false +endif + +REAPACK_FILE = reaper_reapack@(SUFFIX).so + +CXXFLAGS := -Wall -Wextra -Werror +CXXFLAGS += -Wno-unused-parameter -Wno-missing-field-initializers +CXXFLAGS += -Wno-unused-function -Wno-missing-braces +CXXFLAGS += -fdiagnostics-color -fstack-protector-strong -fvisibility=hidden +CXXFLAGS += -pipe -fPIC -O2 -std=c++14 +CXXFLAGS += -Ivendor -Ivendor/WDL -Ivendor/WDL/WDL -Ivendor/WDL/WDL/swell +CXXFLAGS += -DWDL_NO_DEFINE_MINMAX -DSWELL_PROVIDED_BY_APP -DSWELL_TARGET_GDK +CXXFLAGS += -DREAPACK_FILE=\"$(REAPACK_FILE)\" + +WDLFLAGS := -std=c++98 -w + +SWELL := $(WDL)/swell +WDLSOURCE += $(SWELL)/swell-modstub-generic.cpp + +LDFLAGS := -lstdc++ -lpthread -ldl -lcurl -lsqlite3 + +SOFLAGS := -shared +SOTARGET := bin/$(REAPACK_FILE) + +TSTARGET := bin/test + +!build = |> $(CXX) $(CXXFLAGS) -c %f -o %o |> +!link = |> $(CXX) $(CXXFLAGS) %f $(LDFLAGS) -o %o |> + +BUILDDEPS := src/resource.rc_mac_menu src/resource.rc_mac_dlg +: src/resource.rc |> php $(SWELL)/mac_resgen.php %f |> $(BUILDDEPS) diff --git a/src/dialog.cpp b/src/dialog.cpp @@ -57,13 +57,6 @@ WDL_DLGRET Dialog::Proc(HWND handle, UINT msg, WPARAM wParam, LPARAM lParam) dlg->onInit(); break; - case WM_SHOWWINDOW: - // this makes possible to call onHide when destroying the window - // but only if was visible before the destruction request - // (destruction might be caused by the application exiting, - // in which case IsWindowVisible would be false but m_isVisible == true) - dlg->m_isVisible = wParam == 1; - break; case WM_TIMER: dlg->onTimer((int)wParam); break; @@ -124,8 +117,7 @@ int Dialog::HandleKey(MSG *msg, accelerator_register_t *accel) } Dialog::Dialog(const int templateId) - : m_template(templateId), m_isVisible(false), m_minimumSize(), - m_instance(nullptr), m_parent(nullptr), m_handle(nullptr) + : m_template(templateId), m_instance(nullptr), m_parent(nullptr), m_handle(nullptr) { m_accel.translateAccel = HandleKey; m_accel.isLocal = true; @@ -188,9 +180,17 @@ void Dialog::DestroyAll() void Dialog::setVisible(const bool visible, HWND handle) { + if(!handle) + handle = m_handle; + ShowWindow(handle, visible ? SW_SHOW : SW_HIDE); } +bool Dialog::isVisible() const +{ + return IsWindowVisible(m_handle); +} + void Dialog::close(const INT_PTR result) { switch(m_mode) { diff --git a/src/dialog.hpp b/src/dialog.hpp @@ -86,13 +86,10 @@ public: void setEnabled(bool enable) { setEnabled(enable, m_handle); } void setEnabled(bool, HWND); - bool isVisible() const { return m_isVisible; } - void show() { show(m_handle); } - void show(HWND handle) { setVisible(true, handle); } - void hide() { hide(m_handle); } - void hide(HWND handle) { setVisible(false, handle); } - void setVisible(bool visible) { setVisible(visible, m_handle); } - void setVisible(bool, HWND); + bool isVisible() const; + void show(HWND handle = nullptr) { setVisible(true, handle); } + void hide(HWND handle = nullptr) { setVisible(false, handle); } + void setVisible(bool, HWND = nullptr); void close(INT_PTR = 0); void center(); @@ -152,7 +149,6 @@ private: static std::map<HWND, Dialog *> s_instances; const int m_template; - bool m_isVisible; POINT m_minimumSize; WDL_WndSizer m_resizer; Modality m_mode; diff --git a/src/main.cpp b/src/main.cpp @@ -185,7 +185,7 @@ extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT( return 1; } -#ifdef __APPLE__ +#ifndef _WIN32 #include "resource.hpp" #include <swell/swell-dlggen.h> diff --git a/src/platform.cpp b/src/platform.cpp @@ -35,6 +35,10 @@ auto Platform::parse(const char *platform) -> Enum return Darwin32Platform; else if(!strcmp(platform, "darwin64")) return Darwin64Platform; + else if(!strcmp(platform, "linux")) + return LinuxPlatform; + else if(!strcmp(platform, "linux64")) + return Linux64Platform; else return UnknownPlatform; } @@ -51,6 +55,12 @@ bool Platform::test() const case Darwin32Platform: #endif +#elif __linux__ + case LinuxPlatform: +#ifdef __x86_64__ + case Linux64Platform: +#endif + #elif _WIN32 case WindowsPlatform: #ifdef _WIN64 diff --git a/src/platform.hpp b/src/platform.hpp @@ -24,15 +24,16 @@ public: UnknownPlatform, GenericPlatform, - // windows WindowsPlatform, Win32Platform, Win64Platform, - // os x DarwinPlatform, Darwin32Platform, Darwin64Platform, + + LinuxPlatform, + Linux64Platform, }; Platform() : m_value(GenericPlatform) {} diff --git a/src/remote.cpp b/src/remote.cpp @@ -46,11 +46,9 @@ static bool validateName(const string &name) static bool validateUrl(const string &url) { - using namespace std::regex_constants; - // see http://tools.ietf.org/html/rfc3986#section-2 static const regex pattern( - "(?:[a-z0-9._~:/?#[\\]@!$&'()*+,;=-]|%[a-f0-9]{2})+", icase); + "(?:[a-zA-Z0-9._~:/?#[\\]@!$&'()*+,;=-]|%[a-f0-9]{2})+"); smatch match; regex_match(url, match, pattern); diff --git a/src/richedit-gtk.cpp b/src/richedit-gtk.cpp @@ -0,0 +1,49 @@ +/* ReaPack: Package manager for REAPER + * Copyright (C) 2015-2017 Christian Fillion + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "richedit.hpp" + +#ifdef SWELL_TARGET_GDK + +// Starting here and onward is the Linux implementation of RichEdit +// See also richedit.mm and richedit-win32.cpp + +using namespace std; + +void RichEdit::Init() +{ +} + +RichEdit::RichEdit(HWND handle) + : Control(handle) +{ +} + +RichEdit::~RichEdit() +{ +} + +void RichEdit::onNotify(LPNMHDR, LPARAM) +{ +} + +bool RichEdit::setRichText(const string &) +{ + return false; +} + +#endif diff --git a/src/richedit.cpp b/src/richedit-win32.cpp diff --git a/src/transaction.cpp b/src/transaction.cpp @@ -200,7 +200,7 @@ bool Transaction::runTasks() if(m_promptObsolete(selected)) { if(m_taskQueues.empty()) - m_taskQueues.push({}); + m_taskQueues.push(TaskQueue()); for(const auto &entry : selected) m_taskQueues.back().push(make_shared<UninstallTask>(entry, this)); diff --git a/test/index_v1.cpp b/test/index_v1.cpp @@ -263,12 +263,14 @@ TEST_CASE("read source platform", M) { IndexPtr ri = Index::load("src_platform"); - CHECK(ri->packages().size() == 1); + REQUIRE(ri->packages().size() == 1); #ifdef __APPLE__ const auto expected = Platform::DarwinPlatform; #elif _WIN32 const auto expected = Platform::WindowsPlatform; +#elif __linux__ + const auto expected = Platform::LinuxPlatform; #endif REQUIRE(ri->category(0)->package(0)->version(0)->source(0)->platform() diff --git a/test/indexes/v1/ReaPack/cache/src_platform.xml b/test/indexes/v1/ReaPack/cache/src_platform.xml @@ -4,6 +4,7 @@ <version name="1.0"> <source platform="windows" type="effect">https://google.com/</source> <source platform="darwin" type="effect">https://google.com/</source> + <source platform="linux" type="effect">https://google.com/</source> </version> </reapack> </category> diff --git a/test/platform.cpp b/test/platform.cpp @@ -30,14 +30,20 @@ TEST_CASE("platform from string", M) { SECTION("windows 64-bit") REQUIRE(Platform("win64") == Platform::Win64Platform); - SECTION("generic os x") + SECTION("generic macos") REQUIRE(Platform("darwin") == Platform::DarwinPlatform); - SECTION("os x 32-bit") + SECTION("macos 32-bit") REQUIRE(Platform("darwin32") == Platform::Darwin32Platform); - SECTION("os x 64-bit") + SECTION("macos 64-bit") REQUIRE(Platform("darwin64") == Platform::Darwin64Platform); + + SECTION("generic linux") + REQUIRE(Platform("linux") == Platform::LinuxPlatform); + + SECTION("linux 64-bit") + REQUIRE(Platform("linux64") == Platform::Linux64Platform); } TEST_CASE("test platform", M) { @@ -45,6 +51,8 @@ TEST_CASE("test platform", M) { {Platform::GenericPlatform, true}, #ifdef __APPLE__ + {Platform::LinuxPlatform, false}, + {Platform::Linux64Platform, false}, {Platform::WindowsPlatform, false}, {Platform::Win32Platform, false}, {Platform::Win64Platform, false}, @@ -58,10 +66,23 @@ TEST_CASE("test platform", M) { {Platform::Darwin64Platform, false}, #endif +#elif __linux__ + {Platform::DarwinPlatform, false}, + {Platform::Darwin32Platform, false}, + {Platform::Darwin64Platform, false}, + {Platform::WindowsPlatform, false}, + {Platform::Win32Platform, false}, + {Platform::Win64Platform, false}, + + {Platform::LinuxPlatform, true}, + {Platform::Linux64Platform, true}, + #elif _WIN32 {Platform::DarwinPlatform, false}, {Platform::Darwin32Platform, false}, {Platform::Darwin64Platform, false}, + {Platform::LinuxPlatform, false}, + {Platform::Linux64Platform, false}, {Platform::WindowsPlatform, true}, #ifdef _WIN64 @@ -71,6 +92,9 @@ TEST_CASE("test platform", M) { {Platform::Win32Platform, true}, {Platform::Win64Platform, false}, #endif + +#else +#error Untested platform #endif }; diff --git a/test/remote.cpp b/test/remote.cpp @@ -123,6 +123,9 @@ TEST_CASE("valide remote urls", M) { SECTION("escape sequence") remote.setUrl("https://google.com/?q=hello%20world"); + + SECTION("libstdc++ bug #71500") // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71500 + remote.setUrl("https://google.com/RRR"); } TEST_CASE("null remote", M) {