From ad2f9e165d2bdce646507f1aadd133b8f67ae75f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 21 Mar 2017 19:15:12 -0400 Subject: - Can now select between JVM and JS compilation, based on command-line parameters. --- lux-lein/src/leiningen/lux/utils.clj | 2 +- luxc/src/lux.clj | 8 ++++---- luxc/src/lux/compiler.clj | 17 +++++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lux-lein/src/leiningen/lux/utils.clj b/lux-lein/src/leiningen/lux/utils.clj index c70ec2289..a786a4d6d 100644 --- a/lux-lein/src/leiningen/lux/utils.clj +++ b/lux-lein/src/leiningen/lux/utils.clj @@ -90,7 +90,7 @@ (str (java-command project) " -cp " class-path " " (lux-command project source-paths)))) - compile-path (str "release " module) + compile-path (str "release jvm " module) repl-path "repl" ) diff --git a/luxc/src/lux.clj b/luxc/src/lux.clj index 182ddf46f..2daf0000a 100644 --- a/luxc/src/lux.clj +++ b/luxc/src/lux.clj @@ -19,11 +19,11 @@ (defn -main [& args] (|case (&/->list args) - (&/$Cons "release" (&/$Cons program-module (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil)))))) - (time (&compiler/compile-program &/$Release program-module (separate-paths resources-dirs) (separate-paths source-dirs) target-dir)) + (&/$Cons "release" (&/$Cons platform (&/$Cons program-module (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil))))))) + (time (&compiler/compile-program platform &/$Release program-module (separate-paths resources-dirs) (separate-paths source-dirs) target-dir)) - (&/$Cons "debug" (&/$Cons program-module (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil)))))) - (time (&compiler/compile-program &/$Debug program-module (separate-paths resources-dirs) (separate-paths source-dirs) target-dir)) + (&/$Cons "debug" (&/$Cons platform (&/$Cons program-module (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil))))))) + (time (&compiler/compile-program platform &/$Debug program-module (separate-paths resources-dirs) (separate-paths source-dirs) target-dir)) (&/$Cons "repl" (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil))))) (&repl/repl (separate-paths resources-dirs) diff --git a/luxc/src/lux/compiler.clj b/luxc/src/lux/compiler.clj index 0e78fa766..bffedb69e 100644 --- a/luxc/src/lux/compiler.clj +++ b/luxc/src/lux/compiler.clj @@ -10,13 +10,14 @@ [js :as &&js] ))) -(defn init! [resources-dirs ^String target-dir] +(defn init! [platform resources-dirs ^String target-dir] (do (reset! &&core/!output-dir target-dir) (&¶llel/setup!) (&&io/init-libs!) (.mkdirs (new java.io.File target-dir)) - (&&jvm/init! resources-dirs target-dir) - ;; (&&js/init! resources-dirs target-dir) + (case platform + "jvm" (&&jvm/init! resources-dirs target-dir) + "js" (&&js/init! resources-dirs target-dir)) )) (def all-compilers @@ -28,8 +29,8 @@ (defn compile-module [source-dirs name] (&&jvm/compile-module source-dirs name)) -(defn compile-program [mode program-module resources-dir source-dirs target-dir] - (init! resources-dir target-dir) - (&&jvm/compile-program mode program-module resources-dir source-dirs target-dir) - ;; (&&js/compile-program mode program-module resources-dir source-dirs target-dir) - ) +(defn compile-program [platform mode program-module resources-dir source-dirs target-dir] + (init! platform resources-dir target-dir) + (case platform + "jvm" (&&jvm/compile-program mode program-module resources-dir source-dirs target-dir) + "js" (&&js/compile-program mode program-module resources-dir source-dirs target-dir))) -- cgit v1.2.3