From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCjnr-0006vc-45 for guix-patches@gnu.org; Mon, 22 May 2017 05:39:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dCjnq-000165-5r for guix-patches@gnu.org; Mon, 22 May 2017 05:39:03 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:57328) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dCjnq-00015w-2m for guix-patches@gnu.org; Mon, 22 May 2017 05:39:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dCjnp-0001k6-Sv for guix-patches@gnu.org; Mon, 22 May 2017 05:39:01 -0400 Subject: bug#26966: [PATCH 10/22] gnu: Add ecj-javac-on-jamvm-wrapper. Resent-Message-ID: References: <20170517171905.7840-1-rekado@elephly.net> <20170517171905.7840-10-rekado@elephly.net> From: Roel Janssen In-reply-to: <20170517171905.7840-10-rekado@elephly.net> Date: Mon, 22 May 2017 11:38:07 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ricardo Wurmus Cc: 26966@debbugs.gnu.org Ricardo Wurmus writes: > * gnu/packages/java.scm (ecj-javac-on-jamvm-wrapper): New variable. > --- > gnu/packages/java.scm | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) > > diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm > index ae9a5b3d7..940587057 100644 > --- a/gnu/packages/java.scm > +++ b/gnu/packages/java.scm > @@ -542,6 +542,92 @@ gnu.classpath.tools.~a.~a $@" > the GNU Classpath library. They are executed by the JamVM virtual > machine."))) > > +(define ecj-javac-on-jamvm-wrapper > + (package (inherit ecj-javac-wrapper) > + (name "ecj-javac-on-jamvm-wrapper") > + (arguments > + `(#:modules ((guix build utils)) > + #:builder > + ;; TODO: This builder is exactly the same as in ecj-javac-wrapper, > + ;; except that the backend is 'jamvm here. Can we reuse the same > + ;; builder somehow? That would be nice to reuse the same builder. Maybe we could create a package for the builder function that will generate the builder code. Whether that would be better, I don't know. > + (let ((backend 'jamvm)) > + (use-modules (guix build utils)) > + (let* ((bin (string-append (assoc-ref %outputs "out") "/bin")) > + (target (string-append bin "/javac")) > + (guile (string-append (assoc-ref %build-inputs "guile") > + "/bin/guile")) > + (ecj (string-append (assoc-ref %build-inputs "ecj-bootstrap") > + "/share/java/ecj-bootstrap.jar")) > + (java (case backend > + ((sablevm) > + (string-append (assoc-ref %build-inputs "sablevm") > + "/lib/sablevm/bin/java")) > + ((jamvm) > + (string-append (assoc-ref %build-inputs "jamvm") > + "/bin/jamvm")))) > + (bootcp (case backend > + ((sablevm) > + (let ((jvmlib (string-append > + (assoc-ref %build-inputs "sablevm-classpath") > + "/lib/sablevm"))) > + (string-append jvmlib "/jre/lib/rt.jar"))) > + ((jamvm) > + (let ((jvmlib (string-append (assoc-ref %build-inputs "classpath") > + "/share/classpath"))) > + (string-append jvmlib "/lib/glibj.zip:" > + jvmlib "/lib/tools.zip")))))) > + (mkdir-p bin) > + (with-output-to-file target > + (lambda _ > + (format #t "#!~a --no-auto-compile\n!#\n" guile) > + (map write > + `((use-modules (ice-9 match) > + (ice-9 receive) > + (ice-9 hash-table) > + (srfi srfi-1) > + (srfi srfi-26)) > + (define defaults > + '(("-bootclasspath" ,bootcp) > + ("-source" "1.5") > + ("-target" "1.5") > + ("-cp" "."))) > + (define (main args) > + (let ((classpath (getenv "CLASSPATH"))) > + (setenv "CLASSPATH" > + (string-append ,ecj > + (if classpath > + (string-append ":" classpath) > + "")))) > + (receive (vm-args other-args) > + ;; Separate VM arguments from arguments to ECJ. > + (partition (cut string-prefix? "-J" <>) > + (fold (lambda (default acc) > + (if (member (first default) acc) > + acc (append default acc))) > + args defaults)) > + (apply system* ,java > + (append > + ;; Remove "-J" prefix > + (map (cut string-drop <> 2) vm-args) > + '("org.eclipse.jdt.internal.compiler.batch.Main") > + (cons "-nowarn" other-args))))) > + ;; Entry point > + (let ((args (cdr (command-line)))) > + (if (null? args) > + (format (current-error-port) "javac: no arguments given!\n") > + (main args))))))) > + (chmod target #o755) > + #t)))) > + (native-inputs > + `(("guile" ,guile-2.2) > + ("ecj-bootstrap" ,ecj-bootstrap) > + ("jamvm" ,jamvm-bootstrap) > + ("classpath" ,classpath-on-sablevm))) > + (description "This package provides a wrapper around the @dfn{Eclipse > +compiler for Java} (ecj) with a command line interface that is compatible with > +the standard javac executable. The tool runs on JamVM instead of SableVM."))) > + > (define-public java-swt > (package > (name "java-swt") It looks good to me. Kind regards, Roel Janssen