From patchwork Fri Dec 22 12:37:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jean-Pierre De Jesus DIAZ X-Patchwork-Id: 57985 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 6AD2027BBEA; Fri, 22 Dec 2023 12:38:43 +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,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 3E63E27BBE2 for ; Fri, 22 Dec 2023 12:38:42 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGemu-0007JZ-Tc; Fri, 22 Dec 2023 07:38:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGems-0007Hu-O5 for guix-patches@gnu.org; Fri, 22 Dec 2023 07:37:58 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGems-0005VE-FL for guix-patches@gnu.org; Fri, 22 Dec 2023 07:37:58 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rGemw-0001ve-VR for guix-patches@gnu.org; Fri, 22 Dec 2023 07:38:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67969] [PATCH 3/4] gnu: make-nsis: Use cross-compilation. Resent-From: Jean-Pierre De Jesus DIAZ Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 22 Dec 2023 12:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67969 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67969@debbugs.gnu.org Cc: Jean-Pierre De Jesus DIAZ Received: via spool by 67969-submit@debbugs.gnu.org id=B67969.17032486697373 (code B ref 67969); Fri, 22 Dec 2023 12:38:02 +0000 Received: (at 67969) by debbugs.gnu.org; 22 Dec 2023 12:37:49 +0000 Received: from localhost ([127.0.0.1]:46205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGemj-0001uq-3u for submit@debbugs.gnu.org; Fri, 22 Dec 2023 07:37:49 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:51562) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGemY-0001tr-Lr for 67969@debbugs.gnu.org; Fri, 22 Dec 2023 07:37:44 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-336788cb261so1410234f8f.3 for <67969@debbugs.gnu.org>; Fri, 22 Dec 2023 04:37:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundationdevices.com; s=google; t=1703248648; x=1703853448; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OiJZxhiPmD5TSnGOvrqnjf5LBWd1lgh0s7Szkv6H0j8=; b=YXCnvgGeXUlCvdUBwc26b5l1pAFaQA/fK3AjWedi1sQceY5JxGrxwZDVip47CpaoTr tE9SDR7nRQORvvPUnnefrY8pikDR4lpE5hbuD1aFPYzn3hnCks6UCN8NiG4Ior2M/2F5 kDNYrvFTeaDEYoS2zoPSmzKl3yShzbTXx4NShGAS9L5tCIYfjD90Cb0s+uejHdhPoOBW F4SoDYvsb1+SW29X6GzhuLi5HFwGTihFAdnlI4P55ztEX0j60qNl+tUddx0DhhQcru29 f9s9M0984Wmw6SkQPe/G99JGAqM9Af/W8+MRruxslRunlfU3TzA97lKx/qCIu8kzJaTT PQPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703248648; x=1703853448; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OiJZxhiPmD5TSnGOvrqnjf5LBWd1lgh0s7Szkv6H0j8=; b=DDvtBsbNx/r7uVcCEULcut6D5u3DjURHW0bNv3Suz2AUZeVhLv/WAmDYCImPE+stjv 8A3RtEes9wgJel0shMvNYhMMHQoevTs4bR/P/PXlpl7GOt1rDsdY6vchiqTYvDSm6lFr +OAW4570M4Yq5Dz+DM8QcvNXNzBREb9BdQwy3eCDFDtowiEfTP9bTHmbSsLmJREkvFYI uuB3ew1ny4qwXCeIKpcqU80qvO6yxPbPb8mLZDp666cCThq5wJKBUZsx2/MdYQAU0nAV /GjnOVFLuZSiEnGvVez4B+wgmCiVneeq6iEeMCD6T6bnWsl1yBdOmz3w1siDNgL+XZV4 a0qQ== X-Gm-Message-State: AOJu0Yypx33hDZstKTCLV5IO8xknbrQh+8LNBvHXXftUlhEes090E32c +/ZylPfK3rnH+Rj2w/CB8RZRUDwf84bjq6uj/RzHtatl9cGQow== X-Google-Smtp-Source: AGHT+IGrlNq+yJhs7ocBiVGWx3nGMkll3FLWMZKAW6qbsr7j/ipyDdH7K6oEI51J1sTQguONZLLPfQ== X-Received: by 2002:a5d:6484:0:b0:336:62c1:d0af with SMTP id o4-20020a5d6484000000b0033662c1d0afmr786921wri.60.1703248647834; Fri, 22 Dec 2023 04:37:27 -0800 (PST) Received: from jeandudey.home ([89.131.29.87]) by smtp.gmail.com with ESMTPSA id s23-20020adf9797000000b00336813bb588sm4258959wrb.111.2023.12.22.04.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 04:37:27 -0800 (PST) Date: Fri, 22 Dec 2023 13:37:16 +0100 Message-ID: <6e3555889a02b74964be90697fe6f344f7d14615.1703248242.git.jean@foundationdevices.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: 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: , Reply-to: Jean-Pierre De Jesus DIAZ X-ACL-Warn: , Jean-Pierre De Jesus DIAZ via Guix-patches X-Patchwork-Original-From: Jean-Pierre De Jesus DIAZ via Guix-patches via From: Jean-Pierre De Jesus DIAZ Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/installers.scm (make-nsis): Use `#:target' keyword argument in order to cross-compile the package. Change-Id: I403254a08f43bcd21e475807ea592c2f3908ff6b --- gnu/packages/installers.scm | 123 +++++++++++------------------------- 1 file changed, 37 insertions(+), 86 deletions(-) diff --git a/gnu/packages/installers.scm b/gnu/packages/installers.scm index 9879359be7..67e91b908d 100644 --- a/gnu/packages/installers.scm +++ b/gnu/packages/installers.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Carl Dong +;;; Copyright © 2023 Foundation Devices, Inc. ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,17 +22,14 @@ (define-module (gnu packages installers) #:use-module (gnu packages) #:use-module (gnu packages build-tools) #:use-module (gnu packages compression) - #:use-module (gnu packages cross-base) #:use-module (guix packages) #:use-module (guix download) + #:use-module (guix gexp) #:use-module (guix build-system scons) #:use-module (guix utils)) (define (make-nsis machine target-arch nsis-target-type) - (let* ((triplet (string-append machine "-" "w64-mingw32")) - (xbinutils (cross-binutils triplet)) - (xlibc (cross-libc triplet)) - (xgcc (cross-gcc triplet #:libc xlibc))) + (let ((target (string-append machine "-" "w64-mingw32"))) (package (name (string-append "nsis-" machine)) (version "3.09") @@ -44,88 +42,41 @@ (define (make-nsis machine target-arch nsis-target-type) "1qjnvhnj89a40ac10k2mbln0yqscdmawmgw71816i465x734dn0c")) (patches (search-patches "nsis-env-passthru.patch")))) (build-system scons-build-system) - (native-inputs `(("xgcc" ,xgcc) - ("xbinutils" ,xbinutils) - ("mingw-w64" ,xlibc))) - (inputs (list zlib)) (arguments - `(#:scons ,scons-python2 - #:modules ((srfi srfi-1) - (srfi srfi-26) - (guix build utils) - (guix build scons-build-system)) - #:tests? #f - #:scons-flags `("UNICODE=yes" - "SKIPUTILS=MakeLangId,Makensisw,NSIS Menu,SubStart,zip2exe" - "SKIPDOC=COPYING" - "STRIP_CP=no" - ,(string-append "PREFIX=" %output) - ,(string-append "TARGET_ARCH=" ,target-arch) - ,(string-append "XGCC_W32_PREFIX=" ,triplet "-") - ,(string-append "PREFIX_PLUGINAPI_INC=" (assoc-ref %build-inputs "mingw-w64") "/include/") - ,(string-append "PREFIX_PLUGINAPI_LIB=" (assoc-ref %build-inputs "mingw-w64") "/lib/")) - #:build-targets '("makensis" - "stubs" - "plugins" - "utils") - #:install-targets '("install-stubs" - "install-plugins" - "install-data" - "install-utils" - "install-compiler" - "install-conf") - #:phases (modify-phases %standard-phases - (add-before 'build 'fix-env - (lambda _ - (define* (filter-delimited-string delimited-string predicate #:optional (delimiter #\:)) - ;; Given a DELIMITED-STRING delimited by DELIMITER, - ;; only keep items that satisfy PREDICATE - (string-join - (filter predicate (string-split delimited-string delimiter)) - (string delimiter))) - (define (mingw-path? path) - (string-prefix? (assoc-ref %build-inputs "mingw-w64") path)) - (for-each - (lambda (env-name) - (let ((env-val (getenv env-name))) - ;; Remove all mingw-w64 paths from env vars meant - ;; for native toolchain - (setenv env-name - (filter-delimited-string env-val (negate mingw-path?))) - ;; Add the removed paths back into CROSS_-prefixed - ;; version of env vars - (setenv (string-append "CROSS_" env-name) - (filter-delimited-string env-val mingw-path?)))) - '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH" "LIBRARY_PATH")) - ;; Hack to place mingw-w64 path at the end of search - ;; paths. Could probably use a specfile and dirafter - (setenv "CROSS_C_INCLUDE_PATH" - (string-join - `(,@(map (cut string-append - (assoc-ref %build-inputs "xgcc") - "/lib/gcc/" ,triplet "/" - ,(package-version xgcc) <>) - '("/include" - "/include-fixed")) - ,(getenv "CROSS_C_INCLUDE_PATH")) - ":")) - (setenv "CROSS_CPLUS_INCLUDE_PATH" - (string-join - `(,@(map (cut string-append (assoc-ref %build-inputs "xgcc") <>) - `("/include/c++" - ,(string-append "/include/c++/" ,triplet) - "/include/c++/backward" - ,@(map (cut string-append "/lib/gcc/" ,triplet "/" ,(package-version xgcc) <>) - '("/include" - "/include-fixed")))) - ,(getenv "CROSS_CPLUS_INCLUDE_PATH")) - ":")))) - (add-before 'build 'fix-target-detection - (lambda _ - ;; NSIS target detection is screwed up, manually change - ;; it ourselves - (substitute* "Source/build.cpp" (("m_target_type=TARGET_X86UNICODE") - (string-append "m_target_type=" ,nsis-target-type)))))))) + (list #:target target + #:scons scons-python2 + #:tests? #f + #:scons-flags + #~(let ((xlibc (assoc-ref %build-inputs "cross-libc"))) + (list "UNICODE=yes" + "SKIPUTILS=MakeLangId,Makensisw,NSIS Menu,SubStart,zip2exe" + "SKIPDOC=COPYING" + "STRIP_CP=no" + (string-append "PREFIX=" #$output) + (string-append "TARGET_ARCH=" #$target-arch) + (string-append "XGCC_W32_PREFIX=" #$target "-") + (string-append "PREFIX_PLUGINAPI_INC=" xlibc "/include/") + (string-append "PREFIX_PLUGINAPI_LIB=" xlibc "/lib/"))) + #:build-targets #~'("makensis" + "stubs" + "plugins" + "utils") + #:install-targets #~'("install-stubs" + "install-plugins" + "install-data" + "install-utils" + "install-compiler" + "install-conf") + #:phases + #~(modify-phases %standard-phases + (add-before 'build 'fix-target-detection + (lambda _ + ;; NSIS target detection is screwed up, manually change + ;; it ourselves + (substitute* "Source/build.cpp" + (("m_target_type=TARGET_X86UNICODE") + (string-append "m_target_type=" #$nsis-target-type)))))))) + (native-inputs (list zlib)) (home-page "https://nsis.sourceforge.io/Main_Page") (synopsis "System to create Windows installers") (description