Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

declare -path & -lib flags now search user search paths #205

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 20 additions & 13 deletions doc/5.reference/declare-help.pd
@@ -1,31 +1,38 @@
#N canvas 1017 55 612 633 12;
#N canvas 523 55 562 645 12;
#X declare;
#X obj 48 10 declare;
#X text 120 11 - set environment for loading patch;
#X text 44 40 A declare object adds one or more directories to the
search path \, and/or pre-loads one or more libraries ("extensions")
to Pd in preparation for opening the patch from a file. Usage is "declare
[-flag value] [-flag value] ..." where the flag can be:;
#X text 40 182 -lib;
#X text 40 198 -stdlib;
#X text 40 146 -path;
#X text 40 162 -stdpath;
#X text 133 162 add to search path \, relative to Pd;
#X text 48 508 BUG: The name "-stdpath" is confusing \, as it has a
#X text 40 176 -lib;
#X text 40 193 -stdlib;
#X text 40 140 -path;
#X text 40 157 -stdpath;
#X text 138 158 add to search path \, relative to Pd;
#X text 42 551 BUG: The name "-stdpath" is confusing \, as it has a
quite different effect from "-stdpath" on the pd command line.;
#X text 39 293 For instance \, if you put abstractions and/or other
#X text 40 293 For instance \, if you put abstractions and/or other
supporting files in a subdirectory "more" \, you can put an object
\, "declare -path more" to make sure Pd sees them when the patch is
loaded. Or \, if you have files installed in the directory extra/stillmore
(in the Pd installation) you can get it using "declare -stdpath stillmore".
;
#X text 41 395 WARNING: as of version 0.47 \, "declare -path" and "declare
#X text 40 395 WARNING: as of version 0.47 \, "declare -path" and "declare
-stdpath" inside abstractions take effect only within those abstractions.
If Pd's compatibility version is set to 0.46 or earlier the old (buggy)
behavior takes effect.;
#X text 360 591 updated for Pd version 0.49;
#X text 135 143 add to search path \, absolute or relative to the patch
#X text 327 602 updated for Pd version 0.49;
#X text 138 140 add to search path \, relative to the patch or user
paths;
#X text 138 176 load a library \, relative to the patch or user paths
;
#X text 132 181 add to search path \, absolute or relative to the patch
#X text 40 231 (For any of these you may use a full pathname such as
"/tmp/dir" or \, in Windows \, "C:/garbage" instead of a relative path).
;
#X text 135 199 load a binary library \, relative to Pd;
#X text 41 468 As of version 0.49 \, "declare -path" and "declare -lib"
will fall back to user search paths if the relative path to the patch
does not exit. To avoid checking further \, use an explicit relative
path by prepending "./" or "../" to the path or lib name.;
#X text 138 193 load a library \, relative to Pd;
14 changes: 8 additions & 6 deletions src/g_canvas.c
Expand Up @@ -1469,7 +1469,7 @@ static void canvas_completepath(const char *from, char *to, int bufsize,
to[bufsize-dirlen-1] = '\0';
strcat(to, "/");
}
else
else
{ /* append Pd lib dir */
strncpy(to, sys_libdir->s_name, bufsize-10);
to[bufsize-9] = '\0';
Expand Down Expand Up @@ -1509,8 +1509,8 @@ static void canvas_path(t_canvas *x, t_canvasenvironment *e, const char *path)
return;
}

/* explicit relative path, starts with ./ or ../ */
if (path[0] == '.' && (path[1] == '/' || path[1] == '.' && path[2] == '/'))
/* explicit relative-path */
if ((strncmp("./", path, 2) == 0) || (strncmp("../", path, 3) == 0))
{
e->ce_path = namelist_append(e->ce_path, path, 0);
return;
Expand Down Expand Up @@ -1548,6 +1548,7 @@ static void canvas_path(t_canvas *x, t_canvasenvironment *e, const char *path)
}
}
}

static void canvas_lib(t_canvas *x, t_canvasenvironment *e, const char *lib)
{
t_namelist *nl;
Expand All @@ -1558,8 +1559,8 @@ static void canvas_lib(t_canvas *x, t_canvasenvironment *e, const char *lib)
return;
}

/* explicit relative path, starts with ./ or ../ */
if (lib[0] == '.' && (lib[1] == '/' || lib[1] == '.' && lib[2] == '/'))
/* explicit relative-path */
if ((strncmp("./", lib, 2) == 0) || (strncmp("../", lib, 3) == 0))
{
sys_load_lib(x, lib);
return;
Expand All @@ -1580,7 +1581,7 @@ static void canvas_lib(t_canvas *x, t_canvasenvironment *e, const char *lib)
}
}

static void canvas_stdpath(t_canvasenvironment *e, const char *stdpath)
static void canvas_stdpath(t_canvasenvironment *e, char *stdpath)
{
t_namelist *nl;
char strbuf[MAXPDSTRING];
Expand Down Expand Up @@ -1614,6 +1615,7 @@ static void canvas_stdpath(t_canvasenvironment *e, const char *stdpath)
}
}
}

static void canvas_stdlib(t_canvasenvironment *e, const char *stdlib)
{
t_namelist *nl;
Expand Down