aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.md26
-rw-r--r--lux-lein/src/leiningen/lux/builder.clj28
-rw-r--r--lux-lein/src/leiningen/lux/utils.clj42
-rw-r--r--stdlib/source/lux/control/parser/cli.lux9
-rw-r--r--stdlib/source/program/compositor.lux11
-rw-r--r--stdlib/source/test/lux/extension.lux5
-rw-r--r--stdlib/source/test/lux/target/jvm.lux2
7 files changed, 84 insertions, 39 deletions
diff --git a/commands.md b/commands.md
index c8262e479..bdcd22d38 100644
--- a/commands.md
+++ b/commands.md
@@ -66,10 +66,11 @@ cd ~/lux/stdlib/ && lein clean && lein with-profile bibliotheca lux auto test
cd ~/lux/stdlib/ && lein with-profile bibliotheca lux auto test
```
-## Install
+## Deploy
```
cd ~/lux/stdlib/ && lein install
+cd ~/lux/stdlib/ && mvn install:install-file -Dfile=target/library.tar -DgroupId=com.github.luxlang -DartifactId=stdlib -Dversion=0.6.0-SNAPSHOT -Dpackaging=tar
```
## Generate documentation
@@ -286,13 +287,13 @@ cd ~/lux/lux-r/ && lein lux auto build
cd ~/lux/lux-r/ && lein clean && lein lux auto build
```
-# REPL
+## REPL
```
cd ~/lux/lux-r/ && java -jar target/program.jar repl --source ~/lux/stdlib/source --target ~/lux/stdlib/target
```
-# Try
+## Try
```
cd ~/lux/lux-r/ && time java -jar target/program.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux
@@ -319,13 +320,13 @@ cd ~/lux/lux-jvm/ && lein lux auto build
cd ~/lux/lux-jvm/ && lein clean && lein lux auto build
```
-# REPL
+## REPL
```
cd ~/lux/lux-jvm/ && java -jar target/program.jar repl --source ~/lux/stdlib/source --target ~/lux/stdlib/target
```
-# Try
+## Try
```
cd ~/lux/lux-jvm/ && time java -jar target/program.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux
@@ -336,3 +337,18 @@ cd ~/lux/lux-jvm/ && java -jar target/program.jar export --source ~/lux/stdlib/s
cd ~/lux/stdlib/target/ && java -jar program.jar
```
+## Deploy
+
+```
+mvn install:install-file -Dfile=target/program.jar -DgroupId=com.github.luxlang -DartifactId=lux-jvm -Dversion=0.6.0-SNAPSHOT -Dpackaging=jar
+```
+
+# Compiler trial
+
+## Build
+
+```
+cd ~/lux/lux-trial/ && lein clean && lein lux build
+cd ~/lux/lux-trial/target/ && java -jar program.jar
+```
+
diff --git a/lux-lein/src/leiningen/lux/builder.clj b/lux-lein/src/leiningen/lux/builder.clj
index ebfbc7895..76e19b1e8 100644
--- a/lux-lein/src/leiningen/lux/builder.clj
+++ b/lux-lein/src/leiningen/lux/builder.clj
@@ -1,15 +1,21 @@
(ns leiningen.lux.builder
- (:require (leiningen.lux [utils :as &utils]
- [packager :as &packager])))
-
-(def missing-module-error "Please provide a program main module in [:lux :program]")
+ (:require (leiningen.lux
+ [utils :as &utils]
+ [packager :as &packager])))
(defn build [project]
(if-let [program-module (get-in project [:lux :program])]
- (when (time (&utils/run-process (&utils/compile-path project program-module (get project :source-paths (list)))
- nil
- "[COMPILATION BEGAN]"
- "[COMPILATION ENDED]"))
- (time (&packager/package project program-module (get project :resource-paths (list))))
- true)
- (println missing-module-error)))
+ (if-let [command (&utils/build-jvm project program-module)]
+ (when (time (&utils/run-process command
+ nil
+ "[COMPILATION BEGAN]"
+ "[COMPILATION ENDED]"))
+ true)
+ (let [command (&utils/compile-path project program-module (get project :source-paths (list)))]
+ (when (time (&utils/run-process command
+ nil
+ "[COMPILATION BEGAN]"
+ "[COMPILATION ENDED]"))
+ (time (&packager/package project program-module (get project :resource-paths (list))))
+ true)))
+ (println "Please provide a program main module in [:lux :program]")))
diff --git a/lux-lein/src/leiningen/lux/utils.clj b/lux-lein/src/leiningen/lux/utils.clj
index 6829f3d96..a0bb5abe2 100644
--- a/lux-lein/src/leiningen/lux/utils.clj
+++ b/lux-lein/src/leiningen/lux/utils.clj
@@ -1,5 +1,7 @@
(ns leiningen.lux.utils
- (:require (clojure [template :refer [do-template]])
+ (:require (clojure
+ [template :refer [do-template]]
+ [string :as string])
[leiningen.core.classpath :as classpath])
(:import (java.io File
InputStreamReader
@@ -30,6 +32,7 @@
(def ^:private lux-group "com.github.luxlang")
(def ^:private compiler-id [lux-group "luxc-jvm"])
+(def ^:private jvm-compiler-id [lux-group "lux-jvm"])
(def ^:private stdlib-id [lux-group "stdlib"])
(defn ^:private id-path
@@ -38,6 +41,7 @@
(str (.replace group "." "/") "/" name))
(def ^:private compiler-path (id-path compiler-id))
+(def ^:private jvm-compiler-path (id-path jvm-compiler-id))
(def ^:private stdlib-path (id-path stdlib-id))
(defn ^:private project-jars [project]
@@ -47,7 +51,6 @@
(do-template [<name> <path>]
(defn <name> [jar-paths]
- {:post [(not (nil? %))]}
(some (fn [^:private path]
(if (.contains path <path>)
path
@@ -55,6 +58,7 @@
jar-paths))
^:private find-compiler-path (sanitize-path compiler-path)
+ ^:private find-jvm-compiler-path (sanitize-path jvm-compiler-path)
^:private find-stdlib-path (sanitize-path stdlib-path)
)
@@ -62,14 +66,15 @@
(or (.contains path (sanitize-path "org/ow2/asm/asm-all"))
(.contains path (sanitize-path "org/clojure/core.match"))
(.contains path (sanitize-path "org/clojure/clojure"))
- (.contains path (sanitize-path compiler-path))))
+ (.contains path (sanitize-path compiler-path))
+ (.contains path (sanitize-path jvm-compiler-path))))
(defn ^:private filter-compiler-dependencies [jar-paths]
(filter compiler-dependency? jar-paths))
(defn ^:private java-command [project]
(str (get project :java-cmd "java")
- " " (->> (get project :jvm-opts) (interpose " ") (reduce str ""))
+ ;; " " (->> (get project :jvm-opts) (interpose " ") (reduce str ""))
" " vm-options))
(defn ^:private join-paths [paths]
@@ -89,7 +94,6 @@
(let [is-stdlib? (= stdlib-id
(project-id project))
raw-paths (project-jars project)
- compiler-path (prepare-path (find-compiler-path raw-paths))
stdlib-path (when (not is-stdlib?)
(prepare-path (find-stdlib-path raw-paths)))
sdk-path (get-in project [:lux :android :sdk])
@@ -111,6 +115,7 @@
(if is-stdlib?
deps
(list* stdlib-path deps)))
+ compiler-path (prepare-path (find-compiler-path raw-paths))
class-path (->> compiler-dependencies
(list* compiler-path)
(interpose java.io.File/pathSeparator)
@@ -123,6 +128,21 @@
repl-path "repl"
)
+(defn build-jvm [project module]
+ (let [raw-paths (project-jars project)]
+ (when-let [compiler-path (find-jvm-compiler-path raw-paths)]
+ (let [compiler (prepare-path compiler-path)
+ sources (->> (get project :source-paths (list))
+ (map #(str " --source " %))
+ (string/join ""))
+ target (get project :target-path default-target-dir)]
+ (str (java-command project)
+ " -jar " compiler " build"
+ " --library " "~/lux/stdlib/target/library.tar"
+ sources
+ " --target " target
+ " --module " module)))))
+
(def ^:private normal-exit 0)
(defn run-process [command working-directory pre post]
@@ -130,13 +150,13 @@
(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
+ (loop []
+ (when-let [line (.readLine std-out)]
(println line)
- (recur (.readLine std-out))))
- (loop [line (.readLine std-err)]
- (when line
+ (recur)))
+ (loop []
+ (when-let [line (.readLine std-err)]
(println line)
- (recur (.readLine std-err))))
+ (recur)))
(println post)
(= normal-exit (.waitFor process)))))
diff --git a/stdlib/source/lux/control/parser/cli.lux b/stdlib/source/lux/control/parser/cli.lux
index 0b60d783a..f58d78d13 100644
--- a/stdlib/source/lux/control/parser/cli.lux
+++ b/stdlib/source/lux/control/parser/cli.lux
@@ -132,7 +132,7 @@
(wrap [])))
(program: [name]
- (io (log! (text@compose "Hello, " name))))
+ (io (log! (:: text.monoid compose "Hello, " name))))
(program: [{config config^}]
(do io.monad
@@ -156,8 +156,7 @@
[(~+ (|> args
(list@map (function (_ [binding parser])
(list binding parser)))
- list@join))
- (~ g!_) ..end]
+ list@join))]
((~' wrap) ((~! do) (~! io.monad)
[(~ g!output) (~ body)
(~+ (for {@.old
@@ -169,10 +168,10 @@
(` process.run!))))]
((~' wrap) (~ g!output))))))
(~ g!args))
- (#try.Success [(~ g!_) (~ g!output)])
+ (#.Right [(~ g!_) (~ g!output)])
(~ g!output)
- (#try.Failure (~ g!message))
+ (#.Left (~ g!message))
(.error! (~ g!message))
))))
)))
diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux
index 695d8a9d9..4dbd5efcd 100644
--- a/stdlib/source/program/compositor.lux
+++ b/stdlib/source/program/compositor.lux
@@ -109,10 +109,7 @@
[Packager Path]
(Promise Any)))
(do {@ promise.monad}
- [platform (promise.future platform)
- console (|> console.system
- promise.future
- (:: @ map (|>> try.assume console.async)))]
+ [platform (promise.future platform)]
(case service
(#/cli.Compilation compilation)
(<| (or-crash! "Compilation failed:")
@@ -148,5 +145,9 @@
## TODO: Fix the interpreter...
(undefined)
## (<| (or-crash! "Interpretation failed:")
- ## (interpreter.run (try.with promise.monad) console platform interpretation generation-bundle))
+ ## (do {@ promise.monad}
+ ## [console (|> console.system
+ ## promise.future
+ ## (:: @ map (|>> try.assume console.async)))]
+ ## (interpreter.run (try.with promise.monad) console platform interpretation generation-bundle)))
))))
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index da6f89187..9aa8ae987 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -50,7 +50,10 @@
(wrap (#synthesis.Extension self (list)))))
))
-(for {@.jvm
+(for {@.old
+ (as-is)
+
+ @.jvm
(as-is (generation: (..my-generation self phase archive {parameters (<>.some <s>.any)})
(do phase.monad
[]
diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux
index f572b7e1e..18366de69 100644
--- a/stdlib/source/test/lux/target/jvm.lux
+++ b/stdlib/source/test/lux/target/jvm.lux
@@ -963,7 +963,7 @@
(array (/.newarray /instruction.t-int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap]
(function (_ expected)
(for {@.old
- (|>> (:coerce java/lang/Integer) ("jvm ieq" (host.int-to-long expected)))
+ (|>> (:coerce java/lang/Integer) ("jvm ieq" (:coerce java/lang/Integer expected)))
@.jvm
(|>> (:coerce java/lang/Integer) "jvm object cast" ("jvm int =" ("jvm object cast" (:coerce java/lang/Integer expected))))}))))