embedded-channel/zephyr.scm
Stefan 376414e24d Formatting.
zephyr.scm, zephyr/apps.scm, zephyr/modules.scm: Formatting.
2024-11-23 15:13:30 +01:00

133 lines
5.3 KiB
Scheme

;;; 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)
#:use-module (embedded)
#:use-module (gnu packages bootloaders)
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz)
#:use-module (guix build-system copy)
#:use-module (guix build-system trivial)
#:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module ((guix licenses)
#:prefix license:)
#:use-module (guix packages))
;; This is the common directory name for zephyr-modules to look for search-paths
;; to collect in the ZEPHYR_MODULES environment variable. The build-system of
;; Zephyr searches for a file zephyr/module.yml in all paths listed in the
;; environment variable ZEPHYR_MODULES. If that file is missing a name
;; 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
;; common directory name for search-path-specification, we need this
;; intermediate directory as a pattern to find unique module names.
;; Unfortunately search-path-specification is not powerful enough, so
;; complete-zephyr-application needs the correct-ZEPHYR_MODULES build-phase.
(define-public %zephyr-module "zephyr-module")
(define-public zephyr
(let ((version "3.5.0"))
(package
(name "zephyr")
(version version)
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/zephyrproject-rtos/zephyr")
(commit (string-append "zephyr-v" version))))
(file-name (git-file-name name version))
(sha256
(base32 "0mca9ca8b2xjwjg0vl5858fd9l6h0m1jqbd3zr651zryf2897a80"))))
(build-system copy-build-system)
(arguments
(list
#:install-plan
#~(list (list "." "zephyr-base"))
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'set-USER_CACHE_DIR-and-BUILD_VERSION
(lambda _
;; Avoid fetching the BUILD_VERSION from the git repository.
(substitute* "CMakeLists.txt"
(("if *\\(DEFINED BUILD_VERSION\\)")
(string-append
"if (NOT DEFINED BUILD_VERSION)\n"
" set(BUILD_VERSION " #$version ")\n"
"elseif (DEFINED BUILD_VERSION)")))
;; Avoid USER_CACHE_DIR to point to XDG_CACHE_HOME, HOME or to
;; ZEPHYR_BASE inside the store. Instead use the build dir.
(with-output-to-file
"cmake/modules/user_cache.cmake"
(lambda ()
(display
"set(USER_CACHE_DIR ${CMAKE_BINARY_DIR}/cache)\n"))))))))
(native-search-paths
(list (search-path-specification
(variable "ZEPHYR_BASE")
(files '("zephyr-base"))
(separator #f))
(search-path-specification
(variable "ZEPHYR_MODULES")
(files (list %zephyr-module)))))
(home-page "https://zephyrproject.org")
(synopsis "Zephyr Project RTOS")
(description
"The Zephyr Project is a scalable real-time operating system (RTOS)
supporting multiple hardware architectures, optimized for resource constrained
devices, and built with security in mind.")
(license license:apsl2))))
(define-public zephyr-3.5+zmk-fixes
(let ((revision "1")
(commit "8f87b3be1e7631332cd8b245fb94d24d0354d0cb"))
(package/inherit zephyr
(name "zephyr+zmk-fixes")
(version (git-version "3.5.0" revision commit))
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/zmkfirmware/zephyr")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32 "0bgy6psg2wb4fflkz1ww5dkh5qq2yrfr3cqpi2qkwgj250m8cdfb"))))
(home-page "https://github.com/zmkfirmware/zephyr"))))
(define-public zephyr-build-tools
(package
(name "zephyr-build-tools")
(version "1.0.0")
(source #f)
(build-system trivial-build-system)
(arguments (list #:builder #~(mkdir #$output)))
(propagated-inputs (list dtc
python
python-pyelftools
python-pykwalify
python-pyyaml
python-packaging))
(home-page "https://zephyrproject.org")
(synopsis "Zephyr build tools")
(description "Required build tools to build the Zephyr RTOS.")
(license license:apsl2)))