Add dotnet-build-system
This commit is contained in:
parent
415aeda016
commit
0811af822c
97
nonguix/build-system/dotnet.scm
Normal file
97
nonguix/build-system/dotnet.scm
Normal file
|
@ -0,0 +1,97 @@
|
|||
(define-module (nonguix nonguix build-system dotnet)
|
||||
#:use-module (guix store)
|
||||
#:use-module (guix utils)
|
||||
#:use-module (guix gexp)
|
||||
#:use-module (guix monads)
|
||||
#:use-module (guix derivations)
|
||||
#:use-module (guix search-paths)
|
||||
#:use-module (guix build-system)
|
||||
#:use-module (guix build-system gnu)
|
||||
#:use-module (guix build-system copy)
|
||||
#:use-module (guix packages)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:export (%dotnet-build-system-modules
|
||||
default-dotnet
|
||||
lower
|
||||
dotnet-build
|
||||
dotnet-build-system))
|
||||
|
||||
(define %dotnet-build-system-modules
|
||||
`((nonguix build dotnet-build-system)
|
||||
(gnu build utils)))
|
||||
|
||||
(define (default-dotnet)
|
||||
(let ((module (resolve-interface '(nongnu packages dotnet))))
|
||||
(module-ref module 'dotnet)))
|
||||
|
||||
(define* (lower name
|
||||
#:key source inputs native-inputs outputs system target
|
||||
(dotnet (default-dotnet))
|
||||
#:allow-other-keys
|
||||
#:rest arguments)
|
||||
"Return a bag for NAME."
|
||||
(define private-keywords
|
||||
'(#:target #:inputs #:native-inputs))
|
||||
(and (not target)
|
||||
(bag
|
||||
(name name)
|
||||
(system system)
|
||||
(host-inputs `(("dotnet" ,dotnet)
|
||||
,@inputs
|
||||
,@(standard-packages)))
|
||||
(build-inputs `(,@native-inputs))
|
||||
(outputs outputs)
|
||||
(build dotnet-build)
|
||||
(arguments (strip-keyword-arguments private-keywords arguments)))))
|
||||
|
||||
(define* (dotnet-build name inputs
|
||||
#:key
|
||||
guile source
|
||||
(outputs '("out"))
|
||||
(project-name #f)
|
||||
(nuget? #f)
|
||||
(self-contained? #t)
|
||||
(strip-debug-symbols? #t)
|
||||
(search-paths '())
|
||||
(path-shebangs? #t)
|
||||
(phases '(@ (nonguix build dotnet-build-system) %standard-phases))
|
||||
(system (%current-system))
|
||||
(imported-modules %dotnet-build-system-modules)
|
||||
(modules '((nonguix build dotnet-build-system)
|
||||
(guix build utils)))
|
||||
(substitutable? #t)
|
||||
allowed-references
|
||||
disallowed-references)
|
||||
"Build SOURCE using DOTNET, and with INPUTS."
|
||||
(define builder
|
||||
(with-imported-modules imported-modules
|
||||
#~(begin
|
||||
(use-modules #$@modules)
|
||||
#$(with-build-variables inputs outputs
|
||||
#~(dotnet-build #:source #+source
|
||||
#:system #$system
|
||||
#:outputs %outputs
|
||||
#:inputs %build-inputs
|
||||
#:project-name #$project-name
|
||||
#:nuget? #$nuget?
|
||||
#:self-contained? #$self-contained?
|
||||
#:strip-debug-symbols? #$strip-debug-symbols?
|
||||
#:search-paths '#$(map search-path-specification->sexp search-paths)
|
||||
#:phases #$phases
|
||||
#:patch-shebangs? #$patch-shebangs?)))))
|
||||
(mlet %store-monad ((guile (package->derivation (or guiled (default-guile))
|
||||
system #:graft? #f)))
|
||||
(gexp->derivation name builder
|
||||
#:system system
|
||||
#:target #f
|
||||
#:substitutable substitutable?
|
||||
#:allowed-references allowed-references
|
||||
#:disallowed-references disallowed-references
|
||||
#:guile-for-build guile)))
|
||||
|
||||
(define dotnet-build-system
|
||||
(build-system
|
||||
(name 'dotnet)
|
||||
(description "")
|
||||
(lower lower)))
|
59
nonguix/build/dotnet-build-system.scm
Normal file
59
nonguix/build/dotnet-build-system.scm
Normal file
|
@ -0,0 +1,59 @@
|
|||
(define-module (build dotnet-build-system)
|
||||
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
|
||||
#:use-module (guix build utils)
|
||||
#:use-module (ice-9 match)
|
||||
#:export (%standard-phases
|
||||
dotnet-build))
|
||||
|
||||
(define* (dotnet-env #:allow-other-keys)
|
||||
(let* ((directory (or (getenv "TMPDIR") "/tmp"))
|
||||
(template (string-append directory "/dotnet-fake-home.XXXXXX"))
|
||||
(home (mkdtemp template)))
|
||||
;; Dotnet expects a writeable home directory for it's configuration files.
|
||||
(setenv "HOME" home)
|
||||
;; Don't try to expand NuGetFallbackFolder to disk
|
||||
(setenv "DOTNET_SKIP_FIRST_TIME_EXPERIENCE" "1")
|
||||
;; Disable the welcome message
|
||||
(setenv "DOTNET_NOLOGO" "1")
|
||||
(setenv "DOTNET_CLI_TELEMETRY_OPTOUT" "1")))
|
||||
|
||||
(define* (copy-nuget-inputs #:key inputs #:allow-other-keys)
|
||||
"Link nuget inputs into a central place so DOTNET can restore them."
|
||||
(define (copy-input input)
|
||||
(copy-file input (string-append "./nugets/" (strip-store-file-name input))))
|
||||
(begin
|
||||
(mkdir "nugets")
|
||||
(for-each copy-input inputs)))
|
||||
|
||||
(define* (restore-nuget-inputs #:key inputs #:allow-other-keys)
|
||||
"Run DOTNET restore --source ./nugets"
|
||||
(invoke "dotnet" "restore" "--source" "./nugets"))
|
||||
|
||||
(define* (publish #:key output (project-name #f) (nuget? #f) (self-contained? #t) (strip-debug-symbols? #t) #:allow-other-keys)
|
||||
"Run DOTNET publish or DOTNET pack"
|
||||
(define arguments `(,@(if nuget? "pack" "publish")
|
||||
,@(if project-name (list project-name) '())
|
||||
"--configuration" "Release"
|
||||
;; don't try to access nuget.org, use local cache prepared in restore-nuget-inputs
|
||||
"--no-restore"
|
||||
,@(if self-contained? '("--self-contained") '())
|
||||
;; TODO cross-compilation
|
||||
"--target" "linux-x64"
|
||||
"-p:UseAppHost=true"
|
||||
,@(if strip-debug-symbols? '("-p:DebugSymbols=false" "-p:DebugType=none") '())
|
||||
"--output" output)))
|
||||
|
||||
(define %standard-phases
|
||||
(modify-phases gnu:%standard-phases)
|
||||
(delete 'bootstrap)
|
||||
(delete 'configure)
|
||||
(delete 'build)
|
||||
(add-before 'check dotnet-env)
|
||||
(add-before 'check copy-nuget-inputs)
|
||||
(add-before 'check publish)
|
||||
(replace 'install publish))
|
||||
|
||||
(define* (dotnet-build #:key inputs (phases %standard-phases)
|
||||
#:allow-other-keys #:rest args)
|
||||
"Build the given package, applying all of PHASES in order."
|
||||
(apply gnu:gnu-build #:inputs inputs #:phases phases args))
|
Loading…
Reference in New Issue
Block a user