From patchwork Sun Jan 16 01:31:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reily Siegel X-Patchwork-Id: 36403 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9529D27BBE9; Sun, 16 Jan 2022 01:32:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EC87F27BBEA for ; Sun, 16 Jan 2022 01:32:22 +0000 (GMT) Received: from localhost ([::1]:46208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8uP8-0002xx-1n for patchwork@mira.cbaines.net; Sat, 15 Jan 2022 20:32:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8uOo-0002xa-FC for guix-patches@gnu.org; Sat, 15 Jan 2022 20:32:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8uOo-0003Fc-3N for guix-patches@gnu.org; Sat, 15 Jan 2022 20:32:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8uOn-00054A-R9 for guix-patches@gnu.org; Sat, 15 Jan 2022 20:32:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53292] [PATCH] build: clojure-build-system: Support compiling Java sources. Resent-From: Reily Siegel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 16 Jan 2022 01:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 53292 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53292@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164229668119417 (code B ref -1); Sun, 16 Jan 2022 01:32:01 +0000 Received: (at submit) by debbugs.gnu.org; 16 Jan 2022 01:31:21 +0000 Received: from localhost ([127.0.0.1]:42250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8uO8-000537-LD for submit@debbugs.gnu.org; Sat, 15 Jan 2022 20:31:21 -0500 Received: from lists.gnu.org ([209.51.188.17]:47866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8uO4-00052w-EZ for submit@debbugs.gnu.org; Sat, 15 Jan 2022 20:31:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8uO4-0002wi-9F for guix-patches@gnu.org; Sat, 15 Jan 2022 20:31:16 -0500 Received: from mout-p-201.mailbox.org ([80.241.56.171]:60018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1n8uO1-000374-Mp for guix-patches@gnu.org; Sat, 15 Jan 2022 20:31:15 -0500 Received: from smtp202.mailbox.org (smtp202.mailbox.org [80.241.60.245]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4JbyDH0Y2lzQk9y for ; Sun, 16 Jan 2022 02:31:11 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reilysiegel.com; s=MBO0001; t=1642296669; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=OhEdp9U6NE50rA2DWJFEorpH56JQ+lKxJzM8Awzikwo=; b=SGtLo/g1relnQQjDffaRmwPZnYArqMRE06nFC/pD0WiqPOjXewbfa3zum16TQTt4Ui3Dhv 2eT6hkp+lIIgZCXJ1GH1m/mY5bkGXfhxt/Z/cpIlh+zlQcENaGLYLe110BpOTEqNaRUMCa 095QOJCvHUpD+JRN6hiQHaPTZg3zTZguwU/aR02NzHKBEMJHv7TH4ONI3HP+13WOT+svUO tzpma8t3BbpU4C/zovBr6gvRNNRgKcESRDfG8cOyQWIT0iOp9F4ekNLEYzVW4mDtk0m8x6 hFMdlyaLqn/BSYpsp2V+lQuljfAb39m05Rga+LAmtMiZIayQIQs4DmZJKg0dFA== From: Reily Siegel Date: Sat, 15 Jan 2022 20:31:02 -0500 Message-ID: <87pmosii09.fsf@reilysiegel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=80.241.56.171; envelope-from=mail@reilysiegel.com; helo=mout-p-201.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/build/clojure-build-system.scm (compile-java): New variable. * guix/build/clojure-build-system.scm (build): Copy classes compiled from Java and optionally Java sources to the final jar. * guix/build/clojure-build-system.scm (%standard-phases): Add compile-java phase before build. * guix/build/clojure-utils.scm (%java-source-dirs): New variable. * guix/build/clojure-utils.scm (%java-compile-dir): New variable. * guix/build-system/clojure.scm (clojure-build): Include %java-source-dirs and %java-compile-dir. * guix/build-system/clojure.scm (builder): Include %java-source-dirs and %java-compile-dir. --- guix/build-system/clojure.scm | 6 ++++- guix/build/clojure-build-system.scm | 36 +++++++++++++++++++++++------ guix/build/clojure-utils.scm | 10 ++++++++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/guix/build-system/clojure.scm b/guix/build-system/clojure.scm index 634854cf1b..2a0713d297 100644 --- a/guix/build-system/clojure.scm +++ b/guix/build-system/clojure.scm @@ -107,8 +107,10 @@ (define* (clojure-build name inputs #:key source (source-dirs `',%source-dirs) + (java-source-dirs `',%java-source-dirs) (test-dirs `',%test-dirs) (compile-dir %compile-dir) + (java-compile-dir %java-compile-dir) (jar-names `',(package-name->jar-names name)) (main-class %main-class) @@ -142,9 +144,11 @@ (define builder #:source #+source #:source-dirs #$source-dirs + #:java-source-dirs #$java-source-dirs #:test-dirs #$test-dirs #:compile-dir #$compile-dir - + #:java-compile-dir #$java-compile-dir + #:jar-names #$jar-names #:main-class #$main-class #:omit-source? #$omit-source? diff --git a/guix/build/clojure-build-system.scm b/guix/build/clojure-build-system.scm index dd01f95de8..22e90581a5 100644 --- a/guix/build/clojure-build-system.scm +++ b/guix/build/clojure-build-system.scm @@ -34,8 +34,24 @@ (define-module (guix build clojure-build-system) ;; ;; Code: +(define* (compile-java #:key + java-source-dirs java-compile-dir + #:allow-other-keys) + "Compile java sources for use in clojure-build-system." + (let ((java-files (append-map (lambda (dir) + (find-files dir "\\.java$")) + java-source-dirs))) + (mkdir-p java-compile-dir) + (when (not (eq? java-files '())) + (apply invoke + "javac" + "-verbose" + "-d" java-compile-dir + java-files)))) + (define* (build #:key - source-dirs compile-dir + source-dirs java-source-dirs + compile-dir java-compile-dir jar-names main-class omit-source? aot-include aot-exclude #:allow-other-keys) @@ -46,19 +62,24 @@ (define* (build #:key #:all-list libs))) (mkdir-p compile-dir) (eval-with-clojure `(run! compile ',libs*) - source-dirs) + (cons* compile-dir + java-compile-dir + source-dirs)) (let ((source-dir-files-alist (map (lambda (dir) (cons dir (find-files* dir))) - source-dirs)) + (append source-dirs + java-source-dirs))) ;; workaround transitive compilation in Clojure (classes (filter (lambda (class) (any (cut compiled-from? class <>) libs*)) (find-files* compile-dir)))) - (for-each (cut create-jar <> (cons (cons compile-dir classes) - (if omit-source? - '() - source-dir-files-alist)) + (for-each (cut create-jar <> (cons* (cons compile-dir classes) + (cons java-compile-dir + (find-files* java-compile-dir)) + (if omit-source? + '() + source-dir-files-alist)) #:main-class main-class) jar-names) #t))) @@ -94,6 +115,7 @@ (define-with-docs install (define-with-docs %standard-phases "Standard build phases for clojure-build-system." (modify-phases %standard-phases@ant + (add-before 'build 'compile-java compile-java) (replace 'build build) (replace 'check check) (replace 'install install) diff --git a/guix/build/clojure-utils.scm b/guix/build/clojure-utils.scm index 8817cab52a..c5322141d3 100644 --- a/guix/build/clojure-utils.scm +++ b/guix/build/clojure-utils.scm @@ -32,8 +32,10 @@ (define-module (guix build clojure-utils) install-doc %source-dirs + %java-source-dirs %test-dirs %compile-dir + %java-compile-dir package-name->jar-names %main-class %omit-source? @@ -101,6 +103,10 @@ (define-with-docs %source-dirs "A default list of source directories." '("src/")) +(define-with-docs %java-source-dirs + "A default list of java source directories." + '()) + (define-with-docs %test-dirs "A default list of test directories." '("test/")) @@ -109,6 +115,10 @@ (define-with-docs %compile-dir "Default directory for holding class files." "classes/") +(define-with-docs %java-compile-dir + "Default directory for holding java class files." + "java-classes/") + (define (package-name->jar-names name) "Given NAME, a package name like \"foo-0.9.1b\", return the list of default jar names: (\"foo-0.9.1b.jar\" \"foo.jar\")."