shithub: neindaw

Download patch

ref: b56d23c78ede1dc4f74b32bc0f6092d87e79553e
parent: 8b6e57e4d1f2a7b727e42737c54ea105f1a4af21
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Jan 19 06:43:22 EST 2020

dsp: regenerate C code from within 9front through host os interface

--- /dev/null
+++ b/dsp/dsp2c
@@ -1,0 +1,16 @@
+#!/bin/sh
+set -e
+
+for i in $*; do
+	class=$(grep -o declare.*name.* $i | head -1 | sed 's/^[^"]*//g;s/[^A-Za-z0-9]//g')
+	test -z "$class" && echo "$i: name not set in metadata" && exit 1
+	out=$(echo $i | sed 's/dsp$/c/')
+	faust -lang c -a arch.c -cn $class $@ $i -o "$out"
+	# in C () is not the same as (void) so fix it
+	sed 's/new\([^(]*\)() /new\1(void) /' -i "$out"
+	# mark "dsp", "sample_rate", and "inputs" args as USED
+	sed 's/'$class'[A-Z0-9]*\* dsp.*{/&\n\tUSED(dsp);/g' -i "$out"
+	sed 's/ \(sample_rate\|inputs\).*{/&\n\tUSED(\1);/g' -i "$out"
+	# empty structs: add a dummy field
+	sed -z 's/typedef struct {\n\+}/typedef struct {\n      int dummy;\n}/g' -i "$out"
+done
--- a/dsp/mkfile
+++ b/dsp/mkfile
@@ -1,7 +1,7 @@
 </$objtype/mkfile
 
 TARG=\
-	kick_drum
+	kick_drum\
 
 OFILES=\
 	common.$O\
@@ -17,7 +17,8 @@
 </sys/src/cmd/mkmany
 
 %.c: %.dsp
-	echo Need to run gen.sh, $prereq changed
+	os -d `{../osdir} nix-shell ../nix/shell.nix --run './dsp2c '^$"prereq || \
+	{ echo $target needs to be regenerated with "./dsp2c $prereq"; exit 1 }
 
 $BIN/%:	$O.%
 	mkdir -p $BIN
--- a/gen.sh
+++ /dev/null
@@ -1,16 +1,0 @@
-#!/bin/sh
-set -e
-
-for i in dsp/*.dsp; do
-	class=$(grep -o declare.*name.* $i | head -1 | sed 's/^[^"]*//g;s/[^A-Za-z0-9]//g')
-	test -z "$class" && echo "$i: name not set in metadata" && exit 1
-	out=$(echo $i | sed 's/dsp$/c/')
-	faust -lang c -a dsp/arch.c -cn $class $@ $i -o "$out"
-	# in C () is not the same as (void) so fix it
-	sed 's/new\([^(]*\)() /new\1(void) /' -i "$out"
-	# mark "dsp", "sample_rate", and "inputs" args as USED
-	sed 's/'$class'[A-Z0-9]*\* dsp.*{/&\n\tUSED(dsp);/g' -i "$out"
-	sed 's/ \(sample_rate\|inputs\).*{/&\n\tUSED(\1);/g' -i "$out"
-	# empty structs: add a dummy field
-	sed -z 's/typedef struct {\n\+}/typedef struct {\n      int dummy;\n}/g' -i "$out"
-done
--- /dev/null
+++ b/osdir
@@ -1,0 +1,10 @@
+#!/bin/rc
+rfork ne
+
+d=`{pwd}
+a=''
+while(! p=`{ns | grep ' /mnt/term/.* '^$"d^'[ ]*$' | sed 's,.*/mnt/term([^ ]*).*,\1,g'}) {
+	a=`{basename $"d}^/^$"a
+	d=`{basename -d $"d}
+}
+echo $p/$a
--- /dev/null
+++ b/pull_subtree
@@ -1,0 +1,2 @@
+#!/bin/sh
+git subtree pull --prefix microui git@github.com:ftrvxmtrx/microui.git master --squash
--- a/pull_subtree.sh
+++ /dev/null
@@ -1,2 +1,0 @@
-#!/bin/sh
-git subtree pull --prefix microui git@github.com:ftrvxmtrx/microui.git master --squash