Skip to content

Commit 77e7c36

Browse files
authored
fix merging hard coded args with configuration provided args (#765)
1 parent 7719e9b commit 77e7c36

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

ros_buildfarm/workspace.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,19 @@ def call_build_tool(
111111
if install and build_tool == 'catkin_make_isolated':
112112
cmd.append('--install')
113113

114+
if args:
115+
cmd += args
116+
117+
# since `args` might contain the following arguments already it must be
118+
# ensured that the --* is not duplicated since only the last will be used
114119
if cmake_args:
115-
cmd += ['--cmake-args'] + cmake_args
120+
_insert_nargs_arguments(cmd, '--cmake-args', cmake_args)
116121

117122
if make_args:
118123
if build_tool == 'catkin_make_isolated':
119-
cmd += ['--catkin-make-args'] + make_args
124+
_insert_nargs_arguments(cmd, '--catkin-make-args', make_args)
120125
elif build_tool == 'colcon':
121-
cmd += ['--cmake-target'] + make_args
122-
123-
if args:
124-
cmd += args
126+
_insert_nargs_arguments(cmd, '--cmake-target', make_args)
125127

126128
cmd = ' '.join(cmd)
127129

@@ -158,3 +160,11 @@ def call_build_tool(
158160
print("Invoking '%s' in '%s'" % (cmd, workspace_root))
159161
return subprocess.call(
160162
cmd, cwd=workspace_root, shell=True, stderr=subprocess.STDOUT, env=env)
163+
164+
165+
def _insert_nargs_arguments(cmd, argument_name, argument_values):
166+
if argument_name not in cmd:
167+
cmd += [argument_name] + argument_values
168+
else:
169+
index = cmd.index(argument_name)
170+
cmd[index + 1:index + 1] = argument_values

0 commit comments

Comments
 (0)