diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/AlsaStubDriver.cpp | 18 | ||||
-rw-r--r-- | src/JackLibDriver.cpp | 6 | ||||
-rw-r--r-- | src/JackStubDriver.cpp | 18 | ||||
-rw-r--r-- | src/Legend.cpp | 2 | ||||
-rw-r--r-- | src/UIFile.hpp | 17 | ||||
-rw-r--r-- | src/binary_location.h | 4 | ||||
-rw-r--r-- | src/make_alsa_driver.hpp | 13 | ||||
-rw-r--r-- | src/make_jack_driver.hpp | 13 | ||||
-rw-r--r-- | src/patchage.ui.in (renamed from src/patchage.ui) | 0 | ||||
-rw-r--r-- | src/patchage_config.h | 88 |
10 files changed, 138 insertions, 41 deletions
diff --git a/src/AlsaStubDriver.cpp b/src/AlsaStubDriver.cpp new file mode 100644 index 0000000..5dc8f0b --- /dev/null +++ b/src/AlsaStubDriver.cpp @@ -0,0 +1,18 @@ +// Copyright 2007-2022 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "AudioDriver.hpp" +#include "Driver.hpp" +#include "make_alsa_driver.hpp" + +#include <memory> + +namespace patchage { + +std::unique_ptr<Driver> +make_alsa_driver(ILog&, Driver::EventSink) +{ + return nullptr; +} + +} // namespace patchage diff --git a/src/JackLibDriver.cpp b/src/JackLibDriver.cpp index 8728222..8c804ba 100644 --- a/src/JackLibDriver.cpp +++ b/src/JackLibDriver.cpp @@ -31,7 +31,7 @@ #include "patchage_config.h" #include "warnings.hpp" -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA # include <jack/metadata.h> #endif @@ -182,7 +182,7 @@ get_property(const jack_uuid_t subject, const char* const key) { std::string result; -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA char* value = nullptr; char* datatype = nullptr; if (!jack_get_property(subject, key, &value, &datatype)) { @@ -213,7 +213,7 @@ JackLibDriver::get_port_info(const jack_port_t* const port) auto label = PortNames{name}.port(); // Get pretty name to use as a label, if present -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA const auto pretty_name = get_property(uuid, JACK_METADATA_PRETTY_NAME); if (!pretty_name.empty()) { label = pretty_name; diff --git a/src/JackStubDriver.cpp b/src/JackStubDriver.cpp new file mode 100644 index 0000000..a062df1 --- /dev/null +++ b/src/JackStubDriver.cpp @@ -0,0 +1,18 @@ +// Copyright 2020-2022 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "AudioDriver.hpp" +#include "Driver.hpp" +#include "make_jack_driver.hpp" + +#include <memory> + +namespace patchage { + +std::unique_ptr<AudioDriver> +make_jack_driver(ILog&, Driver::EventSink) +{ + return nullptr; +} + +} // namespace patchage diff --git a/src/Legend.cpp b/src/Legend.cpp index e8e4743..294f589 100644 --- a/src/Legend.cpp +++ b/src/Legend.cpp @@ -39,7 +39,7 @@ Legend::Legend(const Configuration& configuration) "Audio", configuration.get_port_color(PortType::jack_audio)); -#ifdef HAVE_JACK_METADATA +#if USE_JACK_METADATA add_button( PortType::jack_cv, "CV", configuration.get_port_color(PortType::jack_cv)); add_button(PortType::jack_osc, diff --git a/src/UIFile.hpp b/src/UIFile.hpp index d7f1e5c..28d7c82 100644 --- a/src/UIFile.hpp +++ b/src/UIFile.hpp @@ -47,25 +47,28 @@ public: static Glib::RefPtr<Gtk::Builder> open(const std::string& base_name) { - std::string ui_filename; + std::cout << "Base name: " << base_name << std::endl; + std::string ui_filename = base_name + ".ui"; + #ifdef PATCHAGE_BINLOC const std::string bundle = bundle_location(); if (!bundle.empty()) { - ui_filename = bundle + "/" + base_name + ".ui"; - if (is_readable(ui_filename)) { - std::cout << "Loading UI file " << ui_filename << std::endl; - return Gtk::Builder::create_from_file(ui_filename); + const std::string bundle_ui_filename = bundle + "/" + ui_filename; + if (is_readable(bundle_ui_filename)) { + std::cout << "Loading UI file " << bundle_ui_filename << std::endl; + return Gtk::Builder::create_from_file(bundle_ui_filename); } } #endif - ui_filename = std::string(PATCHAGE_DATA_DIR) + "/" + base_name + ".ui"; + + ui_filename = std::string(PATCHAGE_DATA_DIR) + "/" + ui_filename; if (is_readable(ui_filename)) { std::cout << "Loading UI file " << ui_filename << std::endl; return Gtk::Builder::create_from_file(ui_filename); } std::stringstream ss; - ss << "Unable to find " << base_name << std::endl; + ss << "Unable to find " << ui_filename << std::endl; throw std::runtime_error(ss.str()); return {}; } diff --git a/src/binary_location.h b/src/binary_location.h index 220c534..d3394f3 100644 --- a/src/binary_location.h +++ b/src/binary_location.h @@ -14,10 +14,6 @@ * along with Patchage. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - #include <dlfcn.h> #include <climits> diff --git a/src/make_alsa_driver.hpp b/src/make_alsa_driver.hpp index f72da99..cfd89c0 100644 --- a/src/make_alsa_driver.hpp +++ b/src/make_alsa_driver.hpp @@ -18,7 +18,6 @@ #define PATCHAGE_MAKE_ALSA_DRIVER_HPP #include "Driver.hpp" -#include "patchage_config.h" #include <memory> @@ -26,21 +25,9 @@ namespace patchage { class ILog; -#if defined(HAVE_ALSA) - std::unique_ptr<Driver> make_alsa_driver(ILog& log, Driver::EventSink emit_event); -#else - -inline std::unique_ptr<Driver> -make_alsa_driver(ILog&, Driver::EventSink) -{ - return nullptr; -} - -#endif - } // namespace patchage #endif // PATCHAGE_MAKE_ALSA_DRIVER_HPP diff --git a/src/make_jack_driver.hpp b/src/make_jack_driver.hpp index abd1ba1..38aef65 100644 --- a/src/make_jack_driver.hpp +++ b/src/make_jack_driver.hpp @@ -18,7 +18,6 @@ #define PATCHAGE_MAKE_JACK_DRIVER_HPP #include "Driver.hpp" -#include "patchage_config.h" #include <memory> @@ -27,21 +26,9 @@ namespace patchage { class AudioDriver; class ILog; -#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS) - std::unique_ptr<AudioDriver> make_jack_driver(ILog& log, Driver::EventSink emit_event); -#else - -inline std::unique_ptr<AudioDriver> -make_jack_driver(ILog&, Driver::EventSink) -{ - return nullptr; -} - -#endif - } // namespace patchage #endif // PATCHAGE_MAKE_JACK_DRIVER_HPP diff --git a/src/patchage.ui b/src/patchage.ui.in index d86fb80..d86fb80 100644 --- a/src/patchage.ui +++ b/src/patchage.ui.in diff --git a/src/patchage_config.h b/src/patchage_config.h new file mode 100644 index 0000000..579a253 --- /dev/null +++ b/src/patchage_config.h @@ -0,0 +1,88 @@ +// Copyright 2021-2022 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +/* + Configuration header that defines reasonable defaults at compile time. + + This allows compile-time configuration from the command line, while still + allowing the source to be built "as-is" without any configuration. The idea + is to support an advanced build system with configuration checks, while still + allowing the code to be simply "thrown at a compiler" with features + determined from the compiler or system headers. Everything can be + overridden, so it should never be necessary to edit this file to build + successfully. + + To ensure that all configure checks are performed, the build system can + define PATCHAGE_NO_DEFAULT_CONFIG to disable defaults. In this case, it must + define all HAVE_FEATURE symbols below to 1 or 0 to enable or disable + features. Any missing definitions will generate a compiler warning. + + To ensure that this header is always included properly, all code that uses + configuration variables includes this header and checks their value with #if + (not #ifdef). Variables like USE_FEATURE are internal and should never be + defined on the command line. +*/ + +#ifndef PATCHAGE_CONFIG_H +#define PATCHAGE_CONFIG_H + +// Define version unconditionally so a warning will catch a mismatch +#define PATCHAGE_VERSION "1.0.7" + +#if !defined(PATCHAGE_NO_DEFAULT_CONFIG) + +// Classic UNIX: dladdr() +# ifndef HAVE_DLADDR +# ifdef __has_include +# if __has_include(<dlfcn.h>) +# define HAVE_DLADDR 1 +# else +# define HAVE_DLADDR 0 +# endif +# elif defined(__unix__) || defined(__APPLE__) +# define HAVE_DLADDR 1 +# else +# define HAVE_DLADDR 0 +# endif +# endif + +// JACK metadata API +# ifndef HAVE_JACK_METADATA +# ifdef __has_include +# if __has_include(<jack/metadata.h>) +# define HAVE_JACK_METADATA 1 +# else +# define HAVE_JACK_METADATA 0 +# endif +# else +# define HAVE_JACK_METADATA 0 +# endif +# endif + +#endif // !defined(PATCHAGE_NO_DEFAULT_CONFIG) + +/* + Make corresponding USE_FEATURE defines based on the HAVE_FEATURE defines from + above or the command line. The code checks for these using #if (not #ifdef), + so there will be an undefined warning if it checks for an unknown feature, + and this header is always required by any code that checks for features, even + if the build system defines them all. +*/ + +#if HAVE_DLADDR +# define USE_DLADDR 1 +#else +# define USE_DLADDR 0 +#endif + +#if HAVE_JACK_METADATA +# define USE_JACK_METADATA 1 +#else +# define USE_JACK_METADATA 0 +#endif + +#ifndef PATCHAGE_USE_LIGHT_THEME +# define PATCHAGE_USE_LIGHT_THEME 0 +#endif + +#endif // PATCHAGE_CONFIG_H |