Add dist targets to most implementations.
authorJoel Martin <github@martintribe.org>
Thu, 18 Feb 2016 06:33:19 +0000 (00:33 -0600)
committerJoel Martin <github@martintribe.org>
Wed, 24 Feb 2016 06:33:20 +0000 (00:33 -0600)
TODO: factor groovy guile julia matlab miniMAL swift

34 files changed:
.gitignore
Makefile
clojure/Makefile
erlang/Makefile
forth/Makefile
fsharp/Makefile
go/Makefile
haskell/Makefile
haxe/Makefile
java/Makefile
java/pom.xml
js/Makefile
kotlin/Makefile
lua/Makefile
make/Makefile
nim/Makefile
ocaml/Makefile
perl/Dockerfile
perl/Makefile
php/Makefile
ps/Makefile
python/Makefile
r/Makefile
racket/Makefile
rpython/Makefile
ruby/Makefile
rust/Makefile
scala/Makefile
scala/assembly.sbt [new file with mode: 0644]
scala/build.sbt
scala/project/assembly.sbt [new file with mode: 0644]
tcl/Makefile
vb/Makefile
vimscript/Makefile

index ab08f8e..379714f 100644 (file)
@@ -1,3 +1,11 @@
+.bash_history
+.cache
+.mal-history
+.crystal
+.lein
+.m2
+.ivy2
+.sbt
 */experiments
 */node_modules
 *.o
 */step8_macros
 */step9_try
 */stepA_mal
-.bash_history
-.mal-history
-.crystal
-.lein
-.m2
-.ivy2
-.sbt
 awk/mal.awk
 bash/mal.sh
 c/mal
@@ -32,6 +33,7 @@ crystal/mal
 cs/*.exe
 cs/*.dll
 cs/*.mdb
+d/*.o
 d/mal
 elixir/_build
 elixir/deps
@@ -44,6 +46,7 @@ erlang/.rebar
 erlang/src/*.beam
 es6/mal.js
 es6/build
+forth/mal.fs
 fsharp/*.exe
 fsharp/*.dll
 fsharp/*.mdb
@@ -57,6 +60,7 @@ haxe/*.n
 haxe/*.py
 haxe/cpp/
 haxe/*.js
+java/mal.jar
 java/target/
 java/dependency-reduced-pom.xml
 js/mal.js
@@ -66,6 +70,7 @@ kotlin/.idea
 kotlin/*.iml
 lua/lib
 lua/linenoise.so
+lua/mal.lua
 make/mal.mk
 mal/mal.mal
 nim/mal
@@ -76,14 +81,24 @@ ocaml/*.swp
 ocaml/*.cmx
 ocaml/*.o
 ocaml/mal_lib.*
+ocaml/mal
+perl/mal.pl
 php/mal.php
+ps/mal.ps
 python/mal.pyz
+r/mal.r
+racket/mal
+rpython/mal
+ruby/mal.rb
 rust/target/
 rust/mal
 rust/Cargo.lock
 rust/.cargo
 r/lib
+scala/mal.jar
 scala/target
 scala/project
+tcl/mal.tcl
 vb/*.exe
 vb/*.dll
+vimscript/mal.vim
index 3927c08..cf6958a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,10 @@ STEP5_EXCLUDES += crystal # test completes, even at 1,000,000
 
 PERF_EXCLUDES = mal  # TODO: fix this
 
+DIST_EXCLUDES += mal
+# TODO: still need to implement dist
+DIST_EXCLUDES += factor groovy guile io julia matlab miniMAL swift
+
 #
 # Utility functions
 #
@@ -182,6 +186,8 @@ forth_RUNSTEP =   gforth ../$(2) $(3)
 fsharp_RUNSTEP =  mono ../$(2) --raw $(3)
 go_RUNSTEP =      ../$(2) $(3)
 groovy_RUNSTEP =  groovy ../$(2) $(3)
+# needs TERM=dumb to work with readline
+guile_RUNSTEP =   guile --no-auto-compile -L ../guile ../$(2) $(3)
 haskell_RUNSTEP = ../$(2) $(3)
 haxe_RUNSTEP =    python3 ../$(2) $(3)
 haxe_RUNSTEP =    $(haxe_RUNSTEP_$(HAXE_MODE))
@@ -211,8 +217,6 @@ swift3_RUNSTEP =  ../$(2) $(3)
 tcl_RUNSTEP =     tclsh ../$(2) --raw $(3)
 vb_RUNSTEP =      mono ../$(2) --raw $(3)
 vimscript_RUNSTEP = ./run_vimscript.sh ../$(2) $(3)
-# needs TERM=dumb to work with readline
-guile_RUNSTEP =   guile --no-auto-compile -L ../guile ../$(2) $(3)
 
 
 vimscript_TEST_OPTS = --test-timeout 30
@@ -233,7 +237,8 @@ ALL_TESTS = $(filter-out $(foreach impl,$(STEP5_EXCLUDES),test^$(impl)^step5),\
 IMPL_STATS = $(foreach impl,$(DO_IMPLS),stats^$(impl))
 IMPL_STATS_LISP = $(foreach impl,$(DO_IMPLS),stats-lisp^$(impl))
 
-IMPL_DIST = $(foreach impl,$(DO_IMPLS),dist^$(impl))
+IMPL_DIST = $(filter-out $(foreach impl,$(DIST_EXCLUDES),dist^$(impl)),\
+              $(foreach impl,$(DO_IMPLS),dist^$(impl)))
 
 DOCKER_BUILD = $(foreach impl,$(DO_IMPLS),docker-build^$(impl))
 
index fb31b76..10c0abf 100644 (file)
@@ -2,7 +2,9 @@ SOURCES_BASE = src/readline.clj src/reader.clj src/printer.clj
 SOURCES_LISP = src/env.clj src/core.clj src/stepA_mal.clj
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
-all dist: deps mal.jar
+all: deps
+
+dist: mal.jar
 
 deps:
        lein deps
index 6797446..808a2a9 100644 (file)
@@ -12,7 +12,7 @@ BINS = $(SRCS:%.erl=%)
 
 #####################
 
-.PHONY: all mal clean stats stats-lisp
+.PHONY: all dist clean stats stats-lisp
 
 all: $(BINS)
 
@@ -34,6 +34,7 @@ $(foreach b,$(BINS),$(eval $(call dep_template,$(b))))
 
 clean:
        rebar clean
+       rm -f mal
 
 stats: $(SOURCES)
        @wc $^
index c744471..1dee2ae 100644 (file)
@@ -1,8 +1,19 @@
-SOURCES_BASE = types.fs str.fs reader.fs printer.fs
+SOURCES_BASE = str.fs types.fs reader.fs printer.fs
 SOURCES_LISP = env.fs core.fs stepA_mal.fs
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
 all:
+       true
+
+dist: mal.fs
+
+mal.fs: $(SOURCES)
+       echo "#! /usr/bin/env gforth" > $@
+       cat $+ | egrep -v "^require |^droprequire " >> $@
+       chmod +x $@
+
+clean:
+       rm -f mal.fs
 
 .PHONY: stats tests $(TESTS)
 
index 4d909ae..9a9c41b 100644 (file)
@@ -24,6 +24,11 @@ CSFLAGS = $(if $(strip $(DEBUG)),-debug+,)
 
 all: $(patsubst %.fs,%.exe,$(SRCS))
 
+dist: mal.exe
+
+mal.exe: stepA_mal.exe
+       cp $< $@
+
 Mono.Terminal.dll: $(TERMINAL_SOURCES)
        mcs $(CSFLAGS) -target:library $+ -out:$@
 
index b83955c..f35976a 100644 (file)
@@ -18,7 +18,9 @@ BINS = $(SRCS:%.go=%)
 
 #####################
 
-all: $(BINS) mal
+all: $(BINS)
+
+dist: mal
 
 mal: $(word $(words $(BINS)),$(BINS))
        cp $< $@
index 71b6234..b5912c6 100644 (file)
@@ -12,7 +12,9 @@ BINS = $(SRCS:%.hs=%)
 
 #####################
 
-all: $(BINS) mal
+all: $(BINS)
+
+dist: mal
 
 mal: $(word $(words $(BINS)),$(BINS))
        cp $< $@
index 031fddb..3257734 100644 (file)
@@ -16,6 +16,20 @@ all-cpp: $(foreach x,$(STEPS),cpp/$(x))
 
 all-js: $(foreach x,$(STEPS),$(x).js)
 
+dist: mal.n mal.py cpp/mal mal.js
+
+mal.n: stepA_mal.n
+       cp $< $@
+
+mal.py: stepA_mal.py
+       cp $< $@
+
+cpp/mal: cpp/stepA_mal
+       cp $< $@
+
+mal.js: stepA_mal.js
+       cp $< $@
+
 
 # Neko target (neko)
 
@@ -65,4 +79,5 @@ node_modules:
 ###
 
 clean:
+       rm -f mal.n mal.py cpp/mal mal.js
        rm -r step*.py cpp/ step*.js step*.n
index 0610ea6..f5e28fe 100644 (file)
@@ -11,12 +11,22 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 all:
        mvn install
 
+dist: mal.jar
+
+mal.jar: target/classes/mal/stepA_mal.class
+       mvn assembly:assembly
+       cp target/mal-0.0.1.jar $@
+
 src/main/mal/%.java:
        mvn install
 
 target/classes/mal/step%.class: src/main/mal/step%.java ${SOURCES}
        mvn install
 
+clean:
+       mvn clean
+       rm -f mal.jar
+
 #.PHONY: stats tests $(TESTS)
 .PHONY: stats
 
index fa2b567..5ee5b7c 100644 (file)
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                        <descriptorRefs>
+                            <descriptorRef>jar-with-dependencies</descriptorRef>
+                        </descriptorRefs>
+                        <archive>
+                            <manifest>
+                                <mainClass>mal.stepA_mal</mainClass>
+                            </manifest>
+                        </archive>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>
index 603c688..175e717 100644 (file)
@@ -1,12 +1,14 @@
 
 TESTS = tests/types.js tests/reader.js
 
-SOURCES_BASE = node_readline.js types.js reader.js printer.js
+SOURCES_BASE = node_readline.js types.js reader.js printer.js interop.js
 SOURCES_LISP = env.js core.js stepA_mal.js
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 WEB_SOURCES = $(SOURCES:node_readline.js=jq_readline.js)
 
-all: node_modules mal.js web/mal.js
+all: node_modules
+
+dist: mal.js web/mal.js
 
 node_modules:
        npm install
index 841698b..8ab4903 100644 (file)
@@ -7,8 +7,13 @@ JARS = $(SOURCES_LISP:%.kt=%.jar)
 
 all: $(JARS)
 
+dist: mal.jar
+
+mal.jar: stepA_mal.jar
+       cp $< $@
+
 clean:
-       rm -vf $(JARS)
+       rm -vf $(JARS) mal.jar
 
 $(JARS): %.jar: src/mal/%.kt $(SOURCES_BASE:%.kt=src/mal/%.kt)
        kotlinc src/mal/$(@:%.jar=%.kt) $(SOURCES_BASE:%.kt=src/mal/%.kt) -include-runtime -d $@
index 494f3f4..ec48fc9 100644 (file)
@@ -6,12 +6,27 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
 all: libs
 
-.PHONY: stats tests $(TESTS)
+dist: mal.lua
+
+SOURCE_NAMES = $(patsubst %.lua,%,$(SOURCES))
+mal.lua: $(SOURCES)
+       echo "#!/usr/bin/env lua" > $@
+       echo "local $(foreach n,$(SOURCE_NAMES),$(n),) M" >> $@
+       echo "M={} $(foreach n,$(SOURCE_NAMES),$(n)=M);" >> $@
+       cat $+ | grep -v -e "return M$$" \
+           -e "return Env" \
+           -e "local M =" \
+           -e "^#!" \
+           $(foreach n,$(SOURCE_NAMES),-e "require('$(n)')") >> $@
+       chmod +x $@
+
 
 clean:
-       rm -f linenoise.so
+       rm -f linenoise.so mal.lua
        rm -rf lib/lua/5.1
 
+.PHONY: stats tests $(TESTS)
+
 stats: $(SOURCES)
        @wc $^
        @printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*--|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
index 6dec57d..2270cac 100644 (file)
@@ -6,6 +6,11 @@ SOURCES_BASE = util.mk numbers.mk readline.mk gmsl.mk types.mk \
 SOURCES_LISP = env.mk core.mk stepA_mal.mk
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
+all:
+       true
+
+dist: mal.mk
+
 mal.mk: $(SOURCES)
        echo "#!/usr/bin/make -f" > $@
        cat $+ | grep -v "^include " >> $@
index 6183cc3..9b145d6 100644 (file)
@@ -14,7 +14,9 @@ BINS = $(SRCS:%.nim=%)
 
 #####################
 
-all: $(BINS) mal
+all: $(BINS)
+
+dist: mal
 
 mal: $(word $(words $(BINS)),$(BINS))
        cp $< $@
index 3b98b93..6a2bb69 100644 (file)
@@ -8,7 +8,9 @@ MAL_LIB = mal_lib.cmxa
 STEP_BINS = $(STEPS:%.ml=%)
 LAST_STEP_BIN = $(word $(words $(STEP_BINS)),$(STEP_BINS))
 
-all: $(STEP_BINS) mal
+all: $(STEP_BINS)
+
+dist: mal
 
 mal: $(LAST_STEP_BIN)
        cp $< $@
index 85bdfe4..b36833e 100644 (file)
@@ -21,4 +21,4 @@ WORKDIR /mal
 # Specific implementation requirements
 ##########################################################
 
-RUN apt-get -y install perl
+RUN apt-get -y install perl libapp-fatpacker-perl
index 512c17c..3774919 100644 (file)
@@ -5,7 +5,16 @@ SOURCES_BASE = readline.pm types.pm reader.pm printer.pm \
 SOURCES_LISP = env.pm core.pm stepA_mal.pl
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
-#all: mal.pl
+all:
+
+dist: mal.pl
+
+mal.pl: $(SOURCES)
+       echo "#!/usr/bin/env perl" > $@
+       fatpack pack stepA_mal.pl >> $@
+
+clean:
+       rm -f mal.pl
 
 .PHONY: stats tests $(TESTS)
 
index e31bb8f..bea654c 100644 (file)
@@ -7,6 +7,16 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
 all:
 
+dist: mal.php
+
+mal.php: $(SOURCES)
+       echo "#!/usr/bin/env php" > $@
+       cat $+ | grep -v "^require_once" >> $@
+       chmod +x $@
+
+clean:
+       rm mal.php
+
 .PHONY: stats tests $(TESTS)
 
 stats: $(SOURCES)
index 7a70809..39f7a09 100644 (file)
@@ -5,6 +5,21 @@ SOURCES_BASE = types.ps reader.ps printer.ps
 SOURCES_LISP = env.ps core.ps stepA_mal.ps
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
+all:
+       true
+
+dist: mal.ps
+
+mal.ps: $(SOURCES)
+       echo "#!/bin/sh" > $@
+       echo "\":\" pop pop pop pop %#; exec gs -d'#!'=null -d'\":\"'=null -q -dNODISPLAY -- \"\$$0\" \"\$$@\"" >> $@
+       cat $+ | grep -v "runlibfile$$" >> $@
+       chmod +x $@
+
+clean:
+       rm -f mal.ps
+
+
 .PHONY: stats tests $(TESTS)
 
 stats: $(SOURCES)
index 944e14d..592a7ca 100644 (file)
@@ -6,16 +6,20 @@ SOURCES_BASE = mal_readline.py mal_types.py reader.py printer.py
 SOURCES_LISP = env.py core.py stepA_mal.py
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
-all: mal.py
+all:
        true
 
-mal.py: stepA_mal.py
-       echo "#!/usr/bin/env python" > $@
-       cat $+ >> $@
+dist: mal.pyz
+
+SHELL := bash
+mal.pyz: $(SOURCES)
+       cp stepA_mal.py __main__.py
+       cat <(echo '#!/usr/bin/env python') <(zip -q - __main__.py $+) > $@
+       rm __main__.py
        chmod +x $@
 
 clean:
-       rm -f mal.py
+       rm -f mal.pyz
 
 .PHONY: stats tests $(TESTS)
 
index c1eec79..c1caebf 100644 (file)
@@ -6,6 +6,16 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
 all: libs
 
+dist: mal.r
+
+mal.r: $(SOURCES)
+       echo "#!/usr/bin/env Rscript" > $@
+       cat $+ | grep -v " source(" >> $@
+       chmod +x $@
+
+clean:
+       rm -f mal.r
+
 .PHONY: stats tests $(TESTS)
 
 stats: $(SOURCES)
index e2da556..3d55efe 100644 (file)
@@ -4,6 +4,15 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
 all:
 
+dist: mal
+
+mal: $(SOURCES)
+       raco exe stepA_mal.rkt
+       mv stepA_mal $@
+
+clean:
+       mal
+
 .PHONY: stats
 
 stats: $(SOURCES)
index 837ca80..a86b4dd 100644 (file)
@@ -10,6 +10,11 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
 all: $(STEPS)
 
+dist: mal
+
+mal: stepA_mal
+       cp $< $@
+
 %: %.py
        $(RPYTHON) --output=$@ $<
 
@@ -26,7 +31,7 @@ $(UPPER_STEPS): $(STEP4_DEPS)
 .PHONY: clean stats stats-lisp
 
 clean:
-       rm -f $(STEPS) *.pyc
+       rm -f mal $(STEPS) *.pyc
        rm -rf __pycache__
 
 stats: $(SOURCES)
index f59681d..f43de1c 100644 (file)
@@ -4,7 +4,18 @@ SOURCES_BASE = mal_readline.rb types.rb reader.rb printer.rb
 SOURCES_LISP = env.rb core.rb stepA_mal.rb
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
-#all: mal.rb
+all:
+       true
+
+dist: mal.rb
+
+mal.rb: $(SOURCES)
+       echo "#!/usr/bin/env ruby" > $@
+       cat $+ | grep -v "^require_relative" >> $@
+       chmod +x $@
+
+clean:
+       rm -f mal.rb
 
 .PHONY: stats tests $(TESTS)
 
index ae5f2ee..e51072b 100644 (file)
@@ -17,9 +17,10 @@ BINS = $(SRCS:%.rs=target/release/%)
 
 all: mal
 
-mal: ${SOURCES_BASE} $(word $(words ${SOURCES_LISP}),${SOURCES_LISP})
-       cargo build --release
-       cp $(word $(words ${BINS}),${BINS})  $@
+dist: mal
+
+mal: target/release/stepA_mal
+       cp $< $@
 
 # TODO: would be nice to build just the step requested
 $(BINS): target/release/%: src/bin/%.rs $(wildcard src/*.rs)
index e4f2a82..b98922b 100644 (file)
@@ -4,9 +4,20 @@ SOURCES_BASE = types.scala reader.scala printer.scala
 SOURCES_LISP = env.scala core.scala stepA_mal.scala
 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
-all:
+all: build
+
+build:
        sbt 'run-main stepA_mal ../tests/incA.mal'
 
+dist: mal.jar
+
+mal.jar: $(SOURCES)
+       sbt assembly
+       cp target/scala-*/mal-assembly*.jar $@
+
+clean:
+       rm -f mal.jar
+
 .PHONY: stats tests $(TESTS)
 
 stats: $(SOURCES)
diff --git a/scala/assembly.sbt b/scala/assembly.sbt
new file mode 100644 (file)
index 0000000..d7a8cdf
--- /dev/null
@@ -0,0 +1,3 @@
+import AssemblyKeys._ // put this at the top of the file
+
+assemblySettings
index d2a2802..a48150a 100644 (file)
@@ -13,3 +13,4 @@ showSuccess := false
 
 logLevel in runMain := Level.Warn
 
+mainClass in Compile := Some("stepA_mal")
diff --git a/scala/project/assembly.sbt b/scala/project/assembly.sbt
new file mode 100644 (file)
index 0000000..54c3252
--- /dev/null
@@ -0,0 +1 @@
+addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
index d030e1a..0e5396d 100644 (file)
@@ -4,6 +4,20 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
 .PHONY: stats stats-lisp
 
+all:
+       true
+
+dist: mal.tcl
+
+mal.tcl: $(SOURCES)
+       echo "#!/usr/bin/env tclsh" > $@
+       cat $+ | grep -v "^source " >> $@
+       chmod +x $@
+
+clean:
+       rm -f mal.tcl
+
+
 stats: $(SOURCES)
        @wc $^
        @printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*\"|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
index 43d71d9..ce5145a 100644 (file)
@@ -21,7 +21,9 @@ FLAGS = $(if $(strip $(DEBUG)),-debug:full,)
 
 #####################
 
-all: mal.exe $(patsubst %.vb,%.exe,$(SRCS))
+all: $(patsubst %.vb,%.exe,$(SRCS))
+
+dist: mal.exe
 
 mal.exe: $(patsubst %.vb,%.exe,$(word $(words $(SOURCES)),$(SOURCES)))
        cp $< $@
index 69cdf2b..dfb1271 100644 (file)
@@ -4,6 +4,17 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
 
 all: libvimreadline.so
 
+dist: mal.vim
+
+mal.vim: $(SOURCES)
+       echo "#!/bin/sh" > $@
+       echo "\":\" ; rundir=\`dirname \$$0\`" >> $@
+       echo "\":\" ; export LD_LIBRARY_PATH=\`readlink -f \$$rundir\`" >> $@
+       echo "\":\" ; exec vim -i NONE -V1 -nNesS \"\$$0\" -- \"\$$@\"" >> $@
+       cat $+ | grep -v "^source " >> $@
+       chmod +x $@
+
+
 libvimreadline.so: vimreadline.o
        $(CC) -g -shared -o $@ $< -lreadline
 
@@ -11,7 +22,7 @@ vimreadline.o: vimreadline.c
        $(CC) -g -fPIC -c $< -o $@
 
 clean:
-       rm -f vimreadline.o libvimreadline.so
+       rm -f vimreadline.o libvimreadline.so mal.vim
 
 stats: $(SOURCES)
        @wc $^