Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Rishabh Gupta
purr-data
Commits
985eaaea
Commit
985eaaea
authored
Feb 19, 2017
by
Jonathan Wilkes
Browse files
Merge branch 'aggraef/purr-data-loader-fixes-backport'
parents
8d69e70b
f1d98259
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
externals/loaders/libdir/Makefile
View file @
985eaaea
#
# Pd library template version 1.0.3
#
For instructions on how to use this template, see:
#
http://puredata.info/docs/dev
el
o
per
/M
akefile
Template
LIBRARY_NAME
=
libdir
#
!/usr/bin/make -f
#
Makefile to the 'libdir' library for Pure Data.
#
Needs Makefile.pdlibbuilder as h
elper
m
akefile
for platform-dependent build
# settings and rules (https://github.com/pure-data/pd-lib-builder).
# add your .c source files, one object per file, to the SOURCES
# variable, help files will be included automatically
SOURCES
=
libdir.c
lib.name
=
libdir
# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will
# be included automatically
PDOBJECTS
=
# special file that does not provide a class
lib.setup.sources
=
# example patches and related files, in the 'examples' subfolder
EXAMPLES
=
# all other C and C++ files in subdirs are source files per class
# (alternatively, enumerate them by hand)
class.sources
=
libdir.c
# manuals and related files, in the 'manual' subfolder
MANUAL
=
datafiles
=
\
TODO.txt
\
LICENSE.txt
\
README.txt
\
libdir-meta.pd
# if you want to include any other files in the source and binary tarballs,
# list them here. This can be anything from header files, test patches,
# documentation, etc. README.txt and LICENSE.txt are required and therefore
# automatically included
EXTRA_DIST
=
TODO.txt
datadirs
=
# NOTE: removed help patch requirement, since this is a loader
cflags
=
-DVERSION
=
'"
$(lib.version)
"'
#------------------------------------------------------------------------------#
#
# things you might need to edit if you are using other C libraries
#
#------------------------------------------------------------------------------#
################################################################################
### pdlibbuilder ###############################################################
################################################################################
CFLAGS
=
-DPD
-I
"
$(PD_INCLUDE)
"
-Wall
-W
-g
LDFLAGS
=
LIBS
=
#------------------------------------------------------------------------------#
#
# you shouldn't need to edit anything below here, if we did it right :)
#
#------------------------------------------------------------------------------#
# get library version from meta file
LIBRARY_VERSION
=
$(
shell
sed
-n
's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p'
$(LIBRARY_NAME)
-meta
.pd
)
CFLAGS
+=
-DVERSION
=
'"
$(LIBRARY_VERSION)
"'
PD_INCLUDE
=
$(PD_PATH)
/include
# where to install the library, overridden below depending on platform
prefix
=
/usr/local
libdir
=
$(prefix)
/lib
pkglibdir
=
$(libdir)
/pd-externals
objectsdir
=
$(pkglibdir)
INSTALL
=
install
INSTALL_PROGRAM
=
$(INSTALL)
-p
-m
644
INSTALL_DATA
=
$(INSTALL)
-p
-m
644
INSTALL_DIR
=
$(INSTALL)
-p
-m
755
-d
ALLSOURCES
:=
$(SOURCES)
$(SOURCES_android)
$(SOURCES_cygwin)
$(SOURCES_macosx)
\
$(SOURCES_iphoneos)
$(SOURCES_linux)
$(SOURCES_windows)
DISTDIR
=
$(LIBRARY_NAME)
-
$(LIBRARY_VERSION)
ORIGDIR
=
pd-
$(LIBRARY_NAME)
_
$(LIBRARY_VERSION)
UNAME
:=
$(
shell
uname
-s
)
ifeq
($(UNAME),Darwin)
CPU
:=
$(
shell
uname
-p
)
ifeq
($(CPU),arm)
# iPhone/iPod Touch
SOURCES
+=
$(SOURCES_iphoneos)
EXTENSION
=
pd_darwin
OS
=
iphoneos
PD_PATH
=
/Applications/Pd-extended.app/Contents/Resources
IPHONE_BASE
=
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
CC
=
$(IPHONE_BASE)
/gcc
CPP
=
$(IPHONE_BASE)
/cpp
CXX
=
$(IPHONE_BASE)
/g++
ISYSROOT
=
-isysroot
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk
IPHONE_CFLAGS
=
-miphoneos-version-min
=
3.0
$(ISYSROOT)
-arch
armv6
OPT_CFLAGS
=
-fast
-funroll-loops
-fomit-frame-pointer
CFLAGS
:=
$(IPHONE_CFLAGS)
$(OPT_CFLAGS)
$(CFLAGS)
LDFLAGS
+=
-arch
armv6
-bundle
-undefined
dynamic_lookup
$(ISYSROOT)
LIBS
+=
-lc
STRIP
=
strip
-x
DISTBINDIR
=
$(DISTDIR)
-
$(OS)
else
# Mac OS X
SOURCES
+=
$(SOURCES_macosx)
EXTENSION
=
pd_darwin
OS
=
macosx
PD_PATH
=
/Applications/Pd-extended.app/Contents/Resources
OPT_CFLAGS
=
-ftree-vectorize
-ftree-vectorizer-verbose
=
2
-fast
# build universal 32-bit on 10.4 and 32/64 on newer
ifeq
($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8)
FAT_FLAGS
=
-arch
ppc
-arch
i386
-mmacosx-version-min
=
10.4
else
FAT_FLAGS
=
-arch
ppc
-arch
i386
-arch
x86_64
-mmacosx-version-min
=
10.4
SOURCES
+=
$(SOURCES_iphoneos)
endif
CFLAGS
+=
$(FAT_FLAGS)
-fPIC
-I
/sw/include
LDFLAGS
+=
$(FAT_FLAGS)
-bundle
-undefined
dynamic_lookup
-L
/sw/lib
# if the 'pd' binary exists, check the linking against it to aid with stripping
LDFLAGS
+=
$(
shell
test
-e
$(PD_PATH)
/bin/pd
&&
echo
-bundle_loader
$(PD_PATH)
/bin/pd
)
LIBS
+=
-lc
STRIP
=
strip
-x
DISTBINDIR
=
$(DISTDIR)
-
$(OS)
# install into ~/Library/Pd on Mac OS X since /usr/local isn't used much
pkglibdir
=
$(HOME)
/Library/Pd
endif
endif
ifeq
($(UNAME),Linux)
CPU
:=
$(
shell
uname
-m
)
SOURCES
+=
$(SOURCES_linux)
EXTENSION
=
pd_linux
OS
=
linux
PD_PATH
=
/usr
OPT_CFLAGS
=
-O6
-funroll-loops
-fomit-frame-pointer
CFLAGS
+=
-fPIC
LDFLAGS
+=
-Wl
,--export-dynamic
-shared
-fPIC
LIBS
+=
-lc
STRIP
=
strip
--strip-unneeded
-R
.note
-R
.comment
DISTBINDIR
=
$(DISTDIR)
-
$(OS)
-
$(
shell
uname
-m
)
endif
ifeq
(CYGWIN,$(findstring CYGWIN,$(UNAME)))
CPU
:=
$(
shell
uname
-m
)
SOURCES
+=
$(SOURCES_cygwin)
EXTENSION
=
dll
OS
=
cygwin
PD_PATH
=
$
(
cygpath
$(PROGRAMFILES)
)
/pd
OPT_CFLAGS
=
-O6
-funroll-loops
-fomit-frame-pointer
CFLAGS
+=
LDFLAGS
+=
-Wl
,--export-dynamic
-shared
-L
"
$(PD_PATH)
/src"
-L
"
$(PD_PATH)
/bin"
LIBS
+=
-lc
-lpd
STRIP
=
strip
--strip-unneeded
-R
.note
-R
.comment
DISTBINDIR
=
$(DISTDIR)
-
$(OS)
endif
ifeq
(MINGW,$(findstring MINGW,$(UNAME)))
CPU
:=
$(
shell
uname
-m
)
SOURCES
+=
$(SOURCES_windows)
EXTENSION
=
dll
OS
=
windows
PD_PATH
=
$(
shell
cd
"
$(PROGRAMFILES)
"
/pd
&&
pwd
)
OPT_CFLAGS
=
-O3
-funroll-loops
-fomit-frame-pointer
CFLAGS
+=
-mms-bitfields
LDFLAGS
+=
-s
-shared
-Wl
,--enable-auto-import
LIBS
+=
-L
"
$(PD_PATH)
/src"
-L
"
$(PD_PATH)
/bin"
-L
"
$(PD_PATH)
/obj"
-lpd
-lwsock32
-lkernel32
-luser32
-lgdi32
STRIP
=
strip
--strip-unneeded
-R
.note
-R
.comment
DISTBINDIR
=
$(DISTDIR)
-
$(OS)
endif
# in case somebody manually set the HELPPATCHES above
HELPPATCHES
?=
$
(
SOURCES:.c
=
-help
.pd
)
$
(
PDOBJECTS:.pd
=
-help
.pd
)
CFLAGS
+=
$(OPT_CFLAGS)
.PHONY
=
install
libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags
$(LIBRARY_NAME)
all
:
$(SOURCES:.c=.$(EXTENSION))
%.o
:
%.c
$(CC)
$(CFLAGS)
-o
"
$*
.o"
-c
"
$*
.c"
%.$(EXTENSION)
:
%.o
$(CC)
$(LDFLAGS)
-o
"
$*
.
$(EXTENSION)
"
"
$*
.o"
$(LIBS)
chmod
a-x
"
$*
.
$(EXTENSION)
"
# this links everything into a single binary file
$(LIBRARY_NAME)
:
$(SOURCES:.c=.o) $(LIBRARY_NAME).o
$(CC)
$(LDFLAGS)
-o
$(LIBRARY_NAME)
.
$(EXTENSION)
$(SOURCES:.c=.o)
$(LIBRARY_NAME)
.o
$(LIBS)
chmod
a-x
$(LIBRARY_NAME)
.
$(EXTENSION)
install
:
libdir_install
# The meta and help files are explicitly installed to make sure they are
# actually there. Those files are not optional, then need to be there.
libdir_install
:
$(SOURCES:.c=.$(EXTENSION)) install-doc install-examples install-manual
$(INSTALL_DIR)
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
$(INSTALL_DATA)
$(LIBRARY_NAME)
-meta
.pd
\
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
test
-z
"
$(
strip
$(SOURCES)
)
"
||
(
\
$(INSTALL_PROGRAM)
$
(
SOURCES:.c
=
.
$(EXTENSION)
)
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
&&
\
$(STRIP)
$(
addprefix
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
/,
$
(
SOURCES:.c
=
.
$(EXTENSION)
))
)
test
-z
"
$(
strip
$(PDOBJECTS)
)
"
||
\
$(INSTALL_DATA)
$(PDOBJECTS)
\
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
# install library linked as single binary
single_install
:
$(LIBRARY_NAME) install-doc install-exec
$(INSTALL_DIR)
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
$(INSTALL_PROGRAM)
$(LIBRARY_NAME)
.
$(EXTENSION)
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
$(STRIP)
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
/
$(LIBRARY_NAME)
.
$(EXTENSION)
install-doc
:
$(INSTALL_DIR)
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
# test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \
# $(INSTALL_DATA) $(HELPPATCHES) \
# $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
$(INSTALL_DATA)
README.txt
$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt
$(INSTALL_DATA)
LICENSE.txt
$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt
install-examples
:
test
-z
"
$(
strip
$(EXAMPLES)
)
"
||
\
$(INSTALL_DIR)
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
/examples
&&
\
for
file
in
$(EXAMPLES)
;
do
\
$(INSTALL_DATA)
examples/
$$
file
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
/examples
;
\
done
install-manual
:
test
-z
"
$(
strip
$(MANUAL)
)
"
||
\
$(INSTALL_DIR)
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
/manual
&&
\
for
file
in
$(MANUAL)
;
do
\
$(INSTALL_DATA)
manual/
$$
file
$(DESTDIR)$(objectsdir)
/
$(LIBRARY_NAME)
/manual
;
\
done
clean
:
-
rm
-f
--
$(SOURCES:.c=.o)
$(SOURCES_LIB:.c=.o)
-
rm
-f
--
$
(
SOURCES:.c
=
.
$(EXTENSION)
)
-
rm
-f
--
$(LIBRARY_NAME)
.o
-
rm
-f
--
$(LIBRARY_NAME)
.
$(EXTENSION)
distclean
:
clean
-
rm
-f
--
$(DISTBINDIR)
.tar.gz
-
rm
-rf
--
$(DISTBINDIR)
-
rm
-f
--
$(DISTDIR)
.tar.gz
-
rm
-rf
--
$(DISTDIR)
-
rm
-f
--
$(ORIGDIR)
.tar.gz
-
rm
-rf
--
$(ORIGDIR)
$(DISTBINDIR)
:
$(INSTALL_DIR)
$(DISTBINDIR)
$(DISTDIR)
:
$(INSTALL_DIR)
$(DISTDIR)
$(ORIGDIR)
:
$(INSTALL_DIR)
$(ORIGDIR)
dist
:
$(DISTDIR)
$(INSTALL_DATA)
Makefile
$(DISTDIR)
$(INSTALL_DATA)
README.txt
$(DISTDIR)
$(INSTALL_DATA)
LICENSE.txt
$(DISTDIR)
$(INSTALL_DATA)
$(LIBRARY_NAME)
-meta
.pd
$(DISTDIR)
test
-z
"
$(
strip
$(ALLSOURCES)
)
"
||
\
$(INSTALL_DATA)
$(ALLSOURCES)
$(DISTDIR)
test
-z
"
$(
strip
$(PDOBJECTS)
)
"
||
\
$(INSTALL_DATA)
$(PDOBJECTS)
$(DISTDIR)
# test -z "$(strip $(HELPPATCHES))" || \
$(INSTALL_DATA)
$(HELPPATCHES)
$(DISTDIR)
test
-z
"$(strip $(EXTRA_DIST))"
||
\
$(INSTALL_DATA)
$(EXTRA_DIST)
$(DISTDIR)
test
-z
"$(strip $(EXAMPLES))"
||
\
$(INSTALL_DIR)
$(DISTDIR)/examples
&&
\
for
file
in
$(EXAMPLES);
do
\
$(INSTALL_DATA)
examples/$$file
$(DISTDIR)/examples;
\
done
test
-z
"$(strip $(MANUAL))"
||
\
$(INSTALL_DIR)
$(DISTDIR)/manual
&&
\
for
file
in
$(MANUAL);
do
\
$(INSTALL_DATA)
manual/$$file
$(DISTDIR)/manual;
\
done
tar
--exclude-vcs
-czpf
$(DISTDIR).tar.gz
$(DISTDIR)
# make a Debian source package
dpkg-source
:
debclean
make distclean dist
mv
$(DISTDIR)
$(ORIGDIR)
tar
--exclude-vcs
-czpf
../
$(ORIGDIR)
.orig.tar.gz
$(ORIGDIR)
rm
-f
--
$(DISTDIR)
.tar.gz
rm
-rf
--
$(DISTDIR)
$(ORIGDIR)
cd
..
&&
dpkg-source
-b
$(LIBRARY_NAME)
etags
:
etags
*
.h
$(SOURCES)
../../pd/src/
*
.[ch] /usr/include/
*
.h /usr/include/
*
/
*
.h
showsetup
:
@
echo
"CFLAGS:
$(CFLAGS)
"
@
echo
"LDFLAGS:
$(LDFLAGS)
"
@
echo
"LIBS:
$(LIBS)
"
@
echo
"PD_INCLUDE:
$(PD_INCLUDE)
"
@
echo
"PD_PATH:
$(PD_PATH)
"
@
echo
"objectsdir:
$(objectsdir)
"
@
echo
"LIBRARY_NAME:
$(LIBRARY_NAME)
"
@
echo
"LIBRARY_VERSION:
$(LIBRARY_VERSION)
"
@
echo
"SOURCES:
$(SOURCES)
"
@
echo
"PDOBJECTS:
$(PDOBJECTS)
"
@
echo
"ALLSOURCES:
$(ALLSOURCES)
"
@
echo
"UNAME:
$(UNAME)
"
@
echo
"CPU:
$(CPU)
"
@
echo
"pkglibdir:
$(pkglibdir)
"
@
echo
"DISTDIR:
$(DISTDIR)
"
@
echo
"ORIGDIR:
$(ORIGDIR)
"
# This Makefile is based on the Makefile from pd-lib-builder written by
# Katja Vetter. You can get it from:
# https://github.com/pure-data/pd-lib-builder
PDLIBBUILDER_DIR
=
.
include
$(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder
externals/loaders/libdir/Makefile.pdlibbuilder
0 → 100644
View file @
985eaaea
This diff is collapsed.
Click to expand it.
externals/loaders/libdir/libdir-meta.pd
View file @
985eaaea
...
...
@@ -2,6 +2,6 @@
#N canvas 25 49 420 300 META 1;
#X text 10 10 NAME libdir;
#X text 10 30 AUTHOR hans@eds.org;
#X text 10 50 VERSION 1.
9
;
#X text 10 50 VERSION 1.
10
;
#X text 10 70 LICENSE BSD;
#X restore 10 10 pd META;
externals/loaders/libdir/libdir.c
View file @
985eaaea
...
...
@@ -10,7 +10,7 @@
/* WARNING: KLUDGE! */
/*
* this struct is not publically defined (its in g_canvas.c) so I need to
* include this here. Its from Pd 0.4
1-test03 2006-11-19
. */
* include this here. Its from Pd 0.4
7-0
. */
struct
_canvasenvironment
{
t_symbol
*
ce_dir
;
/* directory patch lives in */
...
...
@@ -21,7 +21,13 @@ struct _canvasenvironment
};
static
char
*
version
=
"1.9"
;
static
char
*
version
=
#ifdef VERSION
VERSION
#else
"unknown"
#endif
;
/* This loader opens a directory with a -meta.pd file as a library. In the
* long run, the idea is that one folder will have all of objects files, all
...
...
@@ -37,71 +43,131 @@ static char *version = "1.9";
* to have one directory hold the objects, help files, manuals,
* etc. making it a self-contained library. <hans@at.or.at>
*/
/*
* TODO
* - get 'declare' messages from the meta-file, and send them to the current canvas
*/
static
void
libdir_get_fullname
(
char
*
dest
,
size_t
size
,
const
char
*
classname
)
{
snprintf
(
dest
,
size
-
1
,
"%s/%s-meta"
,
classname
,
classname
);
dest
[
size
-
1
]
=
0
;
}
static
int
libdir_add_to_path
(
const
char
*
dirbuf
,
t_canvas
*
canvas
)
{
if
(
sys_isabsolutepath
(
dirbuf
))
{
// only include actual full paths
if
(
canvas
)
{
t_canvasenvironment
*
canvasenvironment
=
canvas_getenv
(
canvas
);
canvasenvironment
->
ce_path
=
namelist_append
(
canvasenvironment
->
ce_path
,
dirbuf
,
0
);
}
else
{
sys_searchpath
=
namelist_append
(
sys_searchpath
,
dirbuf
,
0
);
}
return
1
;
}
return
0
;
}
static
int
libdir_loader
(
t_canvas
*
canvas
,
char
*
classname
)
static
int
libdir_loader
_legacy
(
t_canvas
*
canvas
,
char
*
classname
)
{
int
fd
=
-
1
;
char
helppathname
[
FILENAME_MAX
];
char
fullclassname
[
FILENAME_MAX
],
dirbuf
[
FILENAME_MAX
];
char
*
nameptr
;
t_canvasenvironment
*
canvasenvironment
;
/* look for meta file (classname)/(classname)-meta.pd */
strncpy
(
fullclassname
,
classname
,
FILENAME_MAX
-
6
);
strcat
(
fullclassname
,
"/"
);
strncat
(
fullclassname
,
classname
,
FILENAME_MAX
-
strlen
(
fullclassname
)
-
6
);
strcat
(
fullclassname
,
"-meta"
);
libdir_get_fullname
(
fullclassname
,
FILENAME_MAX
,
classname
);
/* if this is being called from a canvas, then add the library path to the
* canvas-local path */
if
(
canvas
)
{
canvasenvironment
=
canvas_getenv
(
canvas
);
/* setting the canvas to NULL causes it to ignore any canvas-local path */
if
((
fd
=
canvas_open
(
NULL
,
fullclassname
,
".pd"
,
dirbuf
,
&
nameptr
,
FILENAME_MAX
,
0
))
<
0
)
{
return
(
0
);
}
close
(
fd
);
if
(
sys_isabsolutepath
(
dirbuf
))
// only include actual full paths
canvasenvironment
->
ce_path
=
namelist_append
(
canvasenvironment
->
ce_path
,
dirbuf
,
0
);
if
(
sys_verbose
)
post
(
"libdir_loader: added '%s' to the canvas-local objectclass path"
,
classname
);
}
if
(
canvas
)
/* setting the canvas to NULL causes it to ignore any canvas-local path */
fd
=
canvas_open
(
NULL
,
fullclassname
,
".pd"
,
dirbuf
,
&
nameptr
,
FILENAME_MAX
,
0
);
else
fd
=
open_via_path
(
"."
,
fullclassname
,
".pd"
,
dirbuf
,
&
nameptr
,
FILENAME_MAX
,
0
);
if
(
fd
<
0
)
{
if
((
fd
=
open_via_path
(
"."
,
fullclassname
,
".pd"
,
dirbuf
,
&
nameptr
,
FILENAME_MAX
,
0
))
<
0
)
{
return
(
0
);
}
close
(
fd
);
sys_searchpath
=
namelist_append
(
sys_searchpath
,
dirbuf
,
0
);
strncpy
(
helppathname
,
sys_libdir
->
s_name
,
FILENAME_MAX
-
30
);
helppathname
[
FILENAME_MAX
-
30
]
=
0
;
strcat
(
helppathname
,
"/doc/5.reference/"
);
strcat
(
helppathname
,
classname
);
sys_helppath
=
namelist_append
(
sys_helppath
,
helppathname
,
0
);
post
(
"libdir_loader: added '%s' to the global objectclass path"
,
classname
);
// post("\tThis is deprecated behavior.");
return
(
0
);
}
sys_close
(
fd
);
#if 0
if(!canvas) {
char helppathname[FILENAME_MAX];
strncpy(helppathname, sys_libdir->s_name, FILENAME_MAX-30);
helppathname[FILENAME_MAX-30] = 0;
strcat(helppathname, "/doc/5.reference/");
strcat(helppathname, classname);
sys_helppath = namelist_append(sys_helppath, helppathname, 0);
}
#endif
if
(
libdir_add_to_path
(
dirbuf
,
canvas
))
logpost
(
NULL
,
3
,
"libdir_loader: added '%s' to the %s objectclass path"
,
classname
,
canvas
?
"canvas-local"
:
"global"
);
/* post("libdir_loader loaded fullclassname: '%s'\n", fullclassname); */
#if 0
// AG: This is from https://github.com/pure-data/libdir/commit/2f7b873e.
// Seems overly verbose, though, disasbled for now since Purr Data won't
// filter console messages according to their verbosity level.
logpost(NULL, 14, "Loaded libdir '%s' from '%s'", classname, dirbuf);
#endif
return
(
1
);
}
static
int
libdir_loader_pathwise
(
t_canvas
*
canvas
,
const
char
*
classname
,
const
char
*
path
)
{
int
fd
=
-
1
;
char
fullclassname
[
FILENAME_MAX
],
dirbuf
[
FILENAME_MAX
];
char
*
nameptr
;
if
(
!
path
)
{
/* we already tried all paths, so skip this */
return
0
;
}
/* look for meta file (classname)/(classname)-meta.pd */
libdir_get_fullname
(
fullclassname
,
FILENAME_MAX
,
classname
);
if
((
fd
=
sys_trytoopenone
(
path
,
fullclassname
,
".pd"
,
dirbuf
,
&
nameptr
,
FILENAME_MAX
,
0
))
<
0
)
{
return
0
;
}
sys_close
(
fd
);
if
(
libdir_add_to_path
(
dirbuf
,
canvas
))
logpost
(
NULL
,
3
,
"libdir_loader: added '%s' to the %s objectclass path"
,
classname
,
canvas
?
"canvas-local"
:
"global"
);
/* post("libdir_loader loaded fullclassname: '%s'\n", fullclassname); */
if
(
sys_verbose
)
post
(
"Loaded libdir '%s' from '%s'"
,
classname
,
dirbuf
);
#if 0
logpost(NULL, 14, "Loaded libdir '%s' from '%s'", classname, dirbuf);
#endif
return
(
1
);
}
static
t_class
*
libdir_class
;
static
void
*
libdir_new
(
void
)
{
t_pd
*
x
=
pd_new
(
libdir_class
);
return
(
x
);
}
void
libdir_setup
(
void
)
{
/* relies on t.grill's loader functionality, fully added in 0.40 */
sys_register_loader
(
libdir_loader
);
post
(
"libdir loader %s"
,
version
);
post
(
"
\t
compiled on "
__DATE__
" at "
__TIME__
" "
);
post
(
"
\t
compiled against Pd version %d.%d.%d.%s"
,
PD_MAJOR_VERSION
,
PD_MINOR_VERSION
,
PD_BUGFIX_VERSION
,
PD_TEST_VERSION
);
int
major
,
minor
,
bugfix
;
sys_getversion
(
&
major
,
&
minor
,
&
bugfix
);
if
(
major
>
0
||
minor
>=
47
)
{
sys_register_loader
(
libdir_loader_pathwise
);
}
else
{
sys_register_loader
(
libdir_loader_legacy
);
}
logpost
(
NULL
,
3
,
"libdir loader %s"
,
version
);
logpost
(
NULL
,
3
,
"
\t
compiled on "
__DATE__
" at "
__TIME__
" "
);
logpost
(
NULL
,
3
,
"
\t
compiled against Pd version %d.%d.%d.%s"
,
PD_MAJOR_VERSION
,
PD_MINOR_VERSION
,
PD_BUGFIX_VERSION
,
PD_TEST_VERSION
);
libdir_class
=
class_new
(
gensym
(
"libdir"
),
libdir_new
,
0
,
sizeof
(
t_object
),
CLASS_NOINLET
,
0
);
}
void
setup
(
void
)
{
libdir_setup
();
}
pd/src/m_class.c
View file @
985eaaea
...
...
@@ -599,6 +599,7 @@ static t_symbol *addfileextent(t_symbol *s)
return
(
gensym
(
namebuf
));
}
#define MAXOBJDEPTH 1000
static
int
tryingalready
;
void
canvas_popabstraction
(
t_canvas
*
x
);
...
...
@@ -613,39 +614,20 @@ int pd_setloadingabstraction(t_symbol *sym);
doesn't know. Pd tries to load it as an extern, then as an abstraction. */
void
new_anything
(
void
*
dummy
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
t_pd
*
current
;
int
fd
;
char
dirbuf
[
FILENAME_MAX
],
*
nameptr
;
if
(
tryingalready
)
return
;
if
(
tryingalready
>
MAXOBJDEPTH
){
error
(
"maximum object loading depth %d reached"
,
MAXOBJDEPTH
)
;
return
;
}
newest
=
0
;
class_loadsym
=
s
;
if
(
sys_load_lib
(
canvas_getcurrent
(),
s
->
s_name
))
{
tryingalready
=
1
;
tryingalready
++
;
typedmess
(
dummy
,
s
,
argc
,
argv
);
tryingalready
=
0
;
tryingalready
--
;
return
;
}
class_loadsym
=
0
;
current
=
s__X
.
s_thing
;
if
((
fd
=
canvas_open
(
canvas_getcurrent
(),
s
->
s_name
,
".pd"
,
dirbuf
,
&
nameptr
,
FILENAME_MAX
,
0
))
>=
0
||
(
fd
=
canvas_open
(
canvas_getcurrent
(),
s
->
s_name
,
".pat"
,
dirbuf
,
&
nameptr
,
FILENAME_MAX
,
0
))
>=
0
)
{
close
(
fd
);
if
(
!
pd_setloadingabstraction
(
s
))
{
canvas_setargs
(
argc
,
argv
);
binbuf_evalfile
(
gensym
(
nameptr
),
gensym
(
dirbuf
));
canvas_initbang
((
t_canvas
*
)(
s__X
.
s_thing
));
/* JMZ*/
if
(
s__X
.
s_thing
!=
current
)
canvas_popabstraction
((
t_canvas
*
)(
s__X
.
s_thing
));
canvas_setargs
(
0
,
0
);
}
else
error
(
"%s: can't load abstraction within itself
\n
"
,
s
->
s_name
);
}
else
newest
=
0
;
}
t_symbol
s_pointer
=
{
"pointer"
,
0
,
0
};
...
...
pd/src/m_pd.h
View file @
985eaaea
...
...
@@ -11,8 +11,8 @@ extern "C" {
#include
<stdarg.h>
#define PD_MAJOR_VERSION 0
#define PD_MINOR_VERSION 4
3
#define PD_BUGFIX_VERSION
1
0
#define PD_MINOR_VERSION 4
7
#define PD_BUGFIX_VERSION 0
#define PD_TEST_VERSION ""
#define PD_L2ORK_VERSION "2.0"
#define PDL2ORK
...
...
pd/src/s_loader.c
View file @
985eaaea
...
...
@@ -2,20 +2,20 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifdef
HAVE_LIBDL
#if
def
ined(
HAVE_LIBDL
) || defined(__FreeBSD__)
#include
<dlfcn.h>
#endif
#ifdef UNISTD
#ifdef
HAVE_
UNISTD
_H
#include
<stdlib.h>
#include
<unistd.h>