Add copyright and GPL3, optimize comments.
This commit is contained in:
parent
16b3f2b99c
commit
c03fdc6264
122
embedded.scm
122
embedded.scm
|
@ -1,3 +1,22 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;;
|
||||||
|
;;; Copyright © 2023 Stefan <stefan-guix@vodafonemail.de>
|
||||||
|
;;;
|
||||||
|
;;; This file is not 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 (embedded)
|
(define-module (embedded)
|
||||||
#:use-module (guix build-system)
|
#:use-module (guix build-system)
|
||||||
#:use-module (guix build-system gnu)
|
#:use-module (guix build-system gnu)
|
||||||
|
@ -33,7 +52,7 @@
|
||||||
(setenv
|
(setenv
|
||||||
"LD_LIBRARY_PATH"
|
"LD_LIBRARY_PATH"
|
||||||
;; The built gcc will have a workaround to ensure that glibc will always
|
;; The built gcc will have a workaround to ensure that glibc will always
|
||||||
;; find libgcc_s.so. Unfortunately during the configuration of libatomic
|
;; find libgcc_s.so. Unfortunately during the configuration of libatomic
|
||||||
;; and other libraries, the libgcc_s.so is not yet available in its final
|
;; and other libraries, the libgcc_s.so is not yet available in its final
|
||||||
;; installation directory and this workaround causes trouble to the
|
;; installation directory and this workaround causes trouble to the
|
||||||
;; configure script during "checking whether we are cross compiling". As
|
;; configure script during "checking whether we are cross compiling". As
|
||||||
|
@ -54,7 +73,7 @@
|
||||||
;; The gcc package used by the gnu-build-system to build this gcc
|
;; The gcc package used by the gnu-build-system to build this gcc
|
||||||
;; puts the include paths to the C++ headers and to the libc headers
|
;; puts the include paths to the C++ headers and to the libc headers
|
||||||
;; into CPLUS_INCLUDE_PATH. This causes trouble in the gcc build
|
;; into CPLUS_INCLUDE_PATH. This causes trouble in the gcc build
|
||||||
;; process when -nostdinc++ is used. As a mitigation we remove them.
|
;; process when -nostdinc++ is used. As a mitigation we remove them.
|
||||||
;; This would not be necessary, when using this built gcc instead.
|
;; This would not be necessary, when using this built gcc instead.
|
||||||
(string-join
|
(string-join
|
||||||
(remove (lambda (path) (member path paths-to-delete))
|
(remove (lambda (path) (member path paths-to-delete))
|
||||||
|
@ -69,7 +88,7 @@
|
||||||
(dynamic-linker (glibc-dynamic-linker))
|
(dynamic-linker (glibc-dynamic-linker))
|
||||||
(startfile-dir "/lib/"))
|
(startfile-dir "/lib/"))
|
||||||
"Give a build-phase for the GCC compilation to modify the source-code. Use
|
"Give a build-phase for the GCC compilation to modify the source-code. Use
|
||||||
the LIBC package for embedded search-paths. The path DYNAMIC-LINKER is appended
|
the LIBC package for embedded search-paths. The path DYNAMIC-LINKER is appended
|
||||||
to LIBC to form the absolute path to the dynamic-linker. The STRTFILE-DIR is a
|
to LIBC to form the absolute path to the dynamic-linker. The STRTFILE-DIR is a
|
||||||
suffix for LIBC to form the path to startfiles like crt0.o from newlib. All
|
suffix for LIBC to form the path to startfiles like crt0.o from newlib. All
|
||||||
default values match for glibc. For newlib omit DYNAMIC-LINKER and set
|
default values match for glibc. For newlib omit DYNAMIC-LINKER and set
|
||||||
|
@ -91,22 +110,22 @@ STARTFILE-DIR to (string-append \"/\" target \"/lib/\")."
|
||||||
;; Prevent auto-host.h in output:lib to create a cyclic dependency
|
;; Prevent auto-host.h in output:lib to create a cyclic dependency
|
||||||
;; referencing output:out.
|
;; referencing output:out.
|
||||||
(("PREFIX_INCLUDE_DIR \"\\$prefix/include\"")
|
(("PREFIX_INCLUDE_DIR \"\\$prefix/include\"")
|
||||||
(string-append "PREFIX_INCLUDE_DIR \"$libdir/include\"")))
|
"PREFIX_INCLUDE_DIR \"$libdir/include\""))
|
||||||
(substitute* "gcc/genmultilib"
|
(substitute* "gcc/genmultilib"
|
||||||
;; Enforce proper invokations of sh.
|
;; Enforce proper invokations of sh.
|
||||||
(("#!/bin/sh") (string-append "#!" (which "sh"))))
|
(("#!/bin/sh") (string-append "#!" (which "sh"))))
|
||||||
(substitute* "gcc/gcc.cc"
|
(substitute* "gcc/gcc.cc"
|
||||||
;; The STARTFILE_PREFIX_SPEC defines where to find crt1.o and other
|
;; The STARTFILE_PREFIX_SPEC defines where to find crt1.o and other
|
||||||
;; start files of libc. Replace it with a proper path to the libc.
|
;; start files of libc. Replace it with a proper path to the libc.
|
||||||
;; Note: This path is relative to the sysroot which therefore must be /.
|
;; Note: This path is relative to the sysroot which therefore must be /.
|
||||||
(("startfile_prefix_spec = STARTFILE_PREFIX_SPEC;")
|
(("startfile_prefix_spec = STARTFILE_PREFIX_SPEC;")
|
||||||
(string-append "startfile_prefix_spec = \""
|
(string-append "startfile_prefix_spec = \""
|
||||||
#$libc #$startfile-dir "\";")))
|
#$libc #$startfile-dir "\";")))
|
||||||
(substitute* "libstdc++-v3/python/Makefile.in"
|
(substitute* "libstdc++-v3/python/Makefile.in"
|
||||||
;; Change pythondir from output:out to output:lib to prevent
|
;; Change pythondir from #$output:out to #$output:lib to prevent
|
||||||
;; output:lib/lib/libstdc++.so.*-gdb.py to create a cyclic dependency to
|
;; #$output:lib/lib/libstdc++.so.*-gdb.py to create a cyclic dependency
|
||||||
;; output:out/share/…/python. This moves all python files to
|
;; to #$output:out/share/…/python. This moves all python files to
|
||||||
;; output:lib. The option --with-python-dir is still usable.
|
;; #$output:lib. The option --with-python-dir is still usable.
|
||||||
(("pythondir = \\$\\(datadir\\)") "pythondir = $(libdir)/share")
|
(("pythondir = \\$\\(datadir\\)") "pythondir = $(libdir)/share")
|
||||||
(("pythondir = \\$\\(prefix\\)") "pythondir = $(libdir)"))
|
(("pythondir = \\$\\(prefix\\)") "pythondir = $(libdir)"))
|
||||||
#!(substitute* "libsanitizer/asan/asan_linux.cpp"
|
#!(substitute* "libsanitizer/asan/asan_linux.cpp"
|
||||||
|
@ -132,23 +151,23 @@ STARTFILE-DIR to (string-append \"/\" target \"/lib/\")."
|
||||||
KERNEL-HEADERS packages. The defaults refer to glibc and the kernel-headers
|
KERNEL-HEADERS packages. The defaults refer to glibc and the kernel-headers
|
||||||
used to build glibc."
|
used to build glibc."
|
||||||
#~(list
|
#~(list
|
||||||
;; The first include paths are gcc/include-c++ and gcc:lib/…/include.
|
;; The first set of include paths consinsts of #$gcc/include-c++/… and
|
||||||
;; Second is usually /usr/local, which we replace with the empty
|
;; #$gcc:lib/…/include. Second is usually /usr/local, which we replace
|
||||||
;; output:lib/include path.
|
;; with the empty #$output:lib/include path.
|
||||||
(string-append "--with-local-prefix=" #$output:lib)
|
(string-append "--with-local-prefix=" #$output:lib)
|
||||||
;; Third is gcc:lib/…/include-fixed, which expects libc/include and
|
;; Third is #$gcc:lib/…/include-fixed, which expects #$libc/include and
|
||||||
;; kernel-headers/include to follow in this order.
|
;; #$kernel-headers/include to follow in this order.
|
||||||
;; Fourth and usually the last include path is /usr/include containing all
|
;; Fourth and usually the last include path is /usr/include containing all
|
||||||
;; system headers. It is only possible to specify one path for this. Set
|
;; system headers. It is only possible to specify one path for this. Set
|
||||||
;; the libc/include path and prevent the use of /usr/include.
|
;; the #$libc/include path and prevent the use of /usr/include.
|
||||||
(string-append "--with-native-system-header-dir=" #$libc "/include")
|
(string-append "--with-native-system-header-dir=" #$libc "/include")
|
||||||
;; The final include path has to be kernel-headers/include, which has to
|
;; The final include path has to be #$kernel-headers/include, which has to
|
||||||
;; be after libc/include. There is only -idirafter left to achieve this.
|
;; be after #$libc/include. There is only -idirafter left to achieve
|
||||||
;; Add output:lib/lib as a built-in link-time search path.
|
;; this. Add #$output:lib/lib as a built-in link-time search path.
|
||||||
;; Add libc/lib and libc/static as built-in link-time search paths.
|
;; Add #$libc/lib and #$libc/static as built-in link-time search paths.
|
||||||
;; Add a runtime search path to libc/lib, if not linked statically. This
|
;; Add a runtime search path to #$libc/lib, if not linked statically.
|
||||||
;; search path to libc/lib may not be technically necessary because of
|
;; This search path to #$libc/lib may not be technically necessary because
|
||||||
;; the dynamic linker in there, but better use a complete list.
|
;; of the dynamic linker in there, but better use a complete list.
|
||||||
;; Actually libc needs a DT_RUNPATH entry to the libgcc_s.so of the GCC
|
;; Actually libc needs a DT_RUNPATH entry to the libgcc_s.so of the GCC
|
||||||
;; used to build it. This is missing and may requires a fix. As a
|
;; used to build it. This is missing and may requires a fix. As a
|
||||||
;; workaround one can force any program built by this GCC and not linked
|
;; workaround one can force any program built by this GCC and not linked
|
||||||
|
@ -160,9 +179,10 @@ used to build glibc."
|
||||||
"-idirafter " #$kernel-headers "/include "
|
"-idirafter " #$kernel-headers "/include "
|
||||||
;; Embed the link-time search path to libgcc_s.so, libstdc++.so, etc.
|
;; Embed the link-time search path to libgcc_s.so, libstdc++.so, etc.
|
||||||
"%x{-L" #$output:lib "/lib} "
|
"%x{-L" #$output:lib "/lib} "
|
||||||
;; Embed the link-time search paths to libc/lib and libc:static/lib.
|
;; Embed the link-time search paths to #$libc/lib and #$libc:static/lib.
|
||||||
"%x{-L" #$libc "/lib} %x{-L" #$libc:static "/lib} "
|
"%x{-L" #$libc "/lib} %x{-L" #$libc:static "/lib} "
|
||||||
;; Embed the runtime search path to libc/lib, if not staticlally linked.
|
;; Embed the runtime search path to #$libc/lib, if not staticlally
|
||||||
|
;; linked.
|
||||||
"%{nolibc|nostdlib|static:; :%x{-rpath=" #$libc "/lib}} "
|
"%{nolibc|nostdlib|static:; :%x{-rpath=" #$libc "/lib}} "
|
||||||
;; This is a workaround to ensure a pre-loaded libgcc_s.so for libc if
|
;; This is a workaround to ensure a pre-loaded libgcc_s.so for libc if
|
||||||
;; not statically linking. The libstdc++.so and other shared libraries
|
;; not statically linking. The libstdc++.so and other shared libraries
|
||||||
|
@ -176,9 +196,9 @@ used to build glibc."
|
||||||
;; build it, the -rpath is added unconditionally here.
|
;; build it, the -rpath is added unconditionally here.
|
||||||
"%{nodefaultlibs|nostdlib|static|static-libgcc|static-pie:; "
|
"%{nodefaultlibs|nostdlib|static|static-libgcc|static-pie:; "
|
||||||
":%x{-lgcc_s}} %x{-rpath=" #$output:lib "/lib}")
|
":%x{-lgcc_s}} %x{-rpath=" #$output:lib "/lib}")
|
||||||
;; Prevent the C++ headers in output:lib, put them in output:out instead.
|
;; Prevent the C++ headers in #$output:lib, put them in #$output:out
|
||||||
;; Use an unconventional path to prevent it from being added to the
|
;; instead. Use an unconventional path to prevent it from being added to
|
||||||
;; environment variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH.
|
;; the environment variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH.
|
||||||
"--with-gxx-include-dir=$(prefix)/include-c++"
|
"--with-gxx-include-dir=$(prefix)/include-c++"
|
||||||
;; As libc is limited, gcc will not be usable for 32 and 64 bit builds.
|
;; As libc is limited, gcc will not be usable for 32 and 64 bit builds.
|
||||||
"--disable-multilib"
|
"--disable-multilib"
|
||||||
|
@ -275,11 +295,11 @@ necessary paths build-in to preserve a necessary include-order."
|
||||||
(cons (list "ld-wrapper" ld-wrapper) build-inputs)
|
(cons (list "ld-wrapper" ld-wrapper) build-inputs)
|
||||||
build-inputs)))
|
build-inputs)))
|
||||||
|
|
||||||
(define*-public (make-gcc-toolchain-package toolchain)
|
(define*-public (make-gcc-toolchain-package c-toolchain)
|
||||||
"Make a GCC-toolchain package from TOOLCHAIN. The TOOLCHAIN argument must be
|
"Make a GCC-toolchain package from C-TOOLCHAIN. The C-TOOLCHAIN argument must
|
||||||
a list of inputs (label/package tuples) providing equivalent functionality as
|
be a list of inputs (label/package tuples) providing equivalent functionality as
|
||||||
the 'gcc-toolchain' package as passed to 'package-with-c-toolchain'."
|
the 'gcc-toolchain' package as passed to 'package-with-c-toolchain'."
|
||||||
(let ((gcc (car (assoc-ref toolchain "gcc"))))
|
(let ((gcc (car (assoc-ref c-toolchain "gcc"))))
|
||||||
(package
|
(package
|
||||||
(name (string-append (package-name gcc) "-toolchain"))
|
(name (string-append (package-name gcc) "-toolchain"))
|
||||||
(version (package-version gcc))
|
(version (package-version gcc))
|
||||||
|
@ -291,7 +311,7 @@ the 'gcc-toolchain' package as passed to 'package-with-c-toolchain'."
|
||||||
#:builder
|
#:builder
|
||||||
#~(begin
|
#~(begin
|
||||||
(use-modules ((guix build union)))
|
(use-modules ((guix build union)))
|
||||||
(union-build #$output (quote #$(map second toolchain))))))
|
(union-build #$output (quote #$(map second c-toolchain))))))
|
||||||
(synopsis "Complete GCC toolchain for C/C++ development")
|
(synopsis "Complete GCC toolchain for C/C++ development")
|
||||||
(description "This package provides a complete GCC toolchain for C/C++
|
(description "This package provides a complete GCC toolchain for C/C++
|
||||||
development to be installed in user profiles. This includes GCC and Binutils.
|
development to be installed in user profiles. This includes GCC and Binutils.
|
||||||
|
@ -362,8 +382,8 @@ usable on embedded products.")
|
||||||
#:key
|
#:key
|
||||||
(cross-gcc (cross-gcc target))
|
(cross-gcc (cross-gcc target))
|
||||||
(cross-binutils (cross-binutils target)))
|
(cross-binutils (cross-binutils target)))
|
||||||
"Make a newlib-nano package for TARGET with the given CONFIGURE-FLAGS,
|
"Make a newlib-nano package for TARGET with the given CROSS-GCC and
|
||||||
CROSS-GCC and CROSS-BINUTLIS packages for building."
|
CROSS-BINUTLIS packages for building."
|
||||||
(package
|
(package
|
||||||
(inherit (make-newlib-4.3 target
|
(inherit (make-newlib-4.3 target
|
||||||
#:configure-flags
|
#:configure-flags
|
||||||
|
@ -394,35 +414,35 @@ CROSS-GCC and CROSS-BINUTLIS packages for building."
|
||||||
|
|
||||||
(define-public (gcc-cross-newlib-arm-configure-flags target libc)
|
(define-public (gcc-cross-newlib-arm-configure-flags target libc)
|
||||||
"Modify configure-flags to build a GCC cross-compiler for the Arm target
|
"Modify configure-flags to build a GCC cross-compiler for the Arm target
|
||||||
TARGET using the a newlib as LIBC."
|
TARGET using newlib as LIBC."
|
||||||
#~(list
|
#~(list
|
||||||
(string-append "--target=" #$target)
|
(string-append "--target=" #$target)
|
||||||
;; All paths to --with-… options are relative to the sysroot. As store
|
;; All paths to --with-… options are relative to the sysroot. As store
|
||||||
;; pathes are absolute, the sysroot needs to be set to /.
|
;; pathes are absolute, the sysroot needs to be set to /.
|
||||||
"--with-sysroot=/"
|
"--with-sysroot=/"
|
||||||
;; The first include paths are gcc/include-c++ and gcc:lib/…/include.
|
;; The first set of include paths consinsts of #$gcc/include-c++/… and
|
||||||
;; Second is usually /usr/local, which we replace with the empty
|
;; #$gcc:lib/…/include. Second is usually /usr/local, which we replace
|
||||||
;; output:lib/include path.
|
;; with the empty #$output:lib/include path.
|
||||||
(string-append "--with-local-prefix=" #$output:lib)
|
(string-append "--with-local-prefix=" #$output:lib)
|
||||||
;; Third is gcc:lib/…/include-fixed, which expects libc/include and
|
;; Third is #$gcc:lib/…/include-fixed, which expects #$libc/include and
|
||||||
;; kernel-headers/include to follow in this order.
|
;; #$kernel-headers/include to follow in this order.
|
||||||
;; Fourth and usually the last include path is /usr/include containing all
|
;; Fourth and usually the last include path is /usr/include containing all
|
||||||
;; system headers. It is only possible to specify one path for this. Set
|
;; system headers. It is only possible to specify one path for this. Set
|
||||||
;; the libc/target/include path and prevent the use of /usr/include.
|
;; the #$libc/include path and prevent the use of /usr/include.
|
||||||
;; Using newlib as libc for bare-metal does not require kernel-headers.
|
;; Using newlib as libc for bare-metal does not require kernel-headers.
|
||||||
(string-append
|
(string-append
|
||||||
"--with-native-system-header-dir=" #$libc "/" #$target "/include")
|
"--with-native-system-header-dir=" #$libc "/" #$target "/include")
|
||||||
;; Add output/target/lib as a built-in link-time search path.
|
;; Add #$output/#$target/lib and #$libc/#$target/lib as a built-in
|
||||||
;; Add libc/target lib and as a built-in link-time search path.
|
;; link-time search path.
|
||||||
(string-append
|
(string-append
|
||||||
"--with-specs="
|
"--with-specs="
|
||||||
;; Embed the link-time search path to libgcc, libstdc++, etc.
|
;; Embed the link-time search path to libgcc, libstdc++, etc.
|
||||||
"%x{-L" #$output "/" #$target "/lib} "
|
"%x{-L" #$output "/" #$target "/lib} "
|
||||||
;; Embed the link-time search paths to libc.
|
;; Embed the link-time search paths to libc.
|
||||||
"%x{-L" #$libc "/" #$target "/lib}")
|
"%x{-L" #$libc "/" #$target "/lib}")
|
||||||
;; Prevent the C++ headers in output:lib, put them in output:out instead.
|
;; Prevent the C++ headers in #$output:lib, put them in #$output:out
|
||||||
;; Use an unconventional path to prevent it from being added to the
|
;; instead. Use an unconventional path to prevent it from being added to
|
||||||
;; environment variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH.
|
;; the environment variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH.
|
||||||
"--with-gxx-include-dir=$(prefix)/include-c++"
|
"--with-gxx-include-dir=$(prefix)/include-c++"
|
||||||
;; Ensure GCC is build for newlib.
|
;; Ensure GCC is build for newlib.
|
||||||
"--with-newlib"
|
"--with-newlib"
|
||||||
|
@ -431,10 +451,6 @@ TARGET using the a newlib as LIBC."
|
||||||
"--with-multilib-list=aprofile,rmprofile"
|
"--with-multilib-list=aprofile,rmprofile"
|
||||||
;; As newlib does not have a dynamik-linker, disable shared builds.
|
;; As newlib does not have a dynamik-linker, disable shared builds.
|
||||||
"--disable-shared"
|
"--disable-shared"
|
||||||
;; Ensure that the default assembler will be found.
|
|
||||||
;(string-append "--with-as=" #$cross-binutils "/bin/" #$target "-as")
|
|
||||||
;; Ensure that the default linker will be found.
|
|
||||||
;(string-append "--with-ld=" #$cross-binutils "/bin/" #$target "-ld")
|
|
||||||
;; Disable all language frontends except for C and C++.
|
;; Disable all language frontends except for C and C++.
|
||||||
"--enable-languages=c,c++"
|
"--enable-languages=c,c++"
|
||||||
;; Save space by disabling pre-compiled libstdc++ headers.
|
;; Save space by disabling pre-compiled libstdc++ headers.
|
||||||
|
@ -472,9 +488,9 @@ necessary paths build-in to preserve a necessary include-order."
|
||||||
;; However, the cross-binutils package contains only executables
|
;; However, the cross-binutils package contains only executables
|
||||||
;; pefixed with the target name in its bin directory. The ones
|
;; pefixed with the target name in its bin directory. The ones
|
||||||
;; not prefixed reside in its target/bin directory. We create a
|
;; not prefixed reside in its target/bin directory. We create a
|
||||||
;; new package which links that target/bin directory as bin.
|
;; new package, which links that #$target/bin directory as bin.
|
||||||
;; Note: The linker is invoked by collect2, which has different lookup
|
;; Note: The linker is invoked by collect2, which has different lookup
|
||||||
;; rules and finds a prefixed target-ld.
|
;; rules as GCC and finds a prefixed target-ld.
|
||||||
(list
|
(list
|
||||||
(list "binutils-for-toolchain"
|
(list "binutils-for-toolchain"
|
||||||
(package
|
(package
|
||||||
|
@ -499,7 +515,7 @@ necessary paths build-in to preserve a necessary include-order."
|
||||||
make-cross-newlib)
|
make-cross-newlib)
|
||||||
"Make a C-toolchain targeting arm-none-eabi consisting of a cross-compiler,
|
"Make a C-toolchain targeting arm-none-eabi consisting of a cross-compiler,
|
||||||
cross-compiled Binutils, and a newlib C-library. The cross-compiler will be
|
cross-compiled Binutils, and a newlib C-library. The cross-compiler will be
|
||||||
build with with another toolchain using the given host GCC and Binutils. The
|
build with another toolchain using the given host GCC and Binutils. The
|
||||||
function MAKE-GCC is used to create a GCC cross-compiler package using the
|
function MAKE-GCC is used to create a GCC cross-compiler package using the
|
||||||
newlib C-library package created with MAKE-CROSS-NEWLIB. The result can be used
|
newlib C-library package created with MAKE-CROSS-NEWLIB. The result can be used
|
||||||
by the transformation function 'package-with-c-toolchain' and to build a
|
by the transformation function 'package-with-c-toolchain' and to build a
|
||||||
|
|
23
zephyr.scm
23
zephyr.scm
|
@ -1,3 +1,22 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;;
|
||||||
|
;;; Copyright © 2023 Stefan <stefan-guix@vodafonemail.de>
|
||||||
|
;;;
|
||||||
|
;;; This file is not 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 (zephyr)
|
(define-module (zephyr)
|
||||||
#:use-module (embedded)
|
#:use-module (embedded)
|
||||||
#:use-module (gnu packages bootloaders)
|
#:use-module (gnu packages bootloaders)
|
||||||
|
@ -17,8 +36,8 @@
|
||||||
;; property, then the parent directory name is used as the module name. Having
|
;; property, then the parent directory name is used as the module name. Having
|
||||||
;; two modules with the same name is treated as an error. As Guix needs a
|
;; two modules with the same name is treated as an error. As Guix needs a
|
||||||
;; common directory name for search-path-specification, we need this
|
;; common directory name for search-path-specification, we need this
|
||||||
;; intermediate directory as a pattern and to have unique module names.
|
;; intermediate directory as a pattern to find unique module names.
|
||||||
;; Unfortunately search-path-specification is still not powerful enough, so
|
;; Unfortunately search-path-specification is not powerful enough, so
|
||||||
;; complete-zephyr-application needs the correct-ZEPHYR_MODULES build-phase.
|
;; complete-zephyr-application needs the correct-ZEPHYR_MODULES build-phase.
|
||||||
(define-public %zephyr-module "zephyr-module")
|
(define-public %zephyr-module "zephyr-module")
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;;
|
||||||
|
;;; Copyright © 2023 Stefan <stefan-guix@vodafonemail.de>
|
||||||
|
;;;
|
||||||
|
;;; This file is not 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 (zephyr apps)
|
(define-module (zephyr apps)
|
||||||
#:use-module (embedded)
|
#:use-module (embedded)
|
||||||
#:use-module (gnu packages)
|
#:use-module (gnu packages)
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;;
|
||||||
|
;;; Copyright © 2023 Stefan <stefan-guix@vodafonemail.de>
|
||||||
|
;;;
|
||||||
|
;;; This file is not 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 (zephyr modules)
|
(define-module (zephyr modules)
|
||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
#:use-module (guix build-system copy)
|
#:use-module (guix build-system copy)
|
||||||
|
@ -7,7 +26,7 @@
|
||||||
#:use-module (ice-9 regex)
|
#:use-module (ice-9 regex)
|
||||||
#:use-module (zephyr))
|
#:use-module (zephyr))
|
||||||
|
|
||||||
(define-public (zephyr-module-installation-target zephyr-module)
|
(define-public (zephyr-module-installation-target zephyr-module)
|
||||||
"Return the target directory for the install-plan of the copy-build-system for
|
"Return the target directory for the install-plan of the copy-build-system for
|
||||||
the ZEPHYR-MODULE package. It needs to match a certain pattern to collect
|
the ZEPHYR-MODULE package. It needs to match a certain pattern to collect
|
||||||
search-paths for zephyr-modules in the ZEPHYR_MOUDULES environment variable."
|
search-paths for zephyr-modules in the ZEPHYR_MOUDULES environment variable."
|
||||||
|
@ -192,7 +211,7 @@ and a low memory footprint.")
|
||||||
(synopsis "Zephyr module for Mbed TLS")
|
(synopsis "Zephyr module for Mbed TLS")
|
||||||
(description "Zephyr module providing Mbed TLS, a C library that
|
(description "Zephyr module providing Mbed TLS, a C library that
|
||||||
implements cryptographic primitives, X.509 certificate manipulation and the
|
implements cryptographic primitives, X.509 certificate manipulation and the
|
||||||
SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for
|
SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for
|
||||||
embedded systems.")
|
embedded systems.")
|
||||||
(license license:apsl2))))
|
(license license:apsl2))))
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;;
|
||||||
|
;;; Copyright © 2023 Stefan <stefan-guix@vodafonemail.de>
|
||||||
|
;;;
|
||||||
|
;;; This file is not 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 (zephyr zmk)
|
(define-module (zephyr zmk)
|
||||||
#:use-module (guix build union)
|
#:use-module (guix build union)
|
||||||
#:use-module (guix build utils)
|
#:use-module (guix build utils)
|
||||||
|
@ -101,6 +120,22 @@ built on the Zephyr™ Project Real Time Operating System (RTOS).")
|
||||||
#:zephyr zephyr-3.2+zmk-fixes
|
#:zephyr zephyr-3.2+zmk-fixes
|
||||||
#:source-prefix "zmk"))
|
#:source-prefix "zmk"))
|
||||||
|
|
||||||
|
(define*-public (make-zmk-union zmk-packages #:key name synopsis)
|
||||||
|
"Make a union of several ZMK Firmware packages for left and right hand or
|
||||||
|
settings-reset firmware files."
|
||||||
|
(package
|
||||||
|
(inherit (car zmk-packages))
|
||||||
|
(name (or name (package-name (car zmk-packages))))
|
||||||
|
(source #f)
|
||||||
|
(build-system trivial-build-system)
|
||||||
|
(arguments
|
||||||
|
(list #:modules '((guix build union))
|
||||||
|
#:builder
|
||||||
|
#~(begin
|
||||||
|
(use-modules ((guix build union)))
|
||||||
|
(union-build #$output (quote #$zmk-packages)))))
|
||||||
|
(synopsis (or synopsis (package-synopsis (car zmk-packages))))))
|
||||||
|
|
||||||
(define*-public (make-nrfmicro-13-zmk shield #:key zmk-config (extra-name ""))
|
(define*-public (make-nrfmicro-13-zmk shield #:key zmk-config (extra-name ""))
|
||||||
"Make a ZMK firmware package for a keyboard consisting of the nrfmicro 1.3/1.4
|
"Make a ZMK firmware package for a keyboard consisting of the nrfmicro 1.3/1.4
|
||||||
board with a SHIELD PCB. Use the ZMK-CONFIG directory containing optional
|
board with a SHIELD PCB. Use the ZMK-CONFIG directory containing optional
|
||||||
|
@ -118,6 +153,7 @@ shield or board names."
|
||||||
(use-modules (guix build utils))
|
(use-modules (guix build utils))
|
||||||
(substitute* "app/CMakeLists.txt"
|
(substitute* "app/CMakeLists.txt"
|
||||||
;; Move combo.c and behaviour_tap_dance.c above all other behaviors.
|
;; Move combo.c and behaviour_tap_dance.c above all other behaviors.
|
||||||
|
;; This fix is needed to get working layer-tap-dance.
|
||||||
(("^ target_sources\\(app PRIVATE src/combo.c\\)\n") "")
|
(("^ target_sources\\(app PRIVATE src/combo.c\\)\n") "")
|
||||||
(("^ target_sources\\(app PRIVATE src/behaviors/behavior_tap_dance.c\\)\n")
|
(("^ target_sources\\(app PRIVATE src/behaviors/behavior_tap_dance.c\\)\n")
|
||||||
"")
|
"")
|
||||||
|
@ -127,29 +163,17 @@ shield or board names."
|
||||||
" target_sources(app PRIVATE src/combo.c)\n"
|
" target_sources(app PRIVATE src/combo.c)\n"
|
||||||
" target_sources(app PRIVATE src/behaviors/behavior_tap_dance.c)\n"))))))
|
" target_sources(app PRIVATE src/behaviors/behavior_tap_dance.c)\n"))))))
|
||||||
|
|
||||||
(define*-public (make-zmk-union zmk-packages #:key name synopsis)
|
|
||||||
"Make a union of several ZMK Firmware packages for left and right hand or
|
|
||||||
settings-reset firmware files."
|
|
||||||
(package
|
|
||||||
(inherit (car zmk-packages))
|
|
||||||
(name (or name (package-name (car zmk-packages))))
|
|
||||||
(source #f)
|
|
||||||
(build-system trivial-build-system)
|
|
||||||
(arguments
|
|
||||||
(list #:modules '((guix build union))
|
|
||||||
#:builder
|
|
||||||
#~(begin
|
|
||||||
(use-modules ((guix build union)))
|
|
||||||
(union-build #$output (quote #$zmk-packages)))))
|
|
||||||
(synopsis (or synopsis (package-synopsis (car zmk-packages))))))
|
|
||||||
|
|
||||||
(define (hid-modifier modifier)
|
(define (hid-modifier modifier)
|
||||||
|
"Map a symbol for a MODIFIER key into a macro symbol for a ZMK keymap file.
|
||||||
|
An unknown MODIFIER symbol is just returned."
|
||||||
(define hid-modifier->zmk-macro
|
(define hid-modifier->zmk-macro
|
||||||
'((⇧ . LS) (⌃ . LC) (⌥ . LA) (⌘ . LG)
|
'((⇧ . LS) (⌃ . LC) (⌥ . LA) (⌘ . LG)
|
||||||
(R⌘ . RG) (R⌥ . RA) (R⌃ . RC) (R⇧ . RS)))
|
(R⌘ . RG) (R⌥ . RA) (R⌃ . RC) (R⇧ . RS)))
|
||||||
(or (assoc-ref hid-modifier->zmk-macro modifier) modifier))
|
(or (assoc-ref hid-modifier->zmk-macro modifier) modifier))
|
||||||
|
|
||||||
(define-public (special-bindings key-label)
|
(define-public (special-bindings key-label)
|
||||||
|
"Map a KEY-LABEL matching a special-binding into a binding symbol for a
|
||||||
|
ZMK keymap file. An unknown KEY-LABEL symbol is just returned."
|
||||||
(define special-bindings->zmk-name
|
(define special-bindings->zmk-name
|
||||||
'(;; A whole in the keyboard matrix without meaning to ZMK.
|
'(;; A whole in the keyboard matrix without meaning to ZMK.
|
||||||
(◌ . "")
|
(◌ . "")
|
||||||
|
@ -168,6 +192,8 @@ settings-reset firmware files."
|
||||||
(or (assoc-ref special-bindings->zmk-name key-label) key-label))
|
(or (assoc-ref special-bindings->zmk-name key-label) key-label))
|
||||||
|
|
||||||
(define-public (hid key-label)
|
(define-public (hid key-label)
|
||||||
|
"Map a HID KEY-LABEL into a macro symbol for a ZMK keymap file. Any other
|
||||||
|
KEY-LABEL will be treated by 'special-bindings'."
|
||||||
(define hid->zmk-name
|
(define hid->zmk-name
|
||||||
'((⎋ . ESC) (⎙ . PSCRN) (⤓ . SLCK) (⎉ . PAUSE_BREAK)
|
'((⎋ . ESC) (⎙ . PSCRN) (⤓ . SLCK) (⎉ . PAUSE_BREAK)
|
||||||
(^ . GRAVE) (- . MINUS)
|
(^ . GRAVE) (- . MINUS)
|
||||||
|
@ -194,6 +220,8 @@ settings-reset firmware files."
|
||||||
(special-bindings (or (assoc-ref hid->zmk-name key-label) key-label)))
|
(special-bindings (or (assoc-ref hid->zmk-name key-label) key-label)))
|
||||||
|
|
||||||
(define-public (de key-label)
|
(define-public (de key-label)
|
||||||
|
"Map a german KEY-LABEL based on the QWERTZ-layout into an international HID
|
||||||
|
key-label, if needed, and return a symbol for a ZMK keymap file."
|
||||||
(define de->hid
|
(define de->hid
|
||||||
'((ß . -) (´ . =)
|
'((ß . -) (´ . =)
|
||||||
(Z . Y) (Ü . ⟦) (+ . ⟧)
|
(Z . Y) (Ü . ⟦) (+ . ⟧)
|
||||||
|
@ -203,6 +231,8 @@ settings-reset firmware files."
|
||||||
(hid (or (assoc-ref de->hid key-label) key-label)))
|
(hid (or (assoc-ref de->hid key-label) key-label)))
|
||||||
|
|
||||||
(define-public (neo key-label)
|
(define-public (neo key-label)
|
||||||
|
"Map a german KEY-LABEL based on the neo-layout into the international HID
|
||||||
|
key-label, if needed, and return a symbol as needed by a ZMK keymap file."
|
||||||
(define neo->de
|
(define neo->de
|
||||||
'((T1 . ^)
|
'((T1 . ^)
|
||||||
(X . Q) (V . W) (L . E) (C . R) (W . T)
|
(X . Q) (V . W) (L . E) (C . R) (W . T)
|
||||||
|
@ -223,9 +253,9 @@ settings-reset firmware files."
|
||||||
(macros '()))
|
(macros '()))
|
||||||
"Generate the content of a keymap file for ZMK. Each layer in LAYERS has a
|
"Generate the content of a keymap file for ZMK. Each layer in LAYERS has a
|
||||||
name, a layout and multiple rows, of which each contains the key-bindings. The
|
name, a layout and multiple rows, of which each contains the key-bindings. The
|
||||||
last row contains the bindings for sensors. The key-bindings use symbols on
|
last row contains the bindings for sensors. The key-bindings use symbols from
|
||||||
LAYOUT. The BEHAVIORS, COMBOS, MACROS and CONDITIONAL-LAYERS contain lists of
|
the layout. The BEHAVIORS, COMBOS, MACROS and CONDITIONAL-LAYERS contain lists
|
||||||
strings to inject own appropiate definitions for ZMK. PROPERTIES may contain
|
of strings to inject own appropiate definitions for ZMK. PROPERTIES may contain
|
||||||
properties for behaviors or even C macro definitions."
|
properties for behaviors or even C macro definitions."
|
||||||
(define (include file)
|
(define (include file)
|
||||||
"Return an include statement for file"
|
"Return an include statement for file"
|
||||||
|
@ -244,7 +274,7 @@ properties for behaviors or even C macro definitions."
|
||||||
|
|
||||||
(define* (keymap-layer name layout rows)
|
(define* (keymap-layer name layout rows)
|
||||||
"Return a string with a keymap layer definition NAME for a ZMK keymap file,
|
"Return a string with a keymap layer definition NAME for a ZMK keymap file,
|
||||||
consisting of KEYS with their labels based on LAYOUT."
|
consisting of ROWS of keys with their labels based on LAYOUT."
|
||||||
|
|
||||||
(define (zmk-name->string zmk-name)
|
(define (zmk-name->string zmk-name)
|
||||||
"Tansform a ZMK-NAME into a string."
|
"Tansform a ZMK-NAME into a string."
|
||||||
|
@ -412,11 +442,10 @@ resolved by flashing this settings reset firmware to both controllers.")))
|
||||||
(⌥- '(&mt ⌥ -))
|
(⌥- '(&mt ⌥ -))
|
||||||
(⌥. '(&mt ⌥ ·))
|
(⌥. '(&mt ⌥ ·))
|
||||||
(l1␣ '(< 1 ␣))
|
(l1␣ '(< 1 ␣))
|
||||||
(to0 '(&to 0)) ; Switch to layer 0.
|
(l0 '(<d0)) ; Layer tap-dance for layer 0.
|
||||||
(l0 '(<d0)) ; Layer dancing for layer 0.
|
(l1 '(<d1)) ; Layer tap-dance for layer 1.
|
||||||
(l1 '(<d1)) ; Layer dancing for layer 1.
|
(l2 '(<d2)) ; Layer tap-dance for layer 2.
|
||||||
(l2 '(<d2)) ; Layer dancing for layer 2.
|
(l3 '(<d3)) ; Layer tap-dance for layer 3.
|
||||||
(l3 '(<d3)) ; Layer dancing for layer 3.
|
|
||||||
(⌔1 '(⌔ BT_SEL 0))
|
(⌔1 '(⌔ BT_SEL 0))
|
||||||
(⌔2 '(⌔ BT_SEL 1))
|
(⌔2 '(⌔ BT_SEL 1))
|
||||||
(⌔3 '(⌔ BT_SEL 2))
|
(⌔3 '(⌔ BT_SEL 2))
|
||||||
|
|
Loading…
Reference in a new issue