Last active
March 23, 2020 21:40
-
-
Save rauhs/d5bb47c239b58cbf54e1d3d1de221031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# Vars | |
# $< Dependency (right) | |
# $@ Target (left) | |
CLJ_NREPL_PORT:=22340 | |
FIGWHEEL_PORT:=22345 | |
LEIN_NREPL_PORT:=22350 | |
CLJ_NREPL_PORT_TRY:=22355 | |
CLJS_JAR_VERSION:=1.7.228 | |
CLJS_JAR_URL:=https://github.com/clojure/clojurescript/releases/download/r$(CLJS_JAR_VERSION)/cljs.jar | |
MAKEFILE_LIST:=Makefile | |
CLJS_SCRIPT:=scripts/fw.clj | |
CLOSURE_JAR_URL:=https://dl.google.com/closure-compiler/compiler-latest.zip | |
CLOSURE_JAR:=closure-compiler/closure-compiler-v20170218.jar | |
PSEUDO_OUT:=resources/public/js/production-pseudo/compiled/app.js | |
################################################################################ | |
# VARS | |
.PHONY: def_target help | |
export PATH := $(abspath foo/bin):$(PATH) | |
def_target : null | |
help: | |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | |
magic : | |
terminator --config=dev-docs/dev-tools/terminator.cfg & | |
# http://blog.jgc.org/2015/04/the-one-line-you-should-add-to-every.html | |
# Allows: | |
# make print-SOURCE_FILEE | |
print-%: ; @echo $*=$($*) | |
gorilla-repl: ## Start a gorilla REPL | |
@echo "Starting GORILLA for server code" | |
lein with-profile dev-clj gorilla :ip 127.0.0.1 :nrepl-port 22341 :port 22342 | |
clj-repl : | |
@echo "Starting CLOJURE NREPL for server code" | |
lein with-profile dev-clj repl :start :host localhost :port $(CLJ_NREPL_PORT) | |
javac : | |
lein with-profile dev-clj javac | |
clj-repl-try : | |
@echo "Starting CLOJURE NREPL for server code" | |
lein with-profile cass-only repl :start :host localhost :port $(CLJ_NREPL_PORT_TRY) | |
# Also starts a repl from within the code. USE THIS: | |
# Starts the app the trapperkeeper way | |
clj-dev-run : | |
lein with-profile dev-clj run | |
clj-prod-run : | |
lein with-profile prod-clj run | |
clj-repl-conn : | |
lein with-profile dev-clj repl :connect localhost:$(CLJ_NREPL_PORT) | |
all-deps-dump : | |
echo ";; vim: ft=clojure" | tee deps.dev-clj deps.dev-cljs deps.prod-clj deps.prod-cljs > /dev/null | |
lein with-profile dev-clj deps :tree >> deps.dev-clj 2>&1 | |
lein with-profile dev-cljs deps :tree >> deps.dev-cljs 2>&1 | |
lein with-profile prod-clj deps :tree >> deps.prod-clj 2>&1 | |
lein with-profile prod-cljs deps :tree >> deps.prod-cljs 2>&1 | |
# We use `lein run` to run the cljs compiler scripts since we need the | |
# classpath properly set: | |
# We could also do a lower level and use the standalone jar of cljs to test | |
# different versions quickly: | |
cljs-c-jar-dev : | |
java -cp cljs-$(CLJS_JAR_VERSION).jar:scripts:$$(lein with-profile dev-cljs classpath) \ | |
clojure.main scripts/fwcljs.clj dev srs-c.dev | |
cljs-c-dev : | |
lein with-profile dev-cljs run -m clojure.main $(CLJS_SCRIPT) dev srs-c.dev | |
cljs-c-dev-prod : | |
lein with-profile prod-cljs run -m clojure.main $(CLJS_SCRIPT) dev srs-c.dev | |
cljs-c-production-login : | |
rm -rf ./resources/public/js/production/compiled/out | |
lein with-profile prod-cljs run -m clojure.main $(CLJS_SCRIPT) production login | |
cljs-c-production-app : | |
rm -rf ./resources/public/js/production/compiled/out | |
lein with-profile prod-cljs run -m clojure.main $(CLJS_SCRIPT) production app | |
cljs-c-production-pseudo-app : | |
rm -rf ./resources/public/js/production-pseudo/compiled/out | |
lein with-profile prod-cljs run -m clojure.main $(CLJS_SCRIPT) production/pseudo app | |
figwheel : | |
lein with-profile dev-cljs repl :start :port $(FIGWHEEL_PORT) | |
dl-cljs : | |
curl -L $(CLJS_JAR_URL) > cljs-$(CLJS_JAR_VERSION).jar | |
clean-cljs : | |
rm -rf ./resources/public/js/dev/compiled/out | |
rm -rf ./cache/ | |
mkdir -p cache | |
rm -rf ./resources/public/js/production/compiled/out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn vcat [& x] | |
(into [] cat x)) | |
(def cljs-deps | |
'[[org.clojure/clojurescript "1.9.555" #_"1.9.521"] | |
[org.clojure/core.async "0.3.442"] | |
[com.cognitect/transit-cljs "0.8.239"]]) | |
(def clj-deps | |
'[[org.clojure/core.async "0.3.442"] | |
[org.clojure/tools.logging "0.3.1"] | |
[com.cognitect/transit-clj "0.8.300"] | |
[org.clojure/data.priority-map "0.0.7"] | |
[org.clojure/data.json "0.2.6"]]) | |
(def clj-dev-deps | |
'[[org.clojure/tools.trace "0.7.9"] | |
[org.clojure/test.check "0.9.0"] | |
[org.jsoup/jsoup "1.9.2"]]) | |
(def cljs-dev-deps | |
'[[com.cemerick/piggieback "0.2.1"] | |
[figwheel-sidecar "0.5.10"] | |
[ring/ring-core "1.6.0"] | |
[binaryage/devtools "0.9.4"]]) | |
;; Deps for both cljs and clj, dev & prod | |
(def both-deps | |
'[[org.clojure/clojure "1.9.0-alpha15"] | |
[org.clojure/tools.reader "1.0.0-beta4"] | |
[org.clojure/tools.nrepl "0.2.13"] ;; 12 | |
;; Also needed on the server for some src-b stuff | |
[datascript "0.15.5"] | |
[jarohen/nomad "0.7.3"] ;; Flexible configuration management | |
[garden "1.3.2"] ;; Generate CSS | |
[sablono "0.7.6"] ;; hiccup to react | |
[rum "0.10.7" :exclusions [[sablono] | |
[cljsjs/react-dom] | |
[cljsjs/react]]]]) | |
(def both-dev-deps | |
'[;; nrepl with leiningen also adds this to deps: | |
[clojure-complete/clojure-complete "0.2.4"] | |
;; Not sure why I need this separately: | |
;[im.chit/wu.kong "0.1.2"] | |
;[im.chit/vinyasa "0.4.7" :exclusions [im.chit/wu.kong]] | |
[im.chit/lucid.core.aether "1.2.0"] | |
[im.chit/lucid.core.debug "1.2.0"] | |
[im.chit/lucid.core.inject "1.2.0"] | |
[im.chit/lucid.mind "1.2.0"] ;; reflection .* etc | |
[im.chit/lucid.space "1.2.0"] ;; ./pull etc. | |
;; needed for figwheel and injections: | |
[org.clojure/tools.namespace "0.3.0-alpha3" :exclusions [org.clojure/tools.reader]]]) | |
(def all-deps (vcat cljs-deps cljs-dev-deps | |
clj-deps clj-dev-deps | |
both-deps both-dev-deps)) | |
;(assert (apply distinct? all-deps)) | |
(defn deps [env type] | |
(let [v [env type]] | |
(cond-> [] | |
(= :dev env) (into both-dev-deps) | |
(= :cljs type) (into cljs-deps) | |
(= :clj type) (into clj-deps) | |
(= [:dev :cljs] v) (into cljs-dev-deps) | |
(= [:dev :clj] v) (into clj-dev-deps) | |
true (into both-deps) | |
true (with-meta {:replace true})))) | |
#_(deps :dev :cljs) | |
#_(mapv ./pull (deps :dev :cljs)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defn source-paths | |
[env type] | |
(cond-> | |
[(str "env/" (name env) "/" (name type)) | |
(str "src/" (name type)) | |
"src/cljc"] | |
(= :cljs type) | |
(conj "src/js") | |
;; I run my tests also in dev: | |
(= [:dev :clj] [env type]) | |
(conj "test/clj") | |
true (with-meta {:replace true}))) | |
;; Generated for Cursive: | |
(def all-path (vec (distinct (conj (flatten (for [env [:prod :dev] | |
type [:cljs :clj]] | |
(source-paths env type))) | |
"scripts" ; For Cursive to work with fw+cljs | |
)))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(def repl-injections-clj | |
'[(require '[lucid.core.inject :as inject]) | |
(require 'schema.core) | |
;; Enable schema validations on function calls: | |
(schema.core/set-fn-validation! true) | |
(inject/in | |
. | |
[lucid.core.inject :refer [inject [in inject-in]]] | |
[lucid.space pull] | |
clojure.core | |
[lucid.mind .> .? .* .% .%> .& .>ns .>var] | |
[clojure.repl doc] | |
> | |
[clojure.pprint pprint] | |
[clojure.java.shell sh] | |
? | |
[srs-s.user.core u0 find-uuid])]) | |
(def repl-injections-cljs | |
'[(require '[lucid.core.inject :as inject]) | |
(inject/in | |
. | |
[lucid.core.inject :refer [inject [in inject-in]]] | |
[lucid.space pull] | |
clojure.core | |
[lucid.mind .> .? .* .% .%> .& .>ns .>var] | |
[clojure.repl doc])]) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; We can eval and develop this project in our clojure REPL: | |
#_(./pull '[leiningen-core "2.7.1"]) | |
#_(./pull '[leiningen "2.7.1"]) | |
#_(require '[leiningen.core.project :refer [defproject]]) | |
;; Inspect dependencies deps: | |
#_(require 'leiningen.core.classpath) | |
#_(require 'leiningen.core.project) | |
#_(require 'leiningen.deps) | |
;; defproject will def a var called 'project' | |
#_ project | |
(defproject srs-om "0.1.0-SNAPSHOT" | |
:description "x" | |
;; For cursive: | |
:dependencies ~all-deps | |
:main srs-s.main | |
;; Some speedup | |
;; https://github.com/technomancy/leiningen/wiki/Faster | |
:jvm-opts ["-Xverify:none" | |
"-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector" | |
#_"-Dlogback.configurationFile=logback.xml"] | |
:source-paths ~all-path | |
:java-source-paths ["src/java"] | |
:javac-options ["-target" "1.8" "-source" "1.6"] | |
:jar-exclusions [#"\.swp|\.swo"] | |
:resource-paths ["resources"] | |
:test-paths ["test/clj"] | |
:target-path "target/%s/" | |
:compile-path "%s/class-files" | |
;; Just in case I accidentally run deploy: | |
:deploy-branches ["dont-exist-yo"] | |
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"] | |
:test-refresh {:watch-dirs ~(source-paths :dev :clj)} | |
:profiles | |
{:dev-clj | |
{:source-paths ~(source-paths :dev :clj) | |
:dependencies ~(deps :dev :clj) | |
:main srs-s.main | |
:repl-options {:nrepl-middleware []} | |
:global-vars {*warn-on-reflection* true | |
*print-length* 200 ;; avoid infinite sequences in dev mode. | |
*print-namespace-maps* false | |
*assert* true} | |
:jvm-opts ["-XX:-OmitStackTraceInFastThrow" | |
"-Xms400m" ;; starting heap memory | |
;; For now needed to load Omegawiki to datomic mem db: | |
"-Xmx8000m" ;; max heap memory | |
"-Xss1024k" ;; Thread stack size. | |
"-Dclojure.spec.check-asserts=true" | |
"-Dclojure.spec.compile-asserts=true" | |
;"-javaagent:classmexer.jar" | |
;"-javaagent:/home/rauh/.m2/repository/com/github/jbellis/jamm/0.3.1/jamm-0.3.1.jar" | |
"-Dnomad.env=dev"] | |
:env {:is-dev true} | |
:injections ~repl-injections-clj} | |
:dev-clj-test | |
{:source-paths ~(source-paths :dev :clj) | |
:dependencies ~(deps :dev :clj) | |
:jvm-opts ["-XX:-OmitStackTraceInFastThrow" | |
"-Dclojure.spec.check-asserts=true" | |
"-Dclojure.spec.compile-asserts=true" | |
"-Dnomad.env=dev"] | |
:global-vars {*warn-on-reflection* false | |
*assert* true} | |
:env {:is-dev true}} | |
:prod-clj | |
{:source-paths ~(source-paths :prod :clj) | |
:dependencies ~(deps :prod :clj) | |
:global-vars {*warn-on-reflection* false | |
*assert* false} | |
:jvm-opts ["-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector" | |
"-Dclojure.compiler.direct-linking=false" ;; For REPL to work | |
"-Dclojure.compiler.elide-meta=\"[:doc :file :line :added]\"" | |
"-Dclojure.spec.check-asserts=false" | |
"-Dclojure.spec.compile-asserts=false" | |
"-Dclojure.core.async.pool-size=32" | |
"-Dnomad.env=prod" | |
;"-XX:+PrintGCDetails" | |
;"-XX:+PrintGCDateStamps" | |
;"-Xloggc:srs-garbage.log" | |
"-XX:+UseG1GC" ;; better latency, slightly less thruput | |
"-Xms200m" ;; starting heap memory | |
;"-XX:NewRatio=6" ;; Default is 8 for server, but clojure has lots of transient | |
"-Xss1024k"] | |
:env {:is-dev false} | |
:main srs-s.main} | |
:dev-cljs | |
{:source-paths ~(source-paths :dev :cljs) | |
:dependencies ~(deps :dev :cljs) | |
:jvm-opts ["-XX:-OmitStackTraceInFastThrow" | |
"-Dstyler.db=cache/styler-db.clj" | |
"-Dklang.form-meta=#{}" ;; We have trace. | |
"-Dklang.trace=true" | |
"-Dnomad.env=dev"] | |
:main clojure.core | |
:repl-options ^:replace {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl] | |
:welcome (println "now run (load-file \"scripts/fw+cljs.clj\")")} | |
:injections ~repl-injections-cljs | |
:env {:is-dev true}} | |
:prod-cljs | |
{:source-paths ~(source-paths :prod :cljs) | |
:dependencies ~(deps :prod :cljs) | |
:jvm-opts ["-XX:-OmitStackTraceInFastThrow" | |
"-Dklang.configurer=srs-c.klang-config/get-klang-production-config" | |
"-Ddestruct.ensuremap=true" | |
"-Dstyler.db=false" | |
"-Dnomad.env=prod"] | |
:env {:is-dev false}}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also see:
https://gist.github.com/rauhs/2a02e5e04b5bd4e4b4b5