From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CBQcBBgF52FVgQAAgWs5BA (envelope-from ) for ; Tue, 18 Jan 2022 19:21:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 4Ll4OBcF52EM3AAAG6o9tA (envelope-from ) for ; Tue, 18 Jan 2022 19:21:11 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5E2C03FF10 for ; Tue, 18 Jan 2022 19:21:11 +0100 (CET) Received: from localhost ([::1]:52334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9t6U-0002dS-HU for larch@yhetil.org; Tue, 18 Jan 2022 13:21:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9t3S-0001la-Le for guix-patches@gnu.org; Tue, 18 Jan 2022 13:18:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:58758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n9t3R-0007Fa-Ni for guix-patches@gnu.org; Tue, 18 Jan 2022 13:18:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n9t3R-0000lC-Hi for guix-patches@gnu.org; Tue, 18 Jan 2022 13:18:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53292] [PATCH v2] build: clojure-build-system: Support compiling Java References: <87pmosii09.fsf@reilysiegel.com> In-Reply-To: <87pmosii09.fsf@reilysiegel.com> Resent-From: Reily Siegel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 18 Jan 2022 18:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53292 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53292@debbugs.gnu.org Cc: Maxime Devos Received: via spool by 53292-submit@debbugs.gnu.org id=B53292.16425298642895 (code B ref 53292); Tue, 18 Jan 2022 18:18:01 +0000 Received: (at 53292) by debbugs.gnu.org; 18 Jan 2022 18:17:44 +0000 Received: from localhost ([127.0.0.1]:51661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n9t39-0000kc-R5 for submit@debbugs.gnu.org; Tue, 18 Jan 2022 13:17:44 -0500 Received: from mout-p-102.mailbox.org ([80.241.56.152]:24302) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n9t34-0000kK-TU for 53292@debbugs.gnu.org; Tue, 18 Jan 2022 13:17:42 -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-102.mailbox.org (Postfix) with ESMTPS id 4JdcSX2NXVzQjx8; Tue, 18 Jan 2022 19:17:32 +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=1642529850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=L9m+SPlW6Cc+HK1OQ+1DvfNdm6LB8P9NeTaBrBojnqs=; b=NlG5Sx429nptwiF+3RaTQVbNbCweGjWXI2CMjQZp8Wvrpodal92nJMYDRY/Vyhge08rrVf gjVSBOvRvSAXG5ilj/PUMkMSzK9OUQQ5f/8UqEYFiErsFvdKRlJuwx9pthuo4WODWjedth 7L1l066nF18kIEE8j5OCr1QD3iqv2AoYYrIj0q76mu+LtOIeaR6GTuy+6gNmA3H717NzUE aDkpgvT4HsXTsmkB6tB45dqJzmDiYwpaO5RQtTZGeMTFlmcV8SmbYEhg2TEZiXkV2u7JW2 S27SZ6d58fYGJYGkuOlKSq8zcoRxHUbzwV9/VqNgqZWRy7he7J2cjOMdnKZ7OQ== From: Reily Siegel Date: Tue, 18 Jan 2022 13:17:24 -0500 Message-ID: <8735lkzz63.fsf@reilysiegel.com> MIME-Version: 1.0 Content-Type: text/plain 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1642530071; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=L9m+SPlW6Cc+HK1OQ+1DvfNdm6LB8P9NeTaBrBojnqs=; b=dBnUg+Ou0Lg5gaagIZGHkWcP6TCft9FWIYW1ePV2BaA/LgvXMKAu30B6GlC9APEQaoIMRN WYFdARNaoeJ6nmFCq9lvTC0uv0mYJe52jzoquWAdzg9A0LdfQif09njA84bcUKK+f7dvTL z4AMnJuG7hqqPoITVSltP5cAg3ZOD6xvLg5t/yKHKmCZH/KcuTNZs0+p+yD4ID19+Do8B/ 3fFTNsogGcQ4YXyRtwUJauZV2Qu2zRt9HQx4iFhHZtub5MEEfz0dKn7qxS4alZhWoPfLKl 5+/nVgr/513G57QN+I8kd2YNUF//vQPgOfgnP+7t1KzHGMevyw/JislMz0RgNQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642530071; a=rsa-sha256; cv=none; b=Bkau06QZshF6oXhoRSpt4l91wrGvtplKjIc/LC/qgjE5fkQRVmnINUvLAGIxwC1U1AYTXQ iY57HP2wZpXydFp+bSoqDm9LYu2slB6MC0xeSDfMZjN36F2s9OOUAmI/9vgSzOUb/Qb/m0 sxaUu0PEPtxyUU5DG79ZRn04RSZE6GcswGEmyQqaYoQFhqyEqdLN0LuzmKI2eCE/sq168I l+ypvZaiEzS+eBtcjWIjBv60XN9QsH/+8hyT8aGWKFJ5jXJgS6/bttsoxAvg4jYfW71xQR oKolR3n5xhaPToQpZ5B0fq1JiuxLI5DYrNAC0LwtibQGZaanfkBWQLf9h0JZ2g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=reilysiegel.com header.s=MBO0001 header.b=NlG5Sx42; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=reilysiegel.com header.s=MBO0001 header.b=NlG5Sx42; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 5E2C03FF10 X-Spam-Score: -2.32 X-Migadu-Scanner: scn1.migadu.com X-TUID: h20WAIWGpRd5 * 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..7d494078ea 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 (null? 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\")." -- 2.34.0