Skip to content

Commit

Permalink
custom_script: make 'args' parameter as list
Browse files Browse the repository at this point in the history
'args' parameter can be pointed as string or as list

  args: "-v -h"
or
  args:
    - "-v"
    - "-h"

Signed-off-by: Dmytro Semenets <[email protected]>
  • Loading branch information
dsemenets committed Feb 26, 2024
1 parent f320f18 commit 5e5adff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion docs/user-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ script as parameter
type: custom_script # Should be 'custom_script'
work_dir : "script_workdir"
script: "path/to/script/custom_script.py"
args:
- "argument1"
- "argument2"
config:
items:
"rootfs": "images/spider/rootfs.tar.bz2"
Expand Down Expand Up @@ -732,7 +735,8 @@ Mandatory options:

Optional parameters:

* :code:`args` - additional arguments should be passed to :code:`script`
* :code:`args` - additional arguments should be passed to :code:`script`. Can be passed as
string or list

* :code:`additional_deps` - list of additional dependencies. This is
basically :code:`target_images` produced by other components. You
Expand Down
10 changes: 8 additions & 2 deletions moulin/builders/custom_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os.path
from typing import List
from moulin.yaml_wrapper import YamlValue
from moulin.yaml_helpers import YAMLProcessingError
from moulin import ninja_syntax


Expand Down Expand Up @@ -86,11 +87,16 @@ def gen_build(self):

self.generator.build(f"conf-{self.name}", "phony", local_conf_target)
self.generator.newline()

args_node = self.conf.get("args", "")
try:
args = args_node.as_str
except YAMLProcessingError:
args_vals = [x.as_str for x in args_node]
args = " ".join([val for val in args_vals])
self.generator.build(targets, "cs_build", deps, variables=dict(
common_variables,
config_file=local_conf_file,
args=self.conf.get("args", "").as_str))
args=args))
self.generator.newline()

return targets
Expand Down

0 comments on commit 5e5adff

Please sign in to comment.