diff options
author | Eduardo Julian | 2016-12-01 15:25:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-12-01 15:25:07 -0400 |
commit | 4528aee1d700ba0ac611fb07faf4c5a8c7e0b9ad (patch) | |
tree | a7c67379d1e23e1c4851d3037d68a2b695f1e899 /lux-lein/src/leiningen/luxc/utils.clj | |
parent | 74f782af647e9dc9dea53754d48482fa8a18301a (diff) |
- Slightly changed the lux-lein commands.
Diffstat (limited to 'lux-lein/src/leiningen/luxc/utils.clj')
-rw-r--r-- | lux-lein/src/leiningen/luxc/utils.clj | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/lux-lein/src/leiningen/luxc/utils.clj b/lux-lein/src/leiningen/luxc/utils.clj deleted file mode 100644 index bae02d365..000000000 --- a/lux-lein/src/leiningen/luxc/utils.clj +++ /dev/null @@ -1,97 +0,0 @@ -;; Copyright (c) Eduardo Julian. All rights reserved. -;; This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -;; If a copy of the MPL was not distributed with this file, -;; You can obtain one at http://mozilla.org/MPL/2.0/. - -(ns leiningen.luxc.utils - (:refer-clojure :exclude [compile]) - (:require [leiningen.core.classpath :as classpath]) - (:import (java.io File - InputStreamReader - BufferedReader))) - -(def ^:const ^String output-dir "target/jvm") -(def ^:const ^String output-package "program.jar") - -(def ^:private unit-separator (str (char 31))) - -(def ^:private vm-options "-server -Xms2048m -Xmx2048m -XX:+OptimizeStringConcat") - -(defn compile-path [project module source-paths] - (let [output-dir (get-in project [:lux :target] output-dir) - jar-paths (->> ^java.net.URLClassLoader (ClassLoader/getSystemClassLoader) - (.getURLs) - (map #(.getFile ^java.net.URL %)) - (filter #(.endsWith ^String % ".jar"))) - compiler-path (some (fn [^:private path] - (if (.contains path "com/github/luxlang/luxc-jvm") - path - nil)) - jar-paths) - stdlib-path (some (fn [^:private path] - (if (.contains path "com/github/luxlang/lux-stdlib") - path - nil)) - jar-paths) - deps-paths (filter (fn [^:private path] - (or (.contains path "org/ow2/asm/asm-all") - (.contains path "org/clojure/core.match") - (.contains path "org/clojure/clojure"))) - jar-paths) - sdk-path (get-in project [:lux :android :sdk]) - android-path (str sdk-path "/platforms/android-" (get-in project [:lux :android :version]) "/android.jar") - deps-paths (if (.exists (new File android-path)) - (cons android-path deps-paths) - deps-paths)] - (let [class-path (->> (classpath/get-classpath project) - (filter #(.endsWith % ".jar")) - (concat deps-paths) - (list* stdlib-path) - (interpose java.io.File/pathSeparator) - (reduce str "")) - java-cmd (get project :java-cmd "java") - jvm-opts (->> (get project :jvm-opts) (interpose " ") (reduce str ""))] - (str java-cmd " " jvm-opts " " vm-options " -cp " (str compiler-path ":" class-path) - " lux release " module - " " (->> (get project :resource-paths (list)) (interpose unit-separator) (apply str)) - " " (->> source-paths (interpose unit-separator) (apply str)) - " " output-dir)))) - -(defn repl-path [project source-paths] - (let [jar-paths (->> ^java.net.URLClassLoader (ClassLoader/getSystemClassLoader) - (.getURLs) - (map #(.getFile ^java.net.URL %)) - (filter #(.endsWith ^String % ".jar"))) - compiler-path (some (fn [^:private path] - (if (.contains path "com/github/luxlang/luxc-jvm") - path - nil)) - jar-paths) - deps-paths (filter (fn [^:private path] - (or (.contains path "org/ow2/asm/asm-all") - (.contains path "org/clojure/core.match") - (.contains path "org/clojure/clojure"))) - jar-paths)] - (let [class-path (->> (classpath/get-classpath project) (filter #(.endsWith % ".jar")) (concat deps-paths) (interpose ":") (reduce str "")) - java-cmd (get project :java-cmd "java") - jvm-opts (->> (get project :jvm-opts) (interpose " ") (reduce str ""))] - (str java-cmd " " jvm-opts " " vm-options " -cp " (str compiler-path ":" class-path) - " lux repl " (->> source-paths (interpose unit-separator) (apply str)))))) - -(defn run-process [command working-directory pre post] - (let [process (.exec (Runtime/getRuntime) command nil working-directory)] - (with-open [std-out (->> process .getInputStream (new InputStreamReader) (new BufferedReader)) - std-err (->> process .getErrorStream (new InputStreamReader) (new BufferedReader))] - (println pre) - (loop [line (.readLine std-out)] - (when line - (println line) - (recur (.readLine std-out)))) - (loop [had-error? false - line (.readLine std-err)] - (if line - (do (println line) - (recur true (.readLine std-err))) - (when had-error? - (System/exit 1)))) - (println post)))) |