aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/guix.texi8
-rw-r--r--gnu/local.mk2
-rw-r--r--gnu/packages/installers.scm116
-rw-r--r--gnu/packages/patches/nsis-env-passthru.patch12
-rw-r--r--guix/build-system/scons.scm4
-rw-r--r--guix/build/scons-build-system.scm9
6 files changed, 144 insertions, 7 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 97d797c13f..6703c2756c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -6405,9 +6405,11 @@ tool. This build system runs @code{scons} to build the package,
the package.
Additional flags to be passed to @code{scons} can be specified with the
-@code{#:scons-flags} parameter. The version of Python used to run SCons
-can be specified by selecting the appropriate SCons package with the
-@code{#:scons} parameter.
+@code{#:scons-flags} parameter. The default build and install targets
+can be overridden with @code{#:build-targets} and
+@code{#:install-targets} respectively. The version of Python used to
+run SCons can be specified by selecting the appropriate SCons package
+with the @code{#:scons} parameter.
@end defvr
@defvr {Scheme Variable} haskell-build-system
diff --git a/gnu/local.mk b/gnu/local.mk
index 2451698503..0a4ee7c986 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -261,6 +261,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/imagemagick.scm \
%D%/packages/inklingreader.scm \
%D%/packages/inkscape.scm \
+ %D%/packages/installers.scm \
%D%/packages/ipfs.scm \
%D%/packages/irc.scm \
%D%/packages/iso-codes.scm \
@@ -1145,6 +1146,7 @@ dist_patch_DATA = \
%D%/packages/patches/nfs-utils-missing-headers.patch \
%D%/packages/patches/ngircd-handle-zombies.patch \
%D%/packages/patches/nm-plugin-path.patch \
+ %D%/packages/patches/nsis-env-passthru.patch \
%D%/packages/patches/nss-freebl-stubs.patch \
%D%/packages/patches/nss-increase-test-timeout.patch \
%D%/packages/patches/nss-pkgconfig.patch \
diff --git a/gnu/packages/installers.scm b/gnu/packages/installers.scm
new file mode 100644
index 0000000000..3a5f08b95a
--- /dev/null
+++ b/gnu/packages/installers.scm
@@ -0,0 +1,116 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Carl Dong <contact@carldong.me>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages installers)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages cross-base)
+ #:use-module (gnu packages python-xyz)
+ #:use-module (guix packages)
+ #:use-module (guix download)
+ #: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")))
+ (package
+ (name (string-append "nsis-" machine))
+ (version "3.04")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "http://prdownloads.sourceforge.net/nsis/nsis-"
+ version "-src.tar.bz2"))
+ (sha256
+ (base32
+ "1xgllk2mk36ll2509hd31mfq6blgncmdzmwxj3ymrwshdh23d5b0"))
+ (patches (search-patches "nsis-env-passthru.patch"))))
+ (build-system scons-build-system)
+ (native-inputs `(("xgcc" ,(cross-gcc triplet #:libc (cross-libc triplet)))
+ ("xbinutils" ,(cross-binutils triplet))
+ ("mingw-w64" ,(cross-libc triplet))))
+ (inputs `(("zlib" ,zlib)))
+ (arguments
+ `(#:scons ,scons-python2
+ #:modules ((srfi srfi-1)
+ (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?))))
+ '("CPLUS_INCLUDE_PATH" "LIBRARY_PATH" "C_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_X86ANSI")
+ (string-append "m_target_type=" ,nsis-target-type))))))))
+ (home-page "http://nsis.sourceforge.net/")
+ (synopsis "A professional open source system to create Windows installers")
+ (description
+ "NSIS (Nullsoft Scriptable Install System) is a professional open
+source system to create Windows installers. It is designed to be as small and
+flexible as possible and is therefore very suitable for internet
+distribution.")
+ (license (license:non-copyleft "file://COPYING"
+ "See COPYING in the distribution.")))))
+
+(define-public nsis-x86_64
+ (make-nsis "x86_64" "amd64" "TARGET_AMD64"))
+
+(define-public nsis-i686
+ (make-nsis "i686" "x86" "TARGET_X86UNICODE"))
diff --git a/gnu/packages/patches/nsis-env-passthru.patch b/gnu/packages/patches/nsis-env-passthru.patch
new file mode 100644
index 0000000000..36b4092230
--- /dev/null
+++ b/gnu/packages/patches/nsis-env-passthru.patch
@@ -0,0 +1,12 @@
+--- nsis-3.04-src/SConstruct 2019-05-30 14:53:30.276775332 -0400
++++ nsis-3.04-src/SConstruct 2019-05-30 14:54:17.901232914 -0400
+@@ -77,6 +77,9 @@
+ if not toolset and not path:
+ defenv = Environment(TARGET_ARCH = arch)
+
++import os;
++defenv['ENV'] = os.environ
++
+ Export('defenv')
+
+ ######################################################################
diff --git a/guix/build-system/scons.scm b/guix/build-system/scons.scm
index 5e76d64180..aad455c419 100644
--- a/guix/build-system/scons.scm
+++ b/guix/build-system/scons.scm
@@ -76,7 +76,9 @@
#:key
(tests? #t)
(scons-flags ''())
+ (build-targets ''())
(test-target "test")
+ (install-targets ''("install"))
(phases '(@ (guix build scons-build-system)
%standard-phases))
(outputs '("out"))
@@ -101,8 +103,10 @@ provides a 'SConstruct' file as its build system."
source))
#:scons-flags ,scons-flags
#:system ,system
+ #:build-targets ,build-targets
#:test-target ,test-target
#:tests? ,tests?
+ #:install-targets ,install-targets
#:phases ,phases
#:outputs %outputs
#:search-paths ',(map search-path-specification->sexp
diff --git a/guix/build/scons-build-system.scm b/guix/build/scons-build-system.scm
index eb013f03b6..17a0b7b877 100644
--- a/guix/build/scons-build-system.scm
+++ b/guix/build/scons-build-system.scm
@@ -29,7 +29,7 @@
;;
;; Code:
-(define* (build #:key outputs (scons-flags '()) (parallel-build? #t) #:allow-other-keys)
+(define* (build #:key outputs (build-targets '()) (scons-flags '()) (parallel-build? #t) #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(mkdir-p out)
(apply invoke "scons"
@@ -37,7 +37,8 @@
(list "-j" (number->string
(parallel-job-count)))
(list))
- scons-flags))))
+ scons-flags
+ build-targets))))
(define* (check #:key tests? test-target (scons-flags '()) #:allow-other-keys)
"Run the test suite of a given SCons application."
@@ -46,9 +47,9 @@
(format #t "test suite not run~%"))
#t)
-(define* (install #:key outputs (scons-flags '()) #:allow-other-keys)
+(define* (install #:key outputs (install-targets '("install")) (scons-flags '()) #:allow-other-keys)
"Install a given SCons application."
- (apply invoke "scons" "install" scons-flags))
+ (apply invoke "scons" (append scons-flags install-targets)))
(define %standard-phases
(modify-phases gnu:%standard-phases