# Returns a command prefix (docker command and environment variables)
# necessary to launch the given impl and step
get_run_prefix = $(strip $(if $(strip $(DOCKERIZE)),\
- docker run -e STEP=$($2) \
+ docker run -e STEP=$($2) -e MAL_IMPL=$(MAL_IMPL) \
-it --rm -u $(shell id -u) \
-v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal \
-w /mal/$(call actual_impl,$(1)) \
$(foreach env,$(3),-e $(env)) \
$(call impl_to_image,$(call actual_impl,$(1))) \
,\
- env STEP=$($2) \
+ env STEP=$($2) MAL_IMPL=$(MAL_IMPL) \
$(if $(filter haxe,$(1)),HAXE_MODE=$(HAXE_MODE),) \
$(if $(filter factor,$(1)),FACTOR_ROOTS=$(FACTOR_ROOTS),) \
$(3)))
--- /dev/null
+FROM ubuntu:vivid
+MAINTAINER Joel Martin <github@martintribe.org>
+
+##########################################################
+# General requirements for testing or common across many
+# implementations
+##########################################################
+
+RUN apt-get -y update
+
+# Required for running tests
+RUN apt-get -y install make python
+
+# Some typical implementation and test requirements
+RUN apt-get -y install curl libreadline-dev libedit-dev
+
+RUN mkdir -p /mal
+WORKDIR /mal
+
+##########################################################
+# Specific implementation requirements
+##########################################################
+
+# Chuck
+RUN apt-get -y install bison gcc g++ flex
+RUN apt-get -y install libasound2-dev libsndfile1-dev
+RUN cd /tmp && curl -O http://chuck.cs.princeton.edu/release/files/chuck-1.3.5.2.tgz \
+ && tar xvzf /tmp/chuck-1.3.5.2.tgz && cd chuck-1.3.5.2/src \
+ && make linux-alsa && make install \
+ && rm -r /tmp/chuck-1.3.5.2*
+
+ENV HOME /mal
-#!/usr/bin/env ruby
-
-cmdline = ['chuck', '--caution-to-the-wind', '--silent']
-
-# HACK: makes `make MAL_IMPL=chuck "test^mal"` work
-scriptpath = File.expand_path(File.dirname(__FILE__))
-Dir.chdir(scriptpath)
-
-scriptfile = (ENV['STEP'] || 'stepA_mal') + '.ck'
-
-script = File.readlines(scriptfile)
-imports = script.grep(%r{^ *// *@import (.+)}) { $1 }
-import_files = imports.flat_map { |i| Dir[i] }
-cmdline += import_files
-cmdline << scriptfile
-
-File.write('/tmp/chuck-cmdline', cmdline.join(' '))
-File.write('/tmp/chuck-args', ARGV.join(' '))
-
-ENV['CHUCK_ARGS'] = ARGV.join("\a")
-exec(*cmdline)
+#!/bin/bash
+imports=$(grep "^ *// *@import" "$(dirname $0)/${STEP:-stepA_mal}.ck" | awk '{print $3}')
+imports=$(for i in ${imports}; do ls $(dirname $0)/${i}; done)
+old_IFS="${IFS}"; IFS=$'\a'; export CHUCK_ARGS="${*}"; IFS="${old_IFS}"
+exec chuck --caution-to-the-wind --silent ${imports} $(dirname $0)/${STEP:-stepA_mal}.ck