From patchwork Tue Aug 9 18:26:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liliana Marie Prikler X-Patchwork-Id: 41936 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 458F227BBEA; Thu, 25 Aug 2022 08:31:25 +0100 (BST) 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_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS 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 DE41F27BBE9 for ; Thu, 25 Aug 2022 08:31:24 +0100 (BST) Received: from localhost ([::1]:44396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oR7Km-0000K1-2e for patchwork@mira.cbaines.net; Thu, 25 Aug 2022 03:31:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oR7Ee-0004T9-Mn for guix-patches@gnu.org; Thu, 25 Aug 2022 03:25:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59012) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oR7Ee-0006Lo-DX for guix-patches@gnu.org; Thu, 25 Aug 2022 03:25:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oR7Ee-0000BU-9I for guix-patches@gnu.org; Thu, 25 Aug 2022 03:25:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57086] [PATCH v3 5/7] guix: emacs-utils: Add emacs-compile-directory. References: <4c232648145659a2c3edca6d32725d8120cc14d3.camel@gmail.com> In-Reply-To: <4c232648145659a2c3edca6d32725d8120cc14d3.camel@gmail.com> Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 25 Aug 2022 07:25:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57086 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57086@debbugs.gnu.org Received: via spool by 57086-submit@debbugs.gnu.org id=B57086.1661412291626 (code B ref 57086); Thu, 25 Aug 2022 07:25:04 +0000 Received: (at 57086) by debbugs.gnu.org; 25 Aug 2022 07:24:51 +0000 Received: from localhost ([127.0.0.1]:48751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oR7ER-0000A1-3g for submit@debbugs.gnu.org; Thu, 25 Aug 2022 03:24:51 -0400 Received: from mail-ej1-f66.google.com ([209.85.218.66]:38665) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oR7ED-00008V-0H for 57086@debbugs.gnu.org; Thu, 25 Aug 2022 03:24:37 -0400 Received: by mail-ej1-f66.google.com with SMTP id u9so8825507ejy.5 for <57086@debbugs.gnu.org>; Thu, 25 Aug 2022 00:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:content-transfer-encoding:to:subject:date :from:from:to:cc; bh=JbthDGXXHfxjli2NIWJGjYdprZIFZnZlZXQcKcM5itU=; b=PfSI7QtZn0Q6x49Vf23OWxfMGxcsl72O2H1HKWV1+D7KhnD7bH/59tDckgOqvVhduf XbXDUEFIwKVOx0RzAbyIKxftQC6vzoHNxsRRNSfs2F8TSVlgXxX4byoe5ZWf7TXzNDMD BKFJh4+HtmORt4qIROnMlGavrBfpHJTzaABhST4sOUE9ldLKT+62C5ymm099FNzgRDTs Gcc3TvbtpFTA2wT8d87UI6oVzPRU1AZYDZQJyTli26XuDpnsGFnASWBmMhtlu2nt4mxe 5n1ZdTBEUcHHuaPJZVGRWaeE4RRvjB2bgefLz9ipSu8ypiDIDMValcyGR6luup+Ycc/Q loUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:content-transfer-encoding:to:subject:date :from:x-gm-message-state:from:to:cc; bh=JbthDGXXHfxjli2NIWJGjYdprZIFZnZlZXQcKcM5itU=; b=NaMtItSBo/mvlIc8aN/8+mSWST7srbh2VMXM25ha/O4rr3LhoxKftpNZ2qbs7uGnok JKxVbTd5s/usB62NBcwmx0fD6eKhJNf2vfBt4xA45ok/yBbtkEzllVSpt1wBIpM+k5ku W2eF+QQYrtdjngEcJQ0V4WvxBbD48DinuT4l9tXwofMoimqjqNtZh3FQzi5jteqTgV6n RlgMumSzMZxsv97mF9Y+bzRp+chCrk23Ypjoq1/nnepEWMxRQxaNJucynnS7+RQzSRg1 U6SV2a21g2ql3uqstjnunNeXSVIIvy+f5IGu/G/3tUKT5t4bQsdeK3htAj6+Ia5tgzAe JzpQ== X-Gm-Message-State: ACgBeo1fGB5ONGV6WUumnO0NKHRDkCEVs7PzjklFwti30QdZ0uNh2YOR Q/J656/nmFVS5SqoHLOPsEdaoui5/uk= X-Google-Smtp-Source: AA6agR7AgdUkjy0hlZoyq2pE0uTC6NBLWIs3Pl751JBQ1yLlq5uJP8VZFaeH+W3l4vuMeMmM1Z+EmA== X-Received: by 2002:a17:906:58c9:b0:73c:37bb:c4d4 with SMTP id e9-20020a17090658c900b0073c37bbc4d4mr1556523ejs.467.1661412271493; Thu, 25 Aug 2022 00:24:31 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id g2-20020a170906538200b0073d62cc3270sm2019690ejo.118.2022.08.25.00.24.30 for <57086@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 00:24:30 -0700 (PDT) From: Liliana Marie Prikler Date: Tue, 9 Aug 2022 20:26:06 +0200 Message-ID: <3854e9646995cc34c07f92e27c949753ce7d6c5f.camel@gmail.com> MIME-Version: 1.0 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/emacs-utils.scm (emacs-compile-directory): New variable. --- guix/build/emacs-utils.scm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm index 8ee547f2b3..fdca05602e 100644 --- a/guix/build/emacs-utils.scm +++ b/guix/build/emacs-utils.scm @@ -38,6 +38,7 @@ (define-module (guix build emacs-utils) emacs-generate-autoloads emacs-byte-compile-directory + emacs-compile-directory emacs-header-parse as-display @@ -115,6 +116,35 @@ (define* (emacs-byte-compile-directory dir) (byte-recompile-directory (file-name-as-directory ,dir) 0 1)))) (emacs-batch-eval expr))) +(define* (emacs-compile-directory dir) + "Compile all files in DIR to native code. + +If native code is not supported, compile to bytecode instead." + (emacs-batch-eval + `(let ((byte-compile-debug t) ; for proper exit status + (byte+native-compile (native-comp-available-p)) + (files (directory-files-recursively ,dir "\\.el$"))) + (mapc + (lambda (file) + (let (byte-to-native-output-file + ;; First entry is the eln-cache of the homeless shelter, + ;; second entry is the install directory. + (eln-dir (and (native-comp-available-p) + (cadr native-comp-eln-load-path)))) + (if byte+native-compile + (native-compile file + (comp-el-to-eln-filename file eln-dir)) + (byte-compile-file file)) + ;; Sadly, we can't use pcase because quasiquote works different in + ;; Emacs. See `batch-byte+native-compile' in comp.el for the + ;; actual shape of byte-to-native-output-file. + (unless (null byte-to-native-output-file) + (rename-file (car byte-to-native-output-file) + (cdr byte-to-native-output-file) + t)))) + files)) + #:dynamic? #t)) + (define (emacs-header-parse section file) "Parse the header SECTION in FILE and return it as a string." (emacs-batch-script