diff --git a/tests/_template_/Makefile b/tests/_template_/Makefile new file mode 100644 index 0000000..3a4de88 --- /dev/null +++ b/tests/_template_/Makefile @@ -0,0 +1,16 @@ +# Makefile to build class 'helloworld' for Pure Data. +# Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build +# settings and rules. + +# library name +lib.name = _template_ + +# input source file (class name == source file basename) +class.sources = _template_.c + +# all extra files to be included in binary distribution of the library +datafiles = _template_-help.pd _template_-meta.pd + +# include Makefile.pdlibbuilder from submodule directory 'pd-lib-builder' +PDLIBBUILDER_DIR=../.. +include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder diff --git a/tests/_template_/_template_-help.pd b/tests/_template_/_template_-help.pd new file mode 100644 index 0000000..f7f922d --- /dev/null +++ b/tests/_template_/_template_-help.pd @@ -0,0 +1,4 @@ +#N canvas 335 160 450 300 12; +#X obj 143 125 test1; +#X msg 143 93 7; +#X connect 1 0 0 0; diff --git a/tests/_template_/_template_-meta.pd b/tests/_template_/_template_-meta.pd new file mode 100644 index 0000000..7f997bf --- /dev/null +++ b/tests/_template_/_template_-meta.pd @@ -0,0 +1,9 @@ +#N canvas 966 322 200 200 10; +#N canvas 19 51 420 300 META 0; +#X text 10 10 META this is a prototype of a libdir meta file; +#X text 10 51 AUTHOR IOhannes m zmolnig; +#X text 10 110 VERSION 1.0.0; +#X text 10 90 LICENSE CC0; +#X text 10 70 DESCRIPTION Example "_template_" external.; +#X text 10 30 NAME _template_; +#X restore 10 10 pd META; diff --git a/tests/_template_/_template_.c b/tests/_template_/_template_.c new file mode 100644 index 0000000..ef5293e --- /dev/null +++ b/tests/_template_/_template_.c @@ -0,0 +1,13 @@ +#include +t_class*_template__class; +static void _template__float(t_object*x, t_float f1) { + pd_error(x, "%s got %f", __FUNCTION__, f1); +} +static void*_template__new(void) { + return pd_new(_template__class); +} +void _template__setup(void) { + post("%s", __FUNCTION__); + _template__class = class_new(gensym("_template_"), _template__new, 0, sizeof(t_object), 0, A_NULL); + class_addfloat(_template__class, _template__float); +} diff --git a/tests/make-from-template.sh b/tests/make-from-template.sh new file mode 100755 index 0000000..d4f6ade --- /dev/null +++ b/tests/make-from-template.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +template=_template_ +template_dir=${0%/*}/${template} + +outdir=$1 +outdir=${outdir%/} +outname=${outdir##*/} + + +usage() { + cat 1>&2 < + creates a new test-directory from _template_; + must not exist yet. +EOL + if [ "x$@" != "x" ]; then + echo + echo " $@" 1>&2 + fi + exit 1 +} + +if [ "x${outdir}" = "x" ]; then + usage +fi + +if [ -d "${outdir}" ]; then + usage "output directory '${outdir}' already exists!" +fi + +if [ ! -d "${template_dir}" ]; then + echo "unable to find '${template_dir}'" 1>&2 + exit 1 +fi + +mkdir -p "${outdir}" || usage "unable to create '${outdir}'!" +rmdir "${outdir}" +cp -r "${template_dir}" "${outdir}" +find "${outdir}" -type f -exec sed -e "s|${template}|${outname}|g" -i {} + +for f in "${outdir}"/*; do + g=$(echo $f | sed -e "s|${template}|${outname}|g") + if [ "x${f}" != "x${g}" ]; then + mv "${f}" "${g}" + fi +done