Skip to content

Commit

Permalink
awk-es6, Makefile: dist ruiles
Browse files Browse the repository at this point in the history
  • Loading branch information
kanaka committed Feb 24, 2016
1 parent 0eace3d commit b6dc3e3
Show file tree
Hide file tree
Showing 21 changed files with 159 additions and 63 deletions.
91 changes: 49 additions & 42 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
*/experiments
*/node_modules
c/*.o
*.o
*.pyc
bash/mal.sh
c/mal
coffee/mal.coffee
crystal/mal
d/mal
erlang/mal
haskell/mal
haxe/*.n
haxe/*.py
haxe/cpp/
haxe/*.js
js/mal.js
js/web/mal.js
make/mal.mk
mal/mal.mal
nim/mal
php/mal.php
python/mal.py
*/step0_repl
*/step1_read_print
*/step2_eval
Expand All @@ -31,52 +13,77 @@ python/mal.py
*/step8_macros
*/step9_try
*/stepA_mal
.bash_history
.mal-history
.crystal
.lein
.m2
.ivy2
.sbt
awk/mal.awk
bash/mal.sh
c/mal
cpp/mal
clojure/mal.jar
clojure/target
clojure/.lein-repl-history
coffee/mal.coffee
crystal/mal
cs/*.exe
cs/*.dll
cs/*.mdb
clojure/target
clojure/.lein-repl-history
d/mal
elixir/_build
elixir/deps
elixir/erl_crash.dump
elixir/mal
elixir/*.ez
erlang/mal
erlang/ebin
erlang/.rebar
erlang/src/*.beam
es6/mal.js
es6/build
fsharp/*.exe
fsharp/*.dll
fsharp/*.mdb
go/step*
go/mal
groovy/*.class
haskell/mal
haskell/*.hi
haskell/*.o
haxe/*.n
haxe/*.py
haxe/cpp/
haxe/*.js
java/target/
java/dependency-reduced-pom.xml
js/mal.js
js/web/mal.js
kotlin/*.jar
kotlin/.idea
kotlin/*.iml
lua/lib
lua/linenoise.so
make/mal.mk
mal/mal.mal
nim/mal
nim/nimcache*
ocaml/*.cmi
ocaml/*.cmo
ocaml/*.swp
ocaml/*.cmx
ocaml/*.o
ocaml/mal_lib.*
php/mal.php
python/mal.pyz
rust/target/
rust/mal
rust/Cargo.lock
rust/.cargo
r/lib
vb/*.exe
vb/*.dll
scala/target
scala/project
haskell/*.hi
haskell/*.o
lua/lib
lua/linenoise.so
nim/nimcache*
.lein
.m2
.ivy2
.sbt
groovy/*.class
.crystal
es6/build
elixir/_build
elixir/deps
elixir/erl_crash.dump
elixir/*.ez
kotlin/*.jar
kotlin/.idea
kotlin/*.iml
vb/*.exe
vb/*.dll
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,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))

DOCKER_BUILD = $(foreach impl,$(DO_IMPLS),docker-build^$(impl))

IMPL_PERF = $(foreach impl,$(filter-out $(PERF_EXCLUDES),$(DO_IMPLS)),perf^$(impl))
Expand Down Expand Up @@ -295,6 +297,17 @@ $(IMPL_STATS_LISP):
echo "Stats (lisp only) for $(impl):"; \
$(MAKE) --no-print-directory -C $(impl) stats-lisp)

# dist rules

dist: $(IMPL_DIST)

.SECONDEXPANSION:
$(IMPL_DIST):
@echo "----------------------------------------------"; \
$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
echo "Running: make -C $(impl) dist"; \
$(MAKE) --no-print-directory -C $(impl) dist)

# Docker build rules

docker-build: $(DOCKER_BUILD)
Expand Down
11 changes: 9 additions & 2 deletions awk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ SOURCES_BASE = types.awk reader.awk printer.awk
SOURCES_LISP = env.awk core.awk stepA_mal.awk
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)

all: mal.awk
all:
true

dist: mal.awk

mal.awk: $(SOURCES)
echo "#!/usr/bin/awk -f" > $@
echo '#!/bin/sh' > $@
echo 'arbitrary_long_name==0 "exec" "/usr/bin/gawk" "-O" "-f" "$$0" "$$@"' >> $@
cat $+ | grep -v "^@include " >> $@
chmod +x $@

clean:
rm -f mal.awk


.PHONY: stats tests $(TESTS)

Expand Down
5 changes: 4 additions & 1 deletion bash/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ SOURCES_BASE = types.sh reader.sh printer.sh
SOURCES_LISP = env.sh core.sh stepA_mal.sh
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)

all: mal.sh
all:
true

dist: mal.sh

mal.sh: $(SOURCES)
echo "#!/usr/bin/env bash" > $@
Expand Down
4 changes: 3 additions & 1 deletion c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ LDFLAGS += -l$(RL_LIBRARY) $(GLIB_LDFLAGS) -ldl -lffi

#####################

all: $(BINS) mal
all: $(BINS)

dist: mal

mal: $(word $(words $(BINS)),$(BINS))
cp $< $@
Expand Down
11 changes: 10 additions & 1 deletion clojure/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ 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:
all dist: deps mal.jar

deps:
lein deps

mal.jar: $(SOURCES)
lein with-profile +jar uberjar
cp target/mal-0.0.1-SNAPSHOT-standalone.jar $@

clear:
rm -rf target/ mal.jar

.PHONY: stats

stats: $(SOURCES)
Expand Down
6 changes: 4 additions & 2 deletions clojure/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
:step7 {:main step7-quote}
:step8 {:main step8-macros}
:step9 {:main step9-try}
:stepA {:main stepA-mal}}
:stepA {:main stepA-mal}
:jar {:main stepA-mal
:aot [stepA-mal]}}

:main stepA-more)
:main stepA-mal)

3 changes: 2 additions & 1 deletion clojure/src/stepA_mal.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[reader]
[printer]
[env]
[core]))
[core])
(:gen-class))

;; read
(defn READ [& [strng]]
Expand Down
12 changes: 11 additions & 1 deletion coffee/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@ SOURCES_BASE = node_readline.coffee types.coffee \
SOURCES_LISP = env.coffee core.coffee stepA_mal.coffee
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)

all: node_modules
all: node_modules dist

node_modules:
npm install

dist: mal.coffee

mal.coffee: $(SOURCES)
echo "#!/usr/bin/env coffee" > $@
cat $+ | grep -v "= *require('./" >> $@
chmod +x $@

clean:
rm -f mal.coffee


.PHONY: stats tests $(TESTS)

Expand Down
7 changes: 6 additions & 1 deletion cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ TARGETS=$(MAINS:%.cpp=%)

all: $(TARGETS)

dist: mal

mal: stepA_mal
cp $< $@

.deps: *.cpp *.h
$(CXX) $(CXXFLAGS) -MM *.cpp > .deps

Expand All @@ -44,7 +49,7 @@ libmal.a: $(LIBOBJS)
$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
rm -rf *.o $(TARGETS) libmal.a .deps
rm -rf *.o $(TARGETS) libmal.a .deps mal

-include .deps

Expand Down
3 changes: 2 additions & 1 deletion cpp/stepA_mal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ int main(int argc, char* argv[])
safeRep(STRF("(load-file %s)", filename.c_str()), replEnv);
return 0;
}
rep("(println (str \"Mal [\" *host-language* \"]\"))", replEnv);
while (s_readLine.get(prompt, input)) {
safeRep(input, replEnv);
}
Expand Down Expand Up @@ -353,7 +354,7 @@ static const char* malFunctionTable[] = {
(cons (f (first xs)) (map f (rest xs))))))",
"(def! *gensym-counter* (atom 0))",
"(def! gensym (fn* [] (symbol (str \"G__\" (swap! *gensym-counter* (fn* [x] (+ 1 x)))))))",
"(def! *host-language* \"c++\")",
"(def! *host-language* \"C++\")",
};

static void installFunctions(malEnvPtr env) {
Expand Down
4 changes: 3 additions & 1 deletion crystal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ STEPS = step0_repl.cr step1_read_print.cr step2_eval.cr step3_env.cr \
STEP_BINS = $(STEPS:%.cr=%)
LAST_STEP_BIN = $(word $(words $(STEP_BINS)),$(STEP_BINS))

all: $(STEP_BINS) mal
all: $(STEP_BINS)

dist: mal

mal: $(LAST_STEP_BIN)
cp $< $@
Expand Down
4 changes: 3 additions & 1 deletion cs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ FLAGS = $(if $(strip $(DEBUG)),-debug+,)

#####################

all: mal.exe $(patsubst %.cs,%.exe,$(SRCS))
all: $(patsubst %.cs,%.exe,$(SRCS))

dist: mal.exe

mal.exe: $(patsubst %.cs,%.exe,$(word $(words $(SOURCES)),$(SOURCES)))
cp $< $@
Expand Down
4 changes: 3 additions & 1 deletion d/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ LATE_STEPS_BINS = $(LATE_SRCS:%.d=%)

#####################

all: $(BINS) mal
all: $(BINS)

dist: mal

mal: $(word $(words $(BINS)),$(BINS))
cp $< $@
Expand Down
6 changes: 6 additions & 0 deletions elixir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
all:
mix compile

dist: mal

mal: $(SOURCES)
mix escript.build

clean:
mix clean
rm -f mal

stats: $(SOURCES)
@wc $^
Expand Down
5 changes: 5 additions & 0 deletions elixir/lib/mix/tasks/stepA_mal.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ defmodule Mix.Tasks.StepAMal do
import Mal.Types
alias Mal.Function

# for escript execution
def main(args) do
run(args)
end

def run(args) do
env = Mal.Env.new()
Mal.Env.merge(env, Mal.Core.namespace)
Expand Down
7 changes: 6 additions & 1 deletion elixir/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ defmodule Mal.Mixfile do
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps,
default_task: "stepA_mal"]
default_task: "stepA_mal",
escript: escript]
end

def escript do
[main_module: Mix.Tasks.StepAMal]
end

# Configuration for the OTP application
Expand Down
11 changes: 8 additions & 3 deletions erlang/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ BINS = $(SRCS:%.erl=%)

.PHONY: all mal clean stats stats-lisp

all: $(BINS) mal
all: $(BINS)

dist: mal

mal: $(SOURCES)
sed 's/stepA_mal/mal/' src/stepA_mal.erl > src/mal.erl
MAL_STEP=mal rebar compile escriptize
rm src/mal.erl

mal: $(word $(words $(BINS)),$(BINS))
cp $< $@

define dep_template
.PHONY: $(1)
Expand Down
Loading

0 comments on commit b6dc3e3

Please sign in to comment.