From a7d83f19b08eb4c6f79a82fe60c2b86db13f4420 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 24 Nov 2018 13:44:03 +0100 Subject: Squashed 'waflib/' changes from 6e726eb1..5ea8f99f 5ea8f99f Improve test output spacing 0e23b29f Raise exception when test suite fails to ensure non-zero exit status d6de073b Show run time of unit tests 5b655541 Add short configure option for ultra-strict flags 4687ba6d Use gtest-like test output 258903d9 Fix failure count in test group summaries da07e738 Fix verbose tests with Python 3 git-subtree-dir: waflib git-subtree-split: 5ea8f99f6e1246079c1fe6bb590c38a53aadd40d --- src/runtime_paths.cpp | 146 -------------------------------------------------- 1 file changed, 146 deletions(-) delete mode 100644 src/runtime_paths.cpp (limited to 'src/runtime_paths.cpp') diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp deleted file mode 100644 index 8dbe5c0c..00000000 --- a/src/runtime_paths.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2015 David Robillard - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see . -*/ - -#include -#include -#include -#include -#include - -#include - -#include "ingen/runtime_paths.hpp" -#include "ingen/FilePath.hpp" - -#include "ingen_config.h" - -namespace Ingen { - -static FilePath bundle_path; - -#if defined(__APPLE__) -const char search_path_separator = ':'; -static const char* const library_prefix = "lib"; -static const char* const library_suffix = ".dylib"; -#elif defined(_WIN32) && !defined(__CYGWIN__) -const char search_path_separator = ';'; -static const char* const library_prefix = ""; -static const char* const library_suffix = ".dll"; -#else -const char search_path_separator = ':'; -static const char* const library_prefix = "lib"; -static const char* const library_suffix = ".so"; -#endif - -/** Must be called once at startup, and passed a pointer to a function - * that lives in the 'top level' of the bundle (e.g. the executable). - * Passing a function defined in a module etc. will not work! - */ -void -set_bundle_path_from_code(void* function) -{ - Dl_info dli; - dladdr(function, &dli); - -#ifdef BUNDLE - char bin_loc[PATH_MAX]; - realpath(dli.dli_fname, bin_loc); -#else - const char* bin_loc = dli.dli_fname; -#endif - - bundle_path = FilePath(bin_loc).parent_path(); -} - -void -set_bundle_path(const char* path) -{ - bundle_path = FilePath(path); -} - -/** Return the absolute path of a file in an Ingen LV2 bundle - */ -FilePath -bundle_file_path(const std::string& name) -{ - return bundle_path / name; -} - -/** Return the absolute path of a 'resource' file. - */ -FilePath -data_file_path(const std::string& name) -{ -#ifdef BUNDLE - return bundle_path / INGEN_DATA_DIR / name; -#else - return FilePath(INGEN_DATA_DIR) / name; -#endif -} - -/** Return the absolute path of a module (dynamically loaded shared library). - */ -FilePath -ingen_module_path(const std::string& name, FilePath dir) -{ - FilePath ret; - if (dir.empty()) { -#ifdef BUNDLE - dir = FilePath(bundle_path) / INGEN_MODULE_DIR; -#else - dir = FilePath(INGEN_MODULE_DIR); -#endif - } - - return dir / - (std::string(library_prefix) + "ingen_" + name + library_suffix); -} - -FilePath -user_config_dir() -{ - const char* const xdg_config_home = getenv("XDG_CONFIG_HOME"); - const char* const home = getenv("HOME"); - - if (xdg_config_home) { - return FilePath(xdg_config_home); - } else if (home) { - return FilePath(home) / ".config"; - } - - return FilePath(); -} - -std::vector -system_config_dirs() -{ - const char* const xdg_config_dirs = getenv("XDG_CONFIG_DIRS"); - - std::vector paths; - if (xdg_config_dirs) { - std::istringstream ss(xdg_config_dirs); - std::string entry; - while (std::getline(ss, entry, search_path_separator)) { - paths.emplace_back(entry); - } - } else { - paths.emplace_back("/etc/xdg"); - } - - return paths; -} - -} // namespace Ingen -- cgit v1.2.1