embedded-channel/zephyr.scm

113 lines
4.4 KiB
Scheme
Raw Normal View History

(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.
(define-public %zephyr-module "zephyr-module")
;; This is the common directory prefix of zephyr-modules to collect for
;; search-paths in ZEPHYR_MODULES. 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 prefix as a
;; pattern and to have unique module names.
(define-public %zephyr-module-tag "ZEPHYR-MODULE-TAG-")
(define-public zephyr
(let ((version "3.3.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
"05afpxlapqd7i9m03c8kj5ph9dbig94zhyb9mrwg41cm7725lw98"))))
(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 _
(substitute* "CMakeLists.txt"
(("if *\\(DEFINED BUILD_VERSION\\)")
(string-append
"if (NOT DEFINED BUILD_VERSION)\n"
" set(BUILD_VERSION " #$version ")\n"
"elseif (DEFINED BUILD_VERSION)")))
(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))
(separator ";")
(file-pattern (string-append "^" %zephyr-module-tag)))))
(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.2+zmk-fixes
(let ((revision "1")
(commit "0a586db7b58269fb08248b081bdc3b43452da5f4"))
(package/inherit zephyr
(name "zephyr+zmk-fixes")
(version (git-version "3.2.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
"04mqgzhgjb43ybryvpwrbq2g9i0gk7wd7s2ds3fsrakl4hxqss78"))))
(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)))