diff mbox series

[bug#62324] gnu: Add emu8051

Message ID tencent_CB568361E6EB2AA4F49535FA0587ECA20707@qq.com
State New
Headers show
Series [bug#62324] gnu: Add emu8051 | expand

Commit Message

c4droid March 21, 2023, 7:20 a.m. UTC

Comments

Bruno Victal March 21, 2023, 1:43 p.m. UTC | #1
Hi,

On 2023-03-21 07:20, c4droid wrote:
> 
> +      (arguments
> +       `(#:tests? #f ;No test suite
> +         #:make-flags (list (string-append "CC="
> +                                           ,(cc-for-target)))
> +         #:phases (modify-phases %standard-phases
> +                    (delete 'configure) ;No ./configure script
> +                    (add-before 'build 'patch-ncurses
> +                      ;; Replace LDFLAGS -lcurses to -lncurses
> +                      (lambda* _
> +                        (substitute* "Makefile"
> +                          (("-lcurses")
> +                           "-lncurses"))))

How about turning this 'patch-ncurses phase into a patch snippet instead? i.e.

(source
  (origin
    (method ...)
    ...
    (modules '((guix build utils)))
    (snippet
     #~(begin
        ;; Replace LDFLAGS -lcurses to -lncurses
        (substitute* "Makefile"
          (("-lcurses") "-lncurses"))))))

[...]

> +                    (replace 'install
> +                      ;; No installation procedure
> +                      (lambda _
> +                        (install-file "emu"
> +                                      (string-append (assoc-ref %outputs "out")
> +                                                     "/bin")))))))

Use G-Expressions here, i.e.

(arguments
 (list
  #:tests? #f ;No test suite
  #:make-flags #~(list ...)
  #:phases
  #~(modify-phases ...
     ...
     (replace 'install
       (lambda _
        (install-file "emu" (string-append #$output "/bin")))))))


Cheers,
Bruno
Simon South March 21, 2023, 2:47 p.m. UTC | #2
c4droid <c4droid@foxmail.com> writes:
> (home-page "https://github.comjarikomppa/emu8051")

This URL appears to be missing a forward slash.
c4droid March 22, 2023, 12:53 a.m. UTC | #3
Hi, Bruno

Bruno Victal <mirai@makinata.eu> writes:

> Hi,
>
> On 2023-03-21 07:20, c4droid wrote:
>> 
>> +      (arguments
>> +       `(#:tests? #f ;No test suite
>> +         #:make-flags (list (string-append "CC="
>> +                                           ,(cc-for-target)))
>> +         #:phases (modify-phases %standard-phases
>> +                    (delete 'configure) ;No ./configure script
>> +                    (add-before 'build 'patch-ncurses
>> +                      ;; Replace LDFLAGS -lcurses to -lncurses
>> +                      (lambda* _
>> +                        (substitute* "Makefile"
>> +                          (("-lcurses")
>> +                           "-lncurses"))))
>
> How about turning this 'patch-ncurses phase into a patch snippet instead? i.e.
>

I'll change it later, thanks for the hints.

> (source
>   (origin
>     (method ...)
>     ...
>     (modules '((guix build utils)))
>     (snippet
>      #~(begin
>         ;; Replace LDFLAGS -lcurses to -lncurses
>         (substitute* "Makefile"
>           (("-lcurses") "-lncurses"))))))
>
> [...]
>
>> +                    (replace 'install
>> +                      ;; No installation procedure
>> +                      (lambda _
>> +                        (install-file "emu"
>> +                                      (string-append (assoc-ref %outputs "out")
>> +                                                     "/bin")))))))
>
> Use G-Expressions here, i.e.
>
> (arguments
>  (list
>   #:tests? #f ;No test suite
>   #:make-flags #~(list ...)
>   #:phases
>   #~(modify-phases ...
>      ...
>      (replace 'install
>        (lambda _
>         (install-file "emu" (string-append #$output "/bin")))))))
>
>
> Cheers,
> Bruno
c4droid March 22, 2023, 12:56 a.m. UTC | #4
I'll fix it in new patch, my typo fault.

Simon South <simon@simonsouth.net> writes:

> c4droid <c4droid@foxmail.com> writes:
>> (home-page "https://github.comjarikomppa/emu8051")
>
> This URL appears to be missing a forward slash.
c4droid March 22, 2023, 1:48 a.m. UTC | #5
Hi, Bruno

Bruno Victal <mirai@makinata.eu> writes:

> Hi,
>
> On 2023-03-21 07:20, c4droid wrote:
>> 
>> +      (arguments
>> +       `(#:tests? #f ;No test suite
>> +         #:make-flags (list (string-append "CC="
>> +                                           ,(cc-for-target)))
>> +         #:phases (modify-phases %standard-phases
>> +                    (delete 'configure) ;No ./configure script
>> +                    (add-before 'build 'patch-ncurses
>> +                      ;; Replace LDFLAGS -lcurses to -lncurses
>> +                      (lambda* _
>> +                        (substitute* "Makefile"
>> +                          (("-lcurses")
>> +                           "-lncurses"))))
>

The modules and snippet field can be apply to build derivation

> How about turning this 'patch-ncurses phase into a patch snippet instead? i.e.
>
> (source
>   (origin
>     (method ...)
>     ...
>     (modules '((guix build utils)))
>     (snippet
>      #~(begin
>         ;; Replace LDFLAGS -lcurses to -lncurses
>         (substitute* "Makefile"
>           (("-lcurses") "-lncurses"))))))
>
> [...]
>
>> +                    (replace 'install
>> +                      ;; No installation procedure
>> +                      (lambda _
>> +                        (install-file "emu"
>> +                                      (string-append (assoc-ref %outputs "out")
>> +                                                     "/bin")))))))
>

But here, I used G-Expressions here, report gexp is unbound variable.

> Use G-Expressions here, i.e.
>
> (arguments
>  (list
>   #:tests? #f ;No test suite
>   #:make-flags #~(list ...)
>   #:phases
>   #~(modify-phases ...
>      ...
>      (replace 'install
>        (lambda _
>         (install-file "emu" (string-append #$output "/bin")))))))
>
>
> Cheers,
> Bruno
diff mbox series

Patch

From 351280951b0ad515dc6b725dca51a986def1f93f Mon Sep 17 00:00:00 2001
From: c4droid <c4droid@foxmail.com>
Date: Tue, 21 Mar 2023 15:16:10 +0800
Subject: [PATCH] gnu: Add emu8051.

* gnu/packages/embedded.scm (emu8051): New variable.
---
 gnu/packages/embedded.scm | 41 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 8d854c7..50658e4 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -12,6 +12,7 @@ 
 ;;; Copyright © 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
 ;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.org>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2023 c4droid <c4droid@foxmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1747,3 +1748,43 @@  (define-public ts4900-utils
 @item tssilomon
 @end itemize")
       (license license:bsd-2))))
+
+(define-public emu8051
+  (let ((commit "5dc681275151c4a5d7b85ec9ff4ceb1b25abd5a8")
+        (revision "1"))
+    (package
+      (name "emu8051")
+      (version (git-version "0.1" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/jarikomppa/emu8051")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1xxmkcwvd5fjnhwbricafg4xvxvr8dxhfanyfp4rbksw37dgk2fx"))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:tests? #f ;No test suite
+         #:make-flags (list (string-append "CC="
+                                           ,(cc-for-target)))
+         #:phases (modify-phases %standard-phases
+                    (delete 'configure) ;No ./configure script
+                    (add-before 'build 'patch-ncurses
+                      ;; Replace LDFLAGS -lcurses to -lncurses
+                      (lambda* _
+                        (substitute* "Makefile"
+                          (("-lcurses")
+                           "-lncurses"))))
+                    (replace 'install
+                      ;; No installation procedure
+                      (lambda _
+                        (install-file "emu"
+                                      (string-append (assoc-ref %outputs "out")
+                                                     "/bin")))))))
+      (inputs (list ncurses))
+      (home-page "https://github.comjarikomppa/emu8051")
+      (synopsis "8051/8052 emulator with curses-based UI")
+      (description "emu8051 is a simulator of the 8051/8052 microcontrollers.")
+      (license license:expat))))
-- 
2.39.2