[Pkg-electronics-commits] [gnucap] 07/43: make GNUCAP_PLUGPATH behave more like LD_LIBRARY_PATH
felix salfelder
felix-guest at moszumanska.debian.org
Wed Oct 4 03:21:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
felix-guest pushed a commit to branch master
in repository gnucap.
commit e78fe3a5d5cbd5cd347bf408ab478bcbc3a75c4e
Author: Felix Salfelder <felix at salfelder.org>
Date: Sun Mar 12 20:24:18 2017 +0000
make GNUCAP_PLUGPATH behave more like LD_LIBRARY_PATH
- encode in the attach binary (remove gnucap-conf dependency)
- inject via CPPFLAGS (not LDFLAGS)
- changeable after compilation (though not with chrpath..)
also install apps to plugindir=$libdir/gnucap (instead of libdir)
---
apps/Make1 | 2 +-
include/patchlev.h | 2 +-
lib/c_attach.cc | 46 +++++++++++++++++++++++++++-------------------
lib/configure | 4 +++-
4 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/apps/Make1 b/apps/Make1
index 9fb2456..95bce14 100644
--- a/apps/Make1
+++ b/apps/Make1
@@ -23,7 +23,7 @@ TARGET = gnucap-default-plugins
#------------------------------------------------------------------------
INSTALL_FILES = $(TARGET)$(TARGET_EXT)
#------------------------------------------------------------------------
-INSTALL_DIR = $(PREFIX)/lib
+INSTALL_DIR = $(PREFIX)/lib/gnucap
#------------------------------------------------------------------------
DELETED =
#------------------------------------------------------------------------
diff --git a/include/patchlev.h b/include/patchlev.h
index 4fc437a..119aeaa 100644
--- a/include/patchlev.h
+++ b/include/patchlev.h
@@ -1 +1 @@
-#define PATCHLEVEL "plugpath-3 2017.03.12"
+#define PATCHLEVEL "plugpath-3b 2017.03.12"
diff --git a/lib/c_attach.cc b/lib/c_attach.cc
index 48b3f02..1e3caaf 100644
--- a/lib/c_attach.cc
+++ b/lib/c_attach.cc
@@ -25,32 +25,40 @@
#include "c_comand.h"
#include "globals.h"
/*--------------------------------------------------------------------------*/
+#define STRINGIZE(x) #x
+#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
+/*--------------------------------------------------------------------------*/
namespace {
/*--------------------------------------------------------------------------*/
+// DTAGS substitute
+const std::string plugpath("PLUGPATH=" STRINGIZE_VALUE_OF(GNUCAP_PLUGPATH)
+ "\0 (reserved space) ");
+/*--------------------------------------------------------------------------*/
std::map<const std::string, void*> attach_list;
/*--------------------------------------------------------------------------*/
std::string plug_path()
-{
- std::string path = OS::getenv("GNUCAP_PLUGPATH") + ':' + OS::getenv("LD_LIBRARY_PATH") + ':';
- if (FILE* f = popen("gnucap-conf --pkglibdir", "r")) {
- char s[200] = ""; // no gnucap_conf still opens pipe, but nothing in it
- fgets(s, 200, f); // so fgets leaves whatever is in s there.
- path += trim(s);
- }else{unreachable();
+{ untested();
+ std::string path = OS::getenv("GNUCAP_PLUGPATH");
+ if(path==""){ untested();
+ path = plugpath.substr(9);
+ }else{ untested();
}
+
+ path += ':' + OS::getenv("LD_LIBRARY_PATH") + ':';
+
return path;
}
/*--------------------------------------------------------------------------*/
class CMD_ATTACH : public CMD {
public:
void do_it(CS& cmd, CARD_LIST*)
- {
+ { untested();
unsigned here = cmd.cursor();
int dl_scope = RTLD_LOCAL;
int check = RTLD_NOW;
// RTLD_NOW means to resolve symbols on loading
// RTLD_LOCAL means symbols defined in a plugin are local
- do {
+ do { untested();
if (cmd.umatch("public ")) {untested();
dl_scope = RTLD_GLOBAL;
// RTLD_GLOBAL means symbols defined in a plugin are global
@@ -60,7 +68,7 @@ public:
// RTLD_LAZY means to defer resolving symbols until needed
// Use when a plugin will not load because of unresolved symbols,
// but it may work without it.
- }else{
+ }else{ untested();
}
} while (cmd.more() && !cmd.stuck(&here));
@@ -77,26 +85,26 @@ public:
cmd.reset(here);
throw Exception_CS("already loaded, cannot replace when there is a circuit", cmd);
}
- }else{
+ }else{ untested();
}
- if (short_file_name.find('/') == std::string::npos) {
+ if (short_file_name.find('/') == std::string::npos) { untested();
// no '/' in name, search for it
std::string path = plug_path();
std::string full_file_name = findfile(short_file_name, path, R_OK);
- if (full_file_name != "") {
+ if (full_file_name != "") { untested();
// found it in path
handle = dlopen(full_file_name.c_str(), check | dl_scope);
}else{itested();
cmd.reset(here);
throw Exception_CS("plugin not found in " + path, cmd);
}
- }else{itested();
+ }else{untested();
// has '/' in name, don't search, we have full name
handle = dlopen(short_file_name.c_str(), check | dl_scope);
}
- if (handle) {
+ if (handle) { untested();
attach_list[short_file_name] = handle;
}else{itested();
cmd.reset(here);
@@ -133,12 +141,12 @@ DISPATCHER<CMD>::INSTALL d2(&command_dispatcher, "detach|unload", &p2);
class CMD_DETACH_ALL : public CMD {
public:
void do_it(CS& cmd, CARD_LIST*)
- {
- if (CARD_LIST::card_list.is_empty()) {
+ { untested();
+ if (CARD_LIST::card_list.is_empty()) { untested();
for (std::map<std::string, void*>::iterator
- ii = attach_list.begin(); ii != attach_list.end(); ++ii) {
+ ii = attach_list.begin(); ii != attach_list.end(); ++ii) { untested();
void* handle = ii->second;
- if (handle) {
+ if (handle) { untested();
dlclose(handle);
ii->second = NULL;
}else{untested();
diff --git a/lib/configure b/lib/configure
index b027a5f..a013351 100755
--- a/lib/configure
+++ b/lib/configure
@@ -53,7 +53,9 @@ LDFLAGS = -shared
.SUFFIXES:
.SUFFIXES: .o .cc
-.cc.o:; \$(CCC) \$(CXXFLAGS) \$(CPPFLAGS) \$(CCFLAGS) -c \$<
+.cc.o:; \$(CCC) \$(CXXFLAGS) \$(CONF_CPPFLAGS) \$(CPPFLAGS) \$(CCFLAGS) -c \$<
+#------------------------------------------------------------------------
+c_attach.o: CONF_CPPFLAGS=-DGNUCAP_PLUGPATH="\$(PREFIX)/lib/gnucap"
#------------------------------------------------------------------------
\$(TARGET)\$(TARGET_EXT): \$(TARGET_DEPENDS)
rm -f \$@
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-electronics/gnucap.git
More information about the Pkg-electronics-commits
mailing list