Skip to content

Commit

Permalink
[clojure] Fixes to support lumo 1.6.0.
Browse files Browse the repository at this point in the history
- Pass down the CLJ_MODE value for DOCKERIZED builds in addition to
  run/tests.
- Correct deps so that node_modules is installed for CLJ_MODE=cljs for
  all steps.
- Lumo 1.6.0 is currently not able to install globally as root
  (anmonteiro/lumo#206) so add the local
  node_modules/.bin to the PATH in the run script.
- Reader conditionals needed for clojure.reader/cljs.reader until this
  is fixed: anmonteiro/lumo#209
  • Loading branch information
kanaka committed Jul 27, 2017
1 parent e89a017 commit 62fc786
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
.bash_history
.cache
.config
.mal-history
.crystal
.lein
.m2
.ivy2
.sbt
.npm
.node-gyp
*/experiments
*/node_modules
*.o
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,15 @@ actual_impl = $(if $(filter mal,$(1)),$(MAL_IMPL),$(1))
# Returns nothing if DOCKERIZE is not set, otherwise returns the
# docker prefix necessary to run make within the docker environment
# for this impl
get_build_prefix = $(if $(strip $(DOCKERIZE)),docker run -it --rm -u $(shell id -u) -v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal -w /mal/$(1) $(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) $(call impl_to_image,$(1)) ,)
get_build_prefix = $(strip $(if $(strip $(DOCKERIZE)),\
docker run \
-it --rm -u $(shell id -u) \
-v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal \
-w /mal/$(1) \
$(if $(filter clojure,$(1)),-e CLJ_MODE=$(CLJ_MODE),) \
$(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) \
$(call impl_to_image,$(1)) \
,))

# Takes impl and step arguments
# Returns a command prefix (docker command and environment variables)
Expand Down Expand Up @@ -304,7 +312,7 @@ ALL_REPL = $(strip $(sort \
$(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s)))):
$(foreach impl,$(word 1,$(subst /, ,$(@))),\
$(if $(DOCKERIZE), \
$(call get_build_prefix,$(impl))$(MAKE) $(patsubst $(impl)/%,%,$(@)), \
$(call get_build_prefix,$(impl)) $(MAKE) $(patsubst $(impl)/%,%,$(@)), \
$(MAKE) -C $(impl) $(subst $(impl)/,,$(@))))

# Allow IMPL, and IMPL^STEP
Expand Down
14 changes: 10 additions & 4 deletions clojure/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ ENV LEIN_JVM_OPTS -Duser.home=/mal
# For building node modules
RUN apt-get -y install g++

# Add nodesource apt repo config for 7.X
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash -
# Add nodesource apt repo config for 8.X
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -

# Install nodejs.
RUN apt-get -y install nodejs

## Install ffi and lumo-cljs modules globally
#RUN npm install -g ffi lumo-cljs

ENV HOME=/mal

# Install nodejs. Install ffi and lumo-cljs modules globally
RUN apt-get -y install nodejs && npm install -g ffi lumo-cljs
7 changes: 6 additions & 1 deletion clojure/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SOURCES_LISP = src/mal/env.cljc src/mal/core.cljc src/mal/stepA_mal.cljc
SRCS = $(SOURCES_BASE) src/mal/env.cljc src/mal/core.cljc
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)

all: $(if $(filter cljs,$(CLJ_MODE)),node_modules,deps)
DEPS = $(if $(filter cljs,$(CLJ_MODE)),node_modules,deps)

dist: mal.jar mal

Expand All @@ -21,6 +21,11 @@ mal: mal.jar
cat <(echo -e '#!/bin/sh\nexec java -jar "$$0" "$$@"') mal.jar > $@
chmod +x mal

src/mal/%.cljc: $(DEPS)
@true

#src/mal/stepA_mal.cljc: $(DEPS)

target/%.jar: src/mal/%.cljc $(SRCS)
lein with-profile $(word 1,$(subst _, ,$*)) uberjar

Expand Down
2 changes: 1 addition & 1 deletion clojure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "Make a Lisp (mal) language implemented in ClojureScript",
"dependencies": {
"ffi": "2.2.x",
"lumo-cljs": "1.0.0"
"lumo-cljs": "^1.6.0"
}
}
1 change: 1 addition & 0 deletions clojure/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
export PATH=$PATH:$(dirname $0)/node_modules/.bin
STEP=${STEP:-stepA_mal}
if [ "${CLJ_MODE}" = "cljs" ]; then
exec lumo -c $(dirname $0)/src -m mal.${STEP//_/-} "${@}"
Expand Down
6 changes: 4 additions & 2 deletions clojure/src/mal/reader.cljc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(ns mal.reader
(:refer-clojure :exclude [read-string])
(:require [clojure.tools.reader :as r]
[clojure.tools.reader.reader-types :as rt]))
#?(:clj (:require [clojure.tools.reader :as r]
[clojure.tools.reader.reader-types :as rt]))
#?(:cljs (:require [cljs.tools.reader :as r]
[cljs.tools.reader.reader-types :as rt])))

;; change tools.reader syntax-quote to quasiquote
(defn- wrap [sym]
Expand Down

0 comments on commit 62fc786

Please sign in to comment.