| 1 |
# |
| 2 |
# Makefile for smoke-testing the AssemblyScript backend |
| 3 |
# |
| 4 |
|
| 5 |
system := $(shell uname -s) |
| 6 |
system := $(shell echo $(system) | grep MINGW > /dev/null && echo MINGW || echo $(system)) |
| 7 |
ifeq ($(system), MINGW) |
| 8 |
FAUST ?= ../../../build/bin/faust.exe |
| 9 |
COMPARE := ./filesCompare.exe |
| 10 |
else |
| 11 |
FAUST ?= ../../../build/bin/faust |
| 12 |
COMPARE := ./filesCompare |
| 13 |
endif |
| 14 |
|
| 15 |
ASCC ?= asc |
| 16 |
RUNASC ?= node tools/impulseasc.js |
| 17 |
outdir ?= assemblyscript/double |
| 18 |
FAUSTOPTIONS ?= -double |
| 19 |
precision ?= -1 -part |
| 20 |
compare ?= 0 |
| 21 |
|
| 22 |
.PHONY: assemblyscript assemblyscript-wasm assemblyscript-compare-quick test help |
| 23 |
|
| 24 |
dspfiles := $(wildcard dsp/*.dsp) |
| 25 |
listfiles = $(dspfiles:dsp/%.dsp=ir/$1/%.ir) |
| 26 |
|
| 27 |
assemblyscript: ir/$(outdir) $(call listfiles,$(outdir)) |
| 28 |
assemblyscript-wasm: ir/$(outdir) $(dspfiles:dsp/%.dsp=ir/$(outdir)/%.wasm) |
| 29 |
assemblyscript-compare-quick: ir/$(outdir)/noise.ir ir/$(outdir)/APF.ir ir/$(outdir)/UITester.ir |
| 30 |
|
| 31 |
test: |
| 32 |
@echo $(call listfiles,$(outdir)) |
| 33 |
|
| 34 |
help: |
| 35 |
@echo "-------- FAUST impulse response tests --------" |
| 36 |
@echo "Available targets are:" |
| 37 |
@echo " 'assemblyscript' (default): smoke-test the AssemblyScript backend" |
| 38 |
@echo " 'assemblyscript-wasm' : compile generated AssemblyScript with asc" |
| 39 |
@echo " 'assemblyscript-compare-quick' : compare a stable AssemblyScript subset against reference" |
| 40 |
@echo |
| 41 |
@echo "Options:" |
| 42 |
@echo " 'outdir' : define the output directory (default to 'assemblyscript/double')" |
| 43 |
@echo " 'FAUSTOPTIONS' : define additional faust options (-double by default)" |
| 44 |
@echo " 'ASCC' : AssemblyScript compiler command (default: 'asc')" |
| 45 |
@echo " 'RUNASC' : AssemblyScript impulse runner command" |
| 46 |
@echo " 'precision' : define filesCompare expected precision (default: '-1 -part')" |
| 47 |
@echo " 'compare' : compare with reference files (0 by default, set to 1 to enable)" |
| 48 |
|
| 49 |
ir/$(outdir): |
| 50 |
mkdir -p ir/$(outdir) |
| 51 |
|
| 52 |
ir/$(outdir)/%.ts: dsp/%.dsp |
| 53 |
cd $(dir $<); $(FAUST) -lang asc $(notdir $<) $(FAUSTOPTIONS) > ../$@ || (rm -f ../$@; false) |
| 54 |
|
| 55 |
ir/$(outdir)/%.wasm: ir/$(outdir)/%.ts |
| 56 |
@if command -v $(word 1,$(ASCC)) >/dev/null 2>&1 || [ -x "$(word 1,$(ASCC))" ]; then \ |
| 57 |
$(ASCC) $< -O --runtime stub -o $@ || { \ |
| 58 |
echo "Skipping asc compilation for $< (asc command failed)"; \ |
| 59 |
rm -f $@; \ |
| 60 |
}; \ |
| 61 |
else \ |
| 62 |
echo "Skipping asc compilation for $< (asc compiler not found)"; \ |
| 63 |
rm -f $@; \ |
| 64 |
fi |
| 65 |
|
| 66 |
ir/$(outdir)/%.ir: ir/$(outdir)/%.ts ir/$(outdir)/%.wasm |
| 67 |
$(RUNASC) $< > $@ || (rm -f $@; false) |
| 68 |
if [ "$(compare)" = "1" ]; then \ |
| 69 |
$(COMPARE) $@ reference/$(notdir $@) $(precision) || (rm -f $@; false); \ |
| 70 |
fi |