diff --git a/docs/user-reference.rst b/docs/user-reference.rst index d9be601..7b6f72a 100644 --- a/docs/user-reference.rst +++ b/docs/user-reference.rst @@ -678,7 +678,9 @@ Optional parameters: kernel into :code:`additional_deps` of zephyr's config. This will ensure that zephyr will be built **after** DomU. -* :code:`shields` - list of shields should be integrated to zephyr board. +* :code:`shields` - list of shields should be integrated to zephyr board(For Zephyr < 3.4.0). + +* :code:`snippets` - list of snippets should be integrated to zephyr board(For Zephyr >= 3.4.0). * :code:`vars` - list of additional variables that should be passed to cmakw via :code:`west build`. diff --git a/moulin/builders/zephyr.py b/moulin/builders/zephyr.py index ff20e5d..6716606 100644 --- a/moulin/builders/zephyr.py +++ b/moulin/builders/zephyr.py @@ -10,6 +10,7 @@ from moulin import ninja_syntax from moulin.utils import construct_fetcher_dep_cmd from moulin import utils +from moulin.yaml_helpers import YAMLProcessingError def get_builder(conf: YamlValue, name: str, build_dir: str, src_stamps: List[str], @@ -29,7 +30,7 @@ def gen_build_rules(generator: ninja_syntax.Writer): construct_fetcher_dep_cmd(), "cd $build_dir", "source zephyr/zephyr-env.sh", - "$env west build -p auto -b $board -d $work_dir $target -- $shields $vars", + "$env west build -p auto -b $board -d $work_dir $target $snippets -- $shields $vars", ]) generator.rule("zephyr_build", command=f'bash -c "{cmd}"', @@ -72,6 +73,16 @@ def gen_build(self): else: shields = "" + snippets_node = self.conf.get("snippets", None) + if snippets_node: + snippets = " ".join([f"-S {snip.as_str}" for snip in snippets_node]) + else: + snippets = "" + + if shields_node and snippets_node: + raise YAMLProcessingError("Both shields and snippets are specified, only one of them is allowed", + self.conf["snippets"].mark) + vars_node = self.conf.get("vars", None) if vars_node: vars_vals = [ZephyrBuilder.__escape_vars_vals(x.as_str) for x in vars_node] @@ -86,6 +97,7 @@ def gen_build(self): "target": self.conf["target"].as_str, "work_dir": self.conf.get("work_dir", "zephyr/build").as_str, "shields": shields, + "snippets": snippets, "vars": vars_value, "env": env, }