From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yDuhGdoOwmB6TAEAgWs5BA (envelope-from ) for ; Thu, 10 Jun 2021 15:08:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qH0kFdoOwmA3BwAA1q6Kng (envelope-from ) for ; Thu, 10 Jun 2021 13:08:42 +0000 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 6BA2821008 for ; Thu, 10 Jun 2021 15:08:40 +0200 (CEST) Received: from localhost ([::1]:48552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrKQJ-0006Ph-BQ for larch@yhetil.org; Thu, 10 Jun 2021 09:08:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrGFK-0004uC-Es for guix-patches@gnu.org; Thu, 10 Jun 2021 04:41:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52145) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lrGFK-0005iY-76 for guix-patches@gnu.org; Thu, 10 Jun 2021 04:41:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lrGFK-00019X-6D for guix-patches@gnu.org; Thu, 10 Jun 2021 04:41:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48943] [PATCH] import: hackage: Support "common" field and imports Resent-From: Philip Munksgaard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Jun 2021 08:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48943 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48943@debbugs.gnu.org Cc: Philip Munksgaard X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16233144104356 (code B ref -1); Thu, 10 Jun 2021 08:41:02 +0000 Received: (at submit) by debbugs.gnu.org; 10 Jun 2021 08:40:10 +0000 Received: from localhost ([127.0.0.1]:35458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrGER-000189-8f for submit@debbugs.gnu.org; Thu, 10 Jun 2021 04:40:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:49788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrGEO-00017y-ER for submit@debbugs.gnu.org; Thu, 10 Jun 2021 04:40:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrGEN-0003L8-EZ for guix-patches@gnu.org; Thu, 10 Jun 2021 04:40:04 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:39073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrGEL-0004rT-2M for guix-patches@gnu.org; Thu, 10 Jun 2021 04:40:03 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 1E01323AA; Thu, 10 Jun 2021 04:39:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 10 Jun 2021 04:39:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=munksgaard.me; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=fWxxxNzpitI2voLccz4LZT1sCa WWVUvr+Nl+B8eF5r4=; b=XWyAsa1CIs20yqHm1l235WI4ZVAJIRjNoPZNWfsoWH l2oNHb6/dg8u3XFgLz1ur02JAeXMgx0XqBrCYO/EEa7Qio2d72TrC2IveZ9V1pel MVDZtwaNI25SKOotvP1jmr9Est+I0fYUYr1jnfFNvIhRhAdObGBJiebYyZHVRHEk 9AlcIJBM3D3CxRrHvxKck2yHFqkekHp34Ptf1UTIeSJuwrBatB9H5MMRir31X55x VsGbwgnnAlvG050d4P+gFHVozR1BmOKSrgabc6DBDf8/uXzlPr7PqI3+zsHl9j+i wBjxwV/dkW5VHeyisZiNN5JZRRMBZT55X/cmt8WuUSzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=fWxxxNzpitI2voLcc z4LZT1sCaWWVUvr+Nl+B8eF5r4=; b=neDSyKh4gWkziwwZom9UpjREQ1jCxsvoL Xdvgkf1JTCdGAAYQ+kcHwd0spQ2BgM6kH4KLt5bsLrEovXOJeaRSHUaDqJHX6kx+ TFqN3M5feiZHpyqmDsM/sIVSKZjsBot1E6feTOnwGMXjklVhAnHef5TQ8ZNjE1PQ 8cl65Qry5p+v4KMlJQ8v+5oWSe6htPM47a8hVvQdr7FGzo9m7Fmf88QTsfrEKDn9 LgfeJOEQL40zPjUxs6Q3gl1g0C852pXvXoLewn/bOXzUHVHznSuApGE68OcWBbh0 a3RTwQQO0bTHn0Ge+QczMS/T8+et/m4td22WvXEQFalyp8JHKs2eg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedufedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheprfhhihhlihhpucfouhhnkhhsghgrrghrugcuoehphhhilhhiphes mhhunhhkshhgrggrrhgurdhmvgeqnecuggftrfgrthhtvghrnhepjedtjeduudevfeffve ejgedtgeeutedutedvteekteffgfffffffgfeuffetgefhnecuffhomhgrihhnpehgnhhu rdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epphhhihhlihhpsehmuhhnkhhsghgrrghrugdrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 10 Jun 2021 04:39:55 -0400 (EDT) From: Philip Munksgaard Date: Thu, 10 Jun 2021 10:39:53 +0200 Message-Id: <20210610083953.664318-1-philip@munksgaard.me> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.147.123.20; envelope-from=philip@munksgaard.me; helo=wout4-smtp.messagingengine.com 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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Mailman-Approved-At: Thu, 10 Jun 2021 09:08:35 -0400 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1623330522; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=fWxxxNzpitI2voLccz4LZT1sCaWWVUvr+Nl+B8eF5r4=; b=UtPVvAKO93n2PsmrtiZMLhQiANf5TUVrVFHbwrO5y5T+3f0hEGKKoUQFSocNanw3Nndz+3 FpMG70haC6KeWQ0gtuyuOAkptC81lTPtHnAq2sZ6nFRmXSo2xTqy471pPz5+24Z4w2Wj02 O1/doZaGRfyYhegOAZDDR3NjxNQc4CJsZSSx2hP36mbrBPfQMhF5a5Pyd3sIjQ1KPzLwcN OdrwEOIjPNFyVtGMMv3xqDm/ztHlzEiRD9+EMbkDExFtdDK1meDT1jMDAHWQd3qSbZZSM3 SEPTxZoocJ4XinUgeLCStPBIRtMlX/V+RNe28kbvTAgGxsBcKfCW9D0g+D6WjA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1623330522; a=rsa-sha256; cv=none; b=HpZOiFOh+XNB5iFPV5A7kgyvROnX+sesIxSAgMGZtmg2Q9B5Xhj12Hpe4xKKFn9QtA5lDq ZitPOp4OZ7BM7S+AUyL2+V/ifN/jm8jBrZqOUioGzvFJ62vAmH6wSy2sPPYrraHpZUhG5Y odWmSZmixCaZAR4ZpfPZOk/atyaIVkuwm5G9dtoQqoJY4G2Qz2rlIyazMGjM2RquX8zBR1 e+nK9Mbu2BdABWcThBaFdWKuixHUZoiJK8B3uCk0coc3PpJ2Gm4lVNFJkjZ/zYK7Tw0SwL si3gEOc/RfuS32xy2sO6+9f/pcdDOKPd7S9sWtvWDaRCYOsfmUTxT7iGHMtk+Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=munksgaard.me header.s=fm1 header.b=XWyAsa1C; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm3 header.b=neDSyKh4; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 3.57 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=munksgaard.me header.s=fm1 header.b=XWyAsa1C; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm3 header.b=neDSyKh4; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 6BA2821008 X-Spam-Score: 3.57 X-Migadu-Scanner: scn0.migadu.com X-TUID: fG0EYN3IRrIV Fixes . * guix/import/cabal.scm (make-cabal-parser): Modify. (is-common): New variable. (lex-common): New procedure. (is-id): Modify. (eval-cabal): Modify. --- guix/import/cabal.scm | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index da00019297..22b5d164d0 100644 --- a/guix/import/cabal.scm +++ b/guix/import/cabal.scm @@ -145,7 +145,7 @@ to the stack." (lalr-parser ;; --- token definitions (CCURLY VCCURLY OPAREN CPAREN TEST ID VERSION RELATION TRUE FALSE -ANY -NONE - (right: IF FLAG EXEC TEST-SUITE CUSTOM-SETUP SOURCE-REPO BENCHMARK LIB OCURLY) + (right: IF FLAG EXEC TEST-SUITE CUSTOM-SETUP SOURCE-REPO BENCHMARK LIB COMMON OCURLY) (left: OR) (left: PROPERTY AND) (right: ELSE NOT)) @@ -155,6 +155,7 @@ to the stack." (sections source-repo) : (append $1 (list $2)) (sections executables) : (append $1 $2) (sections test-suites) : (append $1 $2) + (sections common) : (append $1 $2) (sections custom-setup) : (append $1 $2) (sections benchmarks) : (append $1 $2) (sections lib-sec) : (append $1 (list $2)) @@ -178,6 +179,10 @@ to the stack." (ts-sec) : (list $1)) (ts-sec (TEST-SUITE OCURLY exprs CCURLY) : `(section test-suite ,$1 ,$3) (TEST-SUITE open exprs close) : `(section test-suite ,$1 ,$3)) + (common (common common-sec) : (append $1 (list $2)) + (common-sec) : (list $1)) + (common-sec (COMMON OCURLY exprs CCURLY) : `(section common ,$1 ,$3) + (COMMON open exprs close) : `(section common ,$1 ,$3)) (custom-setup (CUSTOM-SETUP exprs) : (list `(section custom-setup ,$1 ,$2))) (benchmarks (benchmarks bm-sec) : (append $1 (list $2)) (bm-sec) : (list $1)) @@ -367,6 +372,9 @@ matching a string against the created regexp." (define is-test-suite (make-rx-matcher "^test-suite +([a-z0-9_-]+)" regexp/icase)) +(define is-common (make-rx-matcher "^common +([a-z0-9_-]+)" + regexp/icase)) + (define is-custom-setup (make-rx-matcher "^(custom-setup)" regexp/icase)) @@ -394,7 +402,7 @@ matching a string against the created regexp." (define (is-id s port) (let ((cabal-reserved-words '("if" "else" "library" "flag" "executable" "test-suite" "custom-setup" - "source-repository" "benchmark")) + "source-repository" "benchmark" "common")) (spaces (read-while (cut char-set-contains? char-set:blank <>) port)) (c (peek-char port))) (unread-string spaces port) @@ -469,6 +477,8 @@ string with the read characters." (define (lex-test-suite ts-rx-res loc) (lex-rx-res ts-rx-res 'TEST-SUITE loc)) +(define (lex-common common-rx-res loc) (lex-rx-res common-rx-res 'COMMON loc)) + (define (lex-custom-setup ts-rx-res loc) (lex-rx-res ts-rx-res 'CUSTOM-SETUP loc)) (define (lex-benchmark bm-rx-res loc) (lex-rx-res bm-rx-res 'BENCHMARK loc)) @@ -570,6 +580,7 @@ the current port location." ((is-src-repo s) => (cut lex-src-repo <> loc)) ((is-exec s) => (cut lex-exec <> loc)) ((is-test-suite s) => (cut lex-test-suite <> loc)) + ((is-common s) => (cut lex-common <> loc)) ((is-custom-setup s) => (cut lex-custom-setup <> loc)) ((is-benchmark s) => (cut lex-benchmark <> loc)) ((is-lib s) (lex-lib loc)) @@ -796,7 +807,16 @@ the ordering operation and the version." (let ((value (or (assoc-ref env name) (assoc-ref (cabal-flags->alist (cabal-flags)) name)))) (if (eq? value 'false) #f #t))) + + (define common-stanzas + (filter-map (cut match <> + (('section 'common common-name common) + (cons common-name common)) + (_ #f)) + cabal-sexp)) + (define (eval sexp) + "Given an SEXP and an ENV, return the evaluated (SEXP . ENV)." (match sexp (() '()) ;; nested 'if' @@ -831,6 +851,9 @@ the ordering operation and the version." (list 'section type name (eval parameters))) (((? string? name) values) (list name values)) + ((("import" imports) rest ...) + (eval (append (append-map (cut assoc-ref common-stanzas <>) imports) + rest))) ((element rest ...) (cons (eval element) (eval rest))) (_ (raise (condition -- 2.31.1